diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 8524e7318..5370064c6 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -365,9 +365,10 @@ export class WYSIWYG { const selectTypes = protyle.toolbar.getCurrentType(range); const spanElement = hasClosestByTag(range.startContainer, "SPAN"); const headingElement = hasClosestByAttribute(range.startContainer, "data-type", "NodeHeading"); + const matchHeading = headingElement && headingElement.textContent.replace(Constants.ZWSP, "") === range.toString(); if ((selectTypes.length > 0 && spanElement && spanElement.textContent.replace(Constants.ZWSP, "") === range.toString()) || - (headingElement && headingElement.textContent.replace(Constants.ZWSP, "") === range.toString())) { - if (headingElement) { + matchHeading) { + if (matchHeading) { // 复制标题 https://github.com/siyuan-note/insider/issues/297 tempElement.append(headingElement.cloneNode(true)); } else if (!["DIV", "TD", "TH", "TR"].includes(range.startContainer.parentElement.tagName)) {