Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/15208

Vanessaf2e6bdc755cd
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 9d2b06d900..336b9aa214 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -6,7 +6,7 @@ import {
focusByWbr,
getEditorRange,
getSelectionOffset,
- getSelectionPosition
+ getSelectionPosition, setLastNodeRange
} from "../util/selection";
import {genHintItemHTML, hintEmbed, hintRef, hintSlash} from "./extend";
import {getSavePath, newFile} from "../../util/newFile";
@@ -563,6 +563,13 @@ ${genHintItemHTML(item)}
type: "id",
color: `${response.data}${Constants.ZWSP}${refIsS ? "s" : "d"}${Constants.ZWSP}${(refIsS ? fileNames[0] : realFileName).substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen)}`
});
+ if (protyle.toolbar.range.endContainer.nodeType === 1 &&
+ protyle.toolbar.range.endContainer.childNodes[protyle.toolbar.range.endOffset]) {
+ const refElement = hasPreviousSibling(protyle.toolbar.range.endContainer.childNodes[protyle.toolbar.range.endOffset]) as HTMLElement;
+ if (refElement && refElement.nodeType === 1 && refElement.getAttribute("data-type") === "block-ref") {
+ setLastNodeRange(refElement as HTMLElement, protyle.toolbar.range, false);
+ }
+ }
protyle.toolbar.range.collapse(false);
});
});
@@ -597,6 +604,13 @@ ${genHintItemHTML(item)}
type: "id",
color: `${tempElement.getAttribute("data-id")}${Constants.ZWSP}${tempElement.getAttribute("data-subtype")}${Constants.ZWSP}${tempElement.textContent}`
});
+ if (protyle.toolbar.range.endContainer.nodeType === 1 &&
+ protyle.toolbar.range.endContainer.childNodes[protyle.toolbar.range.endOffset]) {
+ const refElement = hasPreviousSibling(protyle.toolbar.range.endContainer.childNodes[protyle.toolbar.range.endOffset]) as HTMLElement;
+ if (refElement && refElement.nodeType === 1 && refElement.getAttribute("data-type") === "block-ref") {
+ setLastNodeRange(refElement as HTMLElement, protyle.toolbar.range, false);
+ }
+ }
protyle.toolbar.range.collapse(false);
return;
} else if (this.splitChar === ":") {