mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 20:00:17 +01:00
This commit is contained in:
parent
84819beaf7
commit
fbc86d6a90
6 changed files with 39 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ import {Menu} from "./Menu";
|
|||
import {hasClosestByClassName, hasTopClosestByTag} from "../protyle/util/hasClosest";
|
||||
import {App} from "../index";
|
||||
import {Constants} from "../constants";
|
||||
import {textMenu} from "./text";
|
||||
|
||||
|
||||
export class Menus {
|
||||
|
|
@ -89,7 +90,15 @@ export class Menus {
|
|||
initDockMenu(target).popup({x: event.clientX, y: event.clientY});
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (dataType === "textMenu") {
|
||||
/// #if !BROWSER
|
||||
textMenu(target).open({x: event.clientX, y: event.clientY});
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
/// #endif
|
||||
}
|
||||
|
||||
target = target.parentElement;
|
||||
}
|
||||
}, false);
|
||||
|
|
|
|||
26
app/src/menus/text.ts
Normal file
26
app/src/menus/text.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import {Menu} from "../plugin/Menu";
|
||||
|
||||
export const textMenu = (target: Element) => {
|
||||
const menu = new Menu();
|
||||
if (menu.isOpen) {
|
||||
return;
|
||||
}
|
||||
menu.addItem({
|
||||
label: window.siyuan.languages.copy,
|
||||
icon: "iconCopy",
|
||||
click() {
|
||||
document.execCommand("copy");
|
||||
}
|
||||
})
|
||||
menu.addItem({
|
||||
label: window.siyuan.languages.selectAll,
|
||||
icon: "iconSelect",
|
||||
click() {
|
||||
if (getSelection().rangeCount === 0) {
|
||||
return;
|
||||
}
|
||||
getSelection().getRangeAt(0).selectNode(target)
|
||||
}
|
||||
})
|
||||
return menu
|
||||
}
|
||||
|
|
@ -31,7 +31,6 @@ export const exportAsset = (src: string) => {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
|
||||
export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathString?: string) => {
|
||||
/// #if !MOBILE
|
||||
const openSubmenus: IMenu[] = [{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue