From 708da7c7535bbd5357473e25ae7abee6bffa5632 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 30 Apr 2025 12:54:59 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14290 --- app/src/protyle/toolbar/index.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index d7f5e517b..5625451f4 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -485,15 +485,17 @@ export class Toolbar { item.textContent = item.textContent.substring(0, item.textContent.length - 1); removeText += "\n"; } - const inlineElement = document.createElement("span"); - inlineElement.setAttribute("data-type", type); - inlineElement.textContent = item.textContent; - setFontStyle(inlineElement, textObj); + if (item.textContent) { + const inlineElement = document.createElement("span"); + inlineElement.setAttribute("data-type", type); + inlineElement.textContent = item.textContent; + setFontStyle(inlineElement, textObj); - if (type === "text" && !inlineElement.getAttribute("style")) { - newNodes.push(item); - } else { - newNodes.push(inlineElement); + if (type === "text" && !inlineElement.getAttribute("style")) { + newNodes.push(item); + } else { + newNodes.push(inlineElement); + } } } else if (item.nodeType === 1) { let types = (item.getAttribute("data-type") || "").split(" ");