From 5f8bd8ffb8dad82d48ddcbf2c7a241387647e4b1 Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Wed, 12 Jan 2022 17:16:01 +0800 Subject: [PATCH] =?UTF-8?q?update:=20codeblock=20=E4=BB=85=E6=92=A4?= =?UTF-8?q?=E9=94=80=E5=92=8C=E9=87=8D=E5=81=9A=E6=8C=89=E9=94=AE=E9=98=BB?= =?UTF-8?q?=E6=AD=A2=E5=86=92=E6=B3=A1=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/codeblock-vue/src/component/editor.ts | 9 ++++++++- plugins/codeblock/src/component/editor.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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 } =