From ccf48881391bd7acf8af821307cee0873e1e8e63 Mon Sep 17 00:00:00 2001 From: Samuel Gyger Date: Mon, 6 May 2024 01:37:00 -0700 Subject: [PATCH] keymap: change to support bold and italic keyboard shortcuts. --- script/plugins/Keymap/keymap.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/script/plugins/Keymap/keymap.js b/script/plugins/Keymap/keymap.js index 7ff64383..263a6ddd 100644 --- a/script/plugins/Keymap/keymap.js +++ b/script/plugins/Keymap/keymap.js @@ -1,6 +1,8 @@ import { keymap } from 'prosemirror-keymap'; import { splitListItem, sinkListItem, liftListItem } from 'prosemirror-schema-list'; -import { baseKeymap, chainCommands } from 'prosemirror-commands'; +import { + baseKeymap, chainCommands, exitCode, toggleMark, +} from 'prosemirror-commands'; import { redo, undo } from 'prosemirror-history'; @@ -19,6 +21,13 @@ function getKeymapPlugin(schema) { return acc; }, {}); + const formatKeymap = { + 'Mod-b': toggleMark(schema.marks.strong), + 'Mod-B': toggleMark(schema.marks.strong), + 'Mod-i': toggleMark(schema.marks.em), + 'Mod-I': toggleMark(schema.marks.em), + }; + const historyKeymap = { 'Mod-z': undo, 'Mod-Shift-z': redo }; if (!isMac) { historyKeymap['Mod-y'] = redo; @@ -33,6 +42,7 @@ function getKeymapPlugin(schema) { ...baseKeymap, ...customKeymap, ...combinedKeymapUnion, + ...formatKeymap, ...historyKeymap, ...indentationKeymap, };