This commit is contained in:
Vanessa 2023-11-28 21:17:19 +08:00
parent 81f39961eb
commit ec29bc7071
4 changed files with 21 additions and 30 deletions

View file

@ -28,7 +28,7 @@ import {updatePanelByEditor} from "../editor/util";
import {setPanelFocus} from "../layout/util";
/// #endif
import {Background} from "./header/Background";
import {onGet} from "./util/onGet";
import {onGet, setReadonlyByConfig} from "./util/onGet";
import {reloadProtyle} from "./util/reload";
import {renderBacklink} from "./wysiwyg/renderBacklink";
import {setEmpty} from "../mobile/util/setEmpty";
@ -132,7 +132,7 @@ export class Protyle {
break;
case "readonly":
window.siyuan.config.editor.readOnly = data.data;
reloadProtyle(this.protyle, false);
setReadonlyByConfig(this.protyle);
break;
case "heading2doc":
case "li2doc":

View file

@ -240,18 +240,7 @@ const setHTML = (options: {
protyle.breadcrumb.element.nextElementSibling.textContent = "";
}
protyle.element.removeAttribute("disabled-forever");
let readOnly = window.siyuan.config.readonly ? "true" : "false";
if (readOnly === "false") {
readOnly = window.siyuan.config.editor.readOnly ? "true" : "false";
if (readOnly === "false") {
readOnly = protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_READONLY);
}
}
if (readOnly === "true") {
disabledProtyle(protyle);
} else {
enableProtyle(protyle);
}
setReadonlyByConfig(protyle);
}
if (options.action.includes(Constants.CB_GET_SETID)) {
// 点击大纲后,如果需要动态加载,在定位后,需要重置 block.id https://github.com/siyuan-note/siyuan/issues/4487
@ -411,3 +400,18 @@ const focusElementById = (protyle: IProtyle, action: string[]) => {
/// #endif
}
};
export const setReadonlyByConfig = (protyle: IProtyle) => {
let readOnly = window.siyuan.config.readonly ? "true" : "false";
if (readOnly === "false") {
readOnly = window.siyuan.config.editor.readOnly ? "true" : "false";
if (readOnly === "false") {
readOnly = protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_READONLY);
}
}
if (readOnly === "true") {
disabledProtyle(protyle);
} else {
enableProtyle(protyle);
}
}