@designcrowd/library.brand-page 6.0.26-json-prereq-2 → 6.0.27-websitev2-dev-1

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 (186) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-CKBqjDH3.js → CreatedOnBrandCrowd-de-de-BpFKOKIo.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-CRXiimvT.js → CreatedOnBrandCrowd-en-us-USGAnC_n.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-DCYdY6sj.js → CreatedOnBrandCrowd-es-es-CvVx3h4H.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-Dk7LOhxE.js → CreatedOnBrandCrowd-fr-ca-BCwamW5a.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-Dk7LOhxE.js → CreatedOnBrandCrowd-fr-fr-BCwamW5a.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-Cp4ufHJP.js → CreatedOnBrandCrowd-pt-br-Bt72hMrQ.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-Cp4ufHJP.js → CreatedOnBrandCrowd-pt-pt-Bt72hMrQ.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-ZSLkWMwM.js → CreatedOnDcom-de-de-BxUDrgG9.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-BgdIGfT3.js → CreatedOnDcom-en-us-wjVp5eOs.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-D0KemkCZ.js → CreatedOnDcom-es-es-CwFL2q5h.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-BuwNjNbC.js → CreatedOnDcom-fr-ca-BPZ2_PNq.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-DCQcsFPf.js → CreatedOnDcom-fr-fr-D0vLOikZ.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-DD-oLAS1.js → CreatedOnDcom-pt-br-CTwbxm9H.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-D8qLq2wW.js → CreatedOnDcom-pt-pt-Cfqf8LaM.js} +1 -1
  15. package/lib/src/brand-page/components/contact-form/ContactForm.mixin.js +2 -5
  16. package/lib/src/brand-page/models/index.d.ts +26 -34
  17. package/lib/src/brand-page/utils/migration.util.js +0 -11
  18. package/lib/src/brand-page/utils/text.util.d.ts +1 -1
  19. package/lib/src/brand-page/utils/text.util.js +0 -32
  20. package/lib/src/brand-page/utils/vcard.util.js +4 -4
  21. package/lib/src/brand-page/utils/view-model.util.d.ts +0 -1
  22. package/lib/src/brand-page/utils/view-model.util.js +20 -68
  23. package/lib/src/brand-page/view-models.d.ts +3 -3
  24. package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.d.ts +1 -0
  25. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +7 -3
  26. package/lib/src/brand-page-maker/composables/rich-text-editor/bubbleMenu.d.ts +9 -2
  27. package/lib/src/brand-page-maker/composables/rich-text-editor/bubbleMenu.js +10 -6
  28. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontSize.d.ts +20 -0
  29. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontSize.js +44 -0
  30. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/LineHeight.d.ts +27 -0
  31. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/LineHeight.js +44 -0
  32. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.d.ts +1 -1
  33. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.js +103 -24
  34. package/lib/src/brand-page-maker/utils/index.d.ts +0 -2
  35. package/lib/src/brand-page-maker/utils/index.js +0 -2
  36. package/lib/src/brand-page-maker/utils/rich-text-editor.util.d.ts +5 -28
  37. package/lib/src/brand-page-maker/utils/rich-text-editor.util.js +5 -48
  38. package/lib/src/brand-page-maker/validators/field.validator.js +2 -10
  39. package/lib/src/clients/ai-assistant-client.d.ts +1 -0
  40. package/lib/src/clients/ai-assistant-client.js +1 -0
  41. package/lib/src/css/library.brand-page-brandCrowd.min.css +39 -39
  42. package/lib/src/css/library.brand-page-brandPage.min.css +39 -39
  43. package/lib/src/css/library.brand-page-designCom.min.css +39 -39
  44. package/lib/src/css/library.brand-page-preview.min.css +39 -39
  45. package/lib/src/index.d.ts +0 -1
  46. package/lib/src/index.mjs +138 -143
  47. package/lib/src/{lib-Db6j9fQZ.js → lib-Cg4BExY4.js} +72135 -75458
  48. package/lib/src/lib.js +0 -2
  49. package/lib/src/metadata-builder/ai-metadata-executor.d.ts +1 -0
  50. package/lib/src/metadata-builder/ai-metadata-executor.js +19 -0
  51. package/lib/src/metadata-builder/builders/global-font-propagation.d.ts +28 -0
  52. package/lib/src/metadata-builder/builders/global-font-propagation.js +125 -0
  53. package/lib/src/metadata-builder/builders/global-styles-builder.js +16 -0
  54. package/lib/src/metadata-builder/builders/section-builders/about-section-builder.js +3 -2
  55. package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.js +3 -2
  56. package/lib/src/metadata-builder/builders/section-builders/booking-section-builder.js +3 -2
  57. package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.js +4 -3
  58. package/lib/src/metadata-builder/builders/section-builders/images-section-builder.js +3 -2
  59. package/lib/src/metadata-builder/builders/section-builders/index.d.ts +1 -0
  60. package/lib/src/metadata-builder/builders/section-builders/index.js +1 -0
  61. package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.js +2 -1
  62. package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.js +2 -1
  63. package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.js +4 -3
  64. package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.js +3 -2
  65. package/lib/src/metadata-builder/builders/section-builders/support-me-builder.d.ts +8 -0
  66. package/lib/src/metadata-builder/builders/section-builders/support-me-builder.js +25 -0
  67. package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.js +2 -1
  68. package/lib/src/metadata-builder/builders/section-builders/text-section-builder.js +16 -17
  69. package/lib/src/metadata-builder/builders/section-field-maps.js +15 -0
  70. package/lib/src/metadata-builder/builders/section-field-utils.d.ts +6 -1
  71. package/lib/src/metadata-builder/builders/section-field-utils.js +48 -12
  72. package/lib/src/metadata-builder/builders/section-rules/support-me.rules.d.ts +2 -0
  73. package/lib/src/metadata-builder/builders/section-rules/support-me.rules.js +17 -0
  74. package/lib/src/metadata-builder/builders/update-content-text-builder.d.ts +17 -0
  75. package/lib/src/metadata-builder/builders/update-content-text-builder.js +103 -0
  76. package/lib/src/metadata-builder/builders/update-content-text-style-builder.d.ts +16 -0
  77. package/lib/src/metadata-builder/builders/update-content-text-style-builder.js +216 -0
  78. package/lib/src/metadata-builder/helpers/rte.helpers.d.ts +13 -11
  79. package/lib/src/metadata-builder/helpers/rte.helpers.js +73 -14
  80. package/lib/src/metadata-builder/metadata-executor.js +7 -1
  81. package/lib/src/metadata-builder/models.d.ts +4 -0
  82. package/lib/src/metadata-builder/models.js +4 -0
  83. package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +20 -0
  84. package/lib/src/metadata-builder/parsers/ai-toolcall-parser.js +8 -0
  85. package/lib/src/metadata-builder/parsers/section-tool-arguments.d.ts +14 -2
  86. package/lib/src/metadata-builder/sanitizers/rte-schema-check.d.ts +8 -7
  87. package/lib/src/metadata-builder/sanitizers/rte-schema-check.js +52 -21
  88. package/lib/src/shared/content-settings/components/GenericTextInput.mixin.js +1 -14
  89. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.js +3 -12
  90. package/lib/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.mixin.d.ts +2 -3
  91. package/lib/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.mixin.js +3 -10
  92. package/lib/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.d.ts +1 -2
  93. package/lib/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.js +1 -4
  94. package/lib/src/utils/minify-brand-page-metadata.js +8 -4
  95. package/package.json +15 -17
  96. package/src/brand-page/components/contact-form/ContactForm.mixin.ts +2 -5
  97. package/src/brand-page/components/text-wrapper/TextWrapper.vue +6 -17
  98. package/src/brand-page/models/index.ts +26 -35
  99. package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -3
  100. package/src/brand-page/utils/migration.util.ts +0 -12
  101. package/src/brand-page/utils/style.util.test.ts +0 -51
  102. package/src/brand-page/utils/text.util.ts +4 -43
  103. package/src/brand-page/utils/vcard.util.ts +4 -6
  104. package/src/brand-page/utils/view-model.util.ts +26 -94
  105. package/src/brand-page/view-models.ts +2 -3
  106. package/src/brand-page-maker/components/ai-website-builder/AiWebsiteBuilder.vue +1 -1
  107. package/src/brand-page-maker/components/rich-text-editor/RichTextEditor.vue +3 -4
  108. package/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.ts +1 -0
  109. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +7 -3
  110. package/src/brand-page-maker/composables/rich-text-editor/bubbleMenu.ts +10 -6
  111. package/src/brand-page-maker/composables/rich-text-editor/extensions/FontSize.ts +73 -0
  112. package/src/brand-page-maker/composables/rich-text-editor/extensions/LineHeight.ts +85 -0
  113. package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.ts +111 -27
  114. package/src/brand-page-maker/utils/index.ts +0 -2
  115. package/src/brand-page-maker/utils/rich-text-editor.util.test.ts +3 -37
  116. package/src/brand-page-maker/utils/rich-text-editor.util.ts +11 -66
  117. package/src/brand-page-maker/validators/field.validator.ts +2 -10
  118. package/src/clients/ai-assistant-client.ts +1 -0
  119. package/src/lib.ts +0 -9
  120. package/src/metadata-builder/ai-metadata-executor.ts +26 -0
  121. package/src/metadata-builder/builders/global-font-propagation.test.ts +269 -0
  122. package/src/metadata-builder/builders/global-font-propagation.ts +205 -0
  123. package/src/metadata-builder/builders/global-styles-builder.ts +21 -0
  124. package/src/metadata-builder/builders/section-builders/about-section-builder.ts +3 -2
  125. package/src/metadata-builder/builders/section-builders/banner-section-builder.ts +3 -2
  126. package/src/metadata-builder/builders/section-builders/booking-section-builder.ts +5 -2
  127. package/src/metadata-builder/builders/section-builders/contact-form-builder.ts +4 -3
  128. package/src/metadata-builder/builders/section-builders/images-section-builder.ts +3 -2
  129. package/src/metadata-builder/builders/section-builders/index.ts +1 -0
  130. package/src/metadata-builder/builders/section-builders/mailing-list-builder.ts +2 -1
  131. package/src/metadata-builder/builders/section-builders/mailing-list-section-builder.ts +2 -1
  132. package/src/metadata-builder/builders/section-builders/profile-section-builder.ts +6 -3
  133. package/src/metadata-builder/builders/section-builders/shapes-section-builder.ts +3 -2
  134. package/src/metadata-builder/builders/section-builders/support-me-builder.test.ts +177 -0
  135. package/src/metadata-builder/builders/section-builders/support-me-builder.ts +43 -0
  136. package/src/metadata-builder/builders/section-builders/testimonial-section-builder.ts +2 -1
  137. package/src/metadata-builder/builders/section-builders/text-section-builder.ts +18 -21
  138. package/src/metadata-builder/builders/section-field-maps.ts +18 -0
  139. package/src/metadata-builder/builders/section-field-utils.test.ts +83 -0
  140. package/src/metadata-builder/builders/section-field-utils.ts +69 -18
  141. package/src/metadata-builder/builders/section-rules/support-me.rules.ts +39 -0
  142. package/src/metadata-builder/builders/update-content-text-builder.ts +148 -0
  143. package/src/metadata-builder/builders/update-content-text-style-builder.ts +352 -0
  144. package/src/metadata-builder/helpers/rte.helpers.ts +101 -15
  145. package/src/metadata-builder/metadata-executor.ts +8 -0
  146. package/src/metadata-builder/models.ts +5 -0
  147. package/src/metadata-builder/parsers/ai-toolcall-parser.ts +31 -0
  148. package/src/metadata-builder/parsers/section-tool-arguments.ts +14 -1
  149. package/src/metadata-builder/sanitizers/rte-schema-check.ts +53 -24
  150. package/src/shared/content-settings/components/GenericTextInput.mixin.ts +1 -17
  151. package/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.ts +3 -16
  152. package/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.mixin.ts +4 -13
  153. package/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.vue +4 -6
  154. package/src/shared/content-settings/components/text-image-field/TextImageField.vue +3 -6
  155. package/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.ts +1 -6
  156. package/src/shared/content-settings/components/text-items-field/TextItemsField.vue +1 -1
  157. package/src/utils/minify-brand-page-metadata.test.ts +61 -0
  158. package/src/utils/minify-brand-page-metadata.ts +9 -4
  159. package/lib/src/brand-page/utils/migration/migration-20.d.ts +0 -2
  160. package/lib/src/brand-page/utils/migration/migration-20.js +0 -66
  161. package/lib/src/brand-page-maker/__fixtures__/complex-rte.fixture.d.ts +0 -22
  162. package/lib/src/brand-page-maker/__fixtures__/complex-rte.fixture.js +0 -22
  163. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.d.ts +0 -14
  164. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.js +0 -39
  165. package/lib/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.d.ts +0 -28
  166. package/lib/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.js +0 -90
  167. package/lib/src/brand-page-maker/utils/rte-render.util.d.ts +0 -63
  168. package/lib/src/brand-page-maker/utils/rte-render.util.js +0 -95
  169. package/lib/src/brand-page-maker/utils/rte-sanitize.util.d.ts +0 -6
  170. package/lib/src/brand-page-maker/utils/rte-sanitize.util.js +0 -158
  171. package/src/brand-page/utils/migration/migration-20.server.test.ts +0 -125
  172. package/src/brand-page/utils/migration/migration-20.test.ts +0 -72
  173. package/src/brand-page/utils/migration/migration-20.ts +0 -87
  174. package/src/brand-page/utils/text.util.test.ts +0 -47
  175. package/src/brand-page/utils/view-model.pageid-rte.test.ts +0 -104
  176. package/src/brand-page-maker/__fixtures__/complex-rte.fixture.ts +0 -23
  177. package/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.test.ts +0 -52
  178. package/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.ts +0 -42
  179. package/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.ts +0 -137
  180. package/src/brand-page-maker/utils/__snapshots__/rte-render-parity.test.ts.snap +0 -202
  181. package/src/brand-page-maker/utils/rte-features.test.ts +0 -351
  182. package/src/brand-page-maker/utils/rte-render-parity.test.ts +0 -157
  183. package/src/brand-page-maker/utils/rte-render.util.ts +0 -165
  184. package/src/brand-page-maker/utils/rte-sanitize-json.test.ts +0 -158
  185. package/src/brand-page-maker/utils/rte-sanitize.util.ts +0 -195
  186. package/src/brand-page-maker/validators/field.validator.test.ts +0 -55
