From 8cf56951197c10b976530f069a2850d1ff567073 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 6 Dec 2022 20:49:37 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/6798 --- app/src/menus/protyle.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 19d0ff6f3..4a760f026 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -740,7 +740,16 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText label: `
`, bind(element) { const inputElement = element.querySelector("input"); - inputElement.value = linkElement.textContent.replace(Constants.ZWSP, ""); + // https://github.com/siyuan-note/siyuan/issues/6798 + let anchor = linkElement.textContent.replace(Constants.ZWSP, ""); + if (!anchor && linkAddress) { + anchor = linkAddress.replace("https://", "").replace("http://", ""); + if (anchor.length > 16) { + anchor = anchor.substring(0, 16) + "..."; + } + linkElement.innerHTML = Lute.EscapeHTMLStr(anchor); + } + inputElement.value = anchor; inputElement.addEventListener("change", () => { if (!inputElement.value) { linkElement.remove();