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: fix https://github.com/siyuan-note/siyuan/issues/6233
Vanessa9f0fcd8cbc95
diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.tsindex 4dc79f769b..e250b182e5 100644--- a/app/src/protyle/toolbar/Font.ts+++ b/app/src/protyle/toolbar/Font.ts@@ -157,6 +157,15 @@ export const setFontStyle = (textElement: HTMLElement, textOption: ITextOption)textElement.setAttribute("data-subtype", blockRefData[1]);textElement.innerText = blockRefData[2];};+ const setLink = (textOption: string) => {+ const options = textOption.split(Constants.ZWSP)+ textElement.setAttribute("data-href", options[0]);+ textElement.removeAttribute("data-subtype");+ textElement.removeAttribute("data-id");+ if (options[1]) {+ textElement.textContent = options[1];+ }+ };if (textOption) {switch (textOption.type) {@@ -188,9 +197,7 @@ export const setFontStyle = (textElement: HTMLElement, textOption: ITextOption)textElement.textContent = "";break;case "a":- textElement.setAttribute("data-href", textOption.color);- textElement.removeAttribute("data-subtype");- textElement.removeAttribute("data-id");+ setLink(textOption.color);break;case "inline-memo":textElement.removeAttribute("contenteditable");diff --git a/app/src/protyle/toolbar/Link.ts b/app/src/protyle/toolbar/Link.tsindex 2bea6ef49b..bce6ed2a36 100644--- a/app/src/protyle/toolbar/Link.ts+++ b/app/src/protyle/toolbar/Link.ts@@ -3,6 +3,7 @@ import {linkMenu} from "../../menus/protyle";import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";import {focusByRange, focusByWbr} from "../util/selection";import {readText} from "../util/compatibility";+import {Constants} from "../../constants";export class Link extends ToolbarItem {public element: HTMLElement;@@ -27,20 +28,31 @@ export class Link extends ToolbarItem {const rangeString = range.toString().trim();let dataHref = "";+ let dataText = "";try {const clipText = await readText();+// 选中链接时需忽略剪切板内容 https://ld246.com/article/1643035329737if (protyle.lute.IsValidLinkDest(rangeString)) {dataHref = rangeString;} else if (protyle.lute.IsValidLinkDest(clipText)) {dataHref = clipText;+ } else {+ // 360+ const lastSpace = clipText.lastIndexOf(' ')+ if (lastSpace > -1) {+ if (protyle.lute.IsValidLinkDest(clipText.substring(lastSpace))) {+ dataHref = clipText.substring(lastSpace);+ dataText = clipText.substring(0, lastSpace);+ }+ }}} catch (e) {console.log(e);}protyle.toolbar.setInlineMark(protyle, "a", "range", {type: "a",- color: dataHref+ color: dataHref + (dataText ? Constants.ZWSP + dataText : "")});});}