feat: shortcut key for saving (#951)

This commit is contained in:
yy 2025-02-18 05:02:51 -08:00 committed by GitHub
parent ab58e88b3e
commit db1934da58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 2 deletions

View File

@ -40,6 +40,7 @@
:options="editorOptions"
language="javascript"
@editorDidMount="$emit('editorDidMount', $event)"
@shortcutSave="$emit('shortcutSave', $event)"
@change="$emit('change', $event)"
></monaco-editor>
</div>
@ -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)

View File

@ -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) => {

View File

@ -26,6 +26,7 @@
:value="state.pageData"
:options="options"
@change="editorChange"
@shortcutSave="saveSchema"
></monaco-editor>
</div>
<div class="source-code-footer">

View File

@ -20,6 +20,7 @@
:options="options"
@change="change"
@editorDidMount="editorDidMount"
@shortcutSave="saveMethods"
></monaco-editor>
</div>
</div>