mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
bind Cmd-r,s,e directly with Monaco for codeedit
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user