@akinon/ui-editor 1.0.3 → 1.0.4

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 (129) hide show
  1. package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.js +79 -3
  2. package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.tsx +106 -3
  3. package/dist/cjs/tiptap/components/__tests__/tiptap.test.js +42 -4
  4. package/dist/cjs/tiptap/components/__tests__/tiptap.test.tsx +57 -7
  5. package/dist/cjs/tiptap/components/format-bubble-menu.d.ts.map +1 -1
  6. package/dist/cjs/tiptap/components/format-bubble-menu.js +6 -5
  7. package/dist/cjs/tiptap/components/html-code-viewer.d.ts +2 -1
  8. package/dist/cjs/tiptap/components/html-code-viewer.d.ts.map +1 -1
  9. package/dist/cjs/tiptap/components/html-code-viewer.js +62 -22
  10. package/dist/cjs/tiptap/components/image-upload-placeholder.d.ts.map +1 -1
  11. package/dist/cjs/tiptap/components/image-upload-placeholder.js +5 -2
  12. package/dist/cjs/tiptap/components/secure-script-component.d.ts.map +1 -1
  13. package/dist/cjs/tiptap/components/secure-script-component.js +2 -5
  14. package/dist/cjs/tiptap/components/tiptap.d.ts +1 -1
  15. package/dist/cjs/tiptap/components/tiptap.d.ts.map +1 -1
  16. package/dist/cjs/tiptap/components/tiptap.js +84 -56
  17. package/dist/cjs/tiptap/constants/editor-config.d.ts +10 -1
  18. package/dist/cjs/tiptap/constants/editor-config.d.ts.map +1 -1
  19. package/dist/cjs/tiptap/constants/editor-config.js +11 -2
  20. package/dist/cjs/tiptap/constants/html-elements.d.ts +1 -0
  21. package/dist/cjs/tiptap/constants/html-elements.d.ts.map +1 -1
  22. package/dist/cjs/tiptap/constants/html-elements.js +2 -1
  23. package/dist/cjs/tiptap/extensions/comment-extension.d.ts.map +1 -1
  24. package/dist/cjs/tiptap/extensions/comment-extension.js +3 -3
  25. package/dist/cjs/tiptap/extensions/custom-table-cell-extension.d.ts.map +1 -1
  26. package/dist/cjs/tiptap/extensions/custom-table-cell-extension.js +11 -2
  27. package/dist/cjs/tiptap/extensions/custom-table-header-extension.d.ts.map +1 -1
  28. package/dist/cjs/tiptap/extensions/custom-table-header-extension.js +11 -2
  29. package/dist/cjs/tiptap/extensions/html-block-extension.d.ts.map +1 -1
  30. package/dist/cjs/tiptap/extensions/html-block-extension.js +11 -14
  31. package/dist/cjs/tiptap/extensions/html-inline-extension.d.ts.map +1 -1
  32. package/dist/cjs/tiptap/extensions/html-inline-extension.js +11 -14
  33. package/dist/cjs/tiptap/types/index.d.ts +12 -5
  34. package/dist/cjs/tiptap/types/index.d.ts.map +1 -1
  35. package/dist/cjs/tiptap/utils/__tests__/clean-html.test.d.ts +2 -0
  36. package/dist/cjs/tiptap/utils/__tests__/clean-html.test.d.ts.map +1 -0
  37. package/dist/cjs/tiptap/utils/__tests__/clean-html.test.js +93 -0
  38. package/dist/cjs/tiptap/utils/__tests__/clean-html.test.ts +129 -0
  39. package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.d.ts +2 -0
  40. package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.d.ts.map +1 -0
  41. package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.js +105 -0
  42. package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.ts +148 -0
  43. package/dist/cjs/tiptap/utils/__tests__/index.test.js +0 -2
  44. package/dist/cjs/tiptap/utils/__tests__/index.test.ts +0 -2
  45. package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.d.ts +2 -0
  46. package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.d.ts.map +1 -0
  47. package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.js +33 -0
  48. package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.ts +49 -0
  49. package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.js +157 -0
  50. package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.ts +234 -0
  51. package/dist/cjs/tiptap/utils/clean-html.d.ts +9 -0
  52. package/dist/cjs/tiptap/utils/clean-html.d.ts.map +1 -0
  53. package/dist/cjs/tiptap/utils/clean-html.js +75 -0
  54. package/dist/cjs/tiptap/utils/data-attributes-helper.d.ts +20 -0
  55. package/dist/cjs/tiptap/utils/data-attributes-helper.d.ts.map +1 -0
  56. package/dist/cjs/tiptap/utils/data-attributes-helper.js +68 -0
  57. package/dist/cjs/tiptap/utils/index.d.ts +3 -2
  58. package/dist/cjs/tiptap/utils/index.d.ts.map +1 -1
  59. package/dist/cjs/tiptap/utils/index.js +3 -2
  60. package/dist/cjs/tiptap/utils/prettier-format.d.ts +8 -0
  61. package/dist/cjs/tiptap/utils/prettier-format.d.ts.map +1 -0
  62. package/dist/cjs/tiptap/utils/prettier-format.js +26 -0
  63. package/dist/cjs/tiptap/utils/tiptap-extensions.d.ts.map +1 -1
  64. package/dist/cjs/tiptap/utils/tiptap-extensions.js +134 -14
  65. package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.js +79 -3
  66. package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.tsx +106 -3
  67. package/dist/esm/tiptap/components/__tests__/tiptap.test.js +42 -4
  68. package/dist/esm/tiptap/components/__tests__/tiptap.test.tsx +57 -7
  69. package/dist/esm/tiptap/components/format-bubble-menu.d.ts.map +1 -1
  70. package/dist/esm/tiptap/components/format-bubble-menu.js +6 -5
  71. package/dist/esm/tiptap/components/html-code-viewer.d.ts +2 -1
  72. package/dist/esm/tiptap/components/html-code-viewer.d.ts.map +1 -1
  73. package/dist/esm/tiptap/components/html-code-viewer.js +62 -22
  74. package/dist/esm/tiptap/components/image-upload-placeholder.d.ts.map +1 -1
  75. package/dist/esm/tiptap/components/image-upload-placeholder.js +5 -2
  76. package/dist/esm/tiptap/components/secure-script-component.d.ts.map +1 -1
  77. package/dist/esm/tiptap/components/secure-script-component.js +2 -5
  78. package/dist/esm/tiptap/components/tiptap.d.ts +1 -1
  79. package/dist/esm/tiptap/components/tiptap.d.ts.map +1 -1
  80. package/dist/esm/tiptap/components/tiptap.js +84 -56
  81. package/dist/esm/tiptap/constants/editor-config.d.ts +10 -1
  82. package/dist/esm/tiptap/constants/editor-config.d.ts.map +1 -1
  83. package/dist/esm/tiptap/constants/editor-config.js +11 -2
  84. package/dist/esm/tiptap/constants/html-elements.d.ts +1 -0
  85. package/dist/esm/tiptap/constants/html-elements.d.ts.map +1 -1
  86. package/dist/esm/tiptap/constants/html-elements.js +2 -1
  87. package/dist/esm/tiptap/extensions/comment-extension.d.ts.map +1 -1
  88. package/dist/esm/tiptap/extensions/comment-extension.js +3 -3
  89. package/dist/esm/tiptap/extensions/custom-table-cell-extension.d.ts.map +1 -1
  90. package/dist/esm/tiptap/extensions/custom-table-cell-extension.js +11 -2
  91. package/dist/esm/tiptap/extensions/custom-table-header-extension.d.ts.map +1 -1
  92. package/dist/esm/tiptap/extensions/custom-table-header-extension.js +11 -2
  93. package/dist/esm/tiptap/extensions/html-block-extension.d.ts.map +1 -1
  94. package/dist/esm/tiptap/extensions/html-block-extension.js +11 -14
  95. package/dist/esm/tiptap/extensions/html-inline-extension.d.ts.map +1 -1
  96. package/dist/esm/tiptap/extensions/html-inline-extension.js +11 -14
  97. package/dist/esm/tiptap/types/index.d.ts +12 -5
  98. package/dist/esm/tiptap/types/index.d.ts.map +1 -1
  99. package/dist/esm/tiptap/utils/__tests__/clean-html.test.d.ts +2 -0
  100. package/dist/esm/tiptap/utils/__tests__/clean-html.test.d.ts.map +1 -0
  101. package/dist/esm/tiptap/utils/__tests__/clean-html.test.js +93 -0
  102. package/dist/esm/tiptap/utils/__tests__/clean-html.test.ts +129 -0
  103. package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.d.ts +2 -0
  104. package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.d.ts.map +1 -0
  105. package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.js +105 -0
  106. package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.ts +148 -0
  107. package/dist/esm/tiptap/utils/__tests__/index.test.js +0 -2
  108. package/dist/esm/tiptap/utils/__tests__/index.test.ts +0 -2
  109. package/dist/esm/tiptap/utils/__tests__/prettier-format.test.d.ts +2 -0
  110. package/dist/esm/tiptap/utils/__tests__/prettier-format.test.d.ts.map +1 -0
  111. package/dist/esm/tiptap/utils/__tests__/prettier-format.test.js +33 -0
  112. package/dist/esm/tiptap/utils/__tests__/prettier-format.test.ts +49 -0
  113. package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.js +157 -0
  114. package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.ts +234 -0
  115. package/dist/esm/tiptap/utils/clean-html.d.ts +9 -0
  116. package/dist/esm/tiptap/utils/clean-html.d.ts.map +1 -0
  117. package/dist/esm/tiptap/utils/clean-html.js +75 -0
  118. package/dist/esm/tiptap/utils/data-attributes-helper.d.ts +20 -0
  119. package/dist/esm/tiptap/utils/data-attributes-helper.d.ts.map +1 -0
  120. package/dist/esm/tiptap/utils/data-attributes-helper.js +68 -0
  121. package/dist/esm/tiptap/utils/index.d.ts +3 -2
  122. package/dist/esm/tiptap/utils/index.d.ts.map +1 -1
  123. package/dist/esm/tiptap/utils/index.js +3 -2
  124. package/dist/esm/tiptap/utils/prettier-format.d.ts +8 -0
  125. package/dist/esm/tiptap/utils/prettier-format.d.ts.map +1 -0
  126. package/dist/esm/tiptap/utils/prettier-format.js +26 -0
  127. package/dist/esm/tiptap/utils/tiptap-extensions.d.ts.map +1 -1
  128. package/dist/esm/tiptap/utils/tiptap-extensions.js +134 -14
  129. package/package.json +13 -12
