diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js')
-rw-r--r-- | app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js b/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js index 9b1cb76f845..eb1e4885ba6 100644 --- a/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js +++ b/app/assets/javascripts/content_editor/services/track_input_rules_and_shortcuts.js @@ -35,31 +35,33 @@ const trackInputRule = (contentType, inputRule) => { }; const trackInputRulesAndShortcuts = (tiptapExtension) => { - return tiptapExtension.extend({ - addKeyboardShortcuts() { - const shortcuts = this.parent?.() || {}; - const { name } = this; - /** - * We don’t want to track keyboard shortcuts - * that are not deliberately executed to create - * new types of content - */ - const dotNotTrackKeys = [ENTER_KEY, BACKSPACE_KEY]; - const decorated = mapValues(shortcuts, (commandFn, shortcut) => - dotNotTrackKeys.includes(shortcut) - ? commandFn - : trackKeyboardShortcut(name, commandFn, shortcut), - ); + return tiptapExtension + .extend({ + addKeyboardShortcuts() { + const shortcuts = this.parent?.() || {}; + const { name } = this; + /** + * We don’t want to track keyboard shortcuts + * that are not deliberately executed to create + * new types of content + */ + const dotNotTrackKeys = [ENTER_KEY, BACKSPACE_KEY]; + const decorated = mapValues(shortcuts, (commandFn, shortcut) => + dotNotTrackKeys.includes(shortcut) + ? commandFn + : trackKeyboardShortcut(name, commandFn, shortcut), + ); - return decorated; - }, - addInputRules() { - const inputRules = this.parent?.() || []; - const { name } = this; + return decorated; + }, + addInputRules() { + const inputRules = this.parent?.() || []; + const { name } = this; - return inputRules.map((inputRule) => trackInputRule(name, inputRule)); - }, - }); + return inputRules.map((inputRule) => trackInputRule(name, inputRule)); + }, + }) + .configure(tiptapExtension.options); }; export default trackInputRulesAndShortcuts; |