@pie-lib/editable-html-tip-tap 2.1.19 → 2.1.20-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +0 -130
  2. package/lib/components/EditableHtml.js +0 -56
  3. package/lib/components/EditableHtml.js.map +1 -1
  4. package/lib/components/MenuBar.js +12 -81
  5. package/lib/components/MenuBar.js.map +1 -1
  6. package/lib/components/TiptapContainer.js +2 -2
  7. package/lib/components/TiptapContainer.js.map +1 -1
  8. package/lib/components/common/toolbar-buttons.js +5 -6
  9. package/lib/components/common/toolbar-buttons.js.map +1 -1
  10. package/lib/components/icons/TableIcons.js +1 -3
  11. package/lib/components/icons/TableIcons.js.map +1 -1
  12. package/lib/components/icons/TextAlign.js +5 -14
  13. package/lib/components/icons/TextAlign.js.map +1 -1
  14. package/lib/components/respArea/MathTemplated.js +8 -14
  15. package/lib/components/respArea/MathTemplated.js.map +1 -1
  16. package/lib/extensions/math.js +37 -19
  17. package/lib/extensions/math.js.map +1 -1
  18. package/lib/styles/editorContainerStyles.js +2 -2
  19. package/lib/styles/editorContainerStyles.js.map +1 -1
  20. package/package.json +9 -9
  21. package/src/components/EditableHtml.jsx +0 -52
  22. package/src/components/MenuBar.jsx +9 -91
  23. package/src/components/TiptapContainer.jsx +2 -2
  24. package/src/components/common/toolbar-buttons.jsx +4 -6
  25. package/src/components/icons/TableIcons.jsx +1 -9
  26. package/src/components/icons/TextAlign.jsx +5 -39
  27. package/src/components/respArea/MathTemplated.jsx +6 -13
  28. package/src/extensions/math.js +19 -11
  29. package/src/styles/editorContainerStyles.js +2 -2
  30. package/LICENSE.md +0 -5
  31. package/src/__tests__/EditableHtml.test.jsx +0 -668
  32. package/src/__tests__/constants.test.js +0 -19
  33. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  34. package/src/__tests__/editor-attributes.test.jsx +0 -77
  35. package/src/__tests__/extensions.test.js +0 -208
  36. package/src/__tests__/index.test.jsx +0 -154
  37. package/src/__tests__/size-utils.test.js +0 -64
  38. package/src/__tests__/spellcheck.test.jsx +0 -63
  39. package/src/__tests__/theme.test.js +0 -17
  40. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  41. package/src/components/__tests__/CharacterPicker.test.jsx +0 -270
  42. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  43. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  44. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -209
  45. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  46. package/src/components/__tests__/InlineDropdown.test.jsx +0 -557
  47. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  48. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  49. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  50. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  51. package/src/components/__tests__/MenuBar.test.jsx +0 -338
  52. package/src/components/__tests__/RespArea.test.jsx +0 -122
  53. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  54. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  55. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  56. package/src/components/__tests__/characterUtils.test.js +0 -166
  57. package/src/components/__tests__/choice.test.jsx +0 -171
  58. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  59. package/src/components/__tests__/done-button.test.jsx +0 -54
  60. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -247
  61. package/src/components/respArea/DragInTheBlank/__tests__/choice.test.jsx +0 -72
  62. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  63. package/src/extensions/__tests__/css.test.js +0 -196
  64. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  65. package/src/extensions/__tests__/divNode.test.js +0 -87
  66. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  67. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  68. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  69. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  70. package/src/extensions/__tests__/extended-table.test.js +0 -183
  71. package/src/extensions/__tests__/image-component.test.jsx +0 -346
  72. package/src/extensions/__tests__/image.test.js +0 -237
  73. package/src/extensions/__tests__/math.test.js +0 -898
  74. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  75. package/src/extensions/__tests__/media.test.js +0 -271
  76. package/src/extensions/__tests__/responseArea.test.js +0 -655
  77. package/src/utils/__tests__/helper.test.js +0 -126
  78. package/src/utils/__tests__/toolbar.test.js +0 -43
