From 33bc408e2e23a1e57fa7bcd4a42c8be59a1ba965 Mon Sep 17 00:00:00 2001 From: GreatZP Date: Sun, 1 Dec 2024 21:57:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(md):=20=E4=BF=AE=E5=A4=8D=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E9=94=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor-md/src/composables/use-editor-md.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts b/packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts index 65d0c0a00e..5fb37fd4cf 100644 --- a/packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts +++ b/packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts @@ -316,6 +316,24 @@ export function useEditorMd(props: EditorMdProps, ctx: SetupContext) { setTimeout(() => { ctx.emit('contentChange', editorIns.getValue()); }, 100); + + containerRef.value.addEventListener('keydown', (e: KeyboardEvent) => { + let keyCombination = ''; + if (e.ctrlKey) { + keyCombination += 'Ctrl-'; + } + if (e.altKey) { + keyCombination += 'Alt-'; + } + if (e.shiftKey) { + keyCombination += 'Shift-'; + } + keyCombination += e.key.toUpperCase(); + if (shortKeys[keyCombination] && typeof shortKeys[keyCombination] === 'function') { + e.preventDefault(); + shortKeys[keyCombination](); + } + }); }; const onPaste = (e: ClipboardEvent) => {