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

Vanessa011b33c61872
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 4c882af056..444b821f9f 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -1720,12 +1720,18 @@ style="margin:4px 0;width: ${isMobile() ? "100%" : "360px"}" class="b3-text-fiel
} else {
linkElement.removeAttribute("data-href");
}
+ if (!inputElements[1].value && (inputElements[0].value || inputElements[2].value)) {
+ linkElement.textContent = "*";
+ }
const currentRange = getSelection().rangeCount === 0 ? undefined : getSelection().getRangeAt(0);
if (currentRange && !protyle.element.contains(currentRange.startContainer)) {
protyle.toolbar.range.selectNodeContents(linkElement);
protyle.toolbar.range.collapse(false);
focusByRange(protyle.toolbar.range);
}
+ if (!inputElements[1].value && !inputElements[0].value && !inputElements[2].value) {
+ linkElement.remove();
+ }
if (html !== nodeElement.outerHTML) {
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, html);
diff --git a/app/src/protyle/toolbar/Link.ts b/app/src/protyle/toolbar/Link.ts
index 9af7e25f4b..6ac76d5b22 100644
--- a/app/src/protyle/toolbar/Link.ts
+++ b/app/src/protyle/toolbar/Link.ts
@@ -59,6 +59,13 @@ export class Link extends ToolbarItem {
if (!dataHref && clipObject.textPlain.startsWith("assets/")) {
dataHref = clipObject.textPlain;
}
+ // https://github.com/siyuan-note/siyuan/issues/14704 & https://github.com/siyuan-note/siyuan/issues/6798
+ if (dataHref && !dataText) {
+ dataText = decodeURIComponent(dataHref.replace("https://", "").replace("http://", ""));
+ if (dataHref.length > Constants.SIZE_LINK_TEXT_MAX) {
+ dataText = dataHref.substring(0, Constants.SIZE_LINK_TEXT_MAX) + "...";
+ }
+ }
}
} catch (e) {
console.log(e);