Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/5157

Vanessa81c1d785a742
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index e146ec3f9e..f8727725fe 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);