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) {