mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01: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,7 +640,12 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$tree.on('contextmenu', '.fancytree-node', e => {
 | 
					        let touchStart;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.tree = $.ui.fancytree.getTree(this.$tree);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    showContextMenu(e) {
 | 
				
			||||||
        const node = $.ui.fancytree.getNode(e);
 | 
					        const node = $.ui.fancytree.getNode(e);
 | 
				
			||||||
        const note = froca.getNoteFromCache(node.data.noteId);
 | 
					        const note = froca.getNoteFromCache(node.data.noteId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -630,11 +660,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
                treeContextMenu.show(e);
 | 
					                treeContextMenu.show(e);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
            return false; // blocks default browser right click menu
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        this.tree = $.ui.fancytree.getTree(this.$tree);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    prepareRootNode() {
 | 
					    prepareRootNode() {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user