Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/10414

Vanessa5d50582a0ff0
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index 602f5f692e..885c50ed72 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -782,7 +782,6 @@ export const openMenuPanel = (options: {
id,
blockID
}]);
- options.blockElement.setAttribute(Constants.CUSTOM_SY_AV_VIEW, id);
avPanelElement.remove();
event.preventDefault();
event.stopPropagation();
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 5701701f05..d7985ae2b8 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -455,7 +455,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
if (operation.action === "setAttrViewColWidth") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
const cellElement = item.querySelector(`.av__cell[data-col-id="${operation.id}"]`) as HTMLElement;
- if (!cellElement || cellElement.style.width === operation.data || item.getAttribute("custom-sy-av-view") !== operation.keyID) {
+ if (!cellElement || cellElement.style.width === operation.data || item.getAttribute(Constants.CUSTOM_SY_AV_VIEW) !== operation.keyID) {
return;
}
item.querySelectorAll(".av__row").forEach(rowItem => {
@@ -475,13 +475,10 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
});
addDragFill(item.querySelector(".av__cell--select"));
}
- if (operation.action === "removeAttrViewView") {
- item.setAttribute("data-av-type", operation.retData);
- } else if (operation.action === "setAttrViewBlockView") {
+ if (operation.action === "setAttrViewBlockView") {
const viewTabElement = item.querySelector(`.av__views > .layout-tab-bar > .item[data-id="${operation.id}"]`) as HTMLElement;
if (viewTabElement) {
item.dataset.pageSize = viewTabElement.dataset.page;
- item.setAttribute("data-av-type", viewTabElement.dataset.avType);
}
}
avRender(item, protyle, () => {
diff --git a/app/src/protyle/render/av/view.ts b/app/src/protyle/render/av/view.ts
index e8709d78cd..1f4da59192 100644
--- a/app/src/protyle/render/av/view.ts
+++ b/app/src/protyle/render/av/view.ts
@@ -65,7 +65,6 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
id,
blockID: options.blockElement.dataset.nodeId
}]);
- options.blockElement.setAttribute(Constants.CUSTOM_SY_AV_VIEW, id);
}
});
if (options.blockElement.querySelectorAll(".layout-tab-bar .item").length > 1) {
@@ -337,8 +336,6 @@ export const addView = (protyle: IProtyle, blockElement: Element) => {
id,
blockID: blockElement.getAttribute("data-node-id")
}]);
- blockElement.setAttribute(Constants.CUSTOM_SY_AV_VIEW, id);
- blockElement.setAttribute("data-av-type", "table");
}
});
addMenu.addItem({
@@ -358,8 +355,6 @@ export const addView = (protyle: IProtyle, blockElement: Element) => {
id,
blockID: blockElement.getAttribute("data-node-id")
}]);
- blockElement.setAttribute(Constants.CUSTOM_SY_AV_VIEW, id);
- blockElement.setAttribute("data-av-type", "gallery");
}
});
viewElement.classList.add("av__views--show");
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index b5c06a4dba..e97e3cb951 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -510,7 +510,7 @@ export class WYSIWYG {
if (!newWidth || newWidth === oldWidth) {
return;
}
- const viewId = nodeElement.getAttribute("custom-sy-av-view");
+ const viewId = nodeElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW);
transaction(protyle, [{
action: "setAttrViewColWidth",
id: dragColId,
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 62603f13e6..c3056dc139 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -621,6 +621,9 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
}, 450);
}
});
+ if (data["data-av-type"]) {
+ item.setAttribute("data-av-type", data["data-av-type"]);
+ }
const attrElements = item.querySelectorAll(".protyle-attr");
const attrElement = attrElements[attrElements.length - 1];
if (data.new["custom-avs"] && !data.new["av-names"]) {