An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/11124
Vanessaf64dd4543a3c
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 388c78603f..2887b52108 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -1294,7 +1294,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText});const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");- if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) {+ if (focusText || protyle.lute.GetLinkDest(linkAddress)) {inputElements[1].select();} else {inputElements[0].select();diff --git a/app/src/protyle/toolbar/Link.ts b/app/src/protyle/toolbar/Link.tsindex 93ae0ee886..47b6019e8a 100644--- a/app/src/protyle/toolbar/Link.ts+++ b/app/src/protyle/toolbar/Link.ts@@ -31,16 +31,16 @@ export class Link extends ToolbarItem {try {const clipText = await readText();// 选中链接时需忽略剪切板内容 https://ld246.com/article/1643035329737- if (protyle.lute.IsValidLinkDest(rangeString)) {- dataHref = rangeString;- } else if (protyle.lute.IsValidLinkDest(clipText)) {- dataHref = clipText;- } else {+ dataHref = protyle.lute.GetLinkDest(rangeString);+ if (!dataHref) {+ dataHref = protyle.lute.GetLinkDest(clipText);+ }+ if (!dataHref) {// 360const lastSpace = clipText.lastIndexOf(" ");if (lastSpace > -1) {- if (protyle.lute.IsValidLinkDest(clipText.substring(lastSpace))) {- dataHref = clipText.substring(lastSpace);+ dataHref = protyle.lute.GetLinkDest(clipText.substring(lastSpace));+ if (dataHref) {dataText = clipText.substring(0, lastSpace);}}diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex eb00d9e974..bc2307fc0e 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -43,7 +43,7 @@ export const getTextStar = (blockElement: HTMLElement) => {} else if (blockElement.classList.contains("render-node")) {// 需在嵌入块后,代码块前refText += blockElement.dataset.subtype || Lute.UnEscapeHTMLStr(blockElement.getAttribute("data-content"));- } else if (["NodeBlockquote", "NodeList", "NodeSuperBlock", "NodeListItem"].includes(dataType)) {+ } else if (["NodeBlockquote", "NodeList", "NodeSuperBlock", "NodeListItem"].includes(dataType)) {Array.from(blockElement.querySelectorAll("[data-node-id]")).find((item: HTMLElement) => {if (!["NodeBlockquote", "NodeList", "NodeSuperBlock", "NodeListItem"].includes(item.getAttribute("data-type"))) {refText = getTextStar(blockElement.querySelector("[data-node-id]"));@@ -190,8 +190,11 @@ export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: EletextPlain = textPlain.replace(/'.+'\)\)$/, ` "${range.toString()}"))`);} else if (isFileAnnotation(textPlain)) {textPlain = textPlain.replace(/".+">>$/, `"${range.toString()}">>`);- } else if (protyle.lute.IsValidLinkDest(textPlain)) {- textPlain = `[${range.toString()}](${textPlain})`;+ } else {+ const linkDest = protyle.lute.GetLinkDest(textPlain)+ if (linkDest) {+ textPlain = `[${range.toString()}](${linkDest})`;+ }}}insertHTML(protyle.lute.Md2BlockDOM(textPlain), protyle);@@ -443,13 +446,16 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvencolor: firstLine.substring(2).replace(/ ".+">>$/, "")});return;- } else if (protyle.lute.IsValidLinkDest(textPlain)) {+ } else {// https://github.com/siyuan-note/siyuan/issues/8475- protyle.toolbar.setInlineMark(protyle, "a", "range", {- type: "a",- color: textPlain- });- return;+ const linkDest = protyle.lute.GetLinkDest(textPlain)+ if (linkDest) {+ protyle.toolbar.setInlineMark(protyle, "a", "range", {+ type: "a",+ color: linkDest+ });+ return;+ }}}const textPlainDom = protyle.lute.Md2BlockDOM(textPlain);diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex 89a736e9ab..28e3e90aec 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -240,7 +240,7 @@ declare class Lute {public MarkdownStr(name: string, md: string): string;- public IsValidLinkDest(text: string): boolean;+ public GetLinkDest(text: string): string;public BlockDOM2InlineBlockDOM(html: string): string;