From 81c1d785a74278c45272b1fd6668644ed852a581 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 11 Jun 2022 00:50:51 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5157 --- app/src/protyle/toolbar/index.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index e146ec3f9..f8727725f 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -72,6 +72,24 @@ export class Toolbar { this.element.classList.add("fn__none"); return; } + // https://github.com/siyuan-note/siyuan/issues/5157 + let hasImg = true; + let noText = true; + Array.from(range.cloneContents().childNodes).find(item => { + if (item.nodeType !== 1) { + if (item.textContent.length > 0) { + noText = false + return true + } + } else if (!(item as HTMLElement).classList.contains("img")) { + hasImg = false + return true + } + }) + if (hasImg && noText) { + this.element.classList.add("fn__none"); + return; + } // shift+方向键或三击选中,不同的块 https://github.com/siyuan-note/siyuan/issues/3891 const startElement = hasClosestBlock(range.startContainer); const endElement = hasClosestBlock(range.endContainer);