@@ -4,7 +4,6 @@ import setups from '#slidev/setups/monaco'
4
4
import { createSingletonPromise } from '@antfu/utils'
5
5
import { setupTypeAcquisition } from '@typescript/ata'
6
6
import * as monaco from 'monaco-editor'
7
-
8
7
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
9
8
// @ts -expect-error missing types
10
9
import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices'
@@ -16,10 +15,10 @@ import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
16
15
import { ContextViewService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextViewService'
17
16
// @ts -expect-error missing types
18
17
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors'
19
-
20
18
import ts from 'typescript'
21
19
import { watchEffect } from 'vue'
22
20
import { isDark } from '../logic/dark'
21
+ import { shortcutsEnabled } from '../state'
23
22
24
23
window . MonacoEnvironment = {
25
24
getWorker ( _ , label ) {
@@ -97,6 +96,18 @@ const setup = createSingletonPromise(async () => {
97
96
Object . assign ( editorOptions , result ?. editorOptions )
98
97
}
99
98
99
+ // Disable shortcuts when focusing Monaco editor.
100
+ monaco . editor . onDidCreateEditor ( ( editor ) => {
101
+ let areShortcutsEnabled = shortcutsEnabled . value
102
+ editor . onDidFocusEditorWidget ( ( ) => {
103
+ areShortcutsEnabled = shortcutsEnabled . value
104
+ shortcutsEnabled . value = false
105
+ } )
106
+ editor . onDidBlurEditorWidget ( ( ) => {
107
+ shortcutsEnabled . value = areShortcutsEnabled
108
+ } )
109
+ } )
110
+
100
111
// Use Shiki to highlight Monaco
101
112
shikiToMonaco ( highlighter , monaco )
102
113
if ( typeof themes === 'string' ) {
0 commit comments