@@ -1,202 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`BP-5787 RTE render parity (golden master) > T1 — editor renders the complex fixture to the frozen HTML baseline > editor-normalized-html 1`] = `"<h2 style="text-align: center;"><span style="color: var(--logo-text-color);">Themed heading</span></h2><p><strong>bold</strong> <em>italic</em> <u>underline</u> <s>strike</s> <span style="font-family: Montserrat; font-size: 1.5em; letter-spacing: 0.05em; line-height: 1.4;">styled span</span> <mark data-color="#ffe08a" style="background-color: rgb(255, 224, 138); color: inherit;">highlight</mark> <span style="color: rgb(255, 0, 0);">literal hex</span> <a href="/about" target="_self">internal link</a> <a href="https://example.com" target="_blank" rel="noopener noreferrer nofollow">external link</a></p><p style="text-align: right;">second paragraph, right-aligned</p>"`;
4
-
5
- exports[`BP-5787 RTE render parity (golden master) > T1 — render-from-JSON (DOM-less renderer) produces equivalent HTML > serializer-html 1`] = `"<h2 style="text-align: center"><span style="color: var(--logo-text-color)">Themed heading</span></h2><p><strong>bold</strong> <em>italic</em> <u>underline</u> <s>strike</s> <span style="font-family: Montserrat; font-size: 1.5em; letter-spacing: 0.05em; line-height: 1.4">styled span</span> <mark data-color="#ffe08a" style="background-color: #ffe08a; color: inherit">highlight</mark> <span style="color: #FF0000">literal hex</span> <a href="/about" target="_self">internal link</a> <a href="https://example.com" target="_blank" rel="noopener noreferrer nofollow">external link</a></p><p style="text-align: right">second paragraph, right-aligned</p>"`;
6
-
7
- exports[`BP-5787 RTE render parity (golden master) > T6 — freezes the JSON shape that becomes the stored form > editor-json 1`] = `
8
- {
9
- "content": [
10
- {
11
- "attrs": {
12
- "level": 2,
13
- "textAlign": "center",
14
- },
15
- "content": [
16
- {
17
- "marks": [
18
- {
19
- "attrs": {
20
- "color": "var(--logo-text-color)",
21
- "fontFamily": "",
22
- "fontSize": "",
23
- "letterSpacing": "",
24
- "lineHeight": "",
25
- },
26
- "type": "textStyle",
27
- },
28
- ],
29
- "text": "Themed heading",
30
- "type": "text",
31
- },
32
- ],
33
- "type": "heading",
34
- },
35
- {
36
- "attrs": {
37
- "textAlign": null,
38
- },
39
- "content": [
40
- {
41
- "marks": [
42
- {
43
- "type": "bold",
44
- },
45
- ],
46
- "text": "bold",
47
- "type": "text",
48
- },
49
- {
50
- "text": " ",
51
- "type": "text",
52
- },
53
- {
54
- "marks": [
55
- {
56
- "type": "italic",
57
- },
58
- ],
59
- "text": "italic",
60
- "type": "text",
61
- },
62
- {
63
- "text": " ",
64
- "type": "text",
65
- },
66
- {
67
- "marks": [
68
- {
69
- "type": "underline",
70
- },
71
- ],
72
- "text": "underline",
73
- "type": "text",
74
- },
75
- {
76
- "text": " ",
77
- "type": "text",
78
- },
79
- {
80
- "marks": [
81
- {
82
- "type": "strike",
83
- },
84
- ],
85
- "text": "strike",
86
- "type": "text",
87
- },
88
- {
89
- "text": " ",
90
- "type": "text",
91
- },
92
- {
93
- "marks": [
94
- {
95
- "attrs": {
96
- "color": "",
97
- "fontFamily": "Montserrat",
98
- "fontSize": "1.5em",
99
- "letterSpacing": "0.05em",
100
- "lineHeight": "1.4",
101
- },
102
- "type": "textStyle",
103
- },
104
- ],
105
- "text": "styled span",
106
- "type": "text",
107
- },
108
- {
109
- "text": " ",
110
- "type": "text",
111
- },
112
- {
113
- "marks": [
114
- {
115
- "attrs": {
116
- "color": "#ffe08a",
117
- },
118
- "type": "highlight",
119
- },
120
- ],
121
- "text": "highlight",
122
- "type": "text",
123
- },
124
- {
125
- "text": " ",
126
- "type": "text",
127
- },
128
- {
129
- "marks": [
130
- {
131
- "attrs": {
132
- "color": "#FF0000",
133
- "fontFamily": "",
134
- "fontSize": "",
135
- "letterSpacing": "",
136
- "lineHeight": "",
137
- },
138
- "type": "textStyle",
139
- },
140
- ],
141
- "text": "literal hex",
142
- "type": "text",
143
- },
144
- {
145
- "text": " ",
146
- "type": "text",
147
- },
148
- {
149
- "marks": [
150
- {
151
- "attrs": {
152
- "class": null,
153
- "href": "/about",
154
- "rel": null,
155
- "target": "_self",
156
- "title": null,
157
- },
158
- "type": "link",
159
- },
160
- ],
161
- "text": "internal link",
162
- "type": "text",
163
- },
164
- {
165
- "text": " ",
166
- "type": "text",
167
- },
168
- {
169
- "marks": [
170
- {
171
- "attrs": {
172
- "class": null,
173
- "href": "https://example.com",
174
- "rel": "noopener noreferrer nofollow",
175
- "target": "_blank",
176
- "title": null,
177
- },
178
- "type": "link",
179
- },
180
- ],
181
- "text": "external link",
182
- "type": "text",
183
- },
184
- ],
185
- "type": "paragraph",
186
- },
187
- {
188
- "attrs": {
189
- "textAlign": "right",
190
- },
191
- "content": [
192
- {
193
- "text": "second paragraph, right-aligned",
194
- "type": "text",
195
- },
196
- ],
197
- "type": "paragraph",
198
- },
199
- ],
200
- "type": "doc",
201
- }
202
- `;
@@ -1,351 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import { Editor } from '@tiptap/vue-3';
3
- import { getRteExtensions } from '../composables/rich-text-editor/getRteExtensions';
4
- import { toRteJson, renderRteToHtml } from './rte-render.util';
5
- import { sanitizeRteJson } from './rte-sanitize.util';
6
-
7
- /**
8
- * BP-5787 — feature-by-feature coverage of the whole RTE JSON pipeline.
9
- *
10
- * Each case runs a piece of authored HTML through the exact production path:
11
- * HTML → toRteJson (headless editor parse) → sanitizeRteJson → renderRteToHtml
12
- * (DOM-less serialiser)
13
- * and asserts the feature survives end-to-end. One combined golden-master lives
14
- * in rte-render-parity.test.ts; this file isolates every feature so a
15
- * regression in any single one (a mark, a textStyle attr, a link, alignment, a
16
- * block node) fails on its own line instead of inside one opaque snapshot.
17
- */
18
- const pipe = (html: string): string => {
19
- const json = toRteJson(html);
20
-
21
- return renderRteToHtml(sanitizeRteJson(json));
22
- };
23
-
24
- describe('RTE features — inline marks', () => {
25
- it('bold → <strong>', () => {
26
- expect(pipe('<p><strong>x</strong></p>')).toContain('<strong>x</strong>');
27
- });
28
- it('italic → <em>', () => {
29
- expect(pipe('<p><em>x</em></p>')).toContain('<em>x</em>');
30
- });
31
- it('underline → <u>', () => {
32
- expect(pipe('<p><u>x</u></p>')).toContain('<u>x</u>');
33
- });
34
- it('strikethrough → <s>', () => {
35
- expect(pipe('<p><s>x</s></p>')).toContain('<s>x</s>');
36
- });
37
- it('inline code → <code>', () => {
38
- expect(pipe('<p><code>x</code></p>')).toContain('<code>x</code>');
39
- });
40
- });
41
-
42
- describe('RTE features — mark nesting (decoration must inherit font-size)', () => {
43
- // BP-5787 regression: the textStyle <span> that carries font-size must render
44
- // OUTSIDE <u>/<s>, so the decoration marks inherit the applied size. Otherwise
45
- // text-decoration thickness AND vertical position are computed from the base
46
- // paragraph font, giving thin, mis-centred lines on large text (v3 default
47
- // priority regression vs v2). Guarded by TextStyle priority: 99.
48
- it('font-size <span> wraps <u> (not the reverse)', () => {
49
- const out = pipe('<p><span style="font-size: 40px"><u>x</u></span></p>');
50
-
51
- expect(out).toContain('<span style="font-size: 40px"><u>x</u></span>');
52
- expect(out).not.toMatch(/<u><span/);
53
- });
54
-
55
- it('font-size <span> wraps <s> (not the reverse)', () => {
56
- const out = pipe('<p><span style="font-size: 40px"><s>x</s></span></p>');
57
-
58
- expect(out).toContain('<span style="font-size: 40px"><s>x</s></span>');
59
- expect(out).not.toMatch(/<s><span/);
60
- });
61
- });
62
-
63
- describe('RTE features — textStyle attrs (colour/font/spacing)', () => {
64
- it('rgb colour is preserved', () => {
65
- expect(
66
- pipe('<p><span style="color: rgb(255, 0, 0)">x</span></p>'),
67
- ).toContain('color: rgb(255, 0, 0)');
68
- });
69
-
70
- it('hex colour is preserved verbatim (Tiptap v3 no longer normalises to rgb)', () => {
71
- expect(pipe('<p><span style="color: #00ff00">x</span></p>')).toContain(
72
- 'color: #00ff00',
73
- );
74
- });
75
-
76
- it('theme token var(--…) colour survives verbatim (NOT flattened to rgb)', () => {
77
- const out = pipe(
78
- '<p><span style="color: var(--logo-text-color)">x</span></p>',
79
- );
80
-
81
- expect(out).toContain('color: var(--logo-text-color)');
82
- expect(out).not.toContain('rgb(');
83
- });
84
-
85
- it('single-word font-family is preserved', () => {
86
- expect(
87
- pipe('<p><span style="font-family: Montserrat">x</span></p>'),
88
- ).toContain('font-family: Montserrat');
89
- });
90
-
91
- it('multi-word font-family is preserved UNQUOTED (BP-5787 quote-strip)', () => {
92
- const out = pipe('<p><span style="font-family: Open Sans">x</span></p>');
93
-
94
- expect(out).toContain('font-family: Open Sans');
95
- // must not carry the CSS quotes that the sanitiser would otherwise drop
96
- expect(out).not.toContain('font-family: "Open Sans"');
97
- expect(out).not.toContain('&quot;');
98
- });
99
-
100
- it('font-size / letter-spacing / line-height are preserved', () => {
101
- expect(pipe('<p><span style="font-size: 2em">x</span></p>')).toContain(
102
- 'font-size: 2em',
103
- );
104
- expect(
105
- pipe('<p><span style="letter-spacing: 0.1em">x</span></p>'),
106
- ).toContain('letter-spacing: 0.1em');
107
- expect(pipe('<p><span style="line-height: 1.5">x</span></p>')).toContain(
108
- 'line-height: 1.5',
109
- );
110
- });
111
- });
112
-
113
- describe('RTE features — background colour (highlight)', () => {
114
- it('highlight → <mark> with data-color + background-color + color:inherit', () => {
115
- const out = pipe(
116
- '<p><mark data-color="#ffe08a" style="background-color: #ffe08a">x</mark></p>',
117
- );
118
-
119
- expect(out).toContain(
120
- '<mark data-color="#ffe08a" style="background-color: #ffe08a; color: inherit">x</mark>',
121
- );
122
- });
123
-
124
- it('theme token background colour survives verbatim', () => {
125
- const out = pipe(
126
- '<p><mark data-color="var(--logo-primary-color)" style="background-color: var(--logo-primary-color)">x</mark></p>',
127
- );
128
-
129
- expect(out).toContain('background-color: var(--logo-primary-color)');
130
- });
131
- });
132
-
133
- describe('RTE features — hyperlinks', () => {
134
- it('external link keeps href + target + rel', () => {
135
- const out = pipe(
136
- '<p><a target="_blank" rel="noopener noreferrer" href="https://example.com">x</a></p>',
137
- );
138
-
139
- expect(out).toContain('href="https://example.com"');
140
- expect(out).toContain('target="_blank"');
141
- expect(out).toContain('rel="noopener noreferrer"');
142
- });
143
-
144
- it('internal relative link keeps its href', () => {
145
- expect(pipe('<p><a href="/about">x</a></p>')).toContain('href="/about"');
146
- });
147
-
148
- it('internal page reference (pageid:) survives the sanitiser', () => {
149
- // pageid: hrefs are resolved to real routes later in the view-model
150
- // transform; the sanitiser must not strip them.
151
- expect(pipe('<p><a href="pageid:abc-123">x</a></p>')).toContain(
152
- 'href="pageid:abc-123"',
153
- );
154
- });
155
-
156
- it('javascript: link is dropped (mark removed, text kept)', () => {
157
- const out = pipe('<p><a href="javascript:alert(1)">x</a></p>');
158
-
159
- expect(out).not.toContain('<a');
160
- expect(out).not.toContain('javascript:');
161
- expect(out).toContain('x');
162
- });
163
-
164
- it('data: link is dropped', () => {
165
- const out = pipe(
166
- '<p><a href="data:text/html,<script>1</script>">x</a></p>',
167
- );
168
-
169
- expect(out).not.toContain('<a');
170
- expect(out).not.toContain('data:');
171
- });
172
- });
173
-
174
- describe('RTE features — text alignment', () => {
175
- for (const align of ['center', 'right', 'justify', 'left'] as const) {
176
- it(`paragraph text-align: ${align}`, () => {
177
- expect(pipe(`<p style="text-align: ${align}">x</p>`)).toContain(
178
- `<p style="text-align: ${align}">`,
179
- );
180
- });
181
- }
182
-
183
- it('heading carries its alignment', () => {
184
- expect(pipe('<h2 style="text-align: center">x</h2>')).toContain(
185
- '<h2 style="text-align: center">',
186
- );
187
- });
188
- });
189
-
190
- describe('RTE features — block nodes', () => {
191
- it('headings h1–h6', () => {
192
- for (const level of [1, 2, 3, 4, 5, 6]) {
193
- expect(pipe(`<h${level}>x</h${level}>`)).toContain(`<h${level}`);
194
- expect(pipe(`<h${level}>x</h${level}>`)).toContain(`</h${level}>`);
195
- }
196
- });
197
-
198
- it('bullet list → <ul><li>', () => {
199
- const out = pipe('<ul><li>a</li><li>b</li></ul>');
200
-
201
- expect(out).toContain('<ul>');
202
- expect(out).toContain('<li>');
203
- expect(out).toContain('a');
204
- expect(out).toContain('b');
205
- });
206
-
207
- it('ordered list → <ol><li>', () => {
208
- expect(pipe('<ol><li>a</li></ol>')).toContain('<ol>');
209
- });
210
-
211
- it('blockquote → <blockquote>', () => {
212
- expect(pipe('<blockquote><p>q</p></blockquote>')).toContain('<blockquote>');
213
- });
214
-
215
- it('code block → <pre><code>', () => {
216
- expect(pipe('<pre><code>c</code></pre>')).toContain('<pre><code>');
217
- });
218
-
219
- it('hard break → <br/>', () => {
220
- expect(pipe('<p>a<br>b</p>')).toContain('<br/>');
221
- });
222
-
223
- it('horizontal rule → <hr/>', () => {
224
- expect(pipe('<p>a</p><hr><p>b</p>')).toContain('<hr/>');
225
- });
226
- });
227
-
228
- describe('RTE features — combinations & escaping', () => {
229
- it('nested marks (colour + bold + italic) all survive on the same run', () => {
230
- const out = pipe(
231
- '<p><span style="color: rgb(1, 2, 3)"><strong><em>x</em></strong></span></p>',
232
- );
233
-
234
- expect(out).toContain('color: rgb(1, 2, 3)');
235
- expect(out).toContain('<strong>');
236
- expect(out).toContain('<em>');
237
- });
238
-
239
- it('a styled hyperlink keeps both the colour and the link', () => {
240
- const out = pipe(
241
- '<p><a href="https://x.com"><span style="color: rgb(0, 151, 215)">x</span></a></p>',
242
- );
243
-
244
- expect(out).toContain('href="https://x.com"');
245
- expect(out).toContain('color: rgb(0, 151, 215)');
246
- });
247
-
248
- it('HTML-special characters in text are escaped', () => {
249
- const out = pipe('<p>a &lt;b&gt; &amp; "c"</p>');
250
-
251
- expect(out).toContain('&lt;b&gt;');
252
- expect(out).toContain('&amp;');
253
- expect(out).not.toContain('<b>');
254
- });
255
-
256
- it('serialisation is idempotent (serialize(json) === serialize(reparse))', () => {
257
- const html =
258
- '<h2 style="text-align: center"><span style="color: var(--logo-text-color); font-family: Open Sans; font-size: 1.5em">Heading</span></h2>' +
259
- '<p><strong>bold</strong> <em>italic</em> <u>u</u> <s>s</s> ' +
260
- '<mark data-color="#ffe08a" style="background-color: #ffe08a">hl</mark> ' +
261
- '<a target="_blank" rel="noopener noreferrer" href="https://x.com">link</a></p>';
262
- const once = pipe(html);
263
- const twice = renderRteToHtml(sanitizeRteJson(toRteJson(once)));
264
-
265
- expect(twice).toEqual(once);
266
- });
267
- });
268
-
269
- describe('RTE features — maker toolbar commands (emit path)', () => {
270
- let editors: Editor[] = [];
271
-
272
- afterEach(() => {
273
- editors.forEach((e) => e.destroy());
274
- editors = [];
275
- });
276
-
277
- // Apply a real editor command to a full selection (as the toolbar does),
278
- // then run the emitted JSON through sanitise + serialise.
279
- const applied = (fn: (e: Editor) => void): string => {
280
- const editor = new Editor({
281
- extensions: getRteExtensions({ restrictStarterKit: true }),
282
- });
283
-
284
- editors.push(editor);
285
- editor.commands.setContent('<p>styled text</p>');
286
- editor.commands.selectAll();
287
- fn(editor);
288
-
289
- return renderRteToHtml(sanitizeRteJson(editor.getJSON()));
290
- };
291
-
292
- it('setColor', () => {
293
- expect(applied((e) => e.commands.setColor('rgb(255, 0, 0)'))).toContain(
294
- 'color: rgb(255, 0, 0)',
295
- );
296
- });
297
-
298
- it('setHighlight (background colour)', () => {
299
- const out = applied((e) => e.commands.setHighlight({ color: '#ffe08a' }));
300
-
301
- expect(out).toContain('background-color: #ffe08a');
302
- expect(out).toContain('<mark');
303
- });
304
-
305
- it('toggleBold / toggleItalic / toggleUnderline / toggleStrike', () => {
306
- expect(applied((e) => e.commands.toggleBold())).toContain('<strong>');
307
- expect(applied((e) => e.commands.toggleItalic())).toContain('<em>');
308
- expect(applied((e) => e.commands.toggleUnderline())).toContain('<u>');
309
- expect(applied((e) => e.commands.toggleStrike())).toContain('<s>');
310
- });
311
-
312
- it('setFontFamily (multi-word, unquoted)', () => {
313
- const out = applied((e) =>
314
- (e.commands as { setFontFamily: (f: string) => boolean }).setFontFamily(
315
- 'Open Sans',
316
- ),
317
- );
318
-
319
- expect(out).toContain('font-family: Open Sans');
320
- expect(out).not.toContain('&quot;');
321
- });
322
-
323
- it('setFontSize / setLetterSpacing', () => {
324
- expect(
325
- applied((e) =>
326
- (e.commands as { setFontSize: (v: string) => boolean }).setFontSize(
327
- '2em',
328
- ),
329
- ),
330
- ).toContain('font-size: 2em');
331
- expect(
332
- applied((e) =>
333
- (
334
- e.commands as { setLetterSpacing: (v: string) => boolean }
335
- ).setLetterSpacing('0.1em'),
336
- ),
337
- ).toContain('letter-spacing: 0.1em');
338
- });
339
-
340
- it('setTextAlign', () => {
341
- expect(applied((e) => e.commands.setTextAlign('center'))).toContain(
342
- 'text-align: center',
343
- );
344
- });
345
-
346
- it('setLink keeps the href through the pipeline', () => {
347
- expect(
348
- applied((e) => e.commands.setLink({ href: 'https://x.com' })),
349
- ).toContain('href="https://x.com"');
350
- });
351
- });