From e376a5611463edba2c2e1a7a8e271804fadd1f5c Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 19 May 2025 17:09:29 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14821 --- app/src/protyle/toolbar/Link.ts | 7 ++++++- app/src/protyle/toolbar/index.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/toolbar/Link.ts b/app/src/protyle/toolbar/Link.ts index 519ac5f7f..870896e72 100644 --- a/app/src/protyle/toolbar/Link.ts +++ b/app/src/protyle/toolbar/Link.ts @@ -27,6 +27,7 @@ export class Link extends ToolbarItem { let dataHref = ""; let dataText = range.toString().trim().replace(Constants.ZWSP, ""); + let showMenu = false; try { // 选中链接时需忽略剪切板内容 https://ld246.com/article/1643035329737 dataHref = protyle.lute.GetLinkDest(dataText); @@ -65,15 +66,19 @@ export class Link extends ToolbarItem { if (dataHref.length > Constants.SIZE_LINK_TEXT_MAX) { dataText = dataHref.substring(0, Constants.SIZE_LINK_TEXT_MAX) + "..."; } + showMenu = true; } } } catch (e) { console.log(e); } - protyle.toolbar.setInlineMark(protyle, "a", "range", { + const linkElements = protyle.toolbar.setInlineMark(protyle, "a", "range", { type: "a", color: dataHref + (dataText ? Constants.ZWSP + dataText : "") }); + if (showMenu) { + linkMenu(protyle, linkElements[0] as HTMLElement, true); + } }); } } diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 56c0c042d..b99d83657 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -807,6 +807,7 @@ export class Toolbar { } } } + return newNodes; } public showRender(protyle: IProtyle, renderElement: Element, updateElements?: Element[], oldHTML?: string) {