diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /spec/frontend/content_editor/test_utils.js | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'spec/frontend/content_editor/test_utils.js')
-rw-r--r-- | spec/frontend/content_editor/test_utils.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/frontend/content_editor/test_utils.js b/spec/frontend/content_editor/test_utils.js index cf5aa3f2938..b236c630e13 100644 --- a/spec/frontend/content_editor/test_utils.js +++ b/spec/frontend/content_editor/test_utils.js @@ -119,3 +119,26 @@ export const createTestContentEditorExtension = ({ commands = [] } = {}) => { }, }; }; + +export const triggerNodeInputRule = ({ tiptapEditor, inputRuleText }) => { + const { view } = tiptapEditor; + const { state } = tiptapEditor; + const { selection } = state; + + // Triggers the event handler that input rules listen to + view.someProp('handleTextInput', (f) => f(view, selection.from, selection.to, inputRuleText)); +}; + +export const triggerMarkInputRule = ({ tiptapEditor, inputRuleText }) => { + const { view } = tiptapEditor; + + tiptapEditor.chain().setContent(inputRuleText).setTextSelection(0).run(); + + const { state } = tiptapEditor; + const { selection } = state; + + // Triggers the event handler that input rules listen to + view.someProp('handleTextInput', (f) => + f(view, selection.from, inputRuleText.length + 1, inputRuleText), + ); +}; |