From 011b33c61872537217e8fd8f6b180ccf8e9ab547 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 11 May 2025 11:56:15 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14704 --- app/src/menus/protyle.ts | 6 ++++++ app/src/protyle/toolbar/Link.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 4c882af05..444b821f9 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 9af7e25f4..6ac76d5b2 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);