From 107062fb2d78bd970ac0f41c581dee6849e2a9a8 Mon Sep 17 00:00:00 2001 From: sibiraj-s Date: Mon, 18 Jan 2021 13:59:43 +0530 Subject: [PATCH] fix: move history keymaps to keyboard shortcuts --- src/lib/defaultPlugins.ts | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/lib/defaultPlugins.ts b/src/lib/defaultPlugins.ts index 147657f6..029e7ef9 100644 --- a/src/lib/defaultPlugins.ts +++ b/src/lib/defaultPlugins.ts @@ -83,6 +83,15 @@ const buildInputRules = (schema: Schema): Plugin => { }; const getKeyboardShortcuts = (schema: Schema) => { + const historyKeyMap: Record = {}; + + historyKeyMap['Mod-z'] = undo; + if (isMacOs) { + historyKeyMap['Shift-Mod-z'] = redo; + } else { + historyKeyMap['Mod-y'] = redo; + } + return [ keymap({ 'Mod-b': toggleMark(schema.marks.strong), @@ -95,29 +104,11 @@ const getKeyboardShortcuts = (schema: Schema) => { 'Mod-]': sinkListItem(schema.nodes.list_item), Tab: sinkListItem(schema.nodes.list_item) }), - keymap(baseKeymap) + keymap(baseKeymap), + keymap(historyKeyMap) ]; }; -const getHistoryPlugins = (): Plugin[] => { - const plugins: Plugin[] = []; - - const keyMappings: Record = {}; - - keyMappings['Mod-z'] = undo; - if (isMacOs) { - keyMappings['Shift-Mod-z'] = redo; - } else { - keyMappings['Mod-y'] = redo; - } - - plugins.push(history()); - plugins.push(keymap(keyMappings)); - plugins.push(keymap(keyMappings)); - - return plugins; -}; - const getDefaultPlugins = (schema: Schema, options: Options) => { const plugins: Plugin[] = []; @@ -126,7 +117,7 @@ const getDefaultPlugins = (schema: Schema, options: Options) => { } if (options.history) { - plugins.push(...getHistoryPlugins()); + plugins.push(history()); } if (options.inputRules) {