Vanessa 2025-01-05 12:16:03 +08:00
parent 8322087cba
commit d7315fdf5f

View file

@ -1480,13 +1480,49 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
}).element); }).element);
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
} }
if (linkAddress) { window.siyuan.menus.menu.append(new MenuItem({
openMenu(protyle.app, linkAddress, false, true); label: window.siyuan.languages.copy,
if (linkAddress?.startsWith("assets/")) { icon: "iconCopy",
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element); click() {
writeText(protyle.lute.BlockDOM2StdMd(linkElement.outerHTML));
} }
}).element);
if (protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.copy + " " + window.siyuan.languages.replaceTypes.aHref,
icon: "iconLink",
click() {
writeText(linkAddress);
}
}).element);
} }
if (!protyle.disabled) { if (!protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconCut",
label: window.siyuan.languages.cut,
click() {
writeText(protyle.lute.BlockDOM2StdMd(linkElement.outerHTML));
linkElement.insertAdjacentHTML("afterend", "<wbr>");
linkElement.remove();
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, html);
focusByWbr(nodeElement, protyle.toolbar.range);
html = nodeElement.outerHTML;
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconTrashcan",
label: window.siyuan.languages.remove,
click() {
linkElement.insertAdjacentHTML("afterend", "<wbr>");
linkElement.remove();
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, html);
focusByWbr(nodeElement, protyle.toolbar.range);
html = nodeElement.outerHTML;
}
}).element);
if (linkAddress?.startsWith("assets/")) { if (linkAddress?.startsWith("assets/")) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.rename, label: window.siyuan.languages.rename,
@ -1533,61 +1569,26 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
} }
}).element); }).element);
} }
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
writeText(protyle.lute.BlockDOM2StdMd(linkElement.outerHTML));
}
}).element);
if (protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.copy + " " + window.siyuan.languages.replaceTypes.aHref,
icon: "iconLink",
click() {
writeText(linkAddress);
}
}).element);
}
if (!protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconCut",
label: window.siyuan.languages.cut,
click() {
writeText(protyle.lute.BlockDOM2StdMd(linkElement.outerHTML));
linkElement.insertAdjacentHTML("afterend", "<wbr>"); if (linkAddress) {
linkElement.remove(); window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); openMenu(protyle.app, linkAddress, false, true);
updateTransaction(protyle, id, nodeElement.outerHTML, html); if (linkAddress?.startsWith("assets/")) {
focusByWbr(nodeElement, protyle.toolbar.range); window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element);
html = nodeElement.outerHTML;
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconTrashcan",
label: window.siyuan.languages.remove,
click() {
linkElement.insertAdjacentHTML("afterend", "<wbr>");
linkElement.remove();
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, html);
focusByWbr(nodeElement, protyle.toolbar.range);
html = nodeElement.outerHTML;
}
}).element);
if (protyle?.app?.plugins) {
emitOpenMenu({
plugins: protyle.app.plugins,
type: "open-menu-link",
detail: {
protyle,
element: linkElement,
},
separatorPosition: "top",
});
} }
} }
if (!protyle.disabled && protyle?.app?.plugins) {
emitOpenMenu({
plugins: protyle.app.plugins,
type: "open-menu-link",
detail: {
protyle,
element: linkElement,
},
separatorPosition: "top",
});
}
const rect = linkElement.getBoundingClientRect(); const rect = linkElement.getBoundingClientRect();
window.siyuan.menus.menu.popup({ window.siyuan.menus.menu.popup({
x: rect.left, x: rect.left,