Skip to content

Commit

Permalink
fix(md): 修复快捷键功能
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatZPP committed Dec 1, 2024
1 parent 63a0db9 commit 33bc408
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 33bc408

Please sign in to comment.