@@ -93,13 +93,13 @@ export interface ToolbarConfig {
93
93
  * - `history` - Undo and redo actions
94
94
  * - `alignment` - Text alignment options (left, center, right, justify)
95
95
  *
96
- * @example
96
+ * **Example:**
97
97
  * ```tsx
98
98
  * // Hide all formatting and media buttons
99
99
  * toolbar={{ hiddenGroups: ['formatting', 'media'] }}
100
100
  * ```
101
101
  *
102
- * @example
102
+ * **Example:**
103
103
  * ```tsx
104
104
  * // Keep only basic text editing (hide media and alignment)
105
105
  * toolbar={{ hiddenGroups: ['media', 'alignment'] }}
@@ -131,6 +131,11 @@ export interface TextEditorProps {
131
131
  * @default false
132
132
  */
133
133
  readOnly?: boolean;
134
+ /**
135
+ * Sets a maximum height for the editor content area. If the content exceeds this height, it becomes scrollable.
136
+ * @default 400
137
+ */
138
+ contentHeight?: number;
134
139
  /**
135
140
  * Custom class names for different parts of the editor.
136
141
  * Use this to apply custom styling to specific editor sections.
@@ -158,6 +163,8 @@ export interface TextEditorProps {
158
163
  editorContent?: string;
159
164
  /** Class name for the toolbar container */
160
165
  editorToolbar?: string;
166
+ /** Class name for the source mode wrapper (if source mode is enabled) */
167
+ editorSourceModeWrapper?: string;
161
168
  };
162
169
  /**
163
170
  * Configuration object to customize the toolbar visibility.
@@ -181,19 +188,19 @@ export interface TextEditorProps {
181
188
  * - `history` - Undo and redo actions
182
189
  * - `alignment` - Text alignment options (left, center, right, justify)
183
190
  *
184
- * @example
191
+ * **Example:**
185
192
  * ```tsx
186
193
  * // Hide specific formatting buttons
187
194
  * <AkiTextEditor toolbar={{ hiddenButtons: ['bold', 'italic'] }} />
188
195
  * ```
189
196
  *
190
- * @example
197
+ * **Example:**
191
198
  * ```tsx
192
199
  * // Hide entire groups
193
200
  * <AkiTextEditor toolbar={{ hiddenGroups: ['formatting', 'media'] }} />
194
201
  * ```
195
202
  *
196
- * @example
203
+ * **Example:**
197
204
  * ```tsx
198
205
  * // Combine both for fine-grained control
199
206
  * <AkiTextEditor
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OA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C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CACtC;AACD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;IAEhE;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IAEH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE;QACX,kDAAkD;QAClD,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,6CAA6C;QAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,2CAA2C;QAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,yEAAyE;QACzE,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,WAAW,IAAI,MAAM,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=clean-html.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean-html.test.d.ts","sourceRoot":"","sources":["../../../../../src/tiptap/utils/__tests__/clean-html.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,93 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { cleanDuplicateSpans } from '../clean-html';
3
+ describe('clean-html', () => {
4
+ it('should return html as is in non-browser environment', () => {
5
+ // Simulate non-browser environment
6
+ // Note: This relies on how cleanDuplicateSpans checks for window/DOMParser
7
+ const originalWindow = global.window;
8
+ // @ts-expect-error Testing environment specific behavior
9
+ delete global.window;
10
+ const html = '<div>test</div>';
11
+ expect(cleanDuplicateSpans(html)).toBe(html);
12
+ global.window = originalWindow;
13
+ });
14
+ it('should remove empty spans', () => {
15
+ const html = '<div><span></span>Content<span> </span></div>';
16
+ const result = cleanDuplicateSpans(html);
17
+ expect(result).toBe('<div>Content</div>');
18
+ });
19
+ it('should unwrap spans with no attributes', () => {
20
+ const html = '<div><span>Content</span></div>';
21
+ const result = cleanDuplicateSpans(html);
22
+ expect(result).toBe('<div>Content</div>');
23
+ });
24
+ it('should merge nested spans with same styles', () => {
25
+ const html = '<div><span style="color: red;"><span style="color: red;">Content</span></span></div>';
26
+ const result = cleanDuplicateSpans(html);
27
+ expect(result).toBe('<div><span style="color: red;">Content</span></div>');
28
+ });
29
+ it('should unwrap parent span if it has no styles but child does', () => {
30
+ const html = '<div><span><span style="color: red;">Content</span></span></div>';
31
+ const result = cleanDuplicateSpans(html);
32
+ // First expected: Inner content preserved
33
+ // The logic: parent span has no attributes -> unwrap parent -> result is child span
34
+ expect(result).toBe('<div><span style="color: red;">Content</span></div>');
35
+ });
36
+ it('should not merge spans with different styles', () => {
37
+ const html = '<div><span style="color: blue;"><span style="color: red;">Content</span></span></div>';
38
+ const result = cleanDuplicateSpans(html);
39
+ // Should keep both or just behave normally.
40
+ // Our logic only merges if styles are identical or parent has no style.
41
+ expect(result).toContain('color: blue');
42
+ expect(result).toContain('color: red');
43
+ });
44
+ it('should handle complex nesting', () => {
45
+ const html = '<div><span style="color: red;"><span style="color: red;">Red</span></span> <span style="font-weight: bold">Bold</span></div>';
46
+ const result = cleanDuplicateSpans(html);
47
+ expect(result).toBe('<div><span style="color: red;">Red</span> <span style="font-weight: bold">Bold</span></div>');
48
+ });
49
+ it('should handle rgb colors (no conversion)', () => {
50
+ const html = '<div><span style="color: rgb(255, 0, 0);">Red</span></div>';
51
+ const result = cleanDuplicateSpans(html);
52
+ expect(result).toBe('<div><span style="color: rgb(255, 0, 0);">Red</span></div>');
53
+ });
54
+ it('should unwrap parent span if it has other attributes but no style', () => {
55
+ const html = '<div><span class="foo"><span style="color: red;">Content</span></span></div>';
56
+ const result = cleanDuplicateSpans(html);
57
+ // Parent unwrapped because !parentStyle check passes
58
+ expect(result).toBe('<div><span style="color: red;">Content</span></div>');
59
+ });
60
+ it('should not merge if parent has style but child has none', () => {
61
+ const html = '<div><span style="color: red;"><span class="inner">Content</span></span></div>';
62
+ const result = cleanDuplicateSpans(html);
63
+ expect(result).toBe('<div><span style="color: red;"><span class="inner">Content</span></span></div>');
64
+ });
65
+ it('should preserve script tags with type="text/inert"', () => {
66
+ const html = '<div><script type="text/inert">console.log("test")</script></div>';
67
+ const result = cleanDuplicateSpans(html);
68
+ expect(result).toBe('<div><script type="text/inert">console.log("test")</script></div>');
69
+ });
70
+ it('should preserve script tags without type attribute', () => {
71
+ const html = '<div><script>console.log("test")</script></div>';
72
+ const result = cleanDuplicateSpans(html);
73
+ expect(result).toBe('<div><script>console.log("test")</script></div>');
74
+ });
75
+ it('should preserve script tags and clean spans together', () => {
76
+ const html = '<div><span></span><script>console.log("test")</script><span>Content</span></div>';
77
+ const result = cleanDuplicateSpans(html);
78
+ expect(result).toBe('<div><script>console.log("test")</script>Content</div>');
79
+ });
80
+ it('should handle mixed content with text nodes', () => {
81
+ // This test covers line 87: return node.textContent || '';
82
+ // Testing text nodes between elements
83
+ const html = '<div>Start<p>Middle</p>End</div>';
84
+ const result = cleanDuplicateSpans(html);
85
+ expect(result).toBe('<div>Start<p>Middle</p>End</div>');
86
+ });
87
+ it('should handle empty text content fallback', () => {
88
+ // Edge case: elements with only whitespace text nodes
89
+ const html = '<div> </div>';
90
+ const result = cleanDuplicateSpans(html);
91
+ expect(result).toBe('<div> </div>');
92
+ });
93
+ });
@@ -0,0 +1,129 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { cleanDuplicateSpans } from '../clean-html';
4
+
5
+ describe('clean-html', () => {
6
+ it('should return html as is in non-browser environment', () => {
7
+ // Simulate non-browser environment
8
+ // Note: This relies on how cleanDuplicateSpans checks for window/DOMParser
9
+ const originalWindow = global.window;
10
+ // @ts-expect-error Testing environment specific behavior
11
+ delete global.window;
12
+
13
+ const html = '<div>test</div>';
14
+ expect(cleanDuplicateSpans(html)).toBe(html);
15
+
16
+ global.window = originalWindow;
17
+ });
18
+
19
+ it('should remove empty spans', () => {
20
+ const html = '<div><span></span>Content<span> </span></div>';
21
+ const result = cleanDuplicateSpans(html);
22
+ expect(result).toBe('<div>Content</div>');
23
+ });
24
+
25
+ it('should unwrap spans with no attributes', () => {
26
+ const html = '<div><span>Content</span></div>';
27
+ const result = cleanDuplicateSpans(html);
28
+ expect(result).toBe('<div>Content</div>');
29
+ });
30
+
31
+ it('should merge nested spans with same styles', () => {
32
+ const html =
33
+ '<div><span style="color: red;"><span style="color: red;">Content</span></span></div>';
34
+ const result = cleanDuplicateSpans(html);
35
+ expect(result).toBe('<div><span style="color: red;">Content</span></div>');
36
+ });
37
+
38
+ it('should unwrap parent span if it has no styles but child does', () => {
39
+ const html =
40
+ '<div><span><span style="color: red;">Content</span></span></div>';
41
+ const result = cleanDuplicateSpans(html);
42
+ // First expected: Inner content preserved
43
+ // The logic: parent span has no attributes -> unwrap parent -> result is child span
44
+ expect(result).toBe('<div><span style="color: red;">Content</span></div>');
45
+ });
46
+
47
+ it('should not merge spans with different styles', () => {
48
+ const html =
49
+ '<div><span style="color: blue;"><span style="color: red;">Content</span></span></div>';
50
+ const result = cleanDuplicateSpans(html);
51
+ // Should keep both or just behave normally.
52
+ // Our logic only merges if styles are identical or parent has no style.
53
+ expect(result).toContain('color: blue');
54
+ expect(result).toContain('color: red');
55
+ });
56
+
57
+ it('should handle complex nesting', () => {
58
+ const html =
59
+ '<div><span style="color: red;"><span style="color: red;">Red</span></span> <span style="font-weight: bold">Bold</span></div>';
60
+ const result = cleanDuplicateSpans(html);
61
+ expect(result).toBe(
62
+ '<div><span style="color: red;">Red</span> <span style="font-weight: bold">Bold</span></div>'
63
+ );
64
+ });
65
+
66
+ it('should handle rgb colors (no conversion)', () => {
67
+ const html = '<div><span style="color: rgb(255, 0, 0);">Red</span></div>';
68
+ const result = cleanDuplicateSpans(html);
69
+ expect(result).toBe(
70
+ '<div><span style="color: rgb(255, 0, 0);">Red</span></div>'
71
+ );
72
+ });
73
+
74
+ it('should unwrap parent span if it has other attributes but no style', () => {
75
+ const html =
76
+ '<div><span class="foo"><span style="color: red;">Content</span></span></div>';
77
+ const result = cleanDuplicateSpans(html);
78
+ // Parent unwrapped because !parentStyle check passes
79
+ expect(result).toBe('<div><span style="color: red;">Content</span></div>');
80
+ });
81
+
82
+ it('should not merge if parent has style but child has none', () => {
83
+ const html =
84
+ '<div><span style="color: red;"><span class="inner">Content</span></span></div>';
85
+ const result = cleanDuplicateSpans(html);
86
+ expect(result).toBe(
87
+ '<div><span style="color: red;"><span class="inner">Content</span></span></div>'
88
+ );
89
+ });
90
+
91
+ it('should preserve script tags with type="text/inert"', () => {
92
+ const html =
93
+ '<div><script type="text/inert">console.log("test")</script></div>';
94
+ const result = cleanDuplicateSpans(html);
95
+ expect(result).toBe(
96
+ '<div><script type="text/inert">console.log("test")</script></div>'
97
+ );
98
+ });
99
+
100
+ it('should preserve script tags without type attribute', () => {
101
+ const html = '<div><script>console.log("test")</script></div>';
102
+ const result = cleanDuplicateSpans(html);
103
+ expect(result).toBe('<div><script>console.log("test")</script></div>');
104
+ });
105
+
106
+ it('should preserve script tags and clean spans together', () => {
107
+ const html =
108
+ '<div><span></span><script>console.log("test")</script><span>Content</span></div>';
109
+ const result = cleanDuplicateSpans(html);
110
+ expect(result).toBe(
111
+ '<div><script>console.log("test")</script>Content</div>'
112
+ );
113
+ });
114
+
115
+ it('should handle mixed content with text nodes', () => {
116
+ // This test covers line 87: return node.textContent || '';
117
+ // Testing text nodes between elements
118
+ const html = '<div>Start<p>Middle</p>End</div>';
119
+ const result = cleanDuplicateSpans(html);
120
+ expect(result).toBe('<div>Start<p>Middle</p>End</div>');
121
+ });
122
+
123
+ it('should handle empty text content fallback', () => {
124
+ // Edge case: elements with only whitespace text nodes
125
+ const html = '<div> </div>';
126
+ const result = cleanDuplicateSpans(html);
127
+ expect(result).toBe('<div> </div>');
128
+ });
129
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data-attributes-helper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-attributes-helper.test.d.ts","sourceRoot":"","sources":["../../../../../src/tiptap/utils/__tests__/data-attributes-helper.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,105 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { addDataAttributesToParent, createDataAttributesConfig, extractDataAttributes } from '../data-attributes-helper';
3
+ describe('data-attributes-helper', () => {
4
+ describe('createDataAttributesConfig', () => {
5
+ const config = createDataAttributesConfig();
6
+ it('should parse data attributes from HTML element', () => {
7
+ const element = document.createElement('div');
8
+ element.setAttribute('data-test', 'value');
9
+ element.setAttribute('class', 'ignore-me');
10
+ const result = config.dataAttributes.parseHTML(element);
11
+ expect(result).toEqual({ 'data-test': 'value' });
12
+ });
13
+ it('should return empty object if no data attributes present', () => {
14
+ const element = document.createElement('div');
15
+ element.setAttribute('class', 'ignore-me');
16
+ const result = config.dataAttributes.parseHTML(element);
17
+ expect(result).toEqual({});
18
+ });
19
+ it('should render data attributes correctly', () => {
20
+ const result = config.dataAttributes.renderHTML({
21
+ dataAttributes: { 'data-foo': 'bar' }
22
+ });
23
+ expect(result).toEqual({ 'data-foo': 'bar' });
24
+ });
25
+ it('should handle undefined dataAttributes in renderHTML', () => {
26
+ const result = config.dataAttributes.renderHTML({});
27
+ expect(result).toEqual({});
28
+ });
29
+ });
30
+ describe('extractDataAttributes', () => {
31
+ it('should extract data attributes and separate others', () => {
32
+ const attrs = {
33
+ dataAttributes: { 'data-foo': 'bar' },
34
+ other: 'value'
35
+ };
36
+ const { dataAttributes, otherAttrs } = extractDataAttributes(attrs);
37
+ expect(dataAttributes).toEqual({ 'data-foo': 'bar' });
38
+ expect(otherAttrs).toEqual({ other: 'value' });
39
+ });
40
+ it('should handle missing data attributes', () => {
41
+ const attrs = { other: 'value' };
42
+ const { dataAttributes, otherAttrs } = extractDataAttributes(attrs);
43
+ expect(dataAttributes).toEqual({});
44
+ expect(otherAttrs).toEqual({ other: 'value' });
45
+ });
46
+ });
47
+ describe('addDataAttributesToParent', () => {
48
+ const config = addDataAttributesToParent(() => ({
49
+ default: 'value'
50
+ }));
51
+ // Helper to get methods safely
52
+ const getMethods = (key) => config[key];
53
+ it('should include parent attributes', () => {
54
+ expect(config.default).toBe('value');
55
+ });
56
+ describe('class attribute', () => {
57
+ const methods = getMethods('class');
58
+ it('should parse class attribute', () => {
59
+ const element = document.createElement('div');
60
+ element.setAttribute('class', 'test-class');
61
+ expect(methods.parseHTML(element)).toBe('test-class');
62
+ });
63
+ it('should render class attribute', () => {
64
+ expect(methods.renderHTML({ class: 'test-class' })).toEqual({
65
+ class: 'test-class'
66
+ });
67
+ });
68
+ it('should return empty object if class missing', () => {
69
+ expect(methods.renderHTML({})).toEqual({});
70
+ });
71
+ });
72
+ describe('id attribute', () => {
73
+ const methods = getMethods('id');
74
+ it('should parse id attribute', () => {
75
+ const element = document.createElement('div');
76
+ element.setAttribute('id', 'test-id');
77
+ expect(methods.parseHTML(element)).toBe('test-id');
78
+ });
79
+ it('should render id attribute', () => {
80
+ expect(methods.renderHTML({ id: 'test-id' })).toEqual({
81
+ id: 'test-id'
82
+ });
83
+ });
84
+ it('should return empty object if id missing', () => {
85
+ expect(methods.renderHTML({})).toEqual({});
86
+ });
87
+ });
88
+ describe('style attribute', () => {
89
+ const methods = getMethods('style');
90
+ it('should parse style attribute', () => {
91
+ const element = document.createElement('div');
92
+ element.setAttribute('style', 'color: red');
93
+ expect(methods.parseHTML(element)).toBe('color: red');
94
+ });
95
+ it('should render style attribute', () => {
96
+ expect(methods.renderHTML({ style: 'color: red' })).toEqual({
97
+ style: 'color: red'
98
+ });
99
+ });
100
+ it('should return empty object if style missing', () => {
101
+ expect(methods.renderHTML({})).toEqual({});
102
+ });
103
+ });
104
+ });
105
+ });
@@ -0,0 +1,148 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import {
4
+ addDataAttributesToParent,
5
+ createDataAttributesConfig,
6
+ extractDataAttributes
7
+ } from '../data-attributes-helper';
8
+
9
+ describe('data-attributes-helper', () => {
10
+ describe('createDataAttributesConfig', () => {
11
+ const config = createDataAttributesConfig();
12
+
13
+ it('should parse data attributes from HTML element', () => {
14
+ const element = document.createElement('div');
15
+ element.setAttribute('data-test', 'value');
16
+ element.setAttribute('class', 'ignore-me');
17
+
18
+ const result = config.dataAttributes.parseHTML(element);
19
+
20
+ expect(result).toEqual({ 'data-test': 'value' });
21
+ });
22
+
23
+ it('should return empty object if no data attributes present', () => {
24
+ const element = document.createElement('div');
25
+ element.setAttribute('class', 'ignore-me');
26
+
27
+ const result = config.dataAttributes.parseHTML(element);
28
+
29
+ expect(result).toEqual({});
30
+ });
31
+
32
+ it('should render data attributes correctly', () => {
33
+ const result = config.dataAttributes.renderHTML({
34
+ dataAttributes: { 'data-foo': 'bar' }
35
+ });
36
+ expect(result).toEqual({ 'data-foo': 'bar' });
37
+ });
38
+
39
+ it('should handle undefined dataAttributes in renderHTML', () => {
40
+ const result = config.dataAttributes.renderHTML({});
41
+ expect(result).toEqual({});
42
+ });
43
+ });
44
+
45
+ describe('extractDataAttributes', () => {
46
+ it('should extract data attributes and separate others', () => {
47
+ const attrs = {
48
+ dataAttributes: { 'data-foo': 'bar' },
49
+ other: 'value'
50
+ };
51
+
52
+ const { dataAttributes, otherAttrs } = extractDataAttributes(attrs);
53
+
54
+ expect(dataAttributes).toEqual({ 'data-foo': 'bar' });
55
+ expect(otherAttrs).toEqual({ other: 'value' });
56
+ });
57
+
58
+ it('should handle missing data attributes', () => {
59
+ const attrs = { other: 'value' };
60
+ const { dataAttributes, otherAttrs } = extractDataAttributes(attrs);
61
+
62
+ expect(dataAttributes).toEqual({});
63
+ expect(otherAttrs).toEqual({ other: 'value' });
64
+ });
65
+ });
66
+
67
+ describe('addDataAttributesToParent', () => {
68
+ interface AttributeConfig {
69
+ default: unknown;
70
+ parseHTML: (element: HTMLElement) => unknown;
71
+ renderHTML: (
72
+ attributes: Record<string, unknown>
73
+ ) => Record<string, unknown>;
74
+ }
75
+
76
+ const config = addDataAttributesToParent(() => ({
77
+ default: 'value'
78
+ })) as Record<string, unknown>;
79
+
80
+ // Helper to get methods safely
81
+ const getMethods = (key: string): AttributeConfig =>
82
+ config[key] as AttributeConfig;
83
+
84
+ it('should include parent attributes', () => {
85
+ expect(config.default).toBe('value');
86
+ });
87
+
88
+ describe('class attribute', () => {
89
+ const methods = getMethods('class');
90
+
91
+ it('should parse class attribute', () => {
92
+ const element = document.createElement('div');
93
+ element.setAttribute('class', 'test-class');
94
+ expect(methods.parseHTML(element)).toBe('test-class');
95
+ });
96
+
97
+ it('should render class attribute', () => {
98
+ expect(methods.renderHTML({ class: 'test-class' })).toEqual({
99
+ class: 'test-class'
100
+ });
101
+ });
102
+
103
+ it('should return empty object if class missing', () => {
104
+ expect(methods.renderHTML({})).toEqual({});
105
+ });
106
+ });
107
+
108
+ describe('id attribute', () => {
109
+ const methods = getMethods('id');
110
+
111
+ it('should parse id attribute', () => {
112
+ const element = document.createElement('div');
113
+ element.setAttribute('id', 'test-id');
114
+ expect(methods.parseHTML(element)).toBe('test-id');
115
+ });
116
+
117
+ it('should render id attribute', () => {
118
+ expect(methods.renderHTML({ id: 'test-id' })).toEqual({
119
+ id: 'test-id'
120
+ });
121
+ });
122
+
123
+ it('should return empty object if id missing', () => {
124
+ expect(methods.renderHTML({})).toEqual({});
125
+ });
126
+ });
127
+
128
+ describe('style attribute', () => {
129
+ const methods = getMethods('style');
130
+
131
+ it('should parse style attribute', () => {
132
+ const element = document.createElement('div');
133
+ element.setAttribute('style', 'color: red');
134
+ expect(methods.parseHTML(element)).toBe('color: red');
135
+ });
136
+
137
+ it('should render style attribute', () => {
138
+ expect(methods.renderHTML({ style: 'color: red' })).toEqual({
139
+ style: 'color: red'
140
+ });
141
+ });
142
+
143
+ it('should return empty object if style missing', () => {
144
+ expect(methods.renderHTML({})).toEqual({});
145
+ });
146
+ });
147
+ });
148
+ });
@@ -2,9 +2,7 @@ import { describe, expect, it } from 'vitest';
2
2
  import * as index from '../index';
3
3
  describe('tiptap/utils/index', () => {
4
4
  it('should export all required modules', () => {
5
- expect(index).toHaveProperty('formatHtml');
6
5
  expect(index).toHaveProperty('highlightHtml');
7
- expect(index).toHaveProperty('normalizeHtml');
8
6
  expect(index).toHaveProperty('getExtensions');
9
7
  expect(index).toHaveProperty('handleImageFile');
10
8
  expect(index).toHaveProperty('validateLink');
@@ -4,9 +4,7 @@ import * as index from '../index';
4
4
 
5
5
  describe('tiptap/utils/index', () => {
6
6
  it('should export all required modules', () => {
7
- expect(index).toHaveProperty('formatHtml');
8
7
  expect(index).toHaveProperty('highlightHtml');
9
- expect(index).toHaveProperty('normalizeHtml');
10
8
  expect(index).toHaveProperty('getExtensions');
11
9
  expect(index).toHaveProperty('handleImageFile');
12
10
  expect(index).toHaveProperty('validateLink');
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prettier-format.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier-format.test.d.ts","sourceRoot":"","sources":["../../../../../src/tiptap/utils/__tests__/prettier-format.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import * as prettier from 'prettier/standalone';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { formatHtmlWithPrettier } from '../prettier-format';
4
+ vi.mock('prettier/standalone', () => ({
5
+ format: vi.fn()
6
+ }));
7
+ vi.mock('prettier/plugins/html', async (importOriginal) => {
8
+ const mod = await importOriginal();
9
+ return Object.assign({}, mod);
10
+ });
11
+ describe('prettier-format', () => {
12
+ it('should format html successfully', async () => {
13
+ const input = '<div> test </div>';
14
+ const formatted = '<div>test</div>';
15
+ vi.mocked(prettier.format).mockResolvedValue(formatted);
16
+ const result = await formatHtmlWithPrettier(input);
17
+ expect(prettier.format).toHaveBeenCalledWith(input, expect.objectContaining({
18
+ parser: 'html',
19
+ printWidth: 60
20
+ }));
21
+ expect(result).toBe(formatted);
22
+ });
23
+ it('should return original html and warn when formatting fails', async () => {
24
+ const input = 'Invalid HTML';
25
+ const error = new Error('Parse error');
26
+ vi.mocked(prettier.format).mockRejectedValue(error);
27
+ const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => { });
28
+ const result = await formatHtmlWithPrettier(input);
29
+ expect(result).toBe(input);
30
+ expect(consoleSpy).not.toHaveBeenCalled();
31
+ consoleSpy.mockRestore();
32
+ });
33
+ });