@@ -1,196 +0,0 @@
1
- import { CSSMark, removeDialogs } from '../css';
2
-
3
- jest.mock('@tiptap/core', () => ({
4
- Mark: { create: jest.fn((config) => config) },
5
- mergeAttributes: jest.fn((...args) => Object.assign({}, ...args)),
6
- }));
7
-
8
- jest.mock('react-dom', () => ({
9
- render: jest.fn(),
10
- }));
11
-
12
- describe('CSSMark', () => {
13
- describe('configuration', () => {
14
- it('has correct name', () => {
15
- expect(CSSMark.name).toBe('cssmark');
16
- });
17
- });
18
-
19
- describe('addOptions', () => {
20
- it('returns default options with empty classes array', () => {
21
- const options = CSSMark.addOptions();
22
-
23
- expect(options).toHaveProperty('classes');
24
- expect(Array.isArray(options.classes)).toBe(true);
25
- expect(options.classes).toHaveLength(0);
26
- });
27
- });
28
-
29
- describe('addAttributes', () => {
30
- it('returns class attribute configuration', () => {
31
- const attributes = CSSMark.addAttributes();
32
-
33
- expect(attributes).toHaveProperty('class');
34
- expect(attributes.class).toHaveProperty('default', null);
35
- expect(attributes.class).toHaveProperty('parseHTML');
36
- expect(attributes.class).toHaveProperty('renderHTML');
37
- expect(typeof attributes.class.parseHTML).toBe('function');
38
- expect(typeof attributes.class.renderHTML).toBe('function');
39
- });
40
-
41
- it('parseHTML extracts class attribute', () => {
42
- const attributes = CSSMark.addAttributes();
43
- const mockEl = {
44
- getAttribute: jest.fn((attr) => (attr === 'class' ? 'my-class' : null)),
45
- };
46
-
47
- const result = attributes.class.parseHTML(mockEl);
48
-
49
- expect(result).toBe('my-class');
50
- expect(mockEl.getAttribute).toHaveBeenCalledWith('class');
51
- });
52
-
53
- it('renderHTML returns empty object when no class', () => {
54
- const attributes = CSSMark.addAttributes();
55
- const result = attributes.class.renderHTML({ class: null });
56
-
57
- expect(result).toEqual({});
58
- });
59
-
60
- it('renderHTML returns class when present', () => {
61
- const attributes = CSSMark.addAttributes();
62
- const result = attributes.class.renderHTML({ class: 'my-class' });
63
-
64
- expect(result).toEqual({ class: 'my-class' });
65
- });
66
- });
67
-
68
- describe('parseHTML', () => {
69
- beforeEach(() => {
70
- CSSMark.options = { classes: ['allowed-class', 'another-class'] };
71
- });
72
-
73
- it('returns array with span[class] selector', () => {
74
- const rules = CSSMark.parseHTML();
75
-
76
- expect(Array.isArray(rules)).toBe(true);
77
- expect(rules).toHaveLength(1);
78
- expect(rules[0]).toHaveProperty('tag', 'span[class]');
79
- expect(rules[0]).toHaveProperty('getAttrs');
80
- });
81
-
82
- it('matches allowed classes', () => {
83
- const rules = CSSMark.parseHTML();
84
- const mockEl = {
85
- getAttribute: jest.fn(() => 'allowed-class some-other'),
86
- };
87
-
88
- const result = rules[0].getAttrs(mockEl);
89
-
90
- expect(result).toEqual({ class: 'allowed-class' });
91
- });
92
-
93
- it('returns false for non-allowed classes', () => {
94
- const rules = CSSMark.parseHTML();
95
- const mockEl = {
96
- getAttribute: jest.fn(() => 'not-allowed'),
97
- };
98
-
99
- const result = rules[0].getAttrs(mockEl);
100
-
101
- expect(result).toBe(false);
102
- });
103
-
104
- it('handles empty class attribute', () => {
105
- const rules = CSSMark.parseHTML();
106
- const mockEl = {
107
- getAttribute: jest.fn(() => ''),
108
- };
109
-
110
- const result = rules[0].getAttrs(mockEl);
111
-
112
- expect(result).toBe(false);
113
- });
114
- });
115
-
116
- describe('renderHTML', () => {
117
- it('returns span with merged attributes', () => {
118
- const result = CSSMark.renderHTML({
119
- HTMLAttributes: { class: 'my-class' },
120
- });
121
-
122
- expect(result[0]).toBe('span');
123
- expect(result[1]).toEqual({ class: 'my-class' });
124
- expect(result[2]).toBe(0);
125
- });
126
- });
127
-
128
- describe('addCommands', () => {
129
- it('returns setCSSClass command', () => {
130
- const commands = CSSMark.addCommands();
131
-
132
- expect(commands).toHaveProperty('setCSSClass');
133
- expect(typeof commands.setCSSClass).toBe('function');
134
- });
135
-
136
- it('returns unsetCSSClass command', () => {
137
- const commands = CSSMark.addCommands();
138
-
139
- expect(commands).toHaveProperty('unsetCSSClass');
140
- expect(typeof commands.unsetCSSClass).toBe('function');
141
- });
142
-
143
- it('returns openCSSClassDialog command', () => {
144
- const commands = CSSMark.addCommands();
145
-
146
- expect(commands).toHaveProperty('openCSSClassDialog');
147
- expect(typeof commands.openCSSClassDialog).toBe('function');
148
- });
149
-
150
- it('setCSSClass sets mark with class name', () => {
151
- const context = { name: 'cssmark' };
152
- const commands = CSSMark.addCommands.call(context);
153
- const mockCommands = {
154
- setMark: jest.fn(() => true),
155
- };
156
-
157
- const result = commands.setCSSClass('my-class')({ commands: mockCommands });
158
-
159
- expect(mockCommands.setMark).toHaveBeenCalledWith('cssmark', { class: 'my-class' });
160
- expect(result).toBe(true);
161
- });
162
-
163
- it('unsetCSSClass unsets mark', () => {
164
- const context = { name: 'cssmark' };
165
- const commands = CSSMark.addCommands.call(context);
166
- const mockCommands = {
167
- unsetMark: jest.fn(() => true),
168
- };
169
-
170
- const result = commands.unsetCSSClass()({ commands: mockCommands });
171
-
172
- expect(mockCommands.unsetMark).toHaveBeenCalledWith('cssmark');
173
- expect(result).toBe(true);
174
- });
175
- });
176
- });
177
-
178
- describe('removeDialogs', () => {
179
- it('removes all elements with insert-css-dialog class', () => {
180
- const mockElements = [{ remove: jest.fn() }, { remove: jest.fn() }];
181
-
182
- document.querySelectorAll = jest.fn(() => mockElements);
183
-
184
- removeDialogs();
185
-
186
- expect(document.querySelectorAll).toHaveBeenCalledWith('.insert-css-dialog');
187
- expect(mockElements[0].remove).toHaveBeenCalled();
188
- expect(mockElements[1].remove).toHaveBeenCalled();
189
- });
190
-
191
- it('handles no dialogs gracefully', () => {
192
- document.querySelectorAll = jest.fn(() => []);
193
-
194
- expect(() => removeDialogs()).not.toThrow();
195
- });
196
- });
@@ -1,180 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render } from '@testing-library/react';
3
- import CustomToolbarWrapper from '../custom-toolbar-wrapper';
4
-
5
- jest.mock('../../components/common/done-button', () => ({
6
- DoneButton: ({ onClick }) => (
7
- <button data-testid="done-button" onClick={onClick}>
8
- Done
9
- </button>
10
- ),
11
- }));
12
-
13
- jest.mock('@mui/icons-material/Delete', () => ({
14
- __esModule: true,
15
- default: () => <span data-testid="delete-icon">Delete</span>,
16
- }));
17
-
18
- describe('CustomToolbarWrapper', () => {
19
- const mockOnDone = jest.fn();
20
- const mockOnDelete = jest.fn();
21
- const defaultToolbarOpts = {
22
- position: 'bottom',
23
- alignment: 'left',
24
- alwaysVisible: false,
25
- };
26
-
27
- beforeEach(() => {
28
- jest.clearAllMocks();
29
- });
30
-
31
- it('renders without crashing', () => {
32
- const { container } = render(
33
- <CustomToolbarWrapper showDone={false} toolbarOpts={defaultToolbarOpts}>
34
- <div>Test content</div>
35
- </CustomToolbarWrapper>,
36
- );
37
- expect(container).toBeInTheDocument();
38
- });
39
-
40
- it('renders children', () => {
41
- const { getByText } = render(
42
- <CustomToolbarWrapper showDone={false} toolbarOpts={defaultToolbarOpts}>
43
- <div>Test content</div>
44
- </CustomToolbarWrapper>,
45
- );
46
- expect(getByText('Test content')).toBeInTheDocument();
47
- });
48
-
49
- it('does not show done button when showDone is false', () => {
50
- const { queryByTestId } = render(
51
- <CustomToolbarWrapper showDone={false} onDone={mockOnDone} toolbarOpts={defaultToolbarOpts}>
52
- <div>Test content</div>
53
- </CustomToolbarWrapper>,
54
- );
55
- expect(queryByTestId('done-button')).not.toBeInTheDocument();
56
- });
57
-
58
- it('shows done button when showDone is true', () => {
59
- const { getByTestId } = render(
60
- <CustomToolbarWrapper showDone={true} onDone={mockOnDone} toolbarOpts={defaultToolbarOpts}>
61
- <div>Test content</div>
62
- </CustomToolbarWrapper>,
63
- );
64
- expect(getByTestId('done-button')).toBeInTheDocument();
65
- });
66
-
67
- it('calls onDone when done button is clicked', () => {
68
- const { getByTestId } = render(
69
- <CustomToolbarWrapper showDone={true} onDone={mockOnDone} toolbarOpts={defaultToolbarOpts}>
70
- <div>Test content</div>
71
- </CustomToolbarWrapper>,
72
- );
73
-
74
- const doneButton = getByTestId('done-button');
75
- fireEvent.click(doneButton);
76
-
77
- expect(mockOnDone).toHaveBeenCalledTimes(1);
78
- });
79
-
80
- it('does not show delete button when deletable is false', () => {
81
- const { queryByTestId } = render(
82
- <CustomToolbarWrapper deletable={false} toolbarOpts={defaultToolbarOpts}>
83
- <div>Test content</div>
84
- </CustomToolbarWrapper>,
85
- );
86
- expect(queryByTestId('delete-icon')).not.toBeInTheDocument();
87
- });
88
-
89
- it('shows delete button when deletable is true', () => {
90
- const { getByTestId } = render(
91
- <CustomToolbarWrapper deletable={true} onDelete={mockOnDelete} toolbarOpts={defaultToolbarOpts}>
92
- <div>Test content</div>
93
- </CustomToolbarWrapper>,
94
- );
95
- expect(getByTestId('delete-icon')).toBeInTheDocument();
96
- });
97
-
98
- it('calls onDelete when delete button is clicked', () => {
99
- const { getByLabelText } = render(
100
- <CustomToolbarWrapper deletable={true} onDelete={mockOnDelete} toolbarOpts={defaultToolbarOpts}>
101
- <div>Test content</div>
102
- </CustomToolbarWrapper>,
103
- );
104
-
105
- const deleteButton = getByLabelText('Delete');
106
- fireEvent.mouseDown(deleteButton);
107
-
108
- expect(mockOnDelete).toHaveBeenCalledTimes(1);
109
- });
110
-
111
- it('applies right alignment from toolbarOpts', () => {
112
- const toolbarOpts = {
113
- ...defaultToolbarOpts,
114
- alignment: 'right',
115
- };
116
-
117
- const { container } = render(
118
- <CustomToolbarWrapper toolbarOpts={toolbarOpts}>
119
- <div>Test content</div>
120
- </CustomToolbarWrapper>,
121
- );
122
-
123
- const toolbar = container.querySelector('.pie-toolbar');
124
- expect(toolbar).toHaveStyle({ right: '0' });
125
- });
126
-
127
- it('applies autoWidth when specified', () => {
128
- const { container } = render(
129
- <CustomToolbarWrapper autoWidth={true} toolbarOpts={defaultToolbarOpts}>
130
- <div>Test content</div>
131
- </CustomToolbarWrapper>,
132
- );
133
-
134
- const toolbar = container.querySelector('.pie-toolbar');
135
- expect(toolbar).toHaveStyle({ width: 'auto' });
136
- });
137
-
138
- it('applies minWidth from toolbarOpts', () => {
139
- const toolbarOpts = {
140
- ...defaultToolbarOpts,
141
- minWidth: '300px',
142
- };
143
-
144
- const { container } = render(
145
- <CustomToolbarWrapper toolbarOpts={toolbarOpts}>
146
- <div>Test content</div>
147
- </CustomToolbarWrapper>,
148
- );
149
-
150
- const toolbar = container.querySelector('.pie-toolbar');
151
- expect(toolbar).toHaveStyle({ minWidth: '300px' });
152
- });
153
-
154
- it('hides toolbar when isHidden is true', () => {
155
- const toolbarOpts = {
156
- ...defaultToolbarOpts,
157
- isHidden: true,
158
- };
159
-
160
- const { container } = render(
161
- <CustomToolbarWrapper toolbarOpts={toolbarOpts}>
162
- <div>Test content</div>
163
- </CustomToolbarWrapper>,
164
- );
165
-
166
- const toolbar = container.querySelector('.pie-toolbar');
167
- expect(toolbar).toHaveStyle({ visibility: 'hidden' });
168
- });
169
-
170
- it('renders multiple children', () => {
171
- const { getByText } = render(
172
- <CustomToolbarWrapper showDone={false} toolbarOpts={defaultToolbarOpts}>
173
- <div>First child</div>
174
- <div>Second child</div>
175
- </CustomToolbarWrapper>,
176
- );
177
- expect(getByText('First child')).toBeInTheDocument();
178
- expect(getByText('Second child')).toBeInTheDocument();
179
- });
180
- });
@@ -1,87 +0,0 @@
1
- import { DivNode } from '../div-node';
2
-
3
- jest.mock('@tiptap/core', () => ({
4
- Node: {
5
- create: jest.fn((config) => config),
6
- },
7
- }));
8
-
9
- describe('DivNode', () => {
10
- describe('configuration', () => {
11
- it('has correct name', () => {
12
- expect(DivNode.name).toBe('div');
13
- });
14
-
15
- it('is block level', () => {
16
- expect(DivNode.group).toBe('block');
17
- expect(DivNode.content).toBe('inline*');
18
- });
19
- });
20
-
21
- describe('parseHTML', () => {
22
- it('parses <div> tags', () => {
23
- const rules = DivNode.parseHTML();
24
-
25
- expect(Array.isArray(rules)).toBe(true);
26
- expect(rules).toHaveLength(1);
27
- expect(rules[0]).toHaveProperty('tag', 'div');
28
- });
29
- });
30
-
31
- describe('renderHTML', () => {
32
- it('renders a <div> tag', () => {
33
- const result = DivNode.renderHTML({ HTMLAttributes: { class: 'foo' } });
34
-
35
- expect(result[0]).toBe('div');
36
- expect(result[1]).toEqual({ class: 'foo' });
37
- });
38
- });
39
-
40
- describe('addKeyboardShortcuts', () => {
41
- it('does nothing when current block is not div', () => {
42
- const mockEditor = {
43
- state: {
44
- selection: {
45
- $from: {
46
- parent: { type: { name: 'paragraph' } },
47
- },
48
- },
49
- },
50
- };
51
-
52
- const shortcuts = DivNode.addKeyboardShortcuts.call({ editor: mockEditor });
53
- const handled = shortcuts.Enter();
54
-
55
- expect(handled).toBe(false);
56
- });
57
-
58
- it('turns div into paragraph and splits when Enter is pressed in a div', () => {
59
- const chain = {
60
- focus: jest.fn(() => chain),
61
- setNode: jest.fn(() => chain),
62
- splitBlock: jest.fn(() => chain),
63
- run: jest.fn(() => true),
64
- };
65
-
66
- const mockEditor = {
67
- state: {
68
- selection: {
69
- $from: {
70
- parent: { type: { name: 'div' } },
71
- },
72
- },
73
- },
74
- chain: () => chain,
75
- };
76
-
77
- const shortcuts = DivNode.addKeyboardShortcuts.call({ editor: mockEditor });
78
- const handled = shortcuts.Enter();
79
-
80
- expect(chain.focus).toHaveBeenCalled();
81
- expect(chain.setNode).toHaveBeenCalledWith('paragraph');
82
- expect(chain.splitBlock).toHaveBeenCalled();
83
- expect(chain.run).toHaveBeenCalled();
84
- expect(handled).toBe(true);
85
- });
86
- });
87
- });
@@ -1,57 +0,0 @@
1
- import { Editor } from '@tiptap/core';
2
- import StarterKit from '@tiptap/starter-kit';
3
- import { DivNode } from '../div-node';
4
- import { EnsureEmptyRootIsDiv } from '../ensure-empty-root-div';
5
-
6
- /** Match EditableHtml so TrailingNode does not add a second empty block next to an empty paragraph. */
7
- const starterKitConfigured = StarterKit.configure({
8
- trailingNode: {
9
- node: 'paragraph',
10
- notAfter: ['paragraph', 'div'],
11
- },
12
- });
13
-
14
- describe('EnsureEmptyRootIsDiv', () => {
15
- const extensions = [starterKitConfigured, DivNode, EnsureEmptyRootIsDiv];
16
-
17
- let editor;
18
-
19
- afterEach(() => {
20
- if (editor) {
21
- editor.destroy();
22
- editor = null;
23
- }
24
- });
25
-
26
- it('replaces a lone root paragraph with an empty div after select-all and delete (full delete flow)', () => {
27
- editor = new Editor({
28
- extensions,
29
- content: '<p>hello</p>',
30
- });
31
-
32
- editor.chain().focus().selectAll().deleteSelection().run();
33
-
34
- expect(editor.state.doc.childCount).toBe(1);
35
- expect(editor.state.doc.firstChild.type.name).toBe('div');
36
- expect(editor.state.doc.firstChild.textContent).toBe('');
37
- });
38
-
39
- it('does not replace a root paragraph that still has text', () => {
40
- editor = new Editor({
41
- extensions,
42
- content: '<p>x</p>',
43
- });
44
-
45
- expect(editor.state.doc.firstChild.type.name).toBe('paragraph');
46
- });
47
-
48
- it('does not run when there is more than one top-level block', () => {
49
- editor = new Editor({
50
- extensions,
51
- content: '<p>a</p><p>b</p>',
52
- });
53
-
54
- expect(editor.state.doc.childCount).toBe(2);
55
- expect(editor.state.doc.firstChild.type.name).toBe('paragraph');
56
- });
57
- });
@@ -1,44 +0,0 @@
1
- import { EnsureListItemContentIsDiv } from '../ensure-list-item-content-is-div';
2
-
3
- describe('EnsureListItemContentIsDiv', () => {
4
- it('registers a ProseMirror plugin that rewrites listItem paragraph children to div', () => {
5
- const plugins = EnsureListItemContentIsDiv.config.addProseMirrorPlugins();
6
- expect(Array.isArray(plugins)).toBe(true);
7
- expect(plugins).toHaveLength(1);
8
-
9
- const plugin = plugins[0];
10
- const divType = { name: 'div' };
11
- const tr = { setNodeMarkup: jest.fn() };
12
-
13
- const paragraphChild = {
14
- type: { name: 'paragraph' },
15
- attrs: { class: 'x' },
16
- nodeSize: 6,
17
- };
18
-
19
- const listItemNode = {
20
- type: { name: 'listItem' },
21
- forEach: (cb) => cb(paragraphChild),
22
- };
23
-
24
- const newState = {
25
- schema: { nodes: { div: divType } },
26
- tr,
27
- doc: {
28
- descendants: (cb) => cb(listItemNode, 10),
29
- },
30
- };
31
-
32
- const result = plugin.spec.appendTransaction([{ docChanged: true }], {}, newState);
33
-
34
- expect(tr.setNodeMarkup).toHaveBeenCalledWith(11, divType, paragraphChild.attrs);
35
- expect(result).toBe(tr);
36
- });
37
-
38
- it('returns null when there is no document change', () => {
39
- const plugin = EnsureListItemContentIsDiv.config.addProseMirrorPlugins()[0];
40
-
41
- const result = plugin.spec.appendTransaction([{ docChanged: false }], {}, {});
42
- expect(result).toBeNull();
43
- });
44
- });
@@ -1,13 +0,0 @@
1
- import { ExtendedListItem } from '../extended-list-item';
2
-
3
- describe('ExtendedListItem', () => {
4
- it('extends listItem and prefers div over paragraph in content spec', () => {
5
- expect(ExtendedListItem.name).toBe('listItem');
6
-
7
- const content =
8
- ExtendedListItem.options?.content ?? ExtendedListItem.config?.content ?? ExtendedListItem.extendOptions?.content;
9
-
10
- expect(String(content)).toMatch(/^\(div \| paragraph/);
11
- expect(String(content)).toContain('imageUploadNode');
12
- });
13
- });
@@ -1,22 +0,0 @@
1
- import { ExtendedTableCell, ExtendedTableHeader } from '../extended-table-cell';
2
-
3
- describe('ExtendedTableCell / ExtendedTableHeader', () => {
4
- it('exports cell and header extensions with div preferred over paragraph in content spec', () => {
5
- expect(ExtendedTableCell.name).toBe('tableCell');
6
- expect(ExtendedTableHeader.name).toBe('tableHeader');
7
-
8
- const cellContent =
9
- ExtendedTableCell.options?.content ??
10
- ExtendedTableCell.config?.content ??
11
- ExtendedTableCell.extendOptions?.content;
12
-
13
- expect(String(cellContent)).toMatch(/^\(div \| paragraph/);
14
-
15
- const headerContent =
16
- ExtendedTableHeader.options?.content ??
17
- ExtendedTableHeader.config?.content ??
18
- ExtendedTableHeader.extendOptions?.content;
19
-
20
- expect(headerContent).toBe(cellContent);
21
- });
22
- });