@@ -104,6 +104,20 @@ async function EditorManager($header, $body) {
104104 let autosaveTimeout = null ;
105105 let touchSelectionController = null ;
106106 let touchSelectionSyncRaf = 0 ;
107+ let nativeContextMenuDisabled = null ;
108+
109+ const setNativeContextMenuDisabled = ( disabled ) => {
110+ const value = ! ! disabled ;
111+ if ( nativeContextMenuDisabled === value ) return ;
112+ nativeContextMenuDisabled = value ;
113+ const api = globalThis . system ?. setNativeContextMenuDisabled ;
114+ if ( typeof api !== "function" ) return ;
115+ try {
116+ api . call ( globalThis . system , value ) ;
117+ } catch ( error ) {
118+ console . warn ( "Failed to update native context menu state" , error ) ;
119+ }
120+ } ;
107121
108122 const { scrollbarSize } = appSettings . value ;
109123 const events = {
@@ -1599,8 +1613,13 @@ async function EditorManager($header, $body) {
15991613
16001614 // Attach native DOM event listeners directly to the editor's contentDOM
16011615 const contentDOM = editor . contentDOM ;
1616+ const isFocused =
1617+ contentDOM === document . activeElement ||
1618+ contentDOM . contains ( document . activeElement ) ;
1619+ setNativeContextMenuDisabled ( isFocused ) ;
16021620
16031621 contentDOM . addEventListener ( "focus" , ( _event ) => {
1622+ setNativeContextMenuDisabled ( true ) ;
16041623 const { activeFile } = manager ;
16051624 if ( activeFile ) {
16061625 activeFile . focused = true ;
@@ -1609,6 +1628,7 @@ async function EditorManager($header, $body) {
16091628 } ) ;
16101629
16111630 contentDOM . addEventListener ( "blur" , async ( _event ) => {
1631+ setNativeContextMenuDisabled ( false ) ;
16121632 touchSelectionController ?. setMenu ( false ) ;
16131633 const { hardKeyboardHidden, keyboardHeight } =
16141634 await getSystemConfiguration ( ) ;
0 commit comments