feat: shortcut key for saving (#951)
This commit is contained in:
parent
ab58e88b3e
commit
db1934da58
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
:value="state.pageData"
|
||||
:options="options"
|
||||
@change="editorChange"
|
||||
@shortcutSave="saveSchema"
|
||||
></monaco-editor>
|
||||
</div>
|
||||
<div class="source-code-footer">
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
:options="options"
|
||||
@change="change"
|
||||
@editorDidMount="editorDidMount"
|
||||
@shortcutSave="saveMethods"
|
||||
></monaco-editor>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue