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/5540

Vanessa0c374af4b5c1
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 4e09aafbc2..2fa56cc89b 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 7a1c3b864c..c975e4c8dc 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));