Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/11013

Vanessaffbb1423b36e
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 18e1f53179..8d5a38e24e 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -552,7 +552,6 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
if (["created", "updated", "template", "rollup"].includes(type)) {
return;
}
-
const rowID = rowElement.getAttribute("data-id");
const cellId = item.dataset.id; // 刚创建时无 id,更新需和 oldValue 保持一致
const colId = item.dataset.colId;
@@ -589,14 +588,25 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
if (objEquals(cellValue, oldValue)) {
return;
}
- doOperations.push({
- action: "updateAttrViewCell",
- id: cellId,
- avID,
- keyID: colId,
- rowID,
- data: cellValue
- });
+ if (type === "block" && !item.dataset.detached) {
+ const newId = Lute.NewNodeID()
+ doOperations.push({
+ action: "unbindAttrViewBlock",
+ id: rowID,
+ nextID: newId
+ });
+ rowElement.dataset.id = newId;
+ item.dataset.blockId = newId;
+ } else {
+ doOperations.push({
+ action: "updateAttrViewCell",
+ id: cellId,
+ avID,
+ keyID: colId,
+ rowID,
+ data: cellValue
+ });
+ }
undoOperations.push({
action: "updateAttrViewCell",
id: cellId,
@@ -718,7 +728,7 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0) => {
}
if (["text", "template", "url", "email", "phone", "number", "date", "created", "updated", "lineNumber"].includes(cellValue.type) &&
- ( cellValue.type === "lineNumber" || (cellValue && cellValue[cellValue.type as "url"].content))) {
+ (cellValue.type === "lineNumber" || (cellValue && cellValue[cellValue.type as "url"].content))) {
text += `<span ${cellValue.type !== "number" ? "" : 'style="right:auto;left:5px"'} data-type="copy" class="block__icon"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
}
return text;
@@ -840,7 +850,8 @@ export const dragFillCellsValue = (protyle: IProtyle, nodeElement: HTMLElement,
const originKeys = Object.keys(originData);
Object.keys(newData).forEach((rowID, index) => {
newData[rowID].forEach((item, cellIndex) => {
- if (["rollup", "template", "created", "updated"].includes(item.type)) {
+ if (["rollup", "template", "created", "updated"].includes(item.type) ||
+ (item.type === "block" && item.element.getAttribute("data-detached") !== "true")) {
return;
}
// https://ld246.com/article/1707975507571 数据库下拉填充数据后异常
diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts
index 8fb342f47f..e17c052d8f 100644
--- a/app/src/protyle/util/insertHTML.ts
+++ b/app/src/protyle/util/insertHTML.ts
@@ -71,7 +71,8 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
return true;
}
const type = getTypeByCellElement(cellElement) || cellElement.dataset.type as TAVCol;
- if (["created", "updated", "template", "rollup"].includes(type)) {
+ if (["created", "updated", "template", "rollup"].includes(type) ||
+ (type === "block" && !cellElement.dataset.detached)) {
return;
}
const rowID = currentRowElement.getAttribute("data-id");
@@ -89,7 +90,8 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
return;
}
cellValue = genCellValue(type, cellValue[cellValue.type as "text"].content.toString());
- } else if (cellValue.type === "block") {
+ }
+ if (cellValue.type === "block") {
cellValue.isDetached = true;
delete cellValue.block.id;
}
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index b06ba0815f..cb505f9260 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -50,6 +50,7 @@ type TOperation =
| "updateAttrViewColRollup"
| "hideAttrViewName"
| "setAttrViewColDate"
+ | "unbindAttrViewBlock"
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
type TCardType = "doc" | "notebook" | "all"
type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" |