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/14511

Vanessa5a1c885e76ed
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index fcca357f8d..b1b55fdc61 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -281,6 +281,7 @@ export class Gutter {
avID,
previousID,
srcs: [{
+ itemID: Lute.NewNodeID(),
id: srcIDs[0],
isDetached: true,
content: ""
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 0b8bf3edb1..6a922f65db 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -571,6 +571,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
const rowId = item.getAttribute("data-id");
const blockValue = genCellValueByElement("block", item.querySelector('.av__cell[data-dtype="block"]'));
srcs.push({
+ itemID: Lute.NewNodeID(),
content: blockValue.block.content,
id: rowId,
isDetached: blockValue.isDetached,
diff --git a/app/src/protyle/render/av/addToDatabase.ts b/app/src/protyle/render/av/addToDatabase.ts
index a611a78463..b892490347 100644
--- a/app/src/protyle/render/av/addToDatabase.ts
+++ b/app/src/protyle/render/av/addToDatabase.ts
@@ -10,6 +10,7 @@ export const addFilesToDatabase = (fileLiElements: Element[]) => {
const id = item.getAttribute("data-node-id");
if (id) {
srcs.push({
+ itemID: Lute.NewNodeID(),
id,
isDetached: false
});
@@ -40,6 +41,7 @@ export const addEditorToDatabase = (protyle: IProtyle, range: Range, type?: stri
action: "insertAttrViewBlock",
avID,
srcs: [{
+ itemID: Lute.NewNodeID(),
id: protyle.block.rootID,
isDetached: false
}],
@@ -81,6 +83,7 @@ export const addEditorToDatabase = (protyle: IProtyle, range: Range, type?: stri
ids.forEach(item => {
srcIDs.push(item);
srcs.push({
+ itemID: Lute.NewNodeID(),
id: item,
isDetached: false
});
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts
index 1ee15e3052..6dc1f407d3 100644
--- a/app/src/protyle/render/av/relation.ts
+++ b/app/src/protyle/render/av/relation.ts
@@ -425,6 +425,7 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector
action: "insertAttrViewBlock",
avID: menuElement.firstElementChild.getAttribute("data-av-id"),
srcs: [{
+ itemID: Lute.NewNodeID(),
id: rowId,
isDetached: true,
content
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 9347dfd856..af13d6a432 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -718,14 +718,14 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
const groupQuery = operation.groupID ? `[data-group-id="${operation.groupID}"]` : "";
if (item.getAttribute("data-av-type") === "gallery") {
operation.srcs.forEach(srcItem => {
- const filesElement = item.querySelector(`.av__body${groupQuery} .av__gallery-item[data-id="${srcItem.id}"]`)?.querySelector(".av__gallery-fields");
+ const filesElement = item.querySelector(`.av__body${groupQuery} .av__gallery-item[data-id="${srcItem.itemID}"]`)?.querySelector(".av__gallery-fields");
if (filesElement && filesElement.querySelector('[data-dtype="block"]')?.getAttribute("data-empty") === "true") {
filesElement.classList.add("av__gallery-fields--edit");
}
});
}
if (operation.srcs.length === 1) {
- const popCellElement = item.querySelector(`.av__body${groupQuery} [data-id="${operation.srcs[0].id}"] .av__cell[data-dtype="block"]`) as HTMLElement;
+ const popCellElement = item.querySelector(`.av__body${groupQuery} [data-id="${operation.srcs[0].itemID}"] .av__cell[data-dtype="block"]`) as HTMLElement;
if (popCellElement) {
popTextCell(protyle, [popCellElement], "block");
}
diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts
index 0789e5a9c5..3d19e6a42f 100644
--- a/app/src/protyle/render/av/row.ts
+++ b/app/src/protyle/render/av/row.ts
@@ -360,6 +360,7 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
avID,
previousID: item.previousElementSibling?.getAttribute("data-id") || "",
srcs: [{
+ itemID: Lute.NewNodeID(),
id: item.getAttribute("data-id"),
isDetached: blockValue.isDetached,
content: blockValue.block.content
@@ -405,6 +406,7 @@ export const insertRows = (options: {
const newNodeID = Lute.NewNodeID();
srcIDs.push(newNodeID);
srcs.push({
+ itemID: Lute.NewNodeID(),
id: newNodeID,
isDetached: true,
content: "",
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index e4d6ac82e6..00993c2abe 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -1023,6 +1023,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
const id = item.getAttribute("data-node-id");
sourceIds.push(id);
srcs.push({
+ itemID: Lute.NewNodeID(),
id,
isDetached: false,
});
@@ -1320,6 +1321,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
const groupID = bodyElement && bodyElement.getAttribute("data-group-id");
ids.forEach(id => {
srcs.push({
+ itemID: Lute.NewNodeID(),
id,
isDetached: false,
});
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 63f8d38b2b..b294e6c6a4 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -854,7 +854,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
}
return;
}
- if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
+ if (["addAttrViewCol", "updateAttrViewCol", "updateAttrViewColOptions",
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 61e3984d4d..9d15701b99 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -556,6 +556,7 @@ interface IOperation {
}
interface IOperationSrcs {
+ itemID: string,
id: string,
content?: string,
isDetached: boolean