From 8a08964a5338767f5b2ab69e8fef39e5f6fc1cc5 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 24 Nov 2022 23:57:22 +0800 Subject: [PATCH] :iphone: fix https://github.com/siyuan-note/siyuan/issues/6709 --- app/src/menus/protyle.ts | 16 +++++++++++++++- app/src/protyle/wysiwyg/index.ts | 7 ++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index b2027966a..243527eff 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -1,6 +1,12 @@ import {hasClosestBlock, hasClosestByMatchTag} from "../protyle/util/hasClosest"; import {MenuItem} from "./Menu"; -import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll} from "../protyle/util/selection"; +import { + focusBlock, + focusByRange, + focusByWbr, + getEditorRange, + selectAll, +} from "../protyle/util/selection"; import { deleteColumn, deleteRow, @@ -38,6 +44,8 @@ import {pushBack} from "../mobile/util/MobileBackFoward"; import {exportAsset} from "./util"; import {removeLink} from "../protyle/toolbar/Link"; import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey"; +import {getEnableHTML} from "../protyle/wysiwyg/removeEmbed"; +import {getContenteditableElement} from "../protyle/wysiwyg/getBlock"; export const refMenu = (protyle: IProtyle, element: HTMLElement) => { const nodeElement = hasClosestBlock(element); @@ -310,11 +318,17 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => { html += (item as Element).outerHTML; } }); + if (protyle.disabled) { + html = getEnableHTML(html) + } const tempElement = document.createElement("template"); tempElement.innerHTML = protyle.lute.BlockDOM2HTML(html); writeText(tempElement.content.firstElementChild.innerHTML); } }).element); + if (protyle.disabled) { + return; + } window.siyuan.menus.menu.append(new MenuItem({ icon: "iconCut", accelerator: "⌘X", diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index ddbc596df..d454d469f 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1137,11 +1137,8 @@ export class WYSIWYG { window.siyuan.menus.menu.popup({x, y}); return false; } - if (protyle.disabled) { - return false; - } protyle.toolbar.range = getEditorRange(protyle.element); - if (target.tagName === "SPAN") { // https://ld246.com/article/1665141518103 + if (target.tagName === "SPAN" && !protyle.disabled) { // https://ld246.com/article/1665141518103 const types = protyle.toolbar.getCurrentType(protyle.toolbar.range); if (types.includes("block-ref")) { refMenu(protyle, target); @@ -1172,7 +1169,7 @@ export class WYSIWYG { return false; } } - if (target.tagName === "IMG" && hasClosestByClassName(target, "img")) { + if (!protyle.disabled && target.tagName === "IMG" && hasClosestByClassName(target, "img")) { imgMenu(protyle, protyle.toolbar.range, target.parentElement.parentElement, { clientX: x + 4, clientY: y