Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: https://github.com/siyuan-note/siyuan/issues/6290

Vanessaa7aea90184e9
diff --git a/app/src/mobile/util/MobileBackFoward.ts b/app/src/mobile/util/MobileBackFoward.ts
index e288bc7e22..3daf984357 100644
--- a/app/src/mobile/util/MobileBackFoward.ts
+++ b/app/src/mobile/util/MobileBackFoward.ts
@@ -6,7 +6,7 @@ import {zoomOut} from "../../menus/protyle";
import {processRender} from "../../protyle/util/processCode";
import {highlightRender} from "../../protyle/markdown/highlightRender";
import {blockRender} from "../../protyle/markdown/blockRender";
-import {disabledProtyle, enableProtyle} from "../../protyle/util/onGet";
+import {disabledForeverProtyle, disabledProtyle, enableProtyle} from "../../protyle/util/onGet";
const forwardStack: IBackStack[] = [];
@@ -69,10 +69,14 @@ const focusStack = (backStack: IBackStack) => {
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);
blockRender(protyle, protyle.wysiwyg.element);
- if (protyle.disabled) {
- disabledProtyle(protyle);
+ if (getResponse.data.isSyncing) {
+ disabledForeverProtyle(protyle);
} else {
- enableProtyle(protyle);
+ if (protyle.disabled) {
+ disabledProtyle(protyle);
+ } else {
+ enableProtyle(protyle);
+ }
}
protyle.contentElement.scrollTop = backStack.scrollTop;
window.siyuan.mobileEditor.protyle.breadcrumb?.render(protyle);
diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.ts
index 9a35111934..4c5974fa99 100644
--- a/app/src/protyle/scroll/saveScroll.ts
+++ b/app/src/protyle/scroll/saveScroll.ts
@@ -7,7 +7,7 @@ import {pushBack} from "../../util/backForward";
import {processRender} from "../util/processCode";
import {highlightRender} from "../markdown/highlightRender";
import {blockRender} from "../markdown/blockRender";
-import {disabledProtyle, enableProtyle} from "../util/onGet";
+import {disabledForeverProtyle, disabledProtyle, enableProtyle} from "../util/onGet";
export const saveScroll = (protyle: IProtyle, getObject = false) => {
if (!protyle.wysiwyg.element.firstElementChild) {
@@ -84,10 +84,14 @@ export const restoreScroll = (protyle: IProtyle, scrollAttr: IScrollAttr) => {
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);
blockRender(protyle, protyle.wysiwyg.element);
- if (protyle.disabled) {
- disabledProtyle(protyle);
+ if (getResponse.data.isSyncing) {
+ disabledForeverProtyle(protyle);
} else {
- enableProtyle(protyle);
+ if (protyle.disabled) {
+ disabledProtyle(protyle);
+ } else {
+ enableProtyle(protyle);
+ }
}
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
if (scrollAttr.focusId) {
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index f7e13caf41..60d3f95323 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -85,6 +85,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
content: html,
action,
unScroll: false,
+ isSyncing: data.data.isSyncing,
}, protyle);
removeLoading(protyle);
return;
@@ -116,6 +117,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
content: html,
action,
unScroll: (scrollObj && scrollObj.focusId) ? true : false,
+ isSyncing: data.data.isSyncing,
}, protyle);
if (scrollObj && protyle.options.mode !== "preview") {
@@ -125,7 +127,11 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
});
};
-const setHTML = (options: { content: string, action?: string[], unScroll?: boolean }, protyle: IProtyle) => {
+const setHTML = (options: {
+ content: string,
+ action?: string[],
+ isSyncing: boolean,
+ unScroll?: boolean }, protyle: IProtyle) => {
if (protyle.contentElement.classList.contains("fn__none")) {
return;
}
@@ -231,10 +237,14 @@ const setHTML = (options: { content: string, action?: string[], unScroll?: boole
}
/// #endif
}
- if (protyle.disabled) {
- disabledProtyle(protyle);
+ if (options.isSyncing) {
+ disabledForeverProtyle(protyle)
} else {
- enableProtyle(protyle);
+ if (protyle.disabled) {
+ disabledProtyle(protyle);
+ } else {
+ enableProtyle(protyle);
+ }
}
if (options.action.includes(Constants.CB_GET_SETID)) {
// 点击大纲后,如果需要动态加载,在定位后,需要重置 block.id https://github.com/siyuan-note/siyuan/issues/4487
@@ -274,6 +284,11 @@ const setHTML = (options: { content: string, action?: string[], unScroll?: boole
}
};
+export const disabledForeverProtyle = (protyle: IProtyle) => {
+ disabledProtyle(protyle);
+ protyle.element.setAttribute("disabled-forever", "true");
+}
+
/** 禁用编辑器 */
export const disabledProtyle = (protyle: IProtyle) => {
window.siyuan.menus.menu.remove();
@@ -296,6 +311,9 @@ export const disabledProtyle = (protyle: IProtyle) => {
/** 解除编辑器禁用 */
export const enableProtyle = (protyle: IProtyle) => {
+ if (protyle.element.getAttribute("disabled-forever") === "true") {
+ return;
+ }
protyle.disabled = false;
if (navigator && navigator.maxTouchPoints > 1 && ["MacIntel", "iPhone"].includes(navigator.platform)) {
// iPhone,iPad 端 protyle.wysiwyg.element contenteditable 为 true 时,输入会在块中间插入 span 导致保存失败 https://ld246.com/article/1643473862873/comment/1643813765839#comments
diff --git a/app/src/protyle/wysiwyg/renderBacklink.ts b/app/src/protyle/wysiwyg/renderBacklink.ts
index bdef65cb26..49a3fe70ce 100644
--- a/app/src/protyle/wysiwyg/renderBacklink.ts
+++ b/app/src/protyle/wysiwyg/renderBacklink.ts
@@ -5,7 +5,7 @@ import {Constants} from "../../constants";
import {processRender} from "../util/processCode";
import {highlightRender} from "../markdown/highlightRender";
import {blockRender} from "../markdown/blockRender";
-import {disabledProtyle} from "../util/onGet";
+import {disabledForeverProtyle, disabledProtyle} from "../util/onGet";
export const renderBacklink = (protyle: IProtyle, backlinkData: {
blockPaths: IBreadcrumb[],
@@ -69,7 +69,9 @@ export const loadBreadcrumb = (protyle: IProtyle, element: HTMLElement) => {
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);
blockRender(protyle, protyle.wysiwyg.element);
- if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
+ if (getResponse.data.isSyncing) {
+ disabledForeverProtyle(protyle);
+ } else if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) {
disabledProtyle(protyle);
}
});