From 35ccbaa0f091d8fcc12303660a460bdf82ceeb95 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 27 Feb 2025 21:52:52 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14204 --- app/src/protyle/toolbar/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index e12375db8..329275818 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -446,6 +446,7 @@ export class Toolbar { } } contents.childNodes.forEach((item: HTMLElement, index) => { + let removeText = ""; if (item.nodeType === 3) { if (index === 0 && previousElement && previousElement.nodeType !== 3 && type === previousElement.getAttribute("data-type") && @@ -467,6 +468,11 @@ export class Toolbar { newNodes.push(document.createTextNode(Constants.ZWSP)); item.textContent = item.textContent.substring(1); } + // https://github.com/siyuan-note/siyuan/issues/14204 + while (item.textContent.endsWith("\n")) { + 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; @@ -588,6 +594,9 @@ export class Toolbar { newNodes.push(item); } } + if (removeText) { + newNodes.push(document.createTextNode(removeText)); + } }); } }