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

Vanessa1d8ba5b2254c
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 2e25c5bfcb..9247e5c384 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -2,7 +2,9 @@ import {Constants} from "../constants";
import {fetchPost} from "../util/fetch";
/// #if !MOBILE
import {exportLayout} from "../layout/util";
+import {getAllModels} from "../layout/getAll";
/// #endif
+import {getAllEditor} from "../layout/getAll";
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
@@ -14,7 +16,6 @@ import {escapeHtml} from "../util/escape";
import {getWorkspaceName} from "../util/noRelyPCFunction";
import {needSubscribe} from "../util/needSubscribe";
import {redirectToCheckAuth, setNoteBook} from "../util/pathName";
-import {getAllEditor, getAllModels} from "../layout/getAll";
import {reloadProtyle} from "../protyle/util/reload";
import {Tab} from "../layout/Tab";
import {setEmpty} from "../mobile/util/setEmpty";
@@ -159,6 +160,21 @@ export const setRefDynamicText = (data: {
})
}
+export const setDefRefCount = (data: {
+ "blockID": string,
+ "defBlockID": string,
+ "refText": string,
+ "rootID": string
+}) => {
+ getAllEditor().forEach(item => {
+ // 不能对比 rootId,否则潜入块中的锚文本无法更新
+ const refElement = item.protyle.wysiwyg.element.querySelector(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`);
+ if (refElement) {
+ refElement.innerHTML = data.refText;
+ }
+ })
+}
+
export const lockScreen = (app: App) => {
if (window.siyuan.config.readonly) {
return;
diff --git a/app/src/index.ts b/app/src/index.ts
index e0f21faa8f..fd519aeebf 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -17,7 +17,7 @@ import {
progressBackgroundTask,
progressLoading,
progressStatus,
- reloadSync, setRefDynamicText,
+ reloadSync, setDefRefCount, setRefDynamicText,
setTitle,
transactionError
} from "./dialog/processSystem";
@@ -61,6 +61,9 @@ export class App {
});
if (data) {
switch (data.cmd) {
+ case "setDefRefCount":
+ setDefRefCount(data.data);
+ break;
case "setRefDynamicText":
setRefDynamicText(data.data);
break;
diff --git a/app/src/layout/getAll.ts b/app/src/layout/getAll.ts
index f439e0ce86..3851a07993 100644
--- a/app/src/layout/getAll.ts
+++ b/app/src/layout/getAll.ts
@@ -1,3 +1,4 @@
+/// #if !MOBILE
import {Layout} from "./index";
import {Tab} from "./Tab";
import {Editor} from "../editor";
@@ -12,10 +13,19 @@ import {Tag} from "./dock/Tag";
import {Custom} from "./dock/Custom";
import {Protyle} from "../protyle";
import {Wnd} from "./Wnd";
+/// #endif
export const getAllEditor = () => {
- const models = getAllModels();
const editors: Protyle[] = [];
+ /// #if MOBILE
+ if (window.siyuan.mobile.editor) {
+ editors.push(window.siyuan.mobile.editor);
+ }
+ if (window.siyuan.mobile.popEditor) {
+ editors.push(window.siyuan.mobile.popEditor);
+ }
+ /// #else
+ const models = getAllModels();
models.editor.forEach(item => {
editors.push(item.editor);
});
@@ -45,6 +55,7 @@ export const getAllEditor = () => {
editors.push(editorItem);
});
});
+ /// #endif
return editors;
};
diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.ts
index 281d700fe0..9fd1ac4d42 100644
--- a/app/src/mobile/util/onMessage.ts
+++ b/app/src/mobile/util/onMessage.ts
@@ -3,7 +3,7 @@ import {
processSync,
progressLoading,
progressStatus,
- reloadSync,
+ reloadSync, setDefRefCount, setRefDynamicText,
transactionError
} from "../../dialog/processSystem";
import {Constants} from "../../constants";
@@ -14,6 +14,12 @@ import {reloadEmoji} from "../../emoji";
export const onMessage = (app: App, data: IWebSocketData) => {
if (data) {
switch (data.cmd) {
+ case "setDefRefCount":
+ setDefRefCount(data.data);
+ break;
+ case "setRefDynamicText":
+ setRefDynamicText(data.data);
+ break;
case "reloadPlugin":
reloadPlugin(app, data.data);
break;
diff --git a/app/src/window/index.ts b/app/src/window/index.ts
index 76fe89bd2d..a8a2a570a1 100644
--- a/app/src/window/index.ts
+++ b/app/src/window/index.ts
@@ -11,7 +11,7 @@ import {openFileById} from "../editor/util";
import {
processSync, progressBackgroundTask,
progressLoading,
- progressStatus, reloadSync,
+ progressStatus, reloadSync, setDefRefCount, setRefDynamicText,
setTitle,
transactionError
} from "../dialog/processSystem";
@@ -50,6 +50,12 @@ class App {
});
if (data) {
switch (data.cmd) {
+ case "setDefRefCount":
+ setDefRefCount(data.data);
+ break;
+ case "setRefDynamicText":
+ setRefDynamicText(data.data);
+ break;
case "reloadPlugin":
reloadPlugin(this, data.data);
break;