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

Vanessa8094e28b138b
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 568f634adb..d3fc8c3b93 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -531,11 +531,22 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
e.remove();
}
});
- if (tempElement.childElementCount === 1 && tempElement.childNodes.length === 1 &&
- tempElement.firstElementChild.tagName === "A" && range.toString()) {
+ // https://github.com/siyuan-note/siyuan/issues/14625#issuecomment-2869618067
+ let linkElement;
+ if (tempElement.childElementCount === 1 && tempElement.childNodes.length === 1) {
+ if (tempElement.firstElementChild.tagName === "A") {
+ linkElement = tempElement.firstElementChild;
+ } else if (tempElement.firstElementChild.tagName === "P" &&
+ tempElement.firstElementChild.childElementCount === 1 &&
+ tempElement.firstElementChild.childNodes.length === 1 &&
+ tempElement.firstElementChild.firstElementChild.tagName === "A") {
+ linkElement = tempElement.firstElementChild.firstElementChild;
+ }
+ }
+ if (linkElement) {
protyle.toolbar.setInlineMark(protyle, "a", "range", {
type: "a",
- color: (tempElement.firstElementChild as HTMLLinkElement).href
+ color: `${linkElement.getAttribute("href")}${Constants.ZWSP}${range.toString() || linkElement.textContent}`
});
return;
}