@designcrowd/library.brand-page 6.2.11 → 6.2.12-hotfix-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 (576) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-DDcraD5S.js → CreatedOnBrandCrowd-de-de-nqUI_I7F.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-DtOeaisf.js → CreatedOnBrandCrowd-en-us-DDCeJcXJ.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-BZpmJPew.js → CreatedOnBrandCrowd-es-es-CBlWis_j.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-CqRwC4e7.js → CreatedOnBrandCrowd-fr-ca-C-rbGdQp.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-CqRwC4e7.js → CreatedOnBrandCrowd-fr-fr-C-rbGdQp.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-DId9Dfjh.js → CreatedOnBrandCrowd-pt-br-D00mZacJ.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-DId9Dfjh.js → CreatedOnBrandCrowd-pt-pt-D00mZacJ.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-BTDfmOcm.js → CreatedOnDcom-de-de-CAfeCnEI.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-CeAu9Ayx.js → CreatedOnDcom-en-us-C6Lw_Ed_.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-WCv0K41H.js → CreatedOnDcom-es-es-DwqQcQIa.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-BlfevQDY.js → CreatedOnDcom-fr-ca-CE1qJVaq.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-Cvt7MHPZ.js → CreatedOnDcom-fr-fr-C5UuVJcg.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-DipZuylv.js → CreatedOnDcom-pt-br-C3ik2mkT.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-BCw4lcKN.js → CreatedOnDcom-pt-pt-CFhxxKq7.js} +1 -1
  15. package/lib/src/brand-page/__fixtures__/production-text-style-resolver.fixture.d.ts +16 -0
  16. package/lib/src/brand-page/__fixtures__/production-text-style-resolver.fixture.js +35 -0
  17. package/lib/src/brand-page/components/contact-form/ContactForm.mixin.d.ts +3 -0
  18. package/lib/src/brand-page/components/contact-form/ContactForm.mixin.js +19 -13
  19. package/lib/src/brand-page/components/mailing-list/MailingList.mixin.d.ts +3 -1
  20. package/lib/src/brand-page/components/mailing-list/MailingList.mixin.js +17 -2
  21. package/lib/src/brand-page/components/navigation/button-carousel/ButtonCarouselNavigation.mixin.d.ts +11 -3
  22. package/lib/src/brand-page/components/navigation/button-carousel/ButtonCarouselNavigation.mixin.js +35 -1
  23. package/lib/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.mixin.d.ts +8 -2
  24. package/lib/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.mixin.js +27 -3
  25. package/lib/src/brand-page/components/page/Page.mixin.d.ts +5 -2
  26. package/lib/src/brand-page/components/page/Page.mixin.js +33 -27
  27. package/lib/src/brand-page/components/page-footer/PageFooter.mixin.d.ts +7 -2
  28. package/lib/src/brand-page/components/page-footer/PageFooter.mixin.js +21 -1
  29. package/lib/src/brand-page/components/payment/Payment.mixin.d.ts +5 -2
  30. package/lib/src/brand-page/components/payment/Payment.mixin.js +22 -2
  31. package/lib/src/brand-page/components/payment/support-me/SupportMe.mixin.d.ts +6 -2
  32. package/lib/src/brand-page/components/payment/support-me/SupportMe.mixin.js +32 -1
  33. package/lib/src/brand-page/components/social-links/SocialLinks.stories.js +0 -3
  34. package/lib/src/brand-page/components/testimonial-section/__fixtures__/data.js +0 -3
  35. package/lib/src/brand-page/components/text/Text.stories.js +0 -17
  36. package/lib/src/brand-page/constants/font.constants.d.ts +62 -0
  37. package/lib/src/brand-page/constants/font.constants.js +35 -0
  38. package/lib/src/brand-page/models/index.d.ts +23 -24
  39. package/lib/src/brand-page/models/index.js +20 -7
  40. package/lib/src/brand-page/models/navigation-styles.model.d.ts +1 -1
  41. package/lib/src/brand-page/models/navigation-styles.model.js +17 -8
  42. package/lib/src/brand-page/models/payment.model.d.ts +11 -6
  43. package/lib/src/brand-page/models/styles.model.d.ts +53 -7
  44. package/lib/src/brand-page/models/styles.model.js +115 -27
  45. package/lib/src/brand-page/utils/color-palette.util.d.ts +43 -23
  46. package/lib/src/brand-page/utils/color-palette.util.js +65 -27
  47. package/lib/src/brand-page/utils/color.util.d.ts +13 -9
  48. package/lib/src/brand-page/utils/color.util.js +56 -15
  49. package/lib/src/brand-page/utils/container-text-color.util.d.ts +56 -13
  50. package/lib/src/brand-page/utils/container-text-color.util.js +321 -41
  51. package/lib/src/brand-page/utils/index.d.ts +1 -0
  52. package/lib/src/brand-page/utils/index.js +1 -0
  53. package/lib/src/brand-page/utils/migration/migration-20.js +6 -2
  54. package/lib/src/brand-page/utils/migration/migration-21.js +34 -6
  55. package/lib/src/brand-page/utils/migration/migration-22.d.ts +100 -0
  56. package/lib/src/brand-page/utils/migration/migration-22.js +914 -0
  57. package/lib/src/brand-page/utils/migration.util.js +17 -0
  58. package/lib/src/brand-page/utils/model.util.d.ts +4 -0
  59. package/lib/src/brand-page/utils/model.util.js +4 -0
  60. package/lib/src/brand-page/utils/personalisation.util.js +9 -1
  61. package/lib/src/brand-page/utils/rte-role-lift.util.d.ts +72 -0
  62. package/lib/src/brand-page/utils/rte-role-lift.util.js +275 -0
  63. package/lib/src/brand-page/utils/style.util.d.ts +5 -1
  64. package/lib/src/brand-page/utils/style.util.js +34 -11
  65. package/lib/src/brand-page/utils/text-role-css.util.d.ts +19 -0
  66. package/lib/src/brand-page/utils/text-role-css.util.js +186 -0
  67. package/lib/src/brand-page/utils/text-role-reconnect.util.d.ts +90 -0
  68. package/lib/src/brand-page/utils/text-role-reconnect.util.js +434 -0
  69. package/lib/src/brand-page/utils/text-style.util.d.ts +53 -23
  70. package/lib/src/brand-page/utils/text-style.util.js +122 -22
  71. package/lib/src/brand-page/utils/view-model.util.d.ts +9 -1
  72. package/lib/src/brand-page/utils/view-model.util.js +124 -111
  73. package/lib/src/brand-page/view-models.d.ts +1 -0
  74. package/lib/src/brand-page-maker/components/action-bar/ActionBar.mixin.d.ts +4 -1
  75. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +13 -2
  76. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +4 -4
  77. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMakerTemplateSettings.mixin.d.ts +4 -1
  78. package/lib/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.js +0 -10
  79. package/lib/src/brand-page-maker/components/brand-page-maker/__fixtures__/content-settings-items.fixture.js +0 -1
  80. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +23 -138
  81. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.js +0 -28
  82. package/lib/src/brand-page-maker/components/brandpage-settings/ReplaceImageSettingsForBrandPageSettings.mixin.d.ts +4 -1
  83. package/lib/src/brand-page-maker/components/navigation/Navigation.mixin.d.ts +1 -1
  84. package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +5 -2
  85. package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +4 -1
  86. package/lib/src/brand-page-maker/components/social-share/SocialShare.mixin.d.ts +4 -1
  87. package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +4 -1
  88. package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.d.ts +1 -0
  89. package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.js +1 -0
  90. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +1 -0
  91. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/RoleTypographyFill.d.ts +16 -0
  92. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/RoleTypographyFill.js +61 -0
  93. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/RteClipboard.d.ts +11 -0
  94. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/RteClipboard.js +236 -0
  95. package/lib/src/brand-page-maker/composables/rich-text-editor/font.d.ts +2 -1
  96. package/lib/src/brand-page-maker/composables/rich-text-editor/font.js +25 -6
  97. package/lib/src/brand-page-maker/composables/rich-text-editor/formatting.d.ts +17 -4
  98. package/lib/src/brand-page-maker/composables/rich-text-editor/formatting.js +204 -17
  99. package/lib/src/brand-page-maker/composables/rich-text-editor/hyperlink.d.ts +1 -1
  100. package/lib/src/brand-page-maker/composables/rich-text-editor/hyperlink.js +29 -31
  101. package/lib/src/brand-page-maker/composables/rich-text-editor/keepMarksOnEmpty.d.ts +20 -0
  102. package/lib/src/brand-page-maker/composables/rich-text-editor/keepMarksOnEmpty.js +60 -0
  103. package/lib/src/brand-page-maker/composables/rich-text-editor/spacing.d.ts +2 -1
  104. package/lib/src/brand-page-maker/composables/rich-text-editor/spacing.js +22 -6
  105. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.d.ts +10 -4
  106. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.js +319 -275
  107. package/lib/src/brand-page-maker/constants/config-settings-constant.js +1 -5
  108. package/lib/src/brand-page-maker/convertors/text-css-style-options.convertor.js +6 -2
  109. package/lib/src/brand-page-maker/convertors/text-size-value.convertor.d.ts +1 -1
  110. package/lib/src/brand-page-maker/convertors/text-size-value.convertor.js +3 -1
  111. package/lib/src/brand-page-maker/default-getters/payment-text-and-border-color.default-getter.js +7 -14
  112. package/lib/src/brand-page-maker/default-getters/text-color.default-getter.js +6 -13
  113. package/lib/src/brand-page-maker/models/content-settings.d.ts +8 -0
  114. package/lib/src/brand-page-maker/models/content-settings.js +114 -81
  115. package/lib/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store-utils.d.ts +2 -2
  116. package/lib/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store-utils.js +5 -2
  117. package/lib/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store.js +4 -3
  118. package/lib/src/brand-page-maker/stores/ai-checkpoint/ai-checkpoint-store.d.ts +1257 -117
  119. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.d.ts +6 -1
  120. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +17 -9
  121. package/lib/src/brand-page-maker/stores/history/history-store.d.ts +59 -5
  122. package/lib/src/brand-page-maker/stores/history/history-store.js +22 -2
  123. package/lib/src/brand-page-maker/utils/apply-color-strategy.js +26 -8
  124. package/lib/src/brand-page-maker/utils/index.d.ts +2 -1
  125. package/lib/src/brand-page-maker/utils/index.js +2 -1
  126. package/lib/src/brand-page-maker/utils/rich-text-editor.util.d.ts +117 -15
  127. package/lib/src/brand-page-maker/utils/rich-text-editor.util.js +435 -281
  128. package/lib/src/brand-page-maker/utils/rte-authoring.util.d.ts +4 -0
  129. package/lib/src/brand-page-maker/utils/rte-authoring.util.js +101 -0
  130. package/lib/src/brand-page-maker/utils/rte-clipboard.util.d.ts +126 -0
  131. package/lib/src/brand-page-maker/utils/rte-clipboard.util.js +307 -0
  132. package/lib/src/brand-page-maker/utils/rte-sanitize.util.js +13 -3
  133. package/lib/src/{bundled-translations-zfiA5Tsw.js → bundled-translations-yGrvPE5i.js} +17 -17
  134. package/lib/src/{bundled-translations.de-DE-ChsdSyAP.js → bundled-translations.de-DE-L4Znf8Hs.js} +17 -17
  135. package/lib/src/{bundled-translations.es-ES-DflsWQK0.js → bundled-translations.es-ES-D6iticrK.js} +15 -15
  136. package/lib/src/{bundled-translations.fr-CA-fpDRuZ52.js → bundled-translations.fr-CA-BgAVE-9k.js} +25 -25
  137. package/lib/src/{bundled-translations.fr-FR-Bub73Zt-.js → bundled-translations.fr-FR-B8GbyqxQ.js} +17 -17
  138. package/lib/src/{bundled-translations.pt-BR-BlnWE9TB.js → bundled-translations.pt-BR-DjPU3Db7.js} +25 -25
  139. package/lib/src/{bundled-translations.pt-PT-DmzXlnaS.js → bundled-translations.pt-PT-BaepaDpr.js} +23 -23
  140. package/lib/src/bundles/bundled-translations.de-DE.json +21 -2
  141. package/lib/src/bundles/bundled-translations.es-ES.json +21 -2
  142. package/lib/src/bundles/bundled-translations.fr-CA.json +21 -2
  143. package/lib/src/bundles/bundled-translations.fr-FR.json +21 -2
  144. package/lib/src/bundles/bundled-translations.json +21 -2
  145. package/lib/src/bundles/bundled-translations.pt-BR.json +21 -2
  146. package/lib/src/bundles/bundled-translations.pt-PT.json +21 -2
  147. package/lib/src/clients/ai-assistant-client.d.ts +1 -0
  148. package/lib/src/composables/useTranslate.d.ts +1 -1
  149. package/lib/src/composables/useTranslate.js +1 -1
  150. package/lib/src/css/library.brand-page-brandCrowd.min.css +303 -207
  151. package/lib/src/css/library.brand-page-brandPage.min.css +303 -207
  152. package/lib/src/css/library.brand-page-designCom.min.css +303 -207
  153. package/lib/src/css/library.brand-page-preview.min.css +303 -207
  154. package/lib/src/index.d.ts +2 -1
  155. package/lib/src/index.mjs +195 -191
  156. package/lib/src/{lib-1AqtEmvQ.js → lib-NS94YGdG.js} +36864 -33893
  157. package/lib/src/lib.js +2 -1
  158. package/lib/src/metadata-builder/builders/footer-builder.js +4 -5
  159. package/lib/src/metadata-builder/builders/global-role-propagation.d.ts +58 -0
  160. package/lib/src/metadata-builder/builders/global-role-propagation.js +246 -0
  161. package/lib/src/metadata-builder/builders/global-styles-builder.d.ts +1 -0
  162. package/lib/src/metadata-builder/builders/global-styles-builder.js +116 -45
  163. package/lib/src/metadata-builder/builders/header-builder.js +13 -4
  164. package/lib/src/metadata-builder/builders/section-builders/about-section-builder.js +3 -3
  165. package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.js +3 -3
  166. package/lib/src/metadata-builder/builders/section-builders/booking-section-builder.js +3 -3
  167. package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.js +4 -4
  168. package/lib/src/metadata-builder/builders/section-builders/images-section-builder.js +3 -3
  169. package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.js +2 -2
  170. package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.js +2 -2
  171. package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.js +4 -4
  172. package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.js +3 -3
  173. package/lib/src/metadata-builder/builders/section-builders/social-links-builder.js +8 -2
  174. package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.js +2 -2
  175. package/lib/src/metadata-builder/builders/section-builders/text-section-builder.js +60 -29
  176. package/lib/src/metadata-builder/builders/section-field-maps.js +1 -0
  177. package/lib/src/metadata-builder/builders/section-field-utils.d.ts +48 -19
  178. package/lib/src/metadata-builder/builders/section-field-utils.js +128 -52
  179. package/lib/src/metadata-builder/builders/section-rules/global-styles.rules.d.ts +4 -2
  180. package/lib/src/metadata-builder/builders/section-rules/global-styles.rules.js +28 -12
  181. package/lib/src/metadata-builder/builders/section-rules/social-links.rules.js +5 -1
  182. package/lib/src/metadata-builder/helpers/rte.helpers.d.ts +1 -1
  183. package/lib/src/metadata-builder/helpers/rte.helpers.js +97 -40
  184. package/lib/src/metadata-builder/metadata-executor.js +23 -1
  185. package/lib/src/metadata-builder/models.d.ts +2 -0
  186. package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +18 -19
  187. package/lib/src/metadata-builder/parsers/section-tool-arguments.d.ts +18 -1
  188. package/lib/src/metadata-builder/sanitizers/rte-schema-check.js +1 -1
  189. package/lib/src/metadata-builder/sanitizers/sanitizer-rules.d.ts +0 -1
  190. package/lib/src/metadata-builder/sanitizers/sanitizer-rules.js +5 -8
  191. package/lib/src/metadata-builder/sanitizers/section-args-validator.d.ts +7 -16
  192. package/lib/src/metadata-builder/sanitizers/section-args-validator.js +95 -22
  193. package/lib/src/shared/color-palette/section-color-matches.js +9 -25
  194. package/lib/src/shared/color-strategies/color-strategies.d.ts +15 -0
  195. package/lib/src/shared/color-strategies/color-strategies.js +31 -0
  196. package/lib/src/shared/color-strategies/rte-color.d.ts +8 -0
  197. package/lib/src/shared/color-strategies/rte-color.js +16 -0
  198. package/lib/src/shared/color-strategies/rte-field-pairs.d.ts +23 -0
  199. package/lib/src/shared/color-strategies/rte-field-pairs.js +28 -0
  200. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts +9 -135
  201. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.js +1 -27
  202. package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +12 -2
  203. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.d.ts +7 -0
  204. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +75 -6
  205. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.js +18 -7
  206. package/lib/src/shared/content-settings/components/focused-content-item-settings/FocusedContentItemSettings.mixin.d.ts +6 -1
  207. package/lib/src/shared/content-settings/components/focused-content-item-settings/FocusedContentItemSettings.mixin.js +0 -7
  208. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +1 -0
  209. package/lib/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.js +8 -4
  210. package/lib/src/shared/content-settings/components/text-style-field/TextStyleField.mixin.d.ts +1255 -26
  211. package/lib/src/shared/content-settings/components/text-style-field/TextStyleField.mixin.js +203 -59
  212. package/lib/src/shared/content-settings/store/content-settings-store.d.ts +6 -0
  213. package/lib/src/shared/content-settings/store/content-settings-store.js +105 -8
  214. package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +5 -1
  215. package/lib/src/shared/navigation-style-settings/store/index.d.ts +7 -3
  216. package/lib/src/shared/navigation-style-settings/store/index.js +40 -15
  217. package/lib/src/shared/page-settings/components/delete-page-modal/DeletePageModal.mixin.d.ts +1 -1
  218. package/lib/src/shared/page-settings/components/new-page-modal/NewPageModal.mixin.d.ts +1 -0
  219. package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +17 -5
  220. package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +70 -13
  221. package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.js +10 -2
  222. package/lib/src/shared/page-settings/store/page-settings-store.d.ts +2 -1
  223. package/lib/src/shared/page-settings/store/page-settings-store.js +17 -0
  224. package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +4 -1
  225. package/lib/src/shared/rte-extensions/AutoLink.d.ts +17 -0
  226. package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/AutoLink.js +67 -51
  227. package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/MaxLength.js +4 -1
  228. package/lib/src/shared/rte-extensions/TextEffects.d.ts +28 -0
  229. package/lib/src/shared/rte-extensions/TextEffects.js +96 -0
  230. package/lib/src/shared/rte-extensions/ViewDomParser.d.ts +2 -0
  231. package/lib/src/shared/rte-extensions/ViewDomParser.js +21 -0
  232. package/lib/src/shared/rte-extensions.util.d.ts +25 -0
  233. package/lib/src/{brand-page-maker/composables/rich-text-editor/getRteExtensions.js → shared/rte-extensions.util.js} +62 -7
  234. package/lib/src/shared/rte-link.util.d.ts +1 -0
  235. package/lib/src/shared/rte-link.util.js +1 -0
  236. package/lib/src/shared/rte-render.util.d.ts +112 -0
  237. package/lib/src/shared/rte-render.util.js +255 -0
  238. package/lib/src/shared/rte-shape.util.d.ts +6 -0
  239. package/lib/src/shared/rte-shape.util.js +18 -0
  240. package/lib/src/shared/side-bar/components/SideBar.mixin.d.ts +2 -1
  241. package/lib/src/shared/side-bar/components/SideBarTabButton.mixin.d.ts +1 -0
  242. package/lib/src/shared/side-bar/store/side-bar-store.d.ts +2 -0
  243. package/lib/src/shared/side-bar/store/side-bar-store.js +9 -0
  244. package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +155 -15
  245. package/lib/src/shared/style-settings/components/StyleSettings.mixin.js +7 -1
  246. package/lib/src/shared/style-settings/store/style-settings-store.d.ts +1 -9
  247. package/lib/src/shared/style-settings/store/style-settings-store.js +3 -33
  248. package/lib/src/shared/style-settings/text-style-size-order.d.ts +2 -0
  249. package/lib/src/shared/style-settings/text-style-size-order.js +13 -0
  250. package/lib/src/shared/text-role-typography.util.d.ts +64 -0
  251. package/lib/src/shared/text-role-typography.util.js +183 -0
  252. package/lib/src/utils/minify-brand-page-metadata.d.ts +16 -1
  253. package/lib/src/utils/minify-brand-page-metadata.js +31 -9
  254. package/package.json +1 -1
  255. package/src/brand-page/__fixtures__/migration-22-v21/edited-brandsite-sections.v21.json +982 -0
  256. package/src/brand-page/__fixtures__/migration-22-v21/new-brandcontact-every-section.v21.json +1231 -0
  257. package/src/brand-page/__fixtures__/migration-22-v21/new-brandpage-every-section.v21.json +1231 -0
  258. package/src/brand-page/__fixtures__/migration-22-v21/new-brandsite-every-section.v21.json +1243 -0
  259. package/src/brand-page/__fixtures__/migration-22-v21/real-brandcontact.v21.json +755 -0
  260. package/src/brand-page/__fixtures__/migration-22-v21/real-brandpage-general-link.v21.json +527 -0
  261. package/src/brand-page/__fixtures__/migration-22-v21/real-brandpage-links.v21.json +755 -0
  262. package/src/brand-page/__fixtures__/migration-22-v21/real-brandpage-social-links.v21.json +514 -0
  263. package/src/brand-page/__fixtures__/migration-22-v21/real-brandsite-about.v21.json +459 -0
  264. package/src/brand-page/__fixtures__/migration-22-v21/real-brandsite-footer.v21.json +469 -0
  265. package/src/brand-page/__fixtures__/migration-22-v21/real-brandsite-header-banner.v21.json +481 -0
  266. package/src/brand-page/__fixtures__/migration-22-v21/real-brandsite-sections.v21.json +800 -0
  267. package/src/brand-page/__fixtures__/production-text-style-resolver.fixture.ts +52 -0
  268. package/src/brand-page/components/about-section/AboutSection.vue.test.ts +0 -10
  269. package/src/brand-page/components/contact-form/ContactForm.mixin.test.ts +127 -0
  270. package/src/brand-page/components/contact-form/ContactForm.mixin.ts +31 -14
  271. package/src/brand-page/components/contact-form/ContactForm.vue +26 -12
  272. package/src/brand-page/components/contact-form/ContactForm.vue.test.ts +60 -0
  273. package/src/brand-page/components/mailing-list/MailingList.mixin.test.ts +92 -0
  274. package/src/brand-page/components/mailing-list/MailingList.mixin.ts +28 -3
  275. package/src/brand-page/components/mailing-list/MailingList.vue +9 -4
  276. package/src/brand-page/components/mailing-list/MailingList.vue.test.ts +63 -0
  277. package/src/brand-page/components/navigation/button-carousel/ButtonCarouselNavigation.mixin.ts +51 -1
  278. package/src/brand-page/components/navigation/button-carousel/ButtonCarouselNavigation.test.ts +114 -0
  279. package/src/brand-page/components/navigation/button-carousel/ButtonCarouselNavigation.vue +8 -2
  280. package/src/brand-page/components/navigation/navigation-carousel/NavigationCarousel.test.ts +182 -0
  281. package/src/brand-page/components/navigation/navigation-carousel/NavigationCarousel.vue +59 -12
  282. package/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.mixin.ts +40 -3
  283. package/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.vue +15 -7
  284. package/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.vue.test.ts +133 -3
  285. package/src/brand-page/components/page/Page.mixin.ts +41 -34
  286. package/src/brand-page/components/page/Page.vue +17 -6
  287. package/src/brand-page/components/page/Page.vue.test.ts +91 -1
  288. package/src/brand-page/components/page-footer/PageFooter.mixin.ts +32 -2
  289. package/src/brand-page/components/page-footer/PageFooter.test.ts +79 -0
  290. package/src/brand-page/components/page-footer/PageFooter.vue +12 -4
  291. package/src/brand-page/components/payment/Payment.mixin.ts +34 -2
  292. package/src/brand-page/components/payment/Payment.test.ts +188 -0
  293. package/src/brand-page/components/payment/Payment.vue +12 -5
  294. package/src/brand-page/components/payment/RequestPaymentStripe.vue +1 -0
  295. package/src/brand-page/components/payment/support-me/SupportMe.mixin.ts +49 -2
  296. package/src/brand-page/components/payment/support-me/SupportMe.test.ts +100 -0
  297. package/src/brand-page/components/payment/support-me/SupportMe.vue +7 -1
  298. package/src/brand-page/components/payment/support-me/SupportMe.vue.test.ts +66 -0
  299. package/src/brand-page/components/save-contact/SaveContactWidget.test.ts +100 -0
  300. package/src/brand-page/components/save-contact/SaveContactWidget.vue +6 -3
  301. package/src/brand-page/components/shop/PaymentModal.vue +2 -6
  302. package/src/brand-page/components/shop/PaymentShippingAddress.vue +6 -0
  303. package/src/brand-page/components/shop/Shop.vue +15 -2
  304. package/src/brand-page/components/shop/Shop.vue.test.ts +74 -2
  305. package/src/brand-page/components/social-links/SocialLinks.stories.ts +0 -3
  306. package/src/brand-page/components/social-links/SocialLinks.vue.test.ts +0 -3
  307. package/src/brand-page/components/testimonial-section/__fixtures__/data.ts +0 -3
  308. package/src/brand-page/components/text/Text.stories.ts +0 -17
  309. package/src/brand-page/components/text-wrapper/TextWrapper.parity.test.ts +136 -0
  310. package/src/brand-page/components/text-wrapper/TextWrapper.test.ts +358 -0
  311. package/src/brand-page/components/text-wrapper/TextWrapper.vue +82 -22
  312. package/src/brand-page/constants/font.constants.ts +37 -0
  313. package/src/brand-page/models/footer-icon-color.test.ts +22 -0
  314. package/src/brand-page/models/index.ts +50 -28
  315. package/src/brand-page/models/navigation-styles.model.test.ts +77 -1
  316. package/src/brand-page/models/navigation-styles.model.ts +26 -9
  317. package/src/brand-page/models/payment.model.ts +15 -6
  318. package/src/brand-page/models/styles.model.test.ts +104 -0
  319. package/src/brand-page/models/styles.model.ts +181 -47
  320. package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +619 -115
  321. package/src/brand-page/utils/__snapshots__/migration2.util.test.ts.snap +150 -9
  322. package/src/brand-page/utils/__snapshots__/model.util.test.ts.snap +300 -18
  323. package/src/brand-page/utils/color-palette.util.test.ts +126 -1
  324. package/src/brand-page/utils/color-palette.util.ts +92 -26
  325. package/src/brand-page/utils/color.util.test.ts +62 -29
  326. package/src/brand-page/utils/color.util.ts +77 -14
  327. package/src/brand-page/utils/container-text-color.util.test.ts +672 -26
  328. package/src/brand-page/utils/container-text-color.util.ts +472 -46
  329. package/src/brand-page/utils/index.ts +1 -0
  330. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/edited-brandsite-sections.v22.json +1191 -0
  331. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/new-brandcontact-every-section.v22.json +2022 -0
  332. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/new-brandpage-every-section.v22.json +2013 -0
  333. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/new-brandsite-every-section.v22.json +2027 -0
  334. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandcontact.v22.json +1144 -0
  335. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandpage-general-link.v22.json +642 -0
  336. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandpage-links.v22.json +1135 -0
  337. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandpage-social-links.v22.json +662 -0
  338. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandsite-about.v22.json +638 -0
  339. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandsite-footer.v22.json +610 -0
  340. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandsite-header-banner.v22.json +660 -0
  341. package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandsite-sections.v22.json +1132 -0
  342. package/src/brand-page/utils/migration/migration-01.ts +293 -237
  343. package/src/brand-page/utils/migration/migration-02.ts +8 -1
  344. package/src/brand-page/utils/migration/migration-20.ts +6 -3
  345. package/src/brand-page/utils/migration/migration-20_5.test.ts +5 -2
  346. package/src/brand-page/utils/migration/migration-21.test.ts +34 -0
  347. package/src/brand-page/utils/migration/migration-21.ts +46 -10
  348. package/src/brand-page/utils/migration/migration-22.fixed-input.test.ts +43 -0
  349. package/src/brand-page/utils/migration/migration-22.test.ts +4191 -0
  350. package/src/brand-page/utils/migration/migration-22.text-font-family.test.ts +72 -0
  351. package/src/brand-page/utils/migration/migration-22.ts +1343 -0
  352. package/src/brand-page/utils/migration.util.test.ts +146 -32
  353. package/src/brand-page/utils/migration.util.ts +18 -0
  354. package/src/brand-page/utils/model.util.ts +4 -0
  355. package/src/brand-page/utils/personalisation.util.test.ts +148 -3
  356. package/src/brand-page/utils/personalisation.util.ts +9 -1
  357. package/src/brand-page/utils/rte-role-lift.util.ts +409 -0
  358. package/src/brand-page/utils/style.util.test.ts +35 -2
  359. package/src/brand-page/utils/style.util.ts +45 -11
  360. package/src/brand-page/utils/text-role-css.util.test.ts +525 -0
  361. package/src/brand-page/utils/text-role-css.util.ts +321 -0
  362. package/src/brand-page/utils/text-role-reconnect.util.test.ts +604 -0
  363. package/src/brand-page/utils/text-role-reconnect.util.ts +727 -0
  364. package/src/brand-page/utils/text-style.util.test.ts +305 -0
  365. package/src/brand-page/utils/text-style.util.ts +198 -24
  366. package/src/brand-page/utils/view-model.page-data.test.ts +232 -0
  367. package/src/brand-page/utils/view-model.util.test.ts +954 -133
  368. package/src/brand-page/utils/view-model.util.ts +187 -139
  369. package/src/brand-page/view-models.ts +4 -0
  370. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.blank-site.test.ts +57 -0
  371. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +9 -5
  372. package/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.ts +0 -10
  373. package/src/brand-page-maker/components/brand-page-maker/__fixtures__/content-settings-items.fixture.ts +0 -1
  374. package/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.ts +0 -44
  375. package/src/brand-page-maker/components/rich-text-editor/RichTextEditor.vue +253 -200
  376. package/src/brand-page-maker/components/shop/AddOrEditProductContainer.vue +1 -0
  377. package/src/brand-page-maker/components/template-preview/TemplatePreview.vue +1 -0
  378. package/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.ts +2 -0
  379. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +1 -0
  380. package/src/brand-page-maker/composables/rich-text-editor/block-typography.test.ts +519 -0
  381. package/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.test.ts +1 -1
  382. package/src/brand-page-maker/composables/rich-text-editor/extensions/MaxLength.test.ts +26 -1
  383. package/src/brand-page-maker/composables/rich-text-editor/extensions/RoleTypographyFill.test.ts +110 -0
  384. package/src/brand-page-maker/composables/rich-text-editor/extensions/RoleTypographyFill.ts +99 -0
  385. package/src/brand-page-maker/composables/rich-text-editor/extensions/RteClipboard.ts +397 -0
  386. package/src/brand-page-maker/composables/rich-text-editor/extensions/ViewDomParser.test.ts +139 -0
  387. package/src/brand-page-maker/composables/rich-text-editor/font.ts +36 -5
  388. package/src/brand-page-maker/composables/rich-text-editor/formatting.test.ts +375 -1
  389. package/src/brand-page-maker/composables/rich-text-editor/formatting.ts +301 -17
  390. package/src/brand-page-maker/composables/rich-text-editor/hyperlink.test.ts +82 -1
  391. package/src/brand-page-maker/composables/rich-text-editor/hyperlink.ts +28 -34
  392. package/src/brand-page-maker/composables/rich-text-editor/keepMarksOnEmpty.test.ts +80 -0
  393. package/src/brand-page-maker/composables/rich-text-editor/keepMarksOnEmpty.ts +75 -0
  394. package/src/brand-page-maker/composables/rich-text-editor/spacing.ts +31 -6
  395. package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.test.ts +2485 -0
  396. package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.ts +435 -337
  397. package/src/brand-page-maker/constants/config-settings-constant.ts +0 -6
  398. package/src/brand-page-maker/convertors/text-css-style-options.convertor.test.ts +43 -0
  399. package/src/brand-page-maker/convertors/text-css-style-options.convertor.ts +6 -2
  400. package/src/brand-page-maker/convertors/text-size-value.convertor.test.ts +24 -0
  401. package/src/brand-page-maker/convertors/text-size-value.convertor.ts +17 -13
  402. package/src/brand-page-maker/default-getters/payment-text-and-border-color.default-getter.ts +7 -22
  403. package/src/brand-page-maker/default-getters/text-color.default-getter.ts +5 -21
  404. package/src/brand-page-maker/models/content-settings.test.ts +756 -0
  405. package/src/brand-page-maker/models/content-settings.ts +135 -82
  406. package/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store-utils.test.ts +63 -1
  407. package/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store-utils.ts +16 -3
  408. package/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store.test.ts +34 -0
  409. package/src/brand-page-maker/stores/admin-logo-settings/admin-logo-settings-store.ts +4 -2
  410. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.test.ts +185 -1
  411. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +22 -34
  412. package/src/brand-page-maker/stores/history/history-store.ts +35 -2
  413. package/src/brand-page-maker/utils/__snapshots__/apply-color-strategy.golden.test.ts.snap +528 -0
  414. package/src/brand-page-maker/utils/__snapshots__/rte-render-parity.test.ts.snap +12 -0
  415. package/src/brand-page-maker/utils/apply-color-strategy.golden.test.ts +2 -0
  416. package/src/brand-page-maker/utils/apply-color-strategy.test.ts +181 -3
  417. package/src/brand-page-maker/utils/apply-color-strategy.ts +36 -4
  418. package/src/brand-page-maker/utils/index.ts +2 -1
  419. package/src/brand-page-maker/utils/rich-text-editor.util.test.ts +447 -410
  420. package/src/brand-page-maker/utils/rich-text-editor.util.ts +610 -506
  421. package/src/brand-page-maker/utils/rte-authoring.util.test.ts +244 -0
  422. package/src/brand-page-maker/utils/rte-authoring.util.ts +175 -0
  423. package/src/brand-page-maker/utils/rte-clipboard.util.test.ts +558 -0
  424. package/src/brand-page-maker/utils/rte-clipboard.util.ts +473 -0
  425. package/src/brand-page-maker/utils/rte-features.test.ts +99 -3
  426. package/src/brand-page-maker/utils/rte-render-parity.test.ts +1 -1
  427. package/src/brand-page-maker/utils/rte-render.util.test.ts +230 -0
  428. package/src/brand-page-maker/utils/rte-sanitize-json.test.ts +1 -1
  429. package/src/brand-page-maker/utils/rte-sanitize.util.ts +14 -3
  430. package/src/brand-page-maker/utils/rte-schema-version.test.ts +102 -0
  431. package/src/bundles/bundled-translations.de-DE.json +21 -2
  432. package/src/bundles/bundled-translations.es-ES.json +21 -2
  433. package/src/bundles/bundled-translations.fr-CA.json +21 -2
  434. package/src/bundles/bundled-translations.fr-FR.json +21 -2
  435. package/src/bundles/bundled-translations.json +21 -2
  436. package/src/bundles/bundled-translations.pt-BR.json +21 -2
  437. package/src/bundles/bundled-translations.pt-PT.json +21 -2
  438. package/src/clients/ai-assistant-client.ts +1 -0
  439. package/src/composables/useTranslate.ts +2 -1
  440. package/src/lib.ts +2 -2
  441. package/src/metadata-builder/builders/footer-builder.test.ts +70 -45
  442. package/src/metadata-builder/builders/footer-builder.ts +4 -8
  443. package/src/metadata-builder/builders/global-role-propagation.test.ts +907 -0
  444. package/src/metadata-builder/builders/global-role-propagation.ts +430 -0
  445. package/src/metadata-builder/builders/global-styles-builder.test.ts +1020 -0
  446. package/src/metadata-builder/builders/global-styles-builder.ts +194 -48
  447. package/src/metadata-builder/builders/header-builder.test.ts +112 -40
  448. package/src/metadata-builder/builders/header-builder.ts +18 -8
  449. package/src/metadata-builder/builders/section-builders/about-section-builder.ts +5 -3
  450. package/src/metadata-builder/builders/section-builders/banner-section-builder.ts +5 -3
  451. package/src/metadata-builder/builders/section-builders/booking-section-builder.ts +5 -3
  452. package/src/metadata-builder/builders/section-builders/contact-form-builder.ts +7 -4
  453. package/src/metadata-builder/builders/section-builders/images-section-builder.ts +5 -3
  454. package/src/metadata-builder/builders/section-builders/mailing-list-builder.ts +3 -2
  455. package/src/metadata-builder/builders/section-builders/mailing-list-section-builder.ts +3 -2
  456. package/src/metadata-builder/builders/section-builders/profile-section-builder.ts +7 -7
  457. package/src/metadata-builder/builders/section-builders/shapes-section-builder.ts +5 -3
  458. package/src/metadata-builder/builders/section-builders/social-links-builder.test.ts +2 -2
  459. package/src/metadata-builder/builders/section-builders/social-links-builder.ts +21 -10
  460. package/src/metadata-builder/builders/section-builders/support-me-builder.test.ts +10 -0
  461. package/src/metadata-builder/builders/section-builders/testimonial-section-builder.ts +3 -2
  462. package/src/metadata-builder/builders/section-builders/text-section-builder.ts +111 -61
  463. package/src/metadata-builder/builders/section-field-maps.ts +1 -0
  464. package/src/metadata-builder/builders/section-field-utils.test.ts +545 -2
  465. package/src/metadata-builder/builders/section-field-utils.ts +202 -69
  466. package/src/metadata-builder/builders/section-rules/global-styles.rules.ts +38 -13
  467. package/src/metadata-builder/builders/section-rules/social-links.rules.ts +5 -0
  468. package/src/metadata-builder/helpers/rte.helpers.test.ts +101 -0
  469. package/src/metadata-builder/helpers/rte.helpers.ts +129 -43
  470. package/src/metadata-builder/metadata-executor.test.ts +167 -0
  471. package/src/metadata-builder/metadata-executor.ts +34 -1
  472. package/src/metadata-builder/models.ts +2 -0
  473. package/src/metadata-builder/parsers/ai-toolcall-parser.ts +23 -7
  474. package/src/metadata-builder/parsers/section-tool-arguments.ts +21 -1
  475. package/src/metadata-builder/sanitizers/__tests__/section-args-validator.test.ts +215 -0
  476. package/src/metadata-builder/sanitizers/rte-schema-check.ts +1 -1
  477. package/src/metadata-builder/sanitizers/sanitizer-rules.ts +4 -8
  478. package/src/metadata-builder/sanitizers/section-args-validator.ts +136 -53
  479. package/src/shared/color-palette/section-color-matches.test.ts +15 -11
  480. package/src/shared/color-palette/section-color-matches.ts +9 -28
  481. package/src/shared/color-strategies/color-strategies.ts +35 -0
  482. package/src/shared/color-strategies/rte-color.test.ts +1 -1
  483. package/src/shared/color-strategies/rte-color.ts +19 -0
  484. package/src/shared/color-strategies/rte-field-pairs.test.ts +26 -5
  485. package/src/shared/color-strategies/rte-field-pairs.ts +33 -0
  486. package/src/shared/content-settings/components/color-matches-panel/ColorMatchesPanel.test.ts +43 -66
  487. package/src/shared/content-settings/components/color-matches-panel/ColorMatchesPanel.vue +7 -1
  488. package/src/shared/content-settings/components/content-settings/ContentSettings.mixin.ts +1 -48
  489. package/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.ts +33 -7
  490. package/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.test.ts +128 -1
  491. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.vue +1 -0
  492. package/src/shared/content-settings/components/focused-content-item-settings/FocusedContentItemSettings.mixin.ts +0 -6
  493. package/src/shared/content-settings/components/logo-selection-field/LogoSelection.vue +3 -0
  494. package/src/shared/content-settings/components/logo-size-field/LogoSizeSlider.vue +3 -0
  495. package/src/shared/content-settings/components/logo-size-field/LogoSizeSliderField.vue +1 -0
  496. package/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.vue +1 -0
  497. package/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.test.ts +56 -3
  498. package/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.ts +11 -4
  499. package/src/shared/content-settings/components/text-style-field/TextStyleField.mixin.test.ts +335 -25
  500. package/src/shared/content-settings/components/text-style-field/TextStyleField.mixin.ts +248 -70
  501. package/src/shared/content-settings/components/text-style-field/TextStyleField.vue +113 -25
  502. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.de-DE.json +17 -10
  503. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.es-ES.json +17 -10
  504. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.fr-CA.json +17 -10
  505. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.fr-FR.json +17 -10
  506. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.json +8 -1
  507. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.pt-BR.json +17 -10
  508. package/src/shared/content-settings/components/text-style-field/i18n/text-style-field.pt-PT.json +17 -10
  509. package/src/shared/content-settings/components/text-style-role-dropdown/TextStyleRoleDropdown.test.ts +141 -0
  510. package/src/shared/content-settings/components/text-style-role-dropdown/TextStyleRoleDropdown.vue +136 -0
  511. package/src/shared/content-settings/store/content-settings-store.test.ts +491 -6
  512. package/src/shared/content-settings/store/content-settings-store.ts +159 -17
  513. package/src/shared/logo-settings/components/EditLogoSettings.vue +1 -0
  514. package/src/shared/logo-settings/components/LogoVariations.vue +1 -0
  515. package/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.vue +1 -0
  516. package/src/shared/navigation-style-settings/store/index.test.ts +295 -0
  517. package/src/shared/navigation-style-settings/store/index.ts +65 -15
  518. package/src/shared/page-settings/components/header-settings-panel/HeaderSettingsPanel.vue +2 -0
  519. package/src/shared/page-settings/components/page-settings/PageElement.vue +1 -0
  520. package/src/shared/page-settings/components/page-settings-section-styles/HeaderButtonSettings.test.ts +44 -4
  521. package/src/shared/page-settings/components/page-settings-section-styles/HeaderButtonSettings.vue +13 -4
  522. package/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.navigation.test.ts +89 -0
  523. package/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.text-style.test.ts +91 -0
  524. package/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.ts +14 -2
  525. package/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.vue +2 -0
  526. package/src/shared/page-settings/store/page-settings-store.text-style.test.ts +84 -0
  527. package/src/shared/page-settings/store/page-settings-store.ts +30 -1
  528. package/src/shared/rte-extensions/AutoLink.test.ts +98 -0
  529. package/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/AutoLink.ts +87 -58
  530. package/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/MaxLength.ts +4 -1
  531. package/src/shared/rte-extensions/TextEffects.ts +151 -0
  532. package/src/shared/rte-extensions/ViewDomParser.ts +27 -0
  533. package/src/{brand-page-maker/composables/rich-text-editor/getRteExtensions.ts → shared/rte-extensions.util.ts} +66 -9
  534. package/src/shared/rte-link.util.ts +2 -0
  535. package/src/shared/rte-render.util.ts +385 -0
  536. package/src/shared/rte-shape.util.ts +29 -0
  537. package/src/shared/side-bar/store/side-bar-store.test.ts +27 -1
  538. package/src/shared/side-bar/store/side-bar-store.ts +11 -0
  539. package/src/shared/style-settings/components/StyleSettings.mixin.ts +7 -3
  540. package/src/shared/style-settings/components/StyleSettings.test.ts +116 -0
  541. package/src/shared/style-settings/components/StyleSettings.vue +75 -25
  542. package/src/shared/style-settings/components/i18n/style-settings.de-DE.json +32 -20
  543. package/src/shared/style-settings/components/i18n/style-settings.es-ES.json +32 -20
  544. package/src/shared/style-settings/components/i18n/style-settings.fr-CA.json +32 -20
  545. package/src/shared/style-settings/components/i18n/style-settings.fr-FR.json +32 -20
  546. package/src/shared/style-settings/components/i18n/style-settings.json +13 -3
  547. package/src/shared/style-settings/components/i18n/style-settings.pt-BR.json +32 -20
  548. package/src/shared/style-settings/components/i18n/style-settings.pt-PT.json +32 -20
  549. package/src/shared/style-settings/components/text-style-options-settings-with-state/TextStyleOptionsSettingsWithState.vue +14 -34
  550. package/src/shared/style-settings/store/style-settings-store.ts +3 -49
  551. package/src/shared/style-settings/text-style-size-order.test.ts +76 -0
  552. package/src/shared/style-settings/text-style-size-order.ts +28 -0
  553. package/src/shared/template-settings/components/TemplatesSettings.vue +4 -0
  554. package/src/shared/text-role-typography.util.ts +277 -0
  555. package/src/utils/minify-brand-page-metadata.test.ts +102 -7
  556. package/src/utils/minify-brand-page-metadata.ts +62 -8
  557. package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/AutoLink.d.ts +0 -2
  558. package/lib/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.d.ts +0 -28
  559. package/lib/src/brand-page-maker/utils/rte-render.util.d.ts +0 -63
  560. package/lib/src/brand-page-maker/utils/rte-render.util.js +0 -106
  561. package/lib/src/brand-page-maker/utils/rte-shape.d.ts +0 -18
  562. package/lib/src/brand-page-maker/utils/rte-shape.js +0 -21
  563. package/lib/src/metadata-builder/builders/global-font-propagation.d.ts +0 -41
  564. package/lib/src/metadata-builder/builders/global-font-propagation.js +0 -146
  565. package/src/brand-page-maker/utils/rte-render.util.ts +0 -179
  566. package/src/brand-page-maker/utils/rte-shape.ts +0 -29
  567. package/src/metadata-builder/builders/global-font-propagation.test.ts +0 -401
  568. package/src/metadata-builder/builders/global-font-propagation.ts +0 -238
  569. package/src/shared/style-settings/components/StyleSettingsSection.vue +0 -8
  570. /package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/FontFamily.d.ts +0 -0
  571. /package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/FontFamily.js +0 -0
  572. /package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/LetterSpacing.d.ts +0 -0
  573. /package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/LetterSpacing.js +0 -0
  574. /package/lib/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/MaxLength.d.ts +0 -0
  575. /package/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/FontFamily.ts +0 -0
  576. /package/src/{brand-page-maker/composables/rich-text-editor/extensions → shared/rte-extensions}/LetterSpacing.ts +0 -0
