diff --git a/packages/common/component/MonacoEditor.vue b/packages/common/component/MonacoEditor.vue index 0b545ea374..610835a7ac 100644 --- a/packages/common/component/MonacoEditor.vue +++ b/packages/common/component/MonacoEditor.vue @@ -40,6 +40,7 @@ :options="editorOptions" language="javascript" @editorDidMount="$emit('editorDidMount', $event)" + @shortcutSave="$emit('shortcutSave', $event)" @change="$emit('change', $event)" > @@ -75,7 +76,7 @@ export default { default: true } }, - emits: ['editorDidMount', 'change', 'fullscreenChange'], + emits: ['editorDidMount', 'change', 'fullscreenChange', 'shortcutSave'], setup(props, { emit }) { const editor = ref(null) const fullscreen = ref(false) diff --git a/packages/common/component/VueMonaco.vue b/packages/common/component/VueMonaco.vue index c2e661330d..901028be5f 100644 --- a/packages/common/component/VueMonaco.vue +++ b/packages/common/component/VueMonaco.vue @@ -43,7 +43,7 @@ export default { default: false } }, - emits: ['change', 'editorWillMount', 'editorDidMount'], + emits: ['change', 'editorWillMount', 'editorDidMount', 'shortcutSave'], setup(props, { emit }) { const vueMonaco = { editor: null, @@ -95,6 +95,11 @@ export default { vueMonaco.editor = monaco.editor.create(monacoRef.value, options) } + vueMonaco.editor.addCommand(monacoEditor.KeyMod.CtrlCmd | monacoEditor.KeyCode.KeyS, () => { + // 快捷键 ctrl + s 或 command + s 保存 + emit('shortcutSave') + }) + const editor2 = getModifiedEditor() editor2.onDidChangeModelContent((event) => { diff --git a/packages/plugins/schema/src/Main.vue b/packages/plugins/schema/src/Main.vue index ca0ad37b46..74c219f569 100644 --- a/packages/plugins/schema/src/Main.vue +++ b/packages/plugins/schema/src/Main.vue @@ -26,6 +26,7 @@ :value="state.pageData" :options="options" @change="editorChange" + @shortcutSave="saveSchema" >