1 import {MarkdownEditor} from "./index.mjs";
3 export type MarkdownEditorShortcutMap = Record<string, () => void>;
6 * Provide shortcuts for the editor instance.
8 export function provideShortcutMap(editor: MarkdownEditor): MarkdownEditorShortcutMap {
9 const shortcuts: MarkdownEditorShortcutMap = {};
11 // Insert Image shortcut
12 shortcuts['Shift-Mod-i'] = () => editor.actions.insertImage();
15 shortcuts['Mod-s'] = () => window.$events.emit('editor-save-draft');
18 shortcuts['Mod-Enter'] = () => window.$events.emit('editor-save-page');
21 shortcuts['Shift-Mod-k'] = () => editor.actions.showLinkSelector();
24 shortcuts['Mod-k'] = () => editor.actions.insertLink();
27 shortcuts['Mod-1'] = () => editor.actions.replaceLineStart('##');
28 shortcuts['Mod-2'] = () => editor.actions.replaceLineStart('###');
29 shortcuts['Mod-3'] = () => editor.actions.replaceLineStart('####');
30 shortcuts['Mod-4'] = () => editor.actions.replaceLineStart('#####');
31 shortcuts['Mod-5'] = () => editor.actions.replaceLineStart('');
32 shortcuts['Mod-d'] = () => editor.actions.replaceLineStart('');
33 shortcuts['Mod-6'] = () => editor.actions.replaceLineStart('>');
34 shortcuts['Mod-q'] = () => editor.actions.replaceLineStart('>');
35 shortcuts['Mod-7'] = () => editor.actions.wrapSelection('\n```\n', '\n```');
36 shortcuts['Mod-8'] = () => editor.actions.wrapSelection('`', '`');
37 shortcuts['Shift-Mod-e'] = () => editor.actions.wrapSelection('`', '`');
38 shortcuts['Mod-9'] = () => editor.actions.cycleCalloutTypeAtSelection();
39 shortcuts['Mod-p'] = () => editor.actions.replaceLineStart('-');
40 shortcuts['Mod-o'] = () => editor.actions.replaceLineStartForOrderedList();