diff --git a/src/public/app/menus/context_menu.ts b/src/public/app/menus/context_menu.ts index 9793601d7..bc45c06e0 100644 --- a/src/public/app/menus/context_menu.ts +++ b/src/public/app/menus/context_menu.ts @@ -53,6 +53,7 @@ class ContextMenu { } async show(options: ContextMenuOptions) { + console.warn(new Error().stack); this.options = options; if (this.$widget.hasClass("show")) { diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index c11adc70d..62ec3da2b 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -32,14 +32,14 @@ const TPL = ` position: relative; min-height: 0; } - + .tree { height: 100%; overflow: auto; padding-bottom: 35px; padding-top: 5px; } - + .tree-actions { background-color: var(--launcher-pane-background-color); z-index: 100; @@ -52,7 +52,7 @@ const TPL = ` border-radius: 7px; border: 1px solid var(--main-border-color); } - + button.tree-floating-button { margin: 1px; font-size: 1.5em; @@ -63,76 +63,76 @@ const TPL = ` border-radius: var(--button-border-radius); border: 1px solid transparent; } - + button.tree-floating-button:hover { border: 1px solid var(--button-border-color); } - + .collapse-tree-button { right: 100px; } - + .scroll-to-active-note-button { right: 55px; } - + .tree-settings-button { right: 10px; } - + .tree-settings-popup { - display: none; - position: absolute; - background-color: var(--accented-background-color); - border: 1px solid var(--main-border-color); - padding: 20px; + display: none; + position: absolute; + background-color: var(--accented-background-color); + border: 1px solid var(--main-border-color); + padding: 20px; z-index: 1000; - width: 340px; + width: 340px; border-radius: 10px; } - + .tree .hidden-node-is-hidden { display: none; } - +
- +
- - - - -
- - + +

${t("note_tree.tree-settings-title")}

- +
- +
@@ -601,7 +601,32 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } }); - if (!utils.isMobile()) { + const isMobile = utils.isMobile(); + + if (isMobile) { + let showTimeout; + + this.$tree.on("touchstart", ".fancytree-node", (e) => { + touchStart = new Date().getTime(); + showTimeout = setTimeout(() => { + this.showContextMenu(e); + }, 300) + }); + + this.$tree.on("touchmove", ".fancytree-node", (e) => { + clearTimeout(showTimeout); + }); + + this.$tree.on("touchend", ".fancytree-node", (e) => { + clearTimeout(showTimeout); + e.preventDefault(); + }); + } else { + this.$tree.on('contextmenu', '.fancytree-node', e => { + this.showContextMenu(e); + return false; // blocks default browser right click menu + }); + this.getHotKeys().then(hotKeys => { for (const key in hotKeys) { const handler = hotKeys[key]; @@ -615,28 +640,28 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { }); } - this.$tree.on('contextmenu', '.fancytree-node', e => { - const node = $.ui.fancytree.getNode(e); - const note = froca.getNoteFromCache(node.data.noteId); - - if (note.isLaunchBarConfig()) { - import("../menus/launcher_context_menu.js").then(({default: LauncherContextMenu}) => { - const launcherContextMenu = new LauncherContextMenu(this, node); - launcherContextMenu.show(e); - }); - } else { - import("../menus/tree_context_menu.js").then(({default: TreeContextMenu}) => { - const treeContextMenu = new TreeContextMenu(this, node); - treeContextMenu.show(e); - }); - } - - return false; // blocks default browser right click menu - }); + let touchStart; this.tree = $.ui.fancytree.getTree(this.$tree); } + showContextMenu(e) { + const node = $.ui.fancytree.getNode(e); + const note = froca.getNoteFromCache(node.data.noteId); + + if (note.isLaunchBarConfig()) { + import("../menus/launcher_context_menu.js").then(({default: LauncherContextMenu}) => { + const launcherContextMenu = new LauncherContextMenu(this, node); + launcherContextMenu.show(e); + }); + } else { + import("../menus/tree_context_menu.js").then(({default: TreeContextMenu}) => { + const treeContextMenu = new TreeContextMenu(this, node); + treeContextMenu.show(e); + }); + } + } + prepareRootNode() { return this.prepareNode(froca.getBranch('none_root')); }