Skip to content

Commit 33bc408

Browse files
committed
fix(md): 修复快捷键功能
1 parent 63a0db9 commit 33bc408

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,24 @@ export function useEditorMd(props: EditorMdProps, ctx: SetupContext) {
316316
setTimeout(() => {
317317
ctx.emit('contentChange', editorIns.getValue());
318318
}, 100);
319+
320+
containerRef.value.addEventListener('keydown', (e: KeyboardEvent) => {
321+
let keyCombination = '';
322+
if (e.ctrlKey) {
323+
keyCombination += 'Ctrl-';
324+
}
325+
if (e.altKey) {
326+
keyCombination += 'Alt-';
327+
}
328+
if (e.shiftKey) {
329+
keyCombination += 'Shift-';
330+
}
331+
keyCombination += e.key.toUpperCase();
332+
if (shortKeys[keyCombination] && typeof shortKeys[keyCombination] === 'function') {
333+
e.preventDefault();
334+
shortKeys[keyCombination]();
335+
}
336+
});
319337
};
320338

321339
const onPaste = (e: ClipboardEvent) => {

0 commit comments

Comments
 (0)