From c04a518383ce6b5bd70d3e0dc726ef0773c513da Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 13 Oct 2022 21:34:43 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/6177 --- app/appearance/langs/en_US.json | 1 - app/appearance/langs/es_ES.json | 1 - app/appearance/langs/fr_FR.json | 1 - app/appearance/langs/zh_CHT.json | 1 - app/appearance/langs/zh_CN.json | 1 - app/src/protyle/gutter/index.ts | 52 ++++++++++++++------------------ 6 files changed, 23 insertions(+), 34 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 22257b7ab..4eca5efa8 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -92,7 +92,6 @@ "trafficStat": "Traffic Statistics", "hideHeadingBelowBlocks": "Hide blocks below heading", "matchDiacritics": "Match Diacritics", - "foldTip": "Are you sure to change to edit mode and record the fold state?", "copyHPath": "Copy readable path", "justify": "Justify", "height": "Height", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index f83406667..570558bb4 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -92,7 +92,6 @@ "trafficStat": "Estadísticas de tráfico", "hideHeadingBelowBlocks": "Ocultar bloques por debajo del encabezamiento", "matchDiacritics": " Hacer coincidir los diacríticos", - "foldTip": "¿Seguro que se cambia al modo de edición y se registra el estado de plegado?", "copyHPath": "Copiar ruta legible", "justify": "Justificar", "height": "Altura", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 5ec5ebfe5..13e8ac385 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -92,7 +92,6 @@ "trafficStat": "Statistiques de trafic", "hideHeadingBelowBlocks": "Masquer les blocs sous l'en-tête", "matchDiacritics": "Respecter les accents et diacritiques", - "foldTip": "Êtes-vous sûr de passer en mode édition et d'enregistrer l'état du pli ?", "copyHPath": "Copier le chemin lisible", "justify": "Justifier", "height": "haut", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index d62b70fa9..cf3e99b4d 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -92,7 +92,6 @@ "trafficStat": "流量統計", "hideHeadingBelowBlocks": "隱藏標題下方的塊", "matchDiacritics": "符合變音符號", - "foldTip": "確定修改為編輯模式並記錄折疊狀態?", "copyHPath": "複製可讀路徑", "justify": "兩側對齊", "height": "高度", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index b8fb52198..78af988db 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -92,7 +92,6 @@ "trafficStat": "流量统计", "hideHeadingBelowBlocks": "隐藏标题下方的块", "matchDiacritics": "匹配变音符号", - "foldTip": "确定修改为编辑模式并记录折叠状态?", "copyHPath": "复制可读路径", "justify": "两侧对齐", "height": "高度", diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 1d380674e..639d4b27f 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -134,23 +134,14 @@ export class Gutter { if (buttonElement.getAttribute("disabled")) { return; } - if (protyle.disabled) { - if (isMobile()) { - confirmDialog(window.siyuan.languages["_kernel"]["34"], window.siyuan.languages.foldTip, () => { - (document.getElementById("toolbarName") as HTMLInputElement).readOnly = false; - document.querySelector("#toolbarEdit use").setAttribute("xlink:href", "#iconPreview"); - enableProtyle(protyle); - gutterFold(); - }); - } - } else { + if (!window.siyuan.config.readonly) { gutterFold(); } hideElements(["select"], protyle); window.siyuan.menus.menu.remove(); return; } - if (protyle.disabled) { + if (window.siyuan.config.readonly) { return; } if (window.siyuan.ctrlIsPressed) { @@ -193,7 +184,7 @@ export class Gutter { setFold(protyle, foldElement); } foldElement.classList.remove("protyle-wysiwyg--hl"); - } else if (window.siyuan.shiftIsPressed) { + } else if (window.siyuan.shiftIsPressed && !protyle.disabled) { openAttr(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`), protyle); } else { this.renderMenu(protyle, buttonElement); @@ -207,7 +198,7 @@ export class Gutter { }); this.element.addEventListener("contextmenu", (event: MouseEvent & { target: HTMLInputElement }) => { const buttonElement = hasClosestByTag(event.target, "BUTTON"); - if (!buttonElement || protyle.disabled || buttonElement.getAttribute("data-type") === "fold") { + if (!buttonElement || window.siyuan.config.readonly || buttonElement.getAttribute("data-type") === "fold") { return; } if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) { @@ -1319,25 +1310,27 @@ export class Gutter { insertEmptyBlock(protyle, "afterend", id); } }).element); + } + window.siyuan.menus.menu.append(new MenuItem({ + label: window.siyuan.languages.jumpToParentNext, + accelerator: window.siyuan.config.keymap.editor.general.jumpToParentNext.custom, + click() { + nodeElement.classList.remove("protyle-wysiwyg--select"); + jumpToParentNext(protyle, nodeElement); + } + }).element); + window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); + + if (type !== "NodeThematicBreak") { window.siyuan.menus.menu.append(new MenuItem({ - label: window.siyuan.languages.jumpToParentNext, - accelerator: window.siyuan.config.keymap.editor.general.jumpToParentNext.custom, + label: window.siyuan.languages.fold, + accelerator: `${updateHotkeyTip(window.siyuan.config.keymap.editor.general.collapse.custom)}/${updateHotkeyTip("⌥Click")}`, click() { - nodeElement.classList.remove("protyle-wysiwyg--select"); - jumpToParentNext(protyle, nodeElement); + setFold(protyle, nodeElement); + focusBlock(nodeElement); } }).element); - window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); - - if (type !== "NodeThematicBreak") { - window.siyuan.menus.menu.append(new MenuItem({ - label: window.siyuan.languages.fold, - accelerator: `${updateHotkeyTip(window.siyuan.config.keymap.editor.general.collapse.custom)}/${updateHotkeyTip("⌥Click")}`, - click() { - setFold(protyle, nodeElement); - focusBlock(nodeElement); - } - }).element); + if (!window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) { window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.attr, accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"), @@ -1346,7 +1339,8 @@ export class Gutter { } }).element); } - + } + if (!window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) { const appearanceElement = new MenuItem({ label: window.siyuan.languages.appearance, submenu: this.genCardStyle([nodeElement], protyle).concat(this.genFontStyle([nodeElement], protyle)).concat(this.genBGStyle([nodeElement], protyle))