+import {MarkdownEditorShortcutMap} from "./shortcuts";
+
+/**
+ * Convert editor shortcuts to CodeMirror keybinding format.
+ */
+export function shortcutsToKeyBindings(shortcuts: MarkdownEditorShortcutMap): KeyBinding[] {
+ const keyBindings = [];
+
+ const wrapAction = (action: () => void) => () => {
+ action();
+ return true;
+ };
+
+ for (const [shortcut, action] of Object.entries(shortcuts)) {
+ keyBindings.push({key: shortcut, run: wrapAction(action), preventDefault: true});
+ }
+
+ return keyBindings;
+}