diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tpl index 0e4af5c93..3ebad2d7a 100644 --- a/app/src/assets/template/mobile/index.tpl +++ b/app/src/assets/template/mobile/index.tpl @@ -14,7 +14,7 @@ - + diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts index bc03331e1..6a4e992e8 100644 --- a/app/src/mobile/editor.ts +++ b/app/src/mobile/editor.ts @@ -68,7 +68,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) = }, after: (editor) => { // protyle 仅初始化一次,后续更新时会对 url 等再次复制 - if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || document.querySelector("#toolbarEdit use").getAttribute("xlink:href") === "#iconEdit") { + if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { disabledProtyle(editor.protyle); } else { enableProtyle(editor.protyle); diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts index 6507940ae..60d7140c4 100644 --- a/app/src/mobile/util/initFramework.ts +++ b/app/src/mobile/util/initFramework.ts @@ -92,11 +92,21 @@ export const initFramework = () => { const editElement = document.getElementById("toolbarEdit"); if (window.siyuan.config.readonly) { editElement.classList.add("fn__none"); + } + const inputElement = document.getElementById("toolbarName") as HTMLInputElement; + const editIconElement = editElement.querySelector("use"); + if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { + inputElement.readOnly = true; + editIconElement.setAttribute("xlink:href", "#iconEdit"); } else { - const editIconElement = editElement.querySelector("use"); - editElement.addEventListener(getEventName(), () => { - const inputElement = document.getElementById("toolbarName") as HTMLInputElement; - if (editIconElement.getAttribute("xlink:href") === "#iconEdit") { + inputElement.readOnly = false; + editIconElement.setAttribute("xlink:href", "#iconPreview"); + } + editElement.addEventListener(getEventName(), () => { + const isReadonly = editIconElement.getAttribute("xlink:href") === "#iconPreview" + window.siyuan.config.editor.readOnly = isReadonly; + fetchPost("/api/setting/setEditor", window.siyuan.config.editor, () => { + if (!isReadonly) { enableProtyle(window.siyuan.mobileEditor.protyle); inputElement.readOnly = false; editIconElement.setAttribute("xlink:href", "#iconPreview"); @@ -105,8 +115,9 @@ export const initFramework = () => { inputElement.readOnly = true; editIconElement.setAttribute("xlink:href", "#iconEdit"); } - }); - } + }) + }); + scrimElement.addEventListener(getEventName(), () => { closePanel(); }); @@ -141,10 +152,10 @@ const initEditorName = () => { const inputElement = document.getElementById("toolbarName") as HTMLInputElement; inputElement.setAttribute("placeholder", window.siyuan.languages._kernel[16]); inputElement.addEventListener("focus", () => { - hideKeyboardToolbar(); + hideKeyboardToolbar(); }); inputElement.addEventListener("blur", () => { - if (window.siyuan.config.readonly || document.querySelector("#toolbarEdit use").getAttribute("xlink:href") === "#iconEdit") { + if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { return; } if (!validateName(inputElement.value)) { diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index fb4db8857..a9ac7cdd1 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1649,7 +1649,7 @@ export class WYSIWYG { } const menuElement = hasClosestByClassName(event.target, "protyle-action__menu"); - if (menuElement && !protyle.disabled) { + if (menuElement) { protyle.gutter.renderMenu(protyle, menuElement.parentElement.parentElement); const rect = menuElement.getBoundingClientRect(); window.siyuan.menus.menu.popup({