An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: https://github.com/siyuan-note/siyuan/issues/3565 reload
Vanessa1bb123b74a53
diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.tsindex 643b55a54a..8721a801b2 100644--- a/app/src/block/Panel.ts+++ b/app/src/block/Panel.ts@@ -1,5 +1,5 @@import {hasClosestByClassName} from "../protyle/util/hasClosest";-import Protyle from "../protyle";+import {Protyle} from "../protyle";import {genUUID} from "../util/genID";import {setPadding} from "../protyle/ui/initUI";import {setPosition} from "../util/setPosition";diff --git a/app/src/editor/index.ts b/app/src/editor/index.tsindex 3f1518e275..f6fc3d17d8 100644--- a/app/src/editor/index.ts+++ b/app/src/editor/index.ts@@ -1,5 +1,5 @@import {Tab} from "../layout/Tab";-import Protyle from "../protyle";+import {Protyle} from "../protyle";import {Model} from "../layout/Model";import {disabledProtyle} from "../protyle/util/onGet";import {setPadding} from "../protyle/ui/initUI";diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.tsindex 3d62be6076..b7490bacc4 100644--- a/app/src/layout/dock/Backlink.ts+++ b/app/src/layout/dock/Backlink.ts@@ -2,16 +2,12 @@ import {Tab} from "../Tab";import {Model} from "../Model";import {getDisplayName} from "../../util/pathName";import {Tree} from "../../util/Tree";-import {hasClosestByClassName} from "../../protyle/util/hasClosest";import {getDockByType, setPanelFocus} from "../util";import {fetchPost} from "../../util/fetch";import {Constants} from "../../constants";-import {getAllModels} from "../getAll";-import {onGet} from "../../protyle/util/onGet";import {updateHotkeyTip} from "../../protyle/util/compatibility";import {openFileById} from "../../editor/util";-import {MenuItem} from "../../menus/Menu";-import Protyle from "../../protyle";+import {Protyle} from "../../protyle";export class Backlink extends Model {public element: HTMLElement;@@ -306,6 +302,8 @@ export class Backlink extends Model {}, (response) => {const editorElement = document.createElement("div");editorElement.style.minHeight = "auto";+ editorElement.setAttribute("data-defid", this.blockId)+ editorElement.setAttribute("data-ismention", isMention? "true" : "false")liElement.after(editorElement);const editor = new Protyle(editorElement, {blockId: "",diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.tsindex 11a554ba6e..f0288a881a 100644--- a/app/src/layout/dock/index.ts+++ b/app/src/layout/dock/index.ts@@ -11,7 +11,7 @@ import {Graph} from "./Graph";import {Model} from "../Model";import {getDockByType, resizeTabs, setPanelFocus} from "../util";import {Inbox} from "./Inbox";-import Protyle from "../../protyle";+import {Protyle} from "../../protyle";import {Backlink} from "./Backlink";export class Dock {diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 99df660784..672cbbc5b1 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -383,6 +383,9 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {};export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushBack = true, callback?: () => void) => {+ if (protyle.options.backlinkData) {+ return;+ }const breadcrumbHLElement = protyle.breadcrumb?.element.querySelector(".protyle-breadcrumb__item--active");if (breadcrumbHLElement && breadcrumbHLElement.getAttribute("data-node-id") === id) {if (id === protyle.block.rootID) {diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.tsindex a8e9352e2d..eee3858519 100644--- a/app/src/mobile/editor.ts+++ b/app/src/mobile/editor.ts@@ -1,4 +1,4 @@-import Protyle from "../protyle";+import {Protyle} from "../protyle";import {setEditor} from "./util/setEmpty";import {closePanel} from "./util/closePanel";import {Constants} from "../constants";@@ -21,7 +21,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =setEditMode(window.siyuan.mobileEditor.protyle, "wysiwyg");}let blockElement;- Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {+ Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find((item: HTMLElement) => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {blockElement = item;return true;diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex c5ff89e44c..1d903d3fe5 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -27,7 +27,7 @@ import {onGet} from "./util/onGet";import {reloadProtyle} from "./util/reload";import {renderBacklink} from "./wysiwyg/renderBacklink";-class Protyle {+export class Protyle {public readonly version: string;public protyle: IProtyle;@@ -95,7 +95,7 @@ class Protyle {case "heading2doc":case "li2doc":if (this.protyle.block.rootID === data.data.srcRootBlockID) {- if (this.protyle.block.showAll && data.cmd === "heading2doc") {+ if (this.protyle.block.showAll && data.cmd === "heading2doc" && !this.protyle.options.backlinkData) {fetchPost("/api/filetree/getDoc", {id: this.protyle.block.rootID,size: Constants.SIZE_GET,@@ -245,5 +245,3 @@ class Protyle {destroy(this.protyle);}}--export default Protyle;diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex 76ab100fb9..3a70030fc2 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -654,7 +654,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {}}}- } else if (window.siyuan.dragElement && window.siyuan.dragElement.getAttribute("data-type") === "navigation-file" && targetElement) {+ } else if (window.siyuan.dragElement && window.siyuan.dragElement.getAttribute("data-type") === "navigation-file"+ && targetElement && !protyle.options.backlinkData) {// 文件树拖拽fetchPost("/api/filetree/doc2Heading", {srcID: window.siyuan.dragElement.getAttribute("data-node-id"),diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.tsindex 93e96a38a9..c3471d5c30 100644--- a/app/src/protyle/util/reload.ts+++ b/app/src/protyle/util/reload.ts@@ -3,11 +3,9 @@ import {fetchPost} from "../../util/fetch";import {Constants} from "../../constants";import {onGet} from "./onGet";import {saveScroll} from "../scroll/saveScroll";+import {renderBacklink} from "../wysiwyg/renderBacklink";export const reloadProtyle = (protyle:IProtyle) => {- if (protyle.options.backlinkData) {- return;- }if (window.siyuan.config.editor.displayBookmarkIcon) {protyle.wysiwyg.element.classList.add("protyle-wysiwyg--attr");} else {@@ -15,11 +13,22 @@ export const reloadProtyle = (protyle:IProtyle) => {}protyle.lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);addLoading(protyle);- fetchPost("/api/filetree/getDoc", {- id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,- mode: 0,- size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,- }, getResponse => {- onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true);- });+ if (protyle.options.backlinkData) {+ const isMention = protyle.element.getAttribute("data-ismention") === "true";+ fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {+ defID: protyle.element.getAttribute("data-defid"),+ refTreeID: protyle.block.rootID+ }, response => {+ protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks,+ renderBacklink(protyle, protyle.options.backlinkData);+ });+ } else {+ fetchPost("/api/filetree/getDoc", {+ id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,+ mode: 0,+ size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,+ }, getResponse => {+ onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true);+ });+ }};diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 2c7d97b7ec..fb45f61163 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -446,7 +446,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {// ctrl+home 光标移动到顶if (!event.altKey && !event.shiftKey && isCtrl(event) && event.key === "Home") {if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-index") === "0" ||- protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "true") {+ protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "true" ||+ protyle.options.backlinkData) {focusBlock(protyle.wysiwyg.element.firstElementChild);protyle.contentElement.scrollTop = 0;protyle.scroll.lastScrollTop = 1;diff --git a/app/src/search/index.ts b/app/src/search/index.tsindex 2a7b6ab04f..cfe3e1abb8 100644--- a/app/src/search/index.ts+++ b/app/src/search/index.ts@@ -1,6 +1,6 @@import {Model} from "../layout/Model";import {Tab} from "../layout/Tab";-import Protyle from "../protyle";+import {Protyle} from "../protyle";import {Constants} from "../constants";import {getIconByType} from "../editor/getIcon";import {getDisplayName, getNotebookName} from "../util/pathName";diff --git a/app/src/search/spread.ts b/app/src/search/spread.tsindex 85b480d904..d14682bf97 100644--- a/app/src/search/spread.ts+++ b/app/src/search/spread.ts@@ -2,7 +2,7 @@ import {escapeHtml} from "../util/escape";import {getIconByType} from "../editor/getIcon";import {getDisplayName, getNotebookName, pathPosix} from "../util/pathName";import {Constants} from "../constants";-import Protyle from "../protyle";+import {Protyle} from "../protyle";import {Dialog} from "../dialog";import {fetchPost, fetchSyncPost} from "../util/fetch";import {onGet} from "../protyle/util/onGet";diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex 1c04ac1f20..f5db501b4f 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -401,7 +401,7 @@ interface IOptions {};/** 编辑器异步渲染完成后的回调方法 */- after?(protyle: import("../protyle/index").default): void;+ after?(protyle: import("../protyle").Protyle): void;}interface IProtyle {diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.tsindex 999c3094c7..6fcb14c038 100644--- a/app/src/util/globalShortcut.ts+++ b/app/src/util/globalShortcut.ts@@ -771,7 +771,7 @@ const editKeydown = (event: KeyboardEvent) => {event.stopPropagation();return true;}- if (matchHotKey(window.siyuan.config.keymap.editor.general.wysiwyg.custom, event)) {+ if (matchHotKey(window.siyuan.config.keymap.editor.general.wysiwyg.custom, event) && !protyle.options.backlinkData) {setEditMode(protyle, "wysiwyg");protyle.scroll.lastScrollTop = 0;fetchPost("/api/filetree/getDoc", {diff --git a/app/src/util/history.ts b/app/src/util/history.tsindex ca460ee841..00bf39cf6e 100644--- a/app/src/util/history.ts+++ b/app/src/util/history.ts@@ -6,7 +6,7 @@ import {escapeHtml} from "./escape";import {isMobile} from "./functions";import {hasClosestByClassName} from "../protyle/util/hasClosest";import {renderAssetsPreview} from "../asset/renderAssets";-import Protyle from "../protyle";+import {Protyle} from "../protyle";import {onGet} from "../protyle/util/onGet";let historyEditor: Protyle;