diff --git a/plugins/codeblock-vue/src/component/editor.ts b/plugins/codeblock-vue/src/component/editor.ts index db5cb2e6..e3449ac1 100644 --- a/plugins/codeblock-vue/src/component/editor.ts +++ b/plugins/codeblock-vue/src/component/editor.ts @@ -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 } = diff --git a/plugins/codeblock/src/component/editor.ts b/plugins/codeblock/src/component/editor.ts index cda75a5d..1a18298b 100644 --- a/plugins/codeblock/src/component/editor.ts +++ b/plugins/codeblock/src/component/editor.ts @@ -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 } =