@pie-lib/editable-html-tip-tap 2.2.0-beta.8 → 2.2.0-beta.9

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 (47) hide show
  1. package/package.json +3 -3
  2. package/src/__tests__/EditableHtml.test.jsx +0 -588
  3. package/src/__tests__/constants.test.js +0 -19
  4. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  5. package/src/__tests__/extensions.test.js +0 -208
  6. package/src/__tests__/index.test.jsx +0 -154
  7. package/src/__tests__/size-utils.test.js +0 -64
  8. package/src/__tests__/theme.test.js +0 -17
  9. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  10. package/src/components/__tests__/CharacterPicker.test.jsx +0 -270
  11. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  12. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  13. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -209
  14. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  15. package/src/components/__tests__/InlineDropdown.test.jsx +0 -557
  16. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  17. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  18. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  19. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  20. package/src/components/__tests__/MenuBar.test.jsx +0 -250
  21. package/src/components/__tests__/RespArea.test.jsx +0 -122
  22. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  23. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  24. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  25. package/src/components/__tests__/characterUtils.test.js +0 -166
  26. package/src/components/__tests__/choice.test.jsx +0 -171
  27. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  28. package/src/components/__tests__/done-button.test.jsx +0 -54
  29. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
  30. package/src/components/respArea/DragInTheBlank/__tests__/choice.test.jsx +0 -72
  31. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  32. package/src/extensions/__tests__/css.test.js +0 -196
  33. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  34. package/src/extensions/__tests__/divNode.test.js +0 -87
  35. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  36. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  37. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  38. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  39. package/src/extensions/__tests__/extended-table.test.js +0 -183
  40. package/src/extensions/__tests__/image-component.test.jsx +0 -346
  41. package/src/extensions/__tests__/image.test.js +0 -237
  42. package/src/extensions/__tests__/math.test.js +0 -900
  43. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  44. package/src/extensions/__tests__/media.test.js +0 -271
  45. package/src/extensions/__tests__/responseArea.test.js +0 -655
  46. package/src/utils/__tests__/helper.test.js +0 -126
  47. package/src/utils/__tests__/toolbar.test.js +0 -43
