mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-31 23:11:28 +01:00
bind Cmd-r,s,e directly with Monaco for codeedit
This commit is contained in:
parent
c87caef473
commit
a4551f9e4c
@ -128,6 +128,27 @@ export function CodeEditor({
|
||||
}
|
||||
}
|
||||
|
||||
function handleEditorOnMount(editor: MonacoTypes.editor.IStandaloneCodeEditor, monaco: Monaco) {
|
||||
// bind Cmd:e
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyE, () => {
|
||||
if (onEdit) {
|
||||
onEdit();
|
||||
}
|
||||
});
|
||||
// bind Cmd:s
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () => {
|
||||
if (onSave) {
|
||||
onSave();
|
||||
}
|
||||
});
|
||||
// bind Cmd:r
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyR, () => {
|
||||
if (onCancel) {
|
||||
onCancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const editorOpts = defaultEditorOptions();
|
||||
editorOpts.readOnly = readonly;
|
||||
|
||||
@ -140,6 +161,7 @@ export function CodeEditor({
|
||||
value={text}
|
||||
options={editorOpts}
|
||||
onChange={handleEditorChange}
|
||||
onMount={handleEditorOnMount}
|
||||
path={filename}
|
||||
language={language}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user