diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts index 663dd1e76..87f33bae6 100644 --- a/app/src/block/popover.ts +++ b/app/src/block/popover.ts @@ -82,6 +82,8 @@ export const initBlockPopover = (app: App) => { if (href) { tip = `${href.substring(0, Constants.SIZE_TITLE)}`; tooltipClass = "href"; // 为超链接添加 class https://github.com/siyuan-note/siyuan/issues/11440#issuecomment-2119080691 + } else { + tip = ""; } const title = aElement.getAttribute("data-title"); if (tip && isLocalPath(href) && !aElement.classList.contains("b3-tooltips")) { diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts index cc4fa0cec..4dbeb123f 100644 --- a/app/src/menus/commonMenuItem.ts +++ b/app/src/menus/commonMenuItem.ts @@ -423,7 +423,7 @@ export const copySubMenu = (ids: string[], accelerator = true, focusElement?: El iconHTML: "", label: window.siyuan.languages.copyHPath, accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined, - click: () => { + click: () => { copyTextByType(ids, "hPath"); if (focusElement) { focusBlock(focusElement); diff --git a/app/src/protyle/render/av/asset.ts b/app/src/protyle/render/av/asset.ts index 6e6c37ca7..fac6c0df5 100644 --- a/app/src/protyle/render/av/asset.ts +++ b/app/src/protyle/render/av/asset.ts @@ -212,19 +212,72 @@ export const editAssetItem = (options: { menu.addItem({ iconHTML: "", type: "readonly", - label: `${window.siyuan.languages.link} + label: `
+ ${window.siyuan.languages.link} + + + + +
-${window.siyuan.languages.title} +
+ ${window.siyuan.languages.title} + + + + +
`, + bind(element) { + element.addEventListener("click", (event) => { + let target = event.target as HTMLElement; + while (target) { + if (target.dataset.action === "copy") { + writeText((target.parentElement.nextElementSibling as HTMLTextAreaElement).value); + showMessage(window.siyuan.languages.copied); + break; + } + target = target.parentElement; + } + }); + } + }); + menu.addSeparator() + menu.addItem({ + label: window.siyuan.languages.copy, + icon: "iconCopy", + click() { + writeText(`[${textElements[1].value || textElements[0].value}](${textElements[0].value})`); + } }); } else { menu.addItem({ iconHTML: "", type: "readonly", - label: `${window.siyuan.languages.link} + label: `
+ ${window.siyuan.languages.link} + + + + +
`, + bind(element) { + element.addEventListener("click", (event) => { + let target = event.target as HTMLElement; + while (target) { + if (target.dataset.action === "copy") { + writeText((target.parentElement.nextElementSibling as HTMLTextAreaElement).value); + showMessage(window.siyuan.languages.copied); + break; + } + target = target.parentElement; + } + }); + } }); + menu.addSeparator(); menu.addItem({ label: window.siyuan.languages.copy, icon: "iconCopy", @@ -262,7 +315,10 @@ ${window.siyuan.languages.title} } }); } - menu.addSeparator(); + const openSubMenu = openMenu(options.protyle ? options.protyle.app : window.siyuan.ws.app, linkAddress, true, false); + if (type !== "file" || openSubMenu.length > 0) { + menu.addSeparator(); + } if (type !== "file") { menu.addItem({ icon: "iconPreview", @@ -272,7 +328,13 @@ ${window.siyuan.languages.title} } }); } - openMenu(options.protyle ? options.protyle.app : window.siyuan.ws.app, linkAddress, false, false); + if (openSubMenu.length > 0) { + window.siyuan.menus.menu.append(new MenuItem({ + label: window.siyuan.languages.openBy, + icon: "iconOpen", + submenu: openSubMenu + }).element); + } if (linkAddress?.startsWith("assets/")) { window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element); }