Preserving default word-selection on the contextmenu event in edit mode while adding gesture support

What I’m trying to do

I’m building a plugin that lets users navigate by gestures with the right mouse button in Obsidian’s editor. To detect gestures, I intercept contextmenu on mousedown and re-enable it on mouseup. The goal is to suppress the menu while drawing but show it again on release.

Things I have tried

  • Scanned help docs and existing forum threads on editor events and gestures
  • e.preventDefault() on mousedown to block the menu
  • Re-attached the contextmenu listener on mouseup
  • Dispatching a synthetic contextmenu at original coordinates
  • Calling this.app.commands.executeCommandById(‘selectWord’) ??

Plugin Repository: obsidian-mouse-navigation