@@ -0,0 +1,1343 @@
1
+ import type { MigrationData, MigrationOptions } from '../migration.util';
2
+ import {
3
+ BRAND_PAGE_TYPES,
4
+ type BrandPageModel,
5
+ type HeaderButton,
6
+ type NavOrder,
7
+ type PageModel,
8
+ type TextStyleDeclaration,
9
+ } from '../../models';
10
+ import {
11
+ TEXT_STYLE_TYPES,
12
+ isCanonicalTextStyleType,
13
+ isLegacyTextStyleType,
14
+ type TextStyleOptions,
15
+ type TextStyleType,
16
+ type LegacyTextStyleType,
17
+ } from '../../models/styles.model';
18
+ import {
19
+ CONTENT_TEXT_STYLE_PROPERTY_KEYS,
20
+ type ContentTextStylePropertyKey,
21
+ FONT_FAMILY_CONFIGS,
22
+ DEFAULT_FONT_FAMILY_KEY,
23
+ FONT_SIZE_BODY,
24
+ LINE_HEIGHT_BODY,
25
+ ALIGN_LEFT_ALIGNED,
26
+ ALIGN_RIGHT_ALIGNED,
27
+ MAX_IMAGES_SECTION_ALIGNMENT_ITEMS_LENGTH,
28
+ type FontFamilyKey,
29
+ } from '../../constants';
30
+ import {
31
+ computeLegacyTargets,
32
+ reconnectTextStyleRoles,
33
+ contentFieldReconnectSpec,
34
+ drawnFontFamily,
35
+ siteTextFontName,
36
+ FAMILY_TIERS,
37
+ type LegacyTargetMap,
38
+ type TextRoleFamily,
39
+ type RenderedDefaultsForContent,
40
+ } from '../text-role-reconnect.util';
41
+ import {
42
+ pairedRteTextField,
43
+ rteStyleFieldsFor,
44
+ } from '@shared/color-strategies/rte-field-pairs';
45
+ import {
46
+ containerTextColorDefaults,
47
+ isButtonLabelField,
48
+ titleSurfaceContrastFill,
49
+ } from '../container-text-color.util';
50
+ import {
51
+ stripLiftContentRte,
52
+ textRunFontFamilies,
53
+ } from '../rte-role-lift.util';
54
+ import {
55
+ collectRteTextColors,
56
+ fillUncolouredRteText,
57
+ } from '@shared/color-strategies/rte-color';
58
+ import { isBlankColorValue } from '../color-palette.util';
59
+ import {
60
+ plainTextToRteJson,
61
+ resolveHtmlParser,
62
+ isTiptapDocument,
63
+ type HtmlParser,
64
+ } from '@shared/rte-render.util';
65
+ import type { JSONContent } from '@tiptap/vue-3';
66
+
67
+ // SNAPSHOT DEPENDENCY NOTICE: B/C/D import live shared helpers above. Their source modules carry
68
+ // `MIGRATION-22 SNAPSHOT DEPENDENCY` notices; once v22 ships, copy the v22 semantics here before
69
+ // changing any of them. B1 already owns an inline snapshot of its typography fill.
70
+ // `migration-22.fixed-input.test.ts` fails when a helper change moves this migration's output.
71
+
72
+ /**
73
+ * BP-5969 migration-22 — the single-source text-style migration. Version-gated: runs
74
+ * once when `v < 22`. The durable decisions are `0019-retire-rte-object-style-sync.md`,
75
+ * `0020-role-is-typography-only-colour-is-contrast-derived.md`, and
76
+ * `0021-migrated-content-reconnects-to-nearest-role-with-override.md`.
77
+ *
78
+ * A/B/C are appearance-preserving. D/E/G finish the ADR-0020 colour decouple in the same
79
+ * (still-unreleased) migration — they too preserve appearance, by freezing each element's
80
+ * currently-resolved colour before the role colour and base coat that fed it are removed.
81
+ * One decided exception (ADR-0020, Update 2026-09-29): a social-links section with no base
82
+ * coat to freeze bakes its icon fill to the title's contrast colour instead — a new colour,
83
+ * not a literal freeze of whatever `currentColor` happened to paint under `:root`.
84
+ * A. Seed each old role's colour onto its target tier (D3 base coat) — `seedRoleColours`.
85
+ * Roles keep their §4 size, weight and line height; the old size is preserved as a per-block
86
+ * override by B. The legacy → tier map is computed per-site by `computeLegacyTargets`.
87
+ * A2. (R16) Count the font the site's title/heading, description/paragraph and button text shows,
88
+ * and give each family the winner — each family's font comes from the site's text, not §4 —
89
+ * before B and C link equal text to it — `seedRoleFonts`.
90
+ * B. Seed the absent header-button / brand.contact Save Contact styles (they rendered as
91
+ * `buttons`), then reconnect every text field outside the ten — content, text items, footer
92
+ * copyright, nav, header button, Save Contact — to its nearest role, keeping its look as
93
+ * overrides — `reconnectContentRoles` (the shared `text-role-reconnect.util`). The three old
94
+ * no-role renderer defaults (mailing-list title, Support Me title, text block) are materialised
95
+ * here only, before reconnect persists their effective values; no runtime reader keeps them. A colourless nav
96
+ * link's colour is baked here, not in D: it comes from the legacy role, which B replaces. A
97
+ * payment or shop success message with no role of its own gets the look it drew
98
+ * (`seedSuccessMessageStyle`); D then bakes its colour, like any non-RTE style.
99
+ * C. Baked→override strip/lift on RTE fields (D4) — `stripLiftContentRte`; per field it also folds
100
+ * legacy bold/italic/underline/strike marks into the run's textStyle attrs (`foldSemanticFormattingMarks`)
101
+ * and pins a not-bold legacy block's weight so a bold heading tier can't bold it (`pinLegacyRunWeight`).
102
+ * B1. Convert plain-text RTE-eligible fields to Tiptap docs — `convertPlainRteFields`.
103
+ * D. Bake each element's resolved colour explicitly, social-links icon fills included —
104
+ * `bakeElementColours`.
105
+ * E. Clear the retired role colour — `clearRoleColours`.
106
+ * G. Colour-decouple RTE-paired style objects: remove `color` only — `stripRteStyleColours`.
107
+ * H. Delete the retired site text font and its footer copies — `deleteTextFontFamily`
108
+ * (`0036-retire-text-font-family.md`). A2 and B read it through `siteTextFontName`.
109
+ *
110
+ * Ordering is load-bearing: D reads the base coat off `paragraph1` and the role colours (which A
111
+ * seeds from the old roles), so it must run after A and before E; B must run before C and D, which
112
+ * read each field's reconnected role and pinned typography; G removes the RTE style object's
113
+ * colour, so it must run after D has baked that colour into the mark. B1 runs after C (so C's
114
+ * per-run typography bake sees real editor-baked docs, not a freshly-converted placeholder) and
115
+ * before D (so D colours the converted runs like any other doc). A2 runs before B, C, B1, which
116
+ * read the role's font: on the untouched model, so it counts what a legacy-role or no-role field
117
+ * showed before B relinks it, and links B and C to bake against the winner it seeds. H runs last,
118
+ * after every reader of the site text font.
119
+ *
120
+ * Version-gated (v only moves forward), so this runs exactly once. A hypothetical re-run is a
121
+ * no-op throughout: B (seed + reconnect), C (strip + weight pin) and B1 (convert) find every button
122
+ * style present and every field on one of the ten, no baked role-equal typography, every bare run
123
+ * already weight-pinned and no plain strings left; D/E/G find every element already coloured, role
124
+ * colours already cleared and RTE style objects already colourless; H finds nothing to delete; and
125
+ * A (`seedRoleColours`) finds nothing to copy — E already cleared the legacy roles' colour
126
+ * (persisted), so the tiers keep their §4 typography untouched. A2 re-counts what the migrated
127
+ * site shows, the same fonts, so it picks the same winners — also a no-op. Unreachable behind the
128
+ * gate; documented here per the migration rules.
129
+ */
130
+
131
+ export { computeLegacyTargets };
132
+ export {
133
+ stripLiftRteDoc,
134
+ foldSemanticFormattingMarks,
135
+ pinLegacyRunWeight,
136
+ stripLiftContentRte,
137
+ } from '../rte-role-lift.util';
138
+
139
+ /**
140
+ * Seed each old legacy role's colour onto its target tier — COLOUR ONLY; the tier keeps its
141
+ * §4 default typography. `bakeElementColours` (D) freezes each element's colour by reading its
142
+ * tier, and the base coat off `paragraph1`, so a legacy block's colour is preserved exactly as
143
+ * long as the tier it links to carries the old role's colour. `clearRoleColours` (E) then wipes
144
+ * the seed once D has read it — the tier ends typography-only, per ADR-0020.
145
+ */
146
+ export const seedRoleColours = (
147
+ options: TextStyleOptions,
148
+ targets: LegacyTargetMap,
149
+ ): void => {
150
+ for (const legacy of Object.keys(targets) as LegacyTextStyleType[]) {
151
+ const source = options[legacy]?.style as unknown as
152
+ | Record<string, unknown>
153
+ | undefined;
154
+ const colour = source?.color;
155
+
156
+ if (colour === undefined || colour === null || colour === '') continue;
157
+
158
+ const target = options[targets[legacy]]?.style as unknown as
159
+ | Record<string, unknown>
160
+ | undefined;
161
+
162
+ // The canonical target normally pre-exists (the model constructor seeds all 10); guard
163
+ // defensively for pre-10-role metadata rather than assume it.
164
+ if (target) target.color = colour;
165
+ }
166
+ };
167
+
168
+ // An absent header-button or brand.contact Save Contact style rendered as `buttons`. Seeding
169
+ // it lets the reconnect move it to `button` with that look kept as overrides.
170
+ const seedAbsentButtonStyles = (brandPageModel: BrandPageModel): void => {
171
+ for (const header of [
172
+ brandPageModel.pageHeaderDesktop,
173
+ brandPageModel.pageHeaderMobile,
174
+ ]) {
175
+ const headerButton = header?.headerButton;
176
+
177
+ if (headerButton) {
178
+ headerButton.buttonTextStyle ??= {
179
+ textStyleType: TEXT_STYLE_TYPES.buttons,
180
+ };
181
+ }
182
+ }
183
+
184
+ if (brandPageModel.brandPageType !== BRAND_PAGE_TYPES.brandContact) return;
185
+
186
+ // The same defaults the view model and the maker store apply when none are saved.
187
+ brandPageModel.saveContactSettings ??= {
188
+ isSavingEnabled: true,
189
+ hideBranding: false,
190
+ };
191
+ brandPageModel.saveContactSettings.buttonTextStyle ??= {
192
+ textStyleType: TEXT_STYLE_TYPES.buttons,
193
+ };
194
+ };
195
+
196
+ // ── R16 — job A2: role fonts on upgrade ───────────────────────────────────
197
+
198
+ const LATO = FONT_FAMILY_CONFIGS[DEFAULT_FONT_FAMILY_KEY].name;
199
+
200
+ // Every display NAME a stored font can resolve to — built once, not re-scanned per vote.
201
+ const FONT_FAMILY_NAMES = new Set(
202
+ Object.values(FONT_FAMILY_CONFIGS).map((config) => config.name),
203
+ );
204
+
205
+ // A stored font counts by its display NAME: a key spelling ('nunito') counts as its name
206
+ // ('Nunito'); a font outside the list casts no vote (Q11) and the stored override survives
207
+ // (B/C compare strictly, so a key-spelled override never drops).
208
+ const voteFontName = (fontFamily: string | undefined): string | undefined => {
209
+ if (!fontFamily) return undefined;
210
+
211
+ const byKey = FONT_FAMILY_CONFIGS[fontFamily as FontFamilyKey]?.name;
212
+
213
+ if (byKey) return byKey;
214
+
215
+ return FONT_FAMILY_NAMES.has(fontFamily) ? fontFamily : undefined;
216
+ };
217
+
218
+ // One tally per family. A `Map` keeps first-insertion order, and a later count never overtakes an
219
+ // EQUAL earlier one, so the winner scan gives the tie to whichever font was first voted for
220
+ // (migration-21's first-seen rule, D11).
221
+ class FontTally {
222
+ private readonly votes = new Map<string, number>();
223
+
224
+ add(fontFamily: string | undefined): void {
225
+ const name = voteFontName(fontFamily);
226
+
227
+ if (!name) return;
228
+
229
+ this.votes.set(name, (this.votes.get(name) ?? 0) + 1);
230
+ }
231
+
232
+ winner(defaultFont: string): string {
233
+ let winner = defaultFont;
234
+ let max = 0;
235
+
236
+ for (const [font, count] of this.votes) {
237
+ if (count > max) {
238
+ max = count;
239
+ winner = font;
240
+ }
241
+ }
242
+
243
+ return winner;
244
+ }
245
+ }
246
+
247
+ // Depth-first through the nav from its home page (`orders[0]`), then any page with no route, in
248
+ // its stored order — `page-settings-store.ts` `syncPagesWithOrders`'s algorithm, read-only here.
249
+ const sitePageOrder = (brandPageModel: BrandPageModel): PageModel[] => {
250
+ const routes = brandPageModel.nav?.routes ?? [];
251
+ const pageIds: string[] = [];
252
+
253
+ const collect = (orders: NavOrder[] | undefined): void => {
254
+ for (const order of orders ?? []) {
255
+ const route = routes.find((r) => r.id === order.routeId);
256
+
257
+ if (route?.pageId) pageIds.push(route.pageId);
258
+
259
+ collect(order.subRoutes);
260
+ }
261
+ };
262
+
263
+ collect(brandPageModel.nav?.orders);
264
+
265
+ const pages = brandPageModel.pages ?? [];
266
+ const byId = new Map(pages.map((page) => [page.id, page]));
267
+ const ordered: PageModel[] = [];
268
+
269
+ for (const id of pageIds) {
270
+ const page = byId.get(id);
271
+
272
+ if (page) {
273
+ ordered.push(page);
274
+ byId.delete(id);
275
+ }
276
+ }
277
+
278
+ ordered.push(...byId.values());
279
+
280
+ return ordered;
281
+ };
282
+
283
+ // Same predicate as `vcard.util`'s `hasProfileContent`, checked directly against the raw model:
284
+ // that one is typed for the rendered view model, which migration runs before building.
285
+ const hasProfileContent = (brandPageModel: BrandPageModel): boolean =>
286
+ (brandPageModel.pages ?? []).some((page) =>
287
+ page.contents?.some((content) => content.type === 'profile'),
288
+ );
289
+
290
+ // A Tiptap doc gives the distinct fonts its non-empty runs show; a non-blank plain string gives
291
+ // the block font; anything else (blank, `false`, absent) casts no vote — read the same way the
292
+ // reconnect will (`drawnFontFamily`), so the count can't disagree with what B and C keep.
293
+ const voteText = (
294
+ tally: FontTally,
295
+ style: TextStyleDeclaration | undefined,
296
+ text: unknown,
297
+ options: TextStyleOptions,
298
+ siteFont: string,
299
+ ): void => {
300
+ if (!style) return;
301
+
302
+ if (isTiptapDocument(text)) {
303
+ const blockFont = drawnFontFamily(style, options, siteFont);
304
+
305
+ for (const font of textRunFontFamilies(text, blockFont)) tally.add(font);
306
+
307
+ return;
308
+ }
309
+
310
+ if (typeof text !== 'string' || text.trim() === '') return;
311
+
312
+ tally.add(drawnFontFamily(style, options, siteFont));
313
+ };
314
+
315
+ // The content-level style key → its plain text field, for the sections whose title/description
316
+ // isn't RTE-paired (`pairedRteTextField` returns nothing for them) — a link button's `title`
317
+ // (`ButtonContent`) and a direct section button's `buttonText` (banner, booking, mailing-list…).
318
+ const CONTENT_LEVEL_TEXT_FIELD: Partial<Record<string, string>> = {
319
+ titleStyle: 'title',
320
+ descriptionStyle: 'description',
321
+ paragraphStyle: 'paragraph',
322
+ buttonTextStyle: 'buttonText',
323
+ };
324
+
325
+ // Payment (Continue/Done) and Support Me (the same widget, `Payment.vue`) always show their
326
+ // fixed-label button whenever the section renders — no persisted field holds the label, so
327
+ // there's nothing to check for blank. Shop's fixed-label "View cart" (`Shop.vue:59`) shows only
328
+ // once it has a product to sell; with none, its button (like an empty title) casts no vote.
329
+ const showsFixedLabelButton = (
330
+ contentType: string | undefined,
331
+ fields: Record<string, unknown>,
332
+ ): boolean =>
333
+ contentType === 'request-payment' ||
334
+ contentType === 'support-me' ||
335
+ (contentType === 'shop-section' &&
336
+ Array.isArray(fields.products) &&
337
+ fields.products.length > 0);
338
+
339
+ // One content: its own title/description/paragraph/button-text field, then (images/shapes only)
340
+ // each item's title/paragraph/buttonText against the section's single heading/paragraph/button
341
+ // style. `headingStyle` never has content-level text of its own, so it only votes per item.
342
+ const voteContentFields = (
343
+ tallies: Record<TextRoleFamily, FontTally>,
344
+ fields: Record<string, unknown>,
345
+ options: TextStyleOptions,
346
+ siteFont: string,
347
+ ): void => {
348
+ const contentType = fields.type as string | undefined;
349
+
350
+ for (const key of [
351
+ 'titleStyle',
352
+ 'descriptionStyle',
353
+ 'paragraphStyle',
354
+ 'buttonTextStyle',
355
+ ] as const) {
356
+ const style = fields[key];
357
+
358
+ if (!style || typeof style !== 'object') continue;
359
+
360
+ if (
361
+ key === 'buttonTextStyle' &&
362
+ showsFixedLabelButton(contentType, fields)
363
+ ) {
364
+ // A fixed-label button's text is an i18n string, never model data — there's nothing to
365
+ // check for blank, so vote its font directly rather than through `voteText`'s text gate.
366
+ tallies.button.add(
367
+ drawnFontFamily(style as TextStyleDeclaration, options, siteFont),
368
+ );
369
+
370
+ continue;
371
+ }
372
+
373
+ // `pairedRteTextField` returns nothing for `buttonTextStyle` (never RTE-paired) and for a
374
+ // button content's own `titleStyle` (a link's plain-text label) — `CONTENT_LEVEL_TEXT_FIELD`
375
+ // is exactly the fallback those two need.
376
+ const textField =
377
+ pairedRteTextField(contentType ?? '', key) ??
378
+ CONTENT_LEVEL_TEXT_FIELD[key];
379
+ // The reconnect's own family (`contentFieldReconnectSpec`), so the vote and the reconnect
380
+ // share one classification: Button text for a link button's `titleStyle` or any
381
+ // `buttonTextStyle`, otherwise fixed by the key.
382
+ const family = contentFieldReconnectSpec(contentType, key).family;
383
+
384
+ if (!textField || !family) continue;
385
+
386
+ voteText(
387
+ tallies[family],
388
+ style as TextStyleDeclaration,
389
+ fields[textField],
390
+ options,
391
+ siteFont,
392
+ );
393
+ }
394
+
395
+ const items = fields.items;
396
+
397
+ if (!Array.isArray(items)) return;
398
+
399
+ // Items belong only to `MediaSection`s (images/shapes) — the section's own `paragraphStyle`
400
+ // never also pairs an RTE field at content level there (only `about-section` does, and it has
401
+ // no items), so an item's paragraph vote never double-counts the section's own.
402
+ const perItemVotes: [
403
+ TextRoleFamily,
404
+ TextStyleDeclaration | undefined,
405
+ string,
406
+ ][] = [
407
+ [
408
+ 'headings',
409
+ fields.headingStyle as TextStyleDeclaration | undefined,
410
+ 'title',
411
+ ],
412
+ [
413
+ 'paragraphs',
414
+ fields.paragraphStyle as TextStyleDeclaration | undefined,
415
+ 'paragraph',
416
+ ],
417
+ [
418
+ 'button',
419
+ fields.buttonTextStyle as TextStyleDeclaration | undefined,
420
+ 'buttonText',
421
+ ],
422
+ ];
423
+
424
+ // A left/right-aligned images-section renders only its first few items
425
+ // (`view-model.util.ts` `mapToImagesSectionViewModel`) — an item past that cutoff never shows,
426
+ // so it casts no vote either.
427
+ const displayStyle = fields.displayStyle;
428
+ const renderedItems =
429
+ contentType === 'images-section' &&
430
+ (displayStyle === ALIGN_LEFT_ALIGNED ||
431
+ displayStyle === ALIGN_RIGHT_ALIGNED)
432
+ ? (items as Record<string, unknown>[]).slice(
433
+ 0,
434
+ MAX_IMAGES_SECTION_ALIGNMENT_ITEMS_LENGTH,
435
+ )
436
+ : (items as Record<string, unknown>[]);
437
+
438
+ for (const item of renderedItems) {
439
+ if (!item || typeof item !== 'object') continue;
440
+
441
+ for (const [family, itemStyle, textField] of perItemVotes) {
442
+ if (itemStyle) {
443
+ voteText(
444
+ tallies[family],
445
+ itemStyle,
446
+ item[textField],
447
+ options,
448
+ siteFont,
449
+ );
450
+ }
451
+ }
452
+ }
453
+ };
454
+
455
+ // The header button renders only with a non-blank label (`view-model.util.ts:1215`) — `isVisible`
456
+ // alone isn't enough, or a visible-but-blank desktop button would wrongly stop the mobile one
457
+ // (which might otherwise render) from getting a turn.
458
+ const headerButtonRenders = (
459
+ headerButton: HeaderButton | undefined,
460
+ ): headerButton is HeaderButton =>
461
+ !!headerButton?.isVisible && !!headerButton.text?.trim();
462
+
463
+ /**
464
+ * A2 — count the font the site's title/heading, description/paragraph and button text shows
465
+ * (`business-rules.md` *Text style roles*), and give each family the winner, before B and C link
466
+ * equal text to it. Runs on the untouched v21 model, after A and before B: a field's font is read
467
+ * the same way B will read its look (`drawnFontFamily`), so the count and the reconnect can't
468
+ * disagree about what a field showed. Only `fontFamily` changes on the ten canonical roles — size,
469
+ * weight and line height stay at their §4 defaults. A family with no vote keeps Lato.
470
+ */
471
+ export const seedRoleFonts = (
472
+ brandPageModel: BrandPageModel,
473
+ options: TextStyleOptions,
474
+ ): void => {
475
+ const siteFont = siteTextFontName(brandPageModel) ?? LATO;
476
+ const tallies: Record<TextRoleFamily, FontTally> = {
477
+ headings: new FontTally(),
478
+ paragraphs: new FontTally(),
479
+ button: new FontTally(),
480
+ };
481
+
482
+ // The header button votes once — the desktop header's, else the mobile one (Q12c).
483
+ for (const header of [
484
+ brandPageModel.pageHeaderDesktop,
485
+ brandPageModel.pageHeaderMobile,
486
+ ]) {
487
+ const headerButton = header?.headerButton;
488
+
489
+ if (!headerButtonRenders(headerButton)) continue;
490
+
491
+ voteText(
492
+ tallies.button,
493
+ headerButton.buttonTextStyle ?? {
494
+ textStyleType: TEXT_STYLE_TYPES.buttons,
495
+ },
496
+ headerButton.text,
497
+ options,
498
+ siteFont,
499
+ );
500
+ break;
501
+ }
502
+
503
+ for (const page of sitePageOrder(brandPageModel)) {
504
+ for (const content of page.contents ?? []) {
505
+ voteContentFields(
506
+ tallies,
507
+ content as unknown as Record<string, unknown>,
508
+ options,
509
+ siteFont,
510
+ );
511
+ }
512
+ }
513
+
514
+ // brand.contact only, and only once the widget is actually turned on (`Page.mixin.ts:535`) and the
515
+ // site has a profile section for it to attach to (`Page.mixin.ts` `shouldShowSaveContactWidget`,
516
+ // `checkHasProfileContent`) — otherwise it never renders, the same "nothing to show" rule as an
517
+ // empty title.
518
+ if (
519
+ brandPageModel.brandPageType === BRAND_PAGE_TYPES.brandContact &&
520
+ brandPageModel.saveContactSettings?.isSavingEnabled !== false &&
521
+ hasProfileContent(brandPageModel)
522
+ ) {
523
+ tallies.button.add(
524
+ drawnFontFamily(
525
+ brandPageModel.saveContactSettings?.buttonTextStyle ?? {
526
+ textStyleType: TEXT_STYLE_TYPES.buttons,
527
+ },
528
+ options,
529
+ siteFont,
530
+ ),
531
+ );
532
+ }
533
+
534
+ // The canonical roles normally pre-exist (the model constructor seeds all 10); guard
535
+ // defensively for pre-10-role metadata rather than assume it (as `seedRoleColours` does). A
536
+ // family with no vote keeps Lato — never the site font, which is only what an UNCOUNTED field
537
+ // inherits (`drawnFontFamily`), not a family-wide default.
538
+ for (const family of Object.keys(tallies) as TextRoleFamily[]) {
539
+ const winner = tallies[family].winner(LATO);
540
+
541
+ for (const role of FAMILY_TIERS[family]) {
542
+ if (options[role]) options[role].style.fontFamily = winner;
543
+ }
544
+ }
545
+ };
546
+
547
+ /**
548
+ * B — seed the absent button styles, then reconnect every text field outside the ten to its
549
+ * nearest role, keeping the look production drew: a field on a role drew only that role's
550
+ * typography (`drawnBeforeCascade`). After this every text field links one of the ten (R14).
551
+ */
552
+ const isUnset = (value: unknown): boolean =>
553
+ value === undefined || value === null || value === '';
554
+
555
+ const isUnlinkedLegacyStyle = (
556
+ style: unknown,
557
+ ): style is Record<string, unknown> => {
558
+ if (!style || typeof style !== 'object') return false;
559
+
560
+ const type = (style as Record<string, unknown>).textStyleType;
561
+
562
+ return (
563
+ !isCanonicalTextStyleType(type as string | undefined) &&
564
+ !isLegacyTextStyleType(type as string | undefined)
565
+ );
566
+ };
567
+
568
+ const setIfUnset = (
569
+ style: Record<string, unknown>,
570
+ key: string,
571
+ value: unknown,
572
+ ): void => {
573
+ if (isUnset(style[key]) && !isUnset(value)) style[key] = value;
574
+ };
575
+
576
+ const styleRecord = (value: unknown): Record<string, unknown> =>
577
+ value && typeof value === 'object' && !Array.isArray(value)
578
+ ? (value as Record<string, unknown>)
579
+ : {};
580
+
581
+ /**
582
+ * B0 — production composed three no-role text styles in its view-model layer. Recreate those
583
+ * values once on the persisted field before B picks the nearest canonical role. A valid legacy
584
+ * role was resolved instead of these component defaults, so it must remain untouched.
585
+ */
586
+ const materialiseNoRoleRendererDefaults = (
587
+ brandPageModel: BrandPageModel,
588
+ ): void => {
589
+ for (const page of brandPageModel.pages ?? []) {
590
+ for (const content of page.contents ?? []) {
591
+ const fields = content as unknown as Record<string, unknown>;
592
+
593
+ if (content.type === 'mailing-list') {
594
+ const style = fields.titleStyle;
595
+
596
+ if (isUnlinkedLegacyStyle(style)) {
597
+ setIfUnset(style, 'fontSize', FONT_SIZE_BODY);
598
+ setIfUnset(style, 'fontWeight', 'bold');
599
+ }
600
+ }
601
+
602
+ if (content.type === 'support-me') {
603
+ const style = fields.titleStyle;
604
+
605
+ if (isUnlinkedLegacyStyle(style)) {
606
+ setIfUnset(style, 'fontWeight', 'bold');
607
+ }
608
+ }
609
+
610
+ if (content.type === 'text') {
611
+ const original = styleRecord(fields.textStyle);
612
+ const isUnlinked = isUnlinkedLegacyStyle(original);
613
+
614
+ // Production's text mapper merged these deprecated sibling objects before the style
615
+ // object. Alignment and colour mattered even on an old role; textSize and the 1.5
616
+ // default only mattered without one, because a role replaced all typography.
617
+ fields.textStyle = isUnlinked
618
+ ? {
619
+ lineHeight: LINE_HEIGHT_BODY,
620
+ ...styleRecord(fields.textSize),
621
+ ...styleRecord(fields.textAlignment),
622
+ ...styleRecord(fields.textColor),
623
+ ...styleRecord(original),
624
+ }
625
+ : {
626
+ ...styleRecord(fields.textAlignment),
627
+ ...styleRecord(fields.textColor),
628
+ ...styleRecord(original),
629
+ };
630
+
631
+ delete fields.textSize;
632
+ delete fields.textAlignment;
633
+ delete fields.textColor;
634
+ }
635
+ }
636
+ }
637
+ };
638
+
639
+ const legacyRenderedDefaults: RenderedDefaultsForContent = (content, key) => {
640
+ const style = content[key];
641
+
642
+ if (!isUnlinkedLegacyStyle(style)) return undefined;
643
+
644
+ if (content.type === 'mailing-list' && key === 'titleStyle') {
645
+ return { fontSize: FONT_SIZE_BODY, fontWeight: 'bold' };
646
+ }
647
+
648
+ if (content.type === 'support-me' && key === 'titleStyle') {
649
+ return { fontWeight: 'bold' };
650
+ }
651
+
652
+ if (content.type === 'text' && key === 'textStyle') {
653
+ return { lineHeight: LINE_HEIGHT_BODY };
654
+ }
655
+
656
+ return undefined;
657
+ };
658
+
659
+ export const reconnectContentRoles = (
660
+ brandPageModel: BrandPageModel,
661
+ targets: LegacyTargetMap,
662
+ options: TextStyleOptions,
663
+ ): void => {
664
+ seedAbsentButtonStyles(brandPageModel);
665
+ materialiseNoRoleRendererDefaults(brandPageModel);
666
+ reconnectTextStyleRoles(brandPageModel, targets, options, {
667
+ drawnBeforeCascade: true,
668
+ renderedDefaultsForContent: legacyRenderedDefaults,
669
+ });
670
+ };
671
+
672
+ // ── BP-5969 ADR-0020: colour decouple (jobs D, E, G) ──────────────────────────
673
+ // Appended to the appearance-preserving A/B/C above. Colour is read via bracket access
674
+ // because `GlobalTextStyleDeclaration.color` is retired from the typed model.
675
+
676
+ type RawStyleObject = {
677
+ color?: string;
678
+ textStyleType?: string;
679
+ applyAutoScale?: boolean;
680
+ textAlign?: string;
681
+ fontWeight?: string;
682
+ };
683
+
684
+ type NoRoleTextStyles = WeakMap<object, Set<string>>;
685
+
686
+ const hasNoRole = (style: unknown): boolean => {
687
+ if (!style || typeof style !== 'object') return false;
688
+
689
+ const textStyleType = (style as RawStyleObject).textStyleType;
690
+
691
+ return (
692
+ !isCanonicalTextStyleType(textStyleType) &&
693
+ !isLegacyTextStyleType(textStyleType)
694
+ );
695
+ };
696
+
697
+ /**
698
+ * Job B assigns a canonical role to every unlinked field. Job D must still use the colour the
699
+ * field rendered with before that assignment: its own colour, container default, then the base coat
700
+ * (never the role B selected merely for typography). Keep the location rather than the style object,
701
+ * because reconnect replaces each style object.
702
+ */
703
+ const captureNoRoleTextStyles = (
704
+ brandPageModel: BrandPageModel,
705
+ ): NoRoleTextStyles => {
706
+ const locations: NoRoleTextStyles = new WeakMap();
707
+ const record = (holder: Record<string, unknown>, key: string): void => {
708
+ if (!hasNoRole(holder[key])) return;
709
+
710
+ const keys = locations.get(holder) ?? new Set<string>();
711
+
712
+ keys.add(key);
713
+ locations.set(holder, keys);
714
+ };
715
+
716
+ for (const page of brandPageModel.pages ?? []) {
717
+ for (const content of page.contents ?? []) {
718
+ const fields = content as unknown as Record<string, unknown>;
719
+
720
+ for (const key of Object.keys(CONTENT_TEXT_STYLE_PROPERTY_KEYS)) {
721
+ record(fields, key);
722
+ }
723
+
724
+ const textItems = fields.textItems;
725
+
726
+ if (Array.isArray(textItems)) {
727
+ for (const item of textItems) {
728
+ if (item && typeof item === 'object') {
729
+ record(item as Record<string, unknown>, 'textStyle');
730
+ }
731
+ }
732
+ }
733
+ }
734
+ }
735
+
736
+ for (const footer of [
737
+ brandPageModel.pageFooterDesktop,
738
+ brandPageModel.pageFooterMobile,
739
+ ]) {
740
+ if (footer && typeof footer === 'object') {
741
+ record(footer as unknown as Record<string, unknown>, 'copyrightStyle');
742
+ }
743
+ }
744
+
745
+ return locations;
746
+ };
747
+
748
+ /**
749
+ * An RTE-eligible field that is a plain string, not a Tiptap doc. On an old site nothing
750
+ * converts plain text → doc (migration-20 only converts HTML), so such a field renders via
751
+ * `TextWrapper`'s PLAIN path from `style.color` — it has no run mark to hold colour. So its
752
+ * colour must be baked onto (D) and never stripped from (G) the style object; only a genuine
753
+ * doc's colour moves into a mark. A non-string field is NOT plain text: a real doc holds its
754
+ * colour in the mark, and an absent (`undefined`/`null`) field renders nothing — either way G
755
+ * safely strips the (now inert) style-object colour. An empty string `''` DOES count as plain
756
+ * text and is kept: a field later filled with plain text must not have lost its colour.
757
+ * `convertPlainRteFields` completes that conversion in this migration; regular runtime paths do not rewrap.
758
+ */
759
+ const isPlainTextValue = (value: unknown): value is string =>
760
+ typeof value === 'string';
761
+
762
+ /** A linked role's colour, read defensively (the typed property is retired). */
763
+ const roleColour = (
764
+ options: TextStyleOptions,
765
+ textStyleType: string | undefined,
766
+ ): string | undefined =>
767
+ textStyleType
768
+ ? (((
769
+ options[textStyleType as TextStyleType]?.style as unknown as
770
+ | Record<string, unknown>
771
+ | undefined
772
+ )?.color as string | undefined) ?? undefined)
773
+ : undefined;
774
+
775
+ /**
776
+ * D — freeze each text element's currently-resolved colour so removing the base coat (F)
777
+ * and the role colour (E) changes no pixels. migration-21 already baked element→frame→role
778
+ * colour into RTE runs, so the only uncoloured runs reaching here inherit the base coat;
779
+ * non-RTE fields (21 left them alone) resolve element→container-default→role→base coat.
780
+ * `buttonTextStyle` and a link button's `titleStyle` are excluded — the button label takes its
781
+ * colour from `buttonStyles`, never the base coat. A social-links section's unset icon fill is
782
+ * frozen here too.
783
+ */
784
+ export const bakeElementColours = (
785
+ brandPageModel: BrandPageModel,
786
+ options: TextStyleOptions,
787
+ noRoleTextStyles: NoRoleTextStyles = new WeakMap(),
788
+ ): void => {
789
+ const baseCoat = roleColour(options, 'paragraph1');
790
+
791
+ for (const page of brandPageModel.pages ?? []) {
792
+ for (const content of page.contents ?? []) {
793
+ const fields = content as unknown as Record<string, unknown>;
794
+ const containerDefaults = containerTextColorDefaults(
795
+ content,
796
+ brandPageModel.styles,
797
+ brandPageModel.brandPageType,
798
+ );
799
+ const rteStyleFields = new Set(rteStyleFieldsFor(content.type));
800
+
801
+ const resolvedColour = (
802
+ style: RawStyleObject | undefined,
803
+ holder: object,
804
+ key: string,
805
+ ): string | undefined =>
806
+ style?.color ||
807
+ containerDefaults[key as ContentTextStylePropertyKey] ||
808
+ (noRoleTextStyles.get(holder)?.has(key)
809
+ ? undefined
810
+ : roleColour(options, style?.textStyleType)) ||
811
+ baseCoat;
812
+
813
+ // Non-RTE style objects → bake onto `style.color`.
814
+ for (const key of Object.keys(CONTENT_TEXT_STYLE_PROPERTY_KEYS)) {
815
+ if (key === 'buttonTextStyle' || rteStyleFields.has(key)) continue;
816
+
817
+ // A link button's label sits on the global button fill, not the page the base coat
818
+ // contrasts: left bare it inherits the button text colour (`isButtonLabelField`).
819
+ if (isButtonLabelField(content, key as ContentTextStylePropertyKey))
820
+ continue;
821
+
822
+ const style = fields[key] as RawStyleObject | undefined;
823
+
824
+ if (!style || !isBlankColorValue(style.color)) continue;
825
+
826
+ const resolved = resolvedColour(style, fields, key);
827
+
828
+ if (!isBlankColorValue(resolved)) style.color = resolved;
829
+ }
830
+
831
+ // RTE-eligible fields. A real doc holds colour in its run marks → fill the runs the mark
832
+ // left uncoloured (the base-coat stragglers). A plain string (an old site never converted
833
+ // to a doc) has NO mark, so its colour lives on the style object → bake it there, like a
834
+ // non-RTE field; G then leaves that colour alone (it only strips when a doc holds it).
835
+ for (const styleField of rteStyleFields) {
836
+ const textField = pairedRteTextField(content.type, styleField);
837
+
838
+ if (!textField) continue;
839
+
840
+ const doc = fields[textField];
841
+
842
+ if (isPlainTextValue(doc)) {
843
+ const style = fields[styleField] as RawStyleObject | undefined;
844
+
845
+ if (style && isBlankColorValue(style.color)) {
846
+ const resolved = resolvedColour(style, fields, styleField);
847
+
848
+ if (!isBlankColorValue(resolved)) style.color = resolved;
849
+ }
850
+
851
+ continue;
852
+ }
853
+
854
+ if (!collectRteTextColors(doc)?.hasUncolouredRuns) continue;
855
+
856
+ const resolved = resolvedColour(
857
+ fields[styleField] as RawStyleObject | undefined,
858
+ fields,
859
+ styleField,
860
+ );
861
+
862
+ if (!isBlankColorValue(resolved)) {
863
+ fields[textField] =
864
+ fillUncolouredRteText(doc, resolved as string) ?? doc;
865
+ }
866
+ }
867
+
868
+ // Social icons had no colour of their own: they painted the base coat (the paragraphs
869
+ // seed, or `currentColor` under `:root`). Freeze it; with no base coat, the title's
870
+ // contrast colour, so every icon ends with a stored fill.
871
+ if (content.type === 'social-links') {
872
+ const iconFillStyles = (fields.iconFillStyles ?? {}) as Record<
873
+ string,
874
+ unknown
875
+ >;
876
+
877
+ if (isBlankColorValue(iconFillStyles.fill as string | undefined)) {
878
+ const fill = !isBlankColorValue(baseCoat)
879
+ ? baseCoat
880
+ : titleSurfaceContrastFill(
881
+ content,
882
+ brandPageModel.styles,
883
+ brandPageModel.brandPageType,
884
+ );
885
+
886
+ if (!isBlankColorValue(fill)) {
887
+ fields.iconFillStyles = { ...iconFillStyles, fill };
888
+ }
889
+ }
890
+ }
891
+
892
+ // brandSite text `textItems` — same rule per item (RTE doc, else the style object).
893
+ const textItems = fields.textItems as
894
+ | { text?: unknown; textStyle?: RawStyleObject }[]
895
+ | undefined;
896
+
897
+ if (Array.isArray(textItems)) {
898
+ for (const item of textItems) {
899
+ if (!item || typeof item !== 'object') continue;
900
+
901
+ const resolved = resolvedColour(item.textStyle, item, 'textStyle');
902
+
903
+ if (isBlankColorValue(resolved)) continue;
904
+
905
+ if (collectRteTextColors(item.text)?.hasUncolouredRuns) {
906
+ item.text =
907
+ fillUncolouredRteText(item.text, resolved as string) ?? item.text;
908
+ } else if (
909
+ item.textStyle &&
910
+ isBlankColorValue(item.textStyle.color)
911
+ ) {
912
+ item.textStyle.color = resolved;
913
+ }
914
+ }
915
+ }
916
+ }
917
+ }
918
+
919
+ // Footer copyright is non-RTE text that resolved through role → base coat, but lives
920
+ // OUTSIDE `pages[].contents`, so freeze it here too — else it loses its colour when E
921
+ // clears the role and F removes the base coat (the copyright-on-dark-footer regression).
922
+ for (const footer of [
923
+ brandPageModel.pageFooterDesktop,
924
+ brandPageModel.pageFooterMobile,
925
+ ]) {
926
+ const style = footer?.copyrightStyle as RawStyleObject | undefined;
927
+
928
+ if (!style || !isBlankColorValue(style.color)) continue;
929
+
930
+ const resolved =
931
+ (noRoleTextStyles.get(footer)?.has('copyrightStyle')
932
+ ? undefined
933
+ : roleColour(options, style.textStyleType)) || baseCoat;
934
+
935
+ if (!isBlankColorValue(resolved)) style.color = resolved;
936
+ }
937
+ };
938
+
939
+ /** E — clear the retired role colour from every role definition (run after D reads it). */
940
+ export const clearRoleColours = (options: TextStyleOptions): void => {
941
+ for (const key of Object.keys(options)) {
942
+ const style = options[key as TextStyleType]?.style as unknown as
943
+ | Record<string, unknown>
944
+ | undefined;
945
+
946
+ if (style && 'color' in style) delete style.color;
947
+ }
948
+ };
949
+
950
+ /**
951
+ * G — colour-decouple the RTE-paired style objects: remove ONLY `color` (D baked it into the
952
+ * mark). Everything else stays — a block-level typography override (a title set to a non-role
953
+ * font/size, `textAlign`, `applyAutoScale`, the role link) is genuine state the renderer
954
+ * applies via `overrideTypographyStyle`; dropping it would lose the override through migration.
955
+ * So the RTE style object becomes `Omit<TextStyleDeclaration, 'color'>`, not a bare role link.
956
+ * Non-RTE per-item styles (`headingStyle`, shapes/images `paragraphStyle`, `testimonialStyle`,
957
+ * …) are not RTE and are untouched.
958
+ */
959
+ const stripRteStyleColour = (style: RawStyleObject | undefined): void => {
960
+ if (style && 'color' in style) delete style.color;
961
+ };
962
+
963
+ export const stripRteStyleColours = (brandPageModel: BrandPageModel): void => {
964
+ for (const page of brandPageModel.pages ?? []) {
965
+ for (const content of page.contents ?? []) {
966
+ const fields = content as unknown as Record<string, unknown>;
967
+
968
+ for (const styleField of rteStyleFieldsFor(content.type)) {
969
+ const textField = pairedRteTextField(content.type, styleField);
970
+
971
+ // A plain-string field keeps its style-object colour — that's its only home (D baked it
972
+ // there, there's no mark). A real doc holds colour in its mark, so strip the object.
973
+ if (textField && isPlainTextValue(fields[textField])) continue;
974
+
975
+ stripRteStyleColour(fields[styleField] as RawStyleObject | undefined);
976
+ }
977
+
978
+ const textItems = fields.textItems as
979
+ | { text?: unknown; textStyle?: RawStyleObject }[]
980
+ | undefined;
981
+
982
+ if (Array.isArray(textItems)) {
983
+ for (const item of textItems) {
984
+ if (!item || typeof item !== 'object') continue;
985
+
986
+ if (isPlainTextValue(item.text)) continue; // plain-text item keeps its baked colour
987
+
988
+ stripRteStyleColour(item.textStyle);
989
+ }
990
+ }
991
+ }
992
+ }
993
+ };
994
+
995
+ /** H — delete the retired site text font and the footers' stray copies. */
996
+ export const deleteTextFontFamily = (brandPageModel: BrandPageModel): void => {
997
+ const holders = [
998
+ brandPageModel.styles?.textStyles,
999
+ brandPageModel.pageFooterDesktop,
1000
+ brandPageModel.pageFooterMobile,
1001
+ ] as unknown as (Record<string, unknown> | undefined)[];
1002
+
1003
+ for (const holder of holders) {
1004
+ if (holder) delete holder['textFontFamily'];
1005
+ }
1006
+ };
1007
+
1008
+ /**
1009
+ * B1 — convert plain-text RTE-eligible fields to Tiptap docs, so every such field is a doc at
1010
+ * load and the editor never runs its plain→RTE "rewrap" (the runtime anti-pattern this retires).
1011
+ *
1012
+ * Only PLAIN strings are converted: migration-20 already did HTML→doc, and the plain-by-design
1013
+ * sections (`shop-section`/`request-payment`/`support-me`) are excluded because `rteStyleFieldsFor`
1014
+ * returns `[]` for them — they render via `TextWrapper`'s plain path and keep their `style.color`.
1015
+ * A converted field's colour is filled by D (into the mark) and its style-object colour stripped
1016
+ * by G, exactly like any other doc.
1017
+ *
1018
+ * Runs AFTER C (see orchestrator) so C only ever sees editor-baked docs and its per-run typography
1019
+ * bake operates on the real runs, not a freshly-converted placeholder.
1020
+ *
1021
+ * Error-tolerant like migration-20: a parse failure (or no DOM parser in this runtime) leaves the
1022
+ * plain string in place, and Path A's D/G plain-text branches keep its colour resolvable — so the
1023
+ * two together are total. `textAlign` is stamped onto the block node from the style object, as the
1024
+ * runtime conversion (`getUpdatedHTMLFromEditor`) does via `setTextAlign`.
1025
+ *
1026
+ * The converted run is then baked with this migration's frozen typography resolver, so it carries all
1027
+ * 7 typography attrs as a role var (follows role edits) or a literal override, not colour alone. Job C
1028
+ * never saw this field (it was still a plain string), so without this bake the run would carry only
1029
+ * colour and the maker toolbar (which reads the run, not the style object) would fall back to the role,
1030
+ * ignoring a block-level override (e.g. a banner title set to a non-role font/size). It stays
1031
+ * appearance-preserving: the fill is idempotent over an already-baked run, so the persisted doc renders
1032
+ * identically — it is now just self-describing.
1033
+ */
1034
+ const setBlockTextAlign = (
1035
+ doc: JSONContent,
1036
+ textAlign: string | undefined,
1037
+ ): void => {
1038
+ if (!textAlign) return;
1039
+
1040
+ for (const block of doc.content ?? []) {
1041
+ block.attrs = { ...(block.attrs ?? {}), textAlign };
1042
+ }
1043
+ };
1044
+
1045
+ // Snapshot the B1 resolver here rather than calling the live render helper. A versioned migration
1046
+ // defines one permanent v21 -> v22 transformation; later renderer fixes must not change its output.
1047
+ const MIGRATION_RTE_TYPOGRAPHY_ATTRS = [
1048
+ ['fontFamily', '--role-font-family'],
1049
+ ['fontSize', '--role-font-size'],
1050
+ ['lineHeight', '--role-line-height'],
1051
+ ['letterSpacing', '--role-letter-spacing'],
1052
+ ['fontWeight', '--role-font-weight'],
1053
+ ['fontStyle', '--role-font-style'],
1054
+ ['textDecoration', '--role-text-decoration'],
1055
+ ] as const;
1056
+
1057
+ type MigrationRteTypographyAttr =
1058
+ (typeof MIGRATION_RTE_TYPOGRAPHY_ATTRS)[number][0];
1059
+
1060
+ type MigrationRteTypography = Partial<
1061
+ Record<MigrationRteTypographyAttr, string>
1062
+ >;
1063
+
1064
+ const MIGRATION_RTE_NEUTRAL_TYPOGRAPHY: Partial<
1065
+ Record<MigrationRteTypographyAttr, string>
1066
+ > = {
1067
+ fontWeight: 'normal',
1068
+ fontStyle: 'normal',
1069
+ textDecoration: 'none',
1070
+ letterSpacing: 'normal',
1071
+ };
1072
+
1073
+ const UNQUOTED_FONT_FAMILY_TOKEN = /^-?[A-Za-z_][A-Za-z0-9_-]*$/;
1074
+
1075
+ const migrationCssFontFamilyValue = (value: string): string =>
1076
+ value
1077
+ .split(',')
1078
+ .map((raw) => {
1079
+ const family = raw.trim();
1080
+
1081
+ if (
1082
+ !family ||
1083
+ family.startsWith('"') ||
1084
+ family.startsWith("'") ||
1085
+ family.startsWith('var(')
1086
+ ) {
1087
+ return family;
1088
+ }
1089
+
1090
+ return family
1091
+ .split(/\s+/)
1092
+ .every((token) => UNQUOTED_FONT_FAMILY_TOKEN.test(token))
1093
+ ? family
1094
+ : `"${family}"`;
1095
+ })
1096
+ .filter(Boolean)
1097
+ .join(', ');
1098
+
1099
+ type MigrationRteNode = {
1100
+ type?: string;
1101
+ marks?: { type: string; attrs?: Record<string, unknown> }[];
1102
+ content?: MigrationRteNode[];
1103
+ };
1104
+
1105
+ const migrationRoleVarRef = (attr: MigrationRteTypographyAttr): string => {
1106
+ const variable = MIGRATION_RTE_TYPOGRAPHY_ATTRS.find(
1107
+ ([name]) => name === attr,
1108
+ )?.[1];
1109
+
1110
+ return `var(${variable})`;
1111
+ };
1112
+
1113
+ const migrationRunTypographyFillValue = (
1114
+ attr: MigrationRteTypographyAttr,
1115
+ roleStyle: MigrationRteTypography | undefined,
1116
+ style: MigrationRteTypography | undefined,
1117
+ ): string | undefined => {
1118
+ const roleValue = roleStyle?.[attr];
1119
+ const blockValue = style?.[attr];
1120
+ const neutral = MIGRATION_RTE_NEUTRAL_TYPOGRAPHY[attr];
1121
+ const hasRole = roleValue != null && roleValue !== '';
1122
+ const hasBlock = blockValue != null && blockValue !== '';
1123
+
1124
+ if (roleStyle == null) return hasBlock ? blockValue : undefined;
1125
+
1126
+ const effectiveRole = hasRole ? roleValue : neutral;
1127
+
1128
+ if (hasBlock && blockValue !== effectiveRole) return blockValue;
1129
+
1130
+ return hasRole || neutral != null ? migrationRoleVarRef(attr) : undefined;
1131
+ };
1132
+
1133
+ const fillMigration22RunTypography = (
1134
+ doc: JSONContent,
1135
+ roleStyle: MigrationRteTypography | undefined,
1136
+ style: MigrationRteTypography | undefined,
1137
+ ): JSONContent => {
1138
+ const clone = JSON.parse(JSON.stringify(doc)) as MigrationRteNode;
1139
+ const runs: MigrationRteNode[] = [];
1140
+
1141
+ const collect = (node: MigrationRteNode | undefined): void => {
1142
+ if (!node) return;
1143
+
1144
+ if (node.type === 'text') runs.push(node);
1145
+
1146
+ node.content?.forEach(collect);
1147
+ };
1148
+
1149
+ collect(clone);
1150
+
1151
+ for (const run of runs) {
1152
+ let mark = run.marks?.find((candidate) => candidate.type === 'textStyle');
1153
+
1154
+ for (const [attr] of MIGRATION_RTE_TYPOGRAPHY_ATTRS) {
1155
+ const existing = mark?.attrs?.[attr];
1156
+
1157
+ if (existing !== undefined && existing !== null && existing !== '')
1158
+ continue;
1159
+
1160
+ let value = migrationRunTypographyFillValue(attr, roleStyle, style);
1161
+
1162
+ if (value == null) continue;
1163
+
1164
+ if (attr === 'fontFamily') value = migrationCssFontFamilyValue(value);
1165
+
1166
+ if (!mark) {
1167
+ mark = { type: 'textStyle', attrs: {} };
1168
+ (run.marks ??= []).push(mark);
1169
+ }
1170
+
1171
+ mark.attrs ??= {};
1172
+ mark.attrs[attr] = value;
1173
+ }
1174
+ }
1175
+
1176
+ return clone as JSONContent;
1177
+ };
1178
+
1179
+ // B1 converts a plain string after job C has run, so it needs C3's not-bold protection locally
1180
+ // too. Keep the whole B1 transform frozen: changing `rte-role-lift.util.ts` must not alter v22.
1181
+ const pinMigration22RunWeight = (
1182
+ doc: JSONContent,
1183
+ roleWeight: string | undefined,
1184
+ blockWeight: string | undefined,
1185
+ ): void => {
1186
+ if (
1187
+ blockWeight === undefined ||
1188
+ blockWeight === null ||
1189
+ blockWeight === '' ||
1190
+ blockWeight === roleWeight
1191
+ ) {
1192
+ return;
1193
+ }
1194
+
1195
+ const runs: MigrationRteNode[] = [];
1196
+ const collect = (node: MigrationRteNode | undefined): void => {
1197
+ if (!node) return;
1198
+
1199
+ if (node.type === 'text') runs.push(node);
1200
+
1201
+ node.content?.forEach(collect);
1202
+ };
1203
+
1204
+ collect(doc as MigrationRteNode);
1205
+
1206
+ for (const run of runs) {
1207
+ let mark = run.marks?.find((candidate) => candidate.type === 'textStyle');
1208
+
1209
+ if (mark?.attrs?.fontWeight != null && mark.attrs.fontWeight !== '')
1210
+ continue;
1211
+
1212
+ if (!mark) {
1213
+ mark = { type: 'textStyle', attrs: {} };
1214
+ (run.marks ??= []).push(mark);
1215
+ }
1216
+
1217
+ mark.attrs ??= {};
1218
+ mark.attrs.fontWeight = blockWeight;
1219
+ }
1220
+ };
1221
+
1222
+ export const convertPlainRteFields = async (
1223
+ brandPageModel: BrandPageModel,
1224
+ options: TextStyleOptions,
1225
+ ): Promise<void> => {
1226
+ let parser: HtmlParser;
1227
+
1228
+ try {
1229
+ parser = await resolveHtmlParser();
1230
+ } catch (error) {
1231
+ // No DOM parser here (e.g. jsdom failed to load on the server). Skip conversion — plain
1232
+ // strings survive to D/G, whose Path A branches keep their colour. Mirrors migration-20.
1233
+ console.error(
1234
+ 'migration-22: no HTML parser available, skipping plain→RTE conversion',
1235
+ error,
1236
+ );
1237
+
1238
+ return;
1239
+ }
1240
+
1241
+ const convert = (
1242
+ value: unknown,
1243
+ style: RawStyleObject | undefined,
1244
+ ): JSONContent | undefined => {
1245
+ if (!isPlainTextValue(value) || value.length === 0) return undefined;
1246
+
1247
+ try {
1248
+ // Pin the schema to v22 too: B1's structure and its attr-fill snapshot together define
1249
+ // the permanent v21 -> v22 result.
1250
+ const doc = plainTextToRteJson(value, parser, 22);
1251
+
1252
+ if (!doc) return undefined;
1253
+
1254
+ setBlockTextAlign(doc, style?.textAlign);
1255
+
1256
+ // Bake the block override + role typography onto the bare run (job C skipped this field
1257
+ // while it was a plain string) so the doc is self-describing for the maker toolbar.
1258
+ const roleStyle = style?.textStyleType
1259
+ ? (options[style.textStyleType as TextStyleType]?.style as
1260
+ | MigrationRteTypography
1261
+ | undefined)
1262
+ : undefined;
1263
+
1264
+ // C3 (before the fill): pin a not-bold legacy block's weight as a literal so the fill can't
1265
+ // treat its `normal` as inert and let the run inherit a bold heading tier. The plain string had
1266
+ // no bold marks, so every run is bare — the fill then keeps this literal and completes the rest.
1267
+ pinMigration22RunWeight(doc, roleStyle?.fontWeight, style?.fontWeight);
1268
+
1269
+ return fillMigration22RunTypography(
1270
+ doc,
1271
+ roleStyle,
1272
+ style as MigrationRteTypography,
1273
+ );
1274
+ } catch (error) {
1275
+ // Leave the plain string; Path A keeps its colour resolvable.
1276
+ console.error(
1277
+ 'migration-22: failed to convert plain RTE field, leaving as text',
1278
+ error,
1279
+ );
1280
+
1281
+ return undefined;
1282
+ }
1283
+ };
1284
+
1285
+ for (const page of brandPageModel.pages ?? []) {
1286
+ for (const content of page.contents ?? []) {
1287
+ const fields = content as unknown as Record<string, unknown>;
1288
+
1289
+ for (const styleField of rteStyleFieldsFor(content.type)) {
1290
+ const textField = pairedRteTextField(content.type, styleField);
1291
+
1292
+ if (!textField) continue;
1293
+
1294
+ const style = fields[styleField] as RawStyleObject | undefined;
1295
+ const doc = convert(fields[textField], style);
1296
+
1297
+ if (doc) fields[textField] = doc;
1298
+ }
1299
+
1300
+ const textItems = fields.textItems as
1301
+ | { text?: unknown; textStyle?: RawStyleObject }[]
1302
+ | undefined;
1303
+
1304
+ if (Array.isArray(textItems)) {
1305
+ for (const item of textItems) {
1306
+ if (!item || typeof item !== 'object') continue;
1307
+
1308
+ const doc = convert(item.text, item.textStyle);
1309
+
1310
+ if (doc) item.text = doc;
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ };
1316
+
1317
+ export const migration22 = async (
1318
+ migrationResult: MigrationData,
1319
+ _options: MigrationOptions,
1320
+ ): Promise<MigrationData> => {
1321
+ const { brandPageModel } = migrationResult;
1322
+ const options = brandPageModel.styles?.textStyles?.textStyleOptions;
1323
+
1324
+ if (options) {
1325
+ const targets = computeLegacyTargets(options); // per-site legacy → nearest tier
1326
+
1327
+ seedRoleColours(options, targets); // A — seed each old role's colour onto its tier
1328
+ seedRoleFonts(brandPageModel, options); // A2 — count the site's fonts onto each role family
1329
+
1330
+ const noRoleTextStyles = captureNoRoleTextStyles(brandPageModel);
1331
+
1332
+ reconnectContentRoles(brandPageModel, targets, options); // B — seed button styles, reconnect every text field
1333
+ stripLiftContentRte(brandPageModel, options); // C — RTE baked → override
1334
+ await convertPlainRteFields(brandPageModel, options); // B1 — plain text → Tiptap doc (after C)
1335
+ bakeElementColours(brandPageModel, options, noRoleTextStyles); // D — freeze resolved colour
1336
+ clearRoleColours(options); // E — retire role colour
1337
+ stripRteStyleColours(brandPageModel); // G — colour-decouple RTE style objects
1338
+ }
1339
+
1340
+ deleteTextFontFamily(brandPageModel); // H — after every reader of the site text font
1341
+
1342
+ return migrationResult;
1343
+ };