mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-23 16:56:10 +01:00
This commit is contained in:
parent
b19613ea94
commit
a7aea90184
4 changed files with 42 additions and 14 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue