From 0c374af4b5c1b75fb3edf5c9b8e46ecf209d5f31 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 30 Jul 2022 16:29:11 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5540 --- app/src/protyle/toolbar/index.ts | 2 +- app/src/protyle/wysiwyg/index.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 4e09aafbc..2fa56cc89 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -199,7 +199,7 @@ export class Toolbar { } else if (startType === "block-ref" || endType === "block-ref") { types.push("blockRef"); } else if (startType === "file-annotation-ref" || endType === "file-annotation-ref") { - types.push("blockRef"); + types.push("fileAnnotationRef"); } else if (startType === "inline-math") { types.push("inline-math"); } diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 7a1c3b864..c975e4c8d 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -225,8 +225,13 @@ export class WYSIWYG { } } else { const tempElement = document.createElement("div"); - if (range.toString() !== "" && range.startContainer.isSameNode(range.endContainer) && range.startContainer.nodeType === 3 - && range.endOffset === range.startContainer.textContent.length && range.startOffset === 0) { + // https://github.com/siyuan-note/siyuan/issues/5540 + const selectTypes = protyle.toolbar.getCurrentType(range) + if ((selectTypes.length === 1 || range.startContainer.parentElement.parentElement.getAttribute("data-type") === "NodeHeading") && + ( + (range.startContainer.nodeType === 3 && range.startContainer.parentElement.textContent === range.toString()) || + (range.startContainer.nodeType !== 3 && range.startContainer.textContent === range.toString()) + )) { if (range.startContainer.parentElement.parentElement.getAttribute("data-type") === "NodeHeading") { // 复制标题 https://github.com/siyuan-note/insider/issues/297 tempElement.append(range.startContainer.parentElement.parentElement.cloneNode(true));