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: Restore focus when reopening bound database blocks https://github.com/siyuan-note/siyuan/issues/18321
Danielbc332da5c67f
diff --git a/app/src/protyle/render/av/openDatabaseRow.ts b/app/src/protyle/render/av/openDatabaseRow.tsindex 68a2b6d315..b243e71426 100644--- a/app/src/protyle/render/av/openDatabaseRow.ts+++ b/app/src/protyle/render/av/openDatabaseRow.ts@@ -1,12 +1,13 @@+import {Constants} from "../../../constants";/// #if MOBILEimport {openMobileFileById} from "../../../mobile/editor";import {Dialog} from "../../../dialog";import {renderAVAttribute} from "./blockAttr";-import {Constants} from "../../../constants";/// #elseimport {openFile, openFileById} from "../../../editor/util";import {Editor} from "../../../editor";import {getAllTabs} from "../../../layout/getAll";+import {zoomOut} from "../../../menus/protyle";/// #endifexport interface IDatabaseRowOpenData {@@ -60,6 +61,23 @@ const showDatabaseRowPreview = (model: Editor, blockID: string) => {model.editor.protyle.contentElement.scrollTop = 0;};+const focusDatabaseRowPreview = (model: Editor, blockID: string) => {+ const editorProtyle = model?.editor?.protyle;+ if (!editorProtyle) {+ return;+ }+ if (editorProtyle.block.showAll && editorProtyle.block.id === blockID) {+ showDatabaseRowPreview(model, blockID);+ return;+ }+ zoomOut({+ protyle: editorProtyle,+ id: blockID,+ reload: true,+ callback: () => showDatabaseRowPreview(model, blockID),+ });+};+const getDatabaseRowPreviewTab = (blockID: string) => {return getAllTabs().find((tab) => {if (tab.model instanceof Editor) {@@ -129,10 +147,24 @@ export const openDatabaseRowByData = (protyle: IProtyle, data: IDatabaseRowOpenD}const openedTab = getDatabaseRowPreviewTab(data.boundBlockID);if (openedTab) {+ const openedModel = openedTab.model;+ if (!(openedModel instanceof Editor)) {+ const initData = openedTab.headElement?.getAttribute("data-initdata");+ if (initData) {+ try {+ const initObj = JSON.parse(initData) as ILayoutJSON;+ initObj.blockId = data.boundBlockID;+ initObj.action = Constants.CB_GET_ALL;+ openedTab.headElement.setAttribute("data-initdata", JSON.stringify(initObj));+ } catch (e) {+ console.warn("Failed to update database row tab init data:", e);+ }+ }+ }openedTab.parent.switchTab(openedTab.headElement);openedTab.parent.showHeading();- if (openedTab.model instanceof Editor) {- showDatabaseRowPreview(openedTab.model, data.boundBlockID);+ if (openedModel instanceof Editor) {+ focusDatabaseRowPreview(openedModel, data.boundBlockID);}return;}