@@ -1,126 +0,0 @@
1
- import { normalizeInitialMarkup } from '../helper';
2
-
3
- describe('normalizeInitialMarkup', () => {
4
- describe('basic normalization', () => {
5
- it('returns empty div for empty string', () => {
6
- expect(normalizeInitialMarkup('')).toBe('<div></div>');
7
- });
8
-
9
- it('returns empty div for null', () => {
10
- expect(normalizeInitialMarkup(null)).toBe('<div></div>');
11
- });
12
-
13
- it('returns empty div for undefined', () => {
14
- expect(normalizeInitialMarkup(undefined)).toBe('<div></div>');
15
- });
16
-
17
- it('wraps plain text in div', () => {
18
- expect(normalizeInitialMarkup('Hello')).toBe('<div>Hello</div>');
19
- });
20
-
21
- it('returns HTML tags as-is when detected as HTML', () => {
22
- // Since '<script>' matches the HTML pattern, it's returned as-is
23
- // To be escaped, it would need to not match the HTML pattern
24
- expect(normalizeInitialMarkup('<script>')).toBe('<script>');
25
- });
26
-
27
- it('escapes HTML entities in plain text', () => {
28
- // Plain text without angle brackets gets escaped
29
- expect(normalizeInitialMarkup('Hello & World')).toBe('<div>Hello &amp; World</div>');
30
- });
31
-
32
- it('returns single div as-is', () => {
33
- const html = '<div>Hello</div>';
34
- expect(normalizeInitialMarkup(html)).toBe(html);
35
- });
36
-
37
- it('returns paragraph as-is', () => {
38
- const html = '<p>Hello</p>';
39
- expect(normalizeInitialMarkup(html)).toBe(html);
40
- });
41
- });
42
-
43
- describe('consecutive divs to paragraph conversion', () => {
44
- it('converts two consecutive divs to paragraph with br', () => {
45
- const input = '<div>A</div><div>B</div>';
46
- const expected = '<p>A<br>B</p>';
47
- expect(normalizeInitialMarkup(input)).toBe(expected);
48
- });
49
-
50
- it('converts three consecutive divs to paragraph with br tags', () => {
51
- const input = '<div>A</div><div>B</div><div>C</div>';
52
- const expected = '<p>A<br>B<br>C</p>';
53
- expect(normalizeInitialMarkup(input)).toBe(expected);
54
- });
55
-
56
- it('handles divs with whitespace', () => {
57
- const input = '<div> A </div><div> B </div>';
58
- const expected = '<p> A <br> B </p>';
59
- expect(normalizeInitialMarkup(input)).toBe(expected);
60
- });
61
-
62
- it('handles divs with inline elements', () => {
63
- const input = '<div><strong>A</strong></div><div><em>B</em></div>';
64
- const expected = '<p><strong>A</strong><br><em>B</em></p>';
65
- expect(normalizeInitialMarkup(input)).toBe(expected);
66
- });
67
-
68
- it('handles empty divs', () => {
69
- const input = '<div></div><div>B</div>';
70
- const expected = '<p><br>B</p>';
71
- expect(normalizeInitialMarkup(input)).toBe(expected);
72
- });
73
-
74
- it('preserves existing br tags within divs', () => {
75
- const input = '<div>A<br>A2</div><div>B</div>';
76
- const expected = '<p>A<br>A2<br>B</p>';
77
- expect(normalizeInitialMarkup(input)).toBe(expected);
78
- });
79
- });
80
-
81
- describe('cases that should NOT convert', () => {
82
- it('does not convert single div', () => {
83
- const input = '<div>Hello</div>';
84
- expect(normalizeInitialMarkup(input)).toBe(input);
85
- });
86
-
87
- it('does not convert divs with nested block elements', () => {
88
- const input = '<div><div>Nested</div></div><div>B</div>';
89
- expect(normalizeInitialMarkup(input)).toBe(input);
90
- });
91
-
92
- it('does not convert divs containing tables', () => {
93
- const input = '<div><table><tr><td>A</td></tr></table></div><div>B</div>';
94
- expect(normalizeInitialMarkup(input)).toBe(input);
95
- });
96
-
97
- it('does not convert divs containing lists', () => {
98
- const input = '<div><ul><li>Item</li></ul></div><div>B</div>';
99
- expect(normalizeInitialMarkup(input)).toBe(input);
100
- });
101
-
102
- it('does not convert mixed element types', () => {
103
- const input = '<div>A</div><p>B</p>';
104
- expect(normalizeInitialMarkup(input)).toBe(input);
105
- });
106
-
107
- it('does not convert paragraphs', () => {
108
- const input = '<p>A</p><p>B</p>';
109
- expect(normalizeInitialMarkup(input)).toBe(input);
110
- });
111
- });
112
-
113
- describe('edge cases', () => {
114
- it('handles divs with attributes', () => {
115
- const input = '<div class="test">A</div><div>B</div>';
116
- // Should not convert since we only want simple divs
117
- expect(normalizeInitialMarkup(input)).toBe(input);
118
- });
119
-
120
- it('handles complex inline formatting', () => {
121
- const input = '<div><strong><em>A</em></strong></div><div><u>B</u></div>';
122
- const expected = '<p><strong><em>A</em></strong><br><u>B</u></p>';
123
- expect(normalizeInitialMarkup(input)).toBe(expected);
124
- });
125
- });
126
- });
@@ -1,43 +0,0 @@
1
- import { setToolbarOpened, TOOLBAR_OPENED_META_KEY } from '../toolbar';
2
-
3
- describe('setToolbarOpened', () => {
4
- const createEditor = (toolbarOpened = false) => {
5
- const tr = {
6
- setMeta: jest.fn().mockReturnThis(),
7
- };
8
-
9
- return {
10
- _toolbarOpened: toolbarOpened,
11
- state: { tr },
12
- view: {
13
- dispatch: jest.fn(),
14
- },
15
- };
16
- };
17
-
18
- it('sets editor._toolbarOpened and dispatches a meta transaction', () => {
19
- const editor = createEditor(false);
20
-
21
- setToolbarOpened(editor, true);
22
-
23
- expect(editor._toolbarOpened).toBe(true);
24
- expect(editor.state.tr.setMeta).toHaveBeenCalledWith(TOOLBAR_OPENED_META_KEY, true);
25
- expect(editor.view.dispatch).toHaveBeenCalledWith(editor.state.tr);
26
- });
27
-
28
- it('does nothing when the value is unchanged', () => {
29
- const editor = createEditor(true);
30
-
31
- setToolbarOpened(editor, true);
32
-
33
- expect(editor.view.dispatch).not.toHaveBeenCalled();
34
- });
35
-
36
- it('coerces the opened value to a boolean', () => {
37
- const editor = createEditor(false);
38
-
39
- setToolbarOpened(editor, 1);
40
-
41
- expect(editor._toolbarOpened).toBe(true);
42
- });
43
- });