mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 13:02:00 +08:00
fix(mobile): display of context menu on iOS
This commit is contained in:
parent
12eff0fef5
commit
bd10babd1b
@ -53,6 +53,7 @@ class ContextMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async show<T extends CommandNames>(options: ContextMenuOptions<T>) {
|
async show<T extends CommandNames>(options: ContextMenuOptions<T>) {
|
||||||
|
console.warn(new Error().stack);
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (this.$widget.hasClass("show")) {
|
if (this.$widget.hasClass("show")) {
|
||||||
|
@ -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 => {
|
this.getHotKeys().then(hotKeys => {
|
||||||
for (const key in hotKeys) {
|
for (const key in hotKeys) {
|
||||||
const handler = hotKeys[key];
|
const handler = hotKeys[key];
|
||||||
@ -615,28 +640,28 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$tree.on('contextmenu', '.fancytree-node', e => {
|
let touchStart;
|
||||||
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
|
|
||||||
});
|
|
||||||
|
|
||||||
this.tree = $.ui.fancytree.getTree(this.$tree);
|
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() {
|
prepareRootNode() {
|
||||||
return this.prepareNode(froca.getBranch('none_root'));
|
return this.prepareNode(froca.getBranch('none_root'));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user