update: codeblock 仅撤销和重做按键阻止冒泡传递

This commit is contained in:
yanmao 2022-01-12 17:16:01 +08:00
parent 5c23bef695
commit 5f8bd8ffb8
2 changed files with 16 additions and 2 deletions

View File

@ -133,7 +133,14 @@ class CodeBlockEditor implements CodeBlockEditorInterface {
},
});
this.codeMirror.on('keydown', (editor, event) => {
event.stopPropagation();
// 撤销和重做使用codemirror自带的操作
if (
isHotkey('mod+z', event) ||
isHotkey('mod+y', event) ||
isHotkey('mod+shift+z', event)
) {
event.stopPropagation();
}
const lineCount = editor.lineCount();
const { line, ch } = editor.getCursor();
const { onUpFocus, onDownFocus, onLeftFocus, onRightFocus } =

View File

@ -96,7 +96,14 @@ class CodeBlockEditor implements CodeBlockEditorInterface {
if (onFocus) onFocus();
});
this.codeMirror.on('keydown', (editor, event) => {
event.stopPropagation();
// 撤销和重做使用codemirror自带的操作
if (
isHotkey('mod+z', event) ||
isHotkey('mod+y', event) ||
isHotkey('mod+shift+z', event)
) {
event.stopPropagation();
}
const lineCount = editor.lineCount();
const { line, ch } = editor.getCursor();
const { onUpFocus, onDownFocus, onLeftFocus, onRightFocus } =