mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
c33401ed7c
commit
1d8ba5b225
5 changed files with 47 additions and 5 deletions
|
|
@ -2,7 +2,9 @@ import {Constants} from "../constants";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
|
import {getAllModels} from "../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
|
import {getAllEditor} from "../layout/getAll";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
@ -14,7 +16,6 @@ import {escapeHtml} from "../util/escape";
|
||||||
import {getWorkspaceName} from "../util/noRelyPCFunction";
|
import {getWorkspaceName} from "../util/noRelyPCFunction";
|
||||||
import {needSubscribe} from "../util/needSubscribe";
|
import {needSubscribe} from "../util/needSubscribe";
|
||||||
import {redirectToCheckAuth, setNoteBook} from "../util/pathName";
|
import {redirectToCheckAuth, setNoteBook} from "../util/pathName";
|
||||||
import {getAllEditor, getAllModels} from "../layout/getAll";
|
|
||||||
import {reloadProtyle} from "../protyle/util/reload";
|
import {reloadProtyle} from "../protyle/util/reload";
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import {setEmpty} from "../mobile/util/setEmpty";
|
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) => {
|
export const lockScreen = (app: App) => {
|
||||||
if (window.siyuan.config.readonly) {
|
if (window.siyuan.config.readonly) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import {
|
||||||
progressBackgroundTask,
|
progressBackgroundTask,
|
||||||
progressLoading,
|
progressLoading,
|
||||||
progressStatus,
|
progressStatus,
|
||||||
reloadSync, setRefDynamicText,
|
reloadSync, setDefRefCount, setRefDynamicText,
|
||||||
setTitle,
|
setTitle,
|
||||||
transactionError
|
transactionError
|
||||||
} from "./dialog/processSystem";
|
} from "./dialog/processSystem";
|
||||||
|
|
@ -61,6 +61,9 @@ export class App {
|
||||||
});
|
});
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.cmd) {
|
switch (data.cmd) {
|
||||||
|
case "setDefRefCount":
|
||||||
|
setDefRefCount(data.data);
|
||||||
|
break;
|
||||||
case "setRefDynamicText":
|
case "setRefDynamicText":
|
||||||
setRefDynamicText(data.data);
|
setRefDynamicText(data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
/// #if !MOBILE
|
||||||
import {Layout} from "./index";
|
import {Layout} from "./index";
|
||||||
import {Tab} from "./Tab";
|
import {Tab} from "./Tab";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
|
|
@ -12,10 +13,19 @@ import {Tag} from "./dock/Tag";
|
||||||
import {Custom} from "./dock/Custom";
|
import {Custom} from "./dock/Custom";
|
||||||
import {Protyle} from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {Wnd} from "./Wnd";
|
import {Wnd} from "./Wnd";
|
||||||
|
/// #endif
|
||||||
|
|
||||||
export const getAllEditor = () => {
|
export const getAllEditor = () => {
|
||||||
const models = getAllModels();
|
|
||||||
const editors: Protyle[] = [];
|
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 => {
|
models.editor.forEach(item => {
|
||||||
editors.push(item.editor);
|
editors.push(item.editor);
|
||||||
});
|
});
|
||||||
|
|
@ -45,6 +55,7 @@ export const getAllEditor = () => {
|
||||||
editors.push(editorItem);
|
editors.push(editorItem);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
/// #endif
|
||||||
return editors;
|
return editors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import {
|
||||||
processSync,
|
processSync,
|
||||||
progressLoading,
|
progressLoading,
|
||||||
progressStatus,
|
progressStatus,
|
||||||
reloadSync,
|
reloadSync, setDefRefCount, setRefDynamicText,
|
||||||
transactionError
|
transactionError
|
||||||
} from "../../dialog/processSystem";
|
} from "../../dialog/processSystem";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
|
|
@ -14,6 +14,12 @@ import {reloadEmoji} from "../../emoji";
|
||||||
export const onMessage = (app: App, data: IWebSocketData) => {
|
export const onMessage = (app: App, data: IWebSocketData) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.cmd) {
|
switch (data.cmd) {
|
||||||
|
case "setDefRefCount":
|
||||||
|
setDefRefCount(data.data);
|
||||||
|
break;
|
||||||
|
case "setRefDynamicText":
|
||||||
|
setRefDynamicText(data.data);
|
||||||
|
break;
|
||||||
case "reloadPlugin":
|
case "reloadPlugin":
|
||||||
reloadPlugin(app, data.data);
|
reloadPlugin(app, data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {openFileById} from "../editor/util";
|
||||||
import {
|
import {
|
||||||
processSync, progressBackgroundTask,
|
processSync, progressBackgroundTask,
|
||||||
progressLoading,
|
progressLoading,
|
||||||
progressStatus, reloadSync,
|
progressStatus, reloadSync, setDefRefCount, setRefDynamicText,
|
||||||
setTitle,
|
setTitle,
|
||||||
transactionError
|
transactionError
|
||||||
} from "../dialog/processSystem";
|
} from "../dialog/processSystem";
|
||||||
|
|
@ -50,6 +50,12 @@ class App {
|
||||||
});
|
});
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.cmd) {
|
switch (data.cmd) {
|
||||||
|
case "setDefRefCount":
|
||||||
|
setDefRefCount(data.data);
|
||||||
|
break;
|
||||||
|
case "setRefDynamicText":
|
||||||
|
setRefDynamicText(data.data);
|
||||||
|
break;
|
||||||
case "reloadPlugin":
|
case "reloadPlugin":
|
||||||
reloadPlugin(this, data.data);
|
reloadPlugin(this, data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue