From ace4d5c9e02e06c0b151e606114be96784c909da Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 12 Jan 2024 15:42:50 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/10155 --- app/src/protyle/util/onGet.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 2341b9c8b..5bb2551f0 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -124,6 +124,7 @@ const setHTML = (options: { } protyle.block.showAll = options.action.includes(Constants.CB_GET_ALL); const REMOVED_OVER_HEIGHT = protyle.contentElement.clientHeight * 8; + const isUpdate = protyle.wysiwyg.element.innerHTML !== "" if (options.action.includes(Constants.CB_GET_APPEND)) { // 动态加载移除 if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select") && !protyle.scroll.keepLazyLoad && protyle.contentElement.scrollHeight > REMOVED_OVER_HEIGHT) { @@ -198,7 +199,7 @@ const setHTML = (options: { protyle.breadcrumb.element.nextElementSibling.textContent = ""; } protyle.element.removeAttribute("disabled-forever"); - setReadonlyByConfig(protyle, options.action); + setReadonlyByConfig(protyle, isUpdate); } focusElementById(protyle, options.action, options.scrollAttr); @@ -431,9 +432,9 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr } }; -export const setReadonlyByConfig = (protyle: IProtyle, action: string[]) => { +export const setReadonlyByConfig = (protyle: IProtyle, isUpdate: boolean) => { let readOnly = window.siyuan.config.readonly ? "true" : "false"; - if (action?.includes(Constants.CB_GET_UNCHANGEID)) { + if (isUpdate) { readOnly = protyle.disabled ? "true" : "false"; } else if (readOnly === "false") { readOnly = window.siyuan.config.editor.readOnly ? "true" : "false";