diff options
Diffstat (limited to 'spec/frontend/content_editor/test_utils.js')
-rw-r--r-- | spec/frontend/content_editor/test_utils.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/frontend/content_editor/test_utils.js b/spec/frontend/content_editor/test_utils.js new file mode 100644 index 00000000000..a92ceb6d058 --- /dev/null +++ b/spec/frontend/content_editor/test_utils.js @@ -0,0 +1,34 @@ +import { Node } from '@tiptap/core'; + +export const createTestContentEditorExtension = () => ({ + tiptapExtension: Node.create({ + name: 'label', + priority: 101, + inline: true, + group: 'inline', + addAttributes() { + return { + labelName: { + default: null, + parseHTML: (element) => { + return { labelName: element.dataset.labelName }; + }, + }, + }; + }, + parseHTML() { + return [ + { + tag: 'span[data-reference="label"]', + }, + ]; + }, + renderHTML({ HTMLAttributes }) { + return ['span', HTMLAttributes, 0]; + }, + }), + serializer: (state, node) => { + state.write(`~${node.attrs.labelName}`); + state.closeBlock(node); + }, +}); |