An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Sync detached database row titles https://github.com/siyuan-note/siyuan/issues/18321
Danielba1ccf3d84e2
diff --git a/app/src/editor/databaseRow.ts b/app/src/editor/databaseRow.tsindex 61a46194dc..82cd45b177 100644--- a/app/src/editor/databaseRow.ts+++ b/app/src/editor/databaseRow.ts@@ -22,6 +22,17 @@ export const newDatabaseRowModel = (options: {let ghostProtyle: Protyle;let resizeObserver: ResizeObserver;let destroyed = false;+ const updateTitle = (custom: Custom, bodyElement: HTMLElement) => {+ const primaryElement = bodyElement.querySelector<HTMLElement>('[data-primary="true"] [data-cell-value]');+ if (!primaryElement?.dataset.cellValue) {+ return;+ }+ const value = JSON.parse(decodeURIComponent(primaryElement.dataset.cellValue)) as IAVCellValue;+ const title = value.block?.content || window.siyuan.languages.untitled;+ custom.data.title = title;+ custom.element.querySelector(".protyle-db-row__title span").textContent = title;+ custom.tab.updateTitle(title);+ };const updateLayout = (custom: Custom) => {const width = custom.element.clientWidth;const padding = getEditorHorizontalPadding(width, window.siyuan.config.editor.fullWidth);@@ -44,7 +55,9 @@ export const newDatabaseRowModel = (options: {bodyElement.className = "custom-attr protyle-db-row__body";previousBodyElement.replaceWith(bodyElement);updateLayout(custom);- renderAVAttribute(bodyElement, options.data.itemID, contextProtyle, undefined,+ renderAVAttribute(bodyElement, options.data.itemID, contextProtyle, (element) => {+ updateTitle(custom, element);+ },{avID: options.data.avID, itemID: options.data.itemID, valueID: options.data.valueID});};const model = new Custom({@@ -63,6 +76,11 @@ export const newDatabaseRowModel = (options: {</div></div>`;custom.element.querySelector(".protyle-db-row__title span").textContent = options.data.title || window.siyuan.languages.untitled;+ custom.element.addEventListener("database-row-title-update", (event) => {+ const title = (event as CustomEvent<string>).detail;+ custom.data.title = title;+ custom.tab.updateTitle(title);+ });updateLayout(custom);resizeObserver = new ResizeObserver(() => updateLayout(custom));resizeObserver.observe(custom.element);diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex 8b1f5020e8..c9f30f9af0 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -967,6 +967,17 @@ export const updateAttrViewCellInOtherElements = (protyle: IProtyle, avID: strin}cellElement.dataset.cellValue = encodeURIComponent(JSON.stringify(value));cellElement.parentElement.dataset.empty = cellValueIsEmpty(value).toString();+ if (value.type === "block") {+ const databaseRowElement = cellElement.closest<HTMLElement>(".protyle-db-row");+ if (databaseRowElement) {+ const title = value.block?.content || window.siyuan.languages.untitled;+ databaseRowElement.querySelector(".protyle-db-row__title span").textContent = title;+ databaseRowElement.dispatchEvent(new CustomEvent("database-row-title-update", {+ bubbles: true,+ detail: title,+ }));+ }+ }};if (sourceElement?.dataset.avId) {updateCustomAttr(sourceElement);