mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-08 05:32:33 +01:00
This commit is contained in:
parent
811d088ff0
commit
734ff8490b
1 changed files with 36 additions and 20 deletions
|
|
@ -737,25 +737,13 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
if (linkAddress) {
|
||||||
icon: "iconTrashcan",
|
openMenu(linkAddress);
|
||||||
label: window.siyuan.languages.remove,
|
|
||||||
click() {
|
|
||||||
protyle.toolbar.setInlineMark(protyle, "link", "remove");
|
|
||||||
}
|
|
||||||
}).element);
|
|
||||||
if (linkAddress?.startsWith("assets/")) {
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
|
||||||
label: window.siyuan.languages.rename,
|
|
||||||
click() {
|
|
||||||
renameAsset(linkAddress);
|
|
||||||
}
|
|
||||||
}).element);
|
|
||||||
}
|
}
|
||||||
|
const submenu: IMenu[] = [];
|
||||||
if (linkAddress?.startsWith("siyuan://blocks/")) {
|
if (linkAddress?.startsWith("siyuan://blocks/")) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
submenu.push({
|
||||||
icon: "iconRefresh",
|
label: window.siyuan.languages.blockRef,
|
||||||
label: window.siyuan.languages.turnInto + " " + window.siyuan.languages.blockRef,
|
|
||||||
click() {
|
click() {
|
||||||
linkElement.setAttribute("data-subtype", "s");
|
linkElement.setAttribute("data-subtype", "s");
|
||||||
linkElement.setAttribute("data-type", "block-ref");
|
linkElement.setAttribute("data-type", "block-ref");
|
||||||
|
|
@ -768,11 +756,39 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
||||||
protyle.toolbar.range.collapse(false);
|
protyle.toolbar.range.collapse(false);
|
||||||
focusByRange(protyle.toolbar.range);
|
focusByRange(protyle.toolbar.range);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
submenu.push({
|
||||||
|
label: window.siyuan.languages.text,
|
||||||
|
click() {
|
||||||
|
protyle.toolbar.setInlineMark(protyle, "link", "remove");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
label: window.siyuan.languages.turnInto,
|
||||||
|
icon: "iconRefresh",
|
||||||
|
submenu
|
||||||
|
}).element);
|
||||||
|
if (linkAddress?.startsWith("assets/")) {
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
label: window.siyuan.languages.rename,
|
||||||
|
click() {
|
||||||
|
renameAsset(linkAddress);
|
||||||
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
if (linkAddress) {
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
openMenu(linkAddress);
|
icon: "iconTrashcan",
|
||||||
}
|
label: window.siyuan.languages.remove,
|
||||||
|
click() {
|
||||||
|
const oldHTML = nodeElement.outerHTML;
|
||||||
|
linkElement.insertAdjacentHTML("afterend", "<wbr>");
|
||||||
|
linkElement.remove();
|
||||||
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
|
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||||
|
focusByWbr(nodeElement, protyle.toolbar.range);
|
||||||
|
}
|
||||||
|
}).element);
|
||||||
const rect = linkElement.getBoundingClientRect();
|
const rect = linkElement.getBoundingClientRect();
|
||||||
window.siyuan.menus.menu.popup({
|
window.siyuan.menus.menu.popup({
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue