mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
This commit is contained in:
parent
8322087cba
commit
d7315fdf5f
1 changed files with 57 additions and 56 deletions
|
|
@ -1480,13 +1480,49 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
|||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
}
|
||||
if (linkAddress) {
|
||||
openMenu(protyle.app, linkAddress, false, true);
|
||||
if (linkAddress?.startsWith("assets/")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).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>");
|
||||
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/")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.rename,
|
||||
|
|
@ -1533,50 +1569,16 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
|||
}
|
||||
}).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>");
|
||||
linkElement.remove();
|
||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||
focusByWbr(nodeElement, protyle.toolbar.range);
|
||||
html = nodeElement.outerHTML;
|
||||
if (linkAddress) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
openMenu(protyle.app, linkAddress, false, true);
|
||||
if (linkAddress?.startsWith("assets/")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element);
|
||||
}
|
||||
}).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) {
|
||||
|
||||
if (!protyle.disabled && protyle?.app?.plugins) {
|
||||
emitOpenMenu({
|
||||
plugins: protyle.app.plugins,
|
||||
type: "open-menu-link",
|
||||
|
|
@ -1587,7 +1589,6 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
|||
separatorPosition: "top",
|
||||
});
|
||||
}
|
||||
}
|
||||
const rect = linkElement.getBoundingClientRect();
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: rect.left,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue