Vanessa 2025-01-05 12:06:02 +08:00
parent 58d47ed548
commit 8322087cba
3 changed files with 70 additions and 6 deletions

View file

@ -82,6 +82,8 @@ export const initBlockPopover = (app: App) => {
if (href) { if (href) {
tip = `<span style="word-break: break-all">${href.substring(0, Constants.SIZE_TITLE)}</span>`; tip = `<span style="word-break: break-all">${href.substring(0, Constants.SIZE_TITLE)}</span>`;
tooltipClass = "href"; // 为超链接添加 class https://github.com/siyuan-note/siyuan/issues/11440#issuecomment-2119080691 tooltipClass = "href"; // 为超链接添加 class https://github.com/siyuan-note/siyuan/issues/11440#issuecomment-2119080691
} else {
tip = "";
} }
const title = aElement.getAttribute("data-title"); const title = aElement.getAttribute("data-title");
if (tip && isLocalPath(href) && !aElement.classList.contains("b3-tooltips")) { if (tip && isLocalPath(href) && !aElement.classList.contains("b3-tooltips")) {

View file

@ -423,7 +423,7 @@ export const copySubMenu = (ids: string[], accelerator = true, focusElement?: El
iconHTML: "", iconHTML: "",
label: window.siyuan.languages.copyHPath, label: window.siyuan.languages.copyHPath,
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined, accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined,
click: () => { click: () => {
copyTextByType(ids, "hPath"); copyTextByType(ids, "hPath");
if (focusElement) { if (focusElement) {
focusBlock(focusElement); focusBlock(focusElement);

View file

@ -212,19 +212,72 @@ export const editAssetItem = (options: {
menu.addItem({ menu.addItem({
iconHTML: "", iconHTML: "",
type: "readonly", type: "readonly",
label: `${window.siyuan.languages.link} label: `<div class="fn__flex">
<span class="fn__flex-center">${window.siyuan.languages.link}</span>
<span class="fn__space"></span>
<span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
<svg><use xlink:href="#iconCopy"></use></svg>
</span>
</div>
<textarea rows="1" style="margin:4px 0;width: ${isMobile() ? "200" : "360"}px;resize: vertical;" class="b3-text-field"></textarea> <textarea rows="1" style="margin:4px 0;width: ${isMobile() ? "200" : "360"}px;resize: vertical;" class="b3-text-field"></textarea>
<div class="fn__hr"></div> <div class="fn__hr"></div>
${window.siyuan.languages.title} <div class="fn__flex">
<span class="fn__flex-center">${window.siyuan.languages.title}</span>
<span class="fn__space"></span>
<span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
<svg><use xlink:href="#iconCopy"></use></svg>
</span>
</div>
<textarea style="width: ${isMobile() ? "200" : "360"}px;margin: 4px 0;resize: vertical;" rows="1" class="b3-text-field"></textarea>`, <textarea style="width: ${isMobile() ? "200" : "360"}px;margin: 4px 0;resize: vertical;" rows="1" class="b3-text-field"></textarea>`,
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 { } else {
menu.addItem({ menu.addItem({
iconHTML: "", iconHTML: "",
type: "readonly", type: "readonly",
label: `${window.siyuan.languages.link} label: `<div class="fn__flex">
<span class="fn__flex-center">${window.siyuan.languages.link}</span>
<span class="fn__space"></span>
<span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
<svg><use xlink:href="#iconCopy"></use></svg>
</span>
</div>
<textarea rows="1" style="margin:4px 0;width: ${isMobile() ? "200" : "360"}px;resize: vertical;" class="b3-text-field"></textarea>`, <textarea rows="1" style="margin:4px 0;width: ${isMobile() ? "200" : "360"}px;resize: vertical;" class="b3-text-field"></textarea>`,
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({ menu.addItem({
label: window.siyuan.languages.copy, label: window.siyuan.languages.copy,
icon: "iconCopy", 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") { if (type !== "file") {
menu.addItem({ menu.addItem({
icon: "iconPreview", 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/")) { if (linkAddress?.startsWith("assets/")) {
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element); window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element);
} }