diff options
Diffstat (limited to 'src/extensions')
-rw-r--r-- | src/extensions/Keymap.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/extensions/Keymap.js b/src/extensions/Keymap.js index f5e74755e..7d98f889d 100644 --- a/src/extensions/Keymap.js +++ b/src/extensions/Keymap.js @@ -20,16 +20,33 @@ * */ -import { Extension } from 'tiptap' +import { Extension, Plugin } from 'tiptap' export default class Keymap extends Extension { get name() { - return 'save' + return 'customkeymap' } keys({ schema }) { return this.options } + get plugins() { + return [new Plugin({ + props: { + handleKeyDown(view, event) { + const key = event.key || event.keyCode + if ((event.ctrlKey || event.metaKey) && !event.shiftKey && (key === 'f' || key === 70)) { + // We need to stop propagation and dispatch the event on the window + // in order to force triggering the browser native search in the text editor + event.stopPropagation() + window.dispatchEvent(event) + return true + } + }, + }, + })] + } + } |