@designcrowd/library.brand-page 5.18.4 → 5.18.5

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 (162) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-DQLtpdLe.js → CreatedOnBrandCrowd-de-de-ciKpCAd9.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-CvEhlADd.js → CreatedOnBrandCrowd-en-us-CZbTS1AZ.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-pYQeTTC0.js → CreatedOnBrandCrowd-es-es-C8MExng5.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-CcE-iCEq.js → CreatedOnBrandCrowd-fr-ca-CO0L9NK2.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-CcE-iCEq.js → CreatedOnBrandCrowd-fr-fr-CO0L9NK2.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-OyhWWWyO.js → CreatedOnBrandCrowd-pt-br-zVDvBF2H.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-OyhWWWyO.js → CreatedOnBrandCrowd-pt-pt-zVDvBF2H.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-DH98FFLS.js → CreatedOnDcom-de-de-WrUSQdjf.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-DK67NN1r.js → CreatedOnDcom-en-us-BqC9YtkL.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-9-QU4BU6.js → CreatedOnDcom-es-es-BzH32Oya.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-U9J9H9VB.js → CreatedOnDcom-fr-ca-D7TYfCW0.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-DqdzB1DJ.js → CreatedOnDcom-fr-fr-DVlyfBtb.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-c4UiWtkB.js → CreatedOnDcom-pt-br-CSRB91ey.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-Do2qJsYp.js → CreatedOnDcom-pt-pt-9KMj5gpc.js} +1 -1
  15. package/lib/src/brand-page/models/navigation-styles.model.d.ts +7 -0
  16. package/lib/src/brand-page/models/navigation-styles.model.js +25 -2
  17. package/lib/src/brand-page/utils/migration/migration-16.d.ts +2 -0
  18. package/lib/src/brand-page/utils/migration/migration-16.js +47 -0
  19. package/lib/src/brand-page/utils/migration.util.js +7 -0
  20. package/lib/src/brand-page-maker/components/action-bar/ActionBar.mixin.d.ts +7 -2
  21. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +7 -2
  22. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +8 -0
  23. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMakerTemplateSettings.mixin.d.ts +7 -2
  24. package/lib/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.js +1 -0
  25. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +87 -2
  26. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.js +5 -0
  27. package/lib/src/brand-page-maker/components/brandpage-settings/ReplaceImageSettingsForBrandPageSettings.mixin.d.ts +7 -2
  28. package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.d.ts +3 -0
  29. package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.js +11 -0
  30. package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +7 -2
  31. package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +7 -2
  32. package/lib/src/brand-page-maker/components/social-share/SocialShare.mixin.d.ts +7 -2
  33. package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +7 -2
  34. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +9 -0
  35. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.js +20 -1
  36. package/lib/src/brand-page-maker/composables/useEventTracker.d.ts +20 -0
  37. package/lib/src/brand-page-maker/composables/useEventTracker.js +17 -0
  38. package/lib/src/brand-page-maker/composables/useUndoRedoFlag.d.ts +17 -0
  39. package/lib/src/brand-page-maker/composables/useUndoRedoFlag.js +25 -0
  40. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.d.ts +41 -2
  41. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +308 -14
  42. package/lib/src/brand-page-maker/stores/history/history-store.d.ts +83 -0
  43. package/lib/src/brand-page-maker/stores/history/history-store.js +495 -0
  44. package/lib/src/brand-page-maker/stores/logo-store/logo-store.d.ts +1 -0
  45. package/lib/src/brand-page-maker/stores/user/user-store.js +1 -0
  46. package/lib/src/bundled-translations-D1q3rSEz.js +175 -0
  47. package/lib/src/bundled-translations.de-DE-BxqLLwbh.js +175 -0
  48. package/lib/src/bundled-translations.es-ES-uh249NlJ.js +175 -0
  49. package/lib/src/bundled-translations.fr-CA-BEQmv2fX.js +175 -0
  50. package/lib/src/bundled-translations.fr-FR-BnNuCojH.js +175 -0
  51. package/lib/src/bundled-translations.pt-BR-CJUOxVlq.js +175 -0
  52. package/lib/src/bundled-translations.pt-PT-Ds9cMEqK.js +175 -0
  53. package/lib/src/bundles/bundled-translations.de-DE.json +3 -1
  54. package/lib/src/bundles/bundled-translations.es-ES.json +3 -1
  55. package/lib/src/bundles/bundled-translations.fr-CA.json +3 -1
  56. package/lib/src/bundles/bundled-translations.fr-FR.json +3 -1
  57. package/lib/src/bundles/bundled-translations.json +3 -1
  58. package/lib/src/bundles/bundled-translations.pt-BR.json +3 -1
  59. package/lib/src/bundles/bundled-translations.pt-PT.json +3 -1
  60. package/lib/src/constants/ui.d.ts +1 -0
  61. package/lib/src/css/library.brand-page-brandCrowd.min.css +77 -82
  62. package/lib/src/css/library.brand-page-brandPage.min.css +77 -83
  63. package/lib/src/css/library.brand-page-designCom.min.css +77 -82
  64. package/lib/src/css/library.brand-page-preview.min.css +77 -82
  65. package/lib/src/index.mjs +62 -60
  66. package/lib/src/{lib-BI3J4Mbk.js → lib-BXbo_N88.js} +35072 -34447
  67. package/lib/src/metadata-builder/builders/reorder-pages-builder.d.ts +13 -0
  68. package/lib/src/metadata-builder/builders/reorder-pages-builder.js +49 -0
  69. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts +87 -2
  70. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.js +5 -0
  71. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.stories.js +1 -0
  72. package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +23 -2
  73. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.d.ts +16 -0
  74. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +7 -2
  75. package/lib/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.d.ts +3 -0
  76. package/lib/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.js +19 -2
  77. package/lib/src/shared/content-settings/components/form-fields-field/FormFieldsField.mixin.js +18 -8
  78. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +64 -0
  79. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.js +6 -0
  80. package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.d.ts +19 -0
  81. package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.js +11 -0
  82. package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +10 -2
  83. package/lib/src/shared/logo-settings/store/editable-logo-store.d.ts +5 -1
  84. package/lib/src/shared/logo-settings/store/editable-logo-store.js +31 -0
  85. package/lib/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.mixin.js +10 -8
  86. package/lib/src/shared/navigation-style-settings/store/index.js +1 -12
  87. package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +24 -2
  88. package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +10 -2
  89. package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +23 -2
  90. package/lib/src/shared/side-bar/components/SideBarTabButton.mixin.d.ts +16 -0
  91. package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +23 -2
  92. package/lib/src/shared/template-settings/components/TemplatesSettings.mixin.d.ts +16 -0
  93. package/package.json +1 -1
  94. package/src/brand-page/components/button/Button.vue +2 -10
  95. package/src/brand-page/components/contact-form/ContactForm.vue +2 -2
  96. package/src/brand-page/components/navigation/navigation-side-menu/NavigationSideMenu.vue +4 -1
  97. package/src/brand-page/models/navigation-styles.model.ts +39 -1
  98. package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -3
  99. package/src/brand-page/utils/migration/migration-16.test.ts +319 -0
  100. package/src/brand-page/utils/migration/migration-16.ts +75 -0
  101. package/src/brand-page/utils/migration.util.ts +8 -0
  102. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +9 -0
  103. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.vue +2 -3
  104. package/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.ts +1 -0
  105. package/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.ts +5 -0
  106. package/src/brand-page-maker/components/color-palette/BpColorPalette.vue +9 -7
  107. package/src/brand-page-maker/components/cookie-collection/CookieSettings.vue +18 -17
  108. package/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.ts +13 -0
  109. package/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.vue +26 -3
  110. package/src/brand-page-maker/components/quick-link-bar/RedoButton.vue +66 -0
  111. package/src/brand-page-maker/components/quick-link-bar/UndoButton.vue +66 -0
  112. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.de-DE.json +6 -4
  113. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.es-ES.json +6 -4
  114. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.fr-CA.json +6 -4
  115. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.fr-FR.json +6 -4
  116. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.json +3 -1
  117. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.pt-BR.json +6 -4
  118. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.pt-PT.json +6 -4
  119. package/src/brand-page-maker/components/quick-link-bar/undo-redo-buttons.test.ts +116 -0
  120. package/src/brand-page-maker/components/save-contact/SaveContact.vue +12 -19
  121. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +10 -0
  122. package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.ts +24 -1
  123. package/src/brand-page-maker/composables/useEventTracker.ts +29 -0
  124. package/src/brand-page-maker/composables/useUndoRedoFlag.ts +30 -0
  125. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.test.ts +377 -0
  126. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +371 -18
  127. package/src/brand-page-maker/stores/history/history-store.test.ts +1120 -0
  128. package/src/brand-page-maker/stores/history/history-store.ts +660 -0
  129. package/src/brand-page-maker/stores/logo-store/logo-store.ts +5 -0
  130. package/src/brand-page-maker/stores/user/user-store.ts +1 -0
  131. package/src/bundles/bundled-translations.de-DE.json +3 -1
  132. package/src/bundles/bundled-translations.es-ES.json +3 -1
  133. package/src/bundles/bundled-translations.fr-CA.json +3 -1
  134. package/src/bundles/bundled-translations.fr-FR.json +3 -1
  135. package/src/bundles/bundled-translations.json +3 -1
  136. package/src/bundles/bundled-translations.pt-BR.json +3 -1
  137. package/src/bundles/bundled-translations.pt-PT.json +3 -1
  138. package/src/constants/ui.ts +1 -0
  139. package/src/metadata-builder/builders/reorder-pages-builder.ts +80 -0
  140. package/src/shared/content-settings/components/color-field/ColorField.vue +10 -5
  141. package/src/shared/content-settings/components/content-settings/ContentSettings.mixin.ts +5 -0
  142. package/src/shared/content-settings/components/content-settings/ContentSettings.stories.ts +1 -0
  143. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.ts +19 -2
  144. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.vue +1 -1
  145. package/src/shared/content-settings/components/form-fields-field/FormFieldsField.mixin.ts +26 -10
  146. package/src/shared/content-settings/components/logo-selection-field/LogoSelection.vue +63 -48
  147. package/src/shared/content-settings/components/page-dropdown-field/PageDropdownField.vue +4 -0
  148. package/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.ts +7 -0
  149. package/src/shared/content-settings/components/text-field/TextField.vue +1 -0
  150. package/src/shared/content-settings/components/text-image-field/TextImageField.vue +33 -4
  151. package/src/shared/logo-settings/components/EditLogoSettings.mixin.ts +11 -0
  152. package/src/shared/logo-settings/store/editable-logo-store.ts +42 -1
  153. package/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.mixin.ts +17 -11
  154. package/src/shared/navigation-style-settings/components/navigation-style-settings/NavigationStyleSettings.vue +4 -1
  155. package/src/shared/navigation-style-settings/store/index.ts +1 -21
  156. package/lib/src/bundled-translations-B5Fkt3qd.js +0 -175
  157. package/lib/src/bundled-translations.de-DE-DpdVePM9.js +0 -175
  158. package/lib/src/bundled-translations.es-ES-BsIcrzZF.js +0 -175
  159. package/lib/src/bundled-translations.fr-CA-G1XCp2Qh.js +0 -175
  160. package/lib/src/bundled-translations.fr-FR-BdwLXOnB.js +0 -175
  161. package/lib/src/bundled-translations.pt-BR-Bvn5ePe7.js +0 -175
  162. package/lib/src/bundled-translations.pt-PT-CDtkb2k1.js +0 -175
@@ -2,6 +2,7 @@ import { EMPTY_LOGO_IMAGE_MODEL, SENSITIVE_CONTENT_TYPES, TEXT_STYLE_TYPES, VIEW
2
2
  import { BackgroundStyles, BRAND_PAGE_TYPES, BrandPageModel, CONTENT_TYPES, NavigationDesktop, NavigationMobile, NavModel, } from '@brand-page';
3
3
  import { useBrandPageMakerUserStore } from '../user';
4
4
  import { defineStore } from 'pinia';
5
+ import { toRaw } from 'vue';
5
6
  import { useUiStore } from '../ui';
6
7
  import { useUiLogoSettingsStore, useUiEditableLogoStore, } from '@shared/logo-settings/store';
7
8
  import { useUiStyleSettingsStore } from '@shared/style-settings/store';
@@ -11,14 +12,14 @@ import { useShopConfigStore } from '@shared/ecommerce-settings/store/shop-settin
11
12
  import { usePageNavigationStore } from '@shared/page-navigation/store/page-navigation-store';
12
13
  import { applyLogoThemeToBrandPageModel, migrateBrandPageModel, applyUserPersonalisationToBrandPageModelAsync, getBrandPageViewModelFromBrandPageModel, isLogoContent, parseLogoThemeToCssStyles, logoUtil, GetLatestModelVersion, } from '@brand-page/utils';
13
14
  import { navigateToPageByPageId } from '../../routing';
14
- import { BRANDPAGE_DEFAULT_ERROR_MESSAGE_DESCRIPTION, BRANDPAGE_DEFAULT_SAVE_MESSAGE_DESCRIPTION, MAKER_MOBILE_BREAKPOINT, MESSAGE_VISIBLE_DURATION, } from '@brand-page-maker/constants';
15
+ import { BRANDPAGE_DEFAULT_ERROR_MESSAGE_DESCRIPTION, BRANDPAGE_DEFAULT_SAVE_MESSAGE_DESCRIPTION, MAKER_MOBILE_BREAKPOINT, MESSAGE_VISIBLE_DURATION, SIDE_BAR_TAB_NAMES, } from '@brand-page-maker/constants';
15
16
  import { useUiSideBarStore } from '@shared/side-bar/store';
16
17
  import { delayInMS } from '../../../utils/ui-util';
17
18
  import { useUiContentSettingsStore } from '@shared/content-settings/store';
18
19
  import { setContentSettingsAddContentOptions } from './brandpage-maker-store-utils';
19
20
  import { useAdminLogoSettingsStore } from '../admin-logo-settings';
20
21
  import { useUiPageSettingsStore } from '@shared/page-settings/store';
21
- import { isColorMatched, mapBrandPageContentToContentSettingsItem, removeContentFieldValues, removeLogoTemplateModel, transformToRTE, } from '@brand-page-maker/utils';
22
+ import { mapBrandPageContentToContentSettingsItem, removeContentFieldValues, removeLogoTemplateModel, transformToRTE, } from '@brand-page-maker/utils';
22
23
  import { useExternalRichTextEditor } from '@brand-page-maker/composables/rich-text-editor/useRichTextEditor';
23
24
  import { UI_DEVICE_MODES, UI_SCREENSIZE_MODES, } from '@shared/models';
24
25
  import { PAGE_SECTIONS } from '@shared/page-settings/models';
@@ -33,6 +34,7 @@ import { useConsent } from '@brand-page/composables/consent.composable';
33
34
  import { commonTr, errorTr } from '@src/composables/useTranslate';
34
35
  import { UPGRADE_CTA_LOCATIONS } from '../../composables/useEventTracker';
35
36
  import { useVideoStore } from '../video';
37
+ import { useHistoryStore } from '../history/history-store';
36
38
  import { findValuesByKey } from '../../../helpers/ts.helper';
37
39
  import { useLogoStore } from '../logo-store';
38
40
  const brandPageTypeTemplateTypeMap = {
@@ -387,6 +389,15 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
387
389
  description: payload.noDescription ? '' : description,
388
390
  },
389
391
  });
392
+ // Any successful save re-baselines the undo stack so a user can't
393
+ // undo back past the persisted state. This covers Save Progress /
394
+ // Publish AND settings-only saves (updateBrandPage,
395
+ // updateSensitiveContent, admin saveTemplate) — settings-tab
396
+ // actions persist the metadata, so allowing undo to roll them
397
+ // back would let the local stack drift from what's saved.
398
+ // reset() no-ops in non-undo-redo sessions (no baseline = nothing
399
+ // to clear).
400
+ useHistoryStore().reset();
390
401
  },
391
402
  hideChangeTemplateConfirmModal() {
392
403
  this.setIsChangeTemplateConfirmModalVisible({
@@ -400,10 +411,11 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
400
411
  this.setSelectedTemplateId({ templateId: false });
401
412
  this.hideChangeTemplateConfirmModal();
402
413
  },
403
- onChangeTemplateConfirmModalConfirm() {
404
- this.applySelectedTemplate();
414
+ async onChangeTemplateConfirmModalConfirm() {
415
+ await this.applySelectedTemplate();
405
416
  this.hideChangeTemplateConfirmModal();
406
417
  this.isModifiedAfterTemplateApplied = false;
418
+ this._captureTemplateSwitchIfEnabled();
407
419
  },
408
420
  onContentChanged() {
409
421
  this.setIsModifiedAfterTemplateApplied();
@@ -411,7 +423,7 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
411
423
  onStyleChanged() {
412
424
  this.setIsModifiedAfterTemplateApplied();
413
425
  },
414
- onTemplateSelected(payload) {
426
+ async onTemplateSelected(payload) {
415
427
  this.setSelectedTemplateId({
416
428
  templateId: payload.templateId,
417
429
  });
@@ -421,7 +433,8 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
421
433
  });
422
434
  }
423
435
  else {
424
- this.applySelectedTemplate();
436
+ await this.applySelectedTemplate();
437
+ this._captureTemplateSwitchIfEnabled();
425
438
  }
426
439
  },
427
440
  setSelectedTabName(payload) {
@@ -447,6 +460,295 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
447
460
  async updateContent(payload) {
448
461
  const uiContentSettingsStore = useUiContentSettingsStore();
449
462
  uiContentSettingsStore.updateContent(payload);
463
+ // NOTE (Bolt 1, 2026-04-23): this action is not the actual edit path used
464
+ // by the UI — sidebar inputs call uiContentSettingsStore.updateItemValue
465
+ // directly. History capture is driven by a deep `watch(brandPageData, ...)`
466
+ // installed in history-store once the baseline is captured, so we do not
467
+ // need to instrument this action. Kept here as a pass-through because
468
+ // removing it may affect other callers.
469
+ },
470
+ /**
471
+ * Restore every store that the `brandPageData` getter reads from, so undo
472
+ * and redo bring back the EXACT document state captured at snapshot time.
473
+ *
474
+ * `initialiseStoresByBrandPageModelAsync` is too narrow for undo/redo — it
475
+ * only rehydrates pages, sections, and nav structure, which is enough for
476
+ * the AI-apply path but leaves navigation styles, backgrounds, button/text/
477
+ * logo/gallery styles, shop config, and several own-store fields unchanged.
478
+ * This action mirrors the full hydration surface of `applySelectedTemplate`
479
+ * (minus the template-specific logo/personalisation logic) so a restore is
480
+ * a complete round-trip of what `brandPageData` returns.
481
+ *
482
+ * Called ONLY by history-store during undo/redo. The history store sets
483
+ * `isApplyingSnapshot=true` across this call to prevent the deep-watcher
484
+ * on `brandPageData` from re-capturing the restored state.
485
+ */
486
+ /**
487
+ * Force-commit a `template_switch` entry to the history store, if the
488
+ * history store has a baseline (which only happens when the undo/redo
489
+ * feature flag is on — see `BrandPageMaker.mixin.ts`).
490
+ */
491
+ _captureTemplateSwitchIfEnabled() {
492
+ const historyStore = useHistoryStore();
493
+ if (!historyStore.baselineCaptured)
494
+ return;
495
+ historyStore.captureTemplateSwitch();
496
+ },
497
+ async applyHistorySnapshot(snapshot, activePageId, logoEditsStr) {
498
+ const styleSettingsStore = useUiStyleSettingsStore();
499
+ const navigationStyleSettingsStore = useUiNavigationStyleSettingsStore();
500
+ const backgroundSettingsStore = useUiBackgroundSettingsStore();
501
+ const pageNavigationStore = usePageNavigationStore();
502
+ const shopStore = useShopConfigStore();
503
+ // 1. Pages + header/footer sections (also covers content items).
504
+ this.initialisePagesForCurrentPage({
505
+ pages: snapshot.pages,
506
+ sections: {
507
+ [PAGE_SECTIONS.header]: {
508
+ [VIEWPORTS.desktop]: snapshot.pageHeaderDesktop,
509
+ [VIEWPORTS.mobile]: snapshot.pageHeaderMobile,
510
+ },
511
+ [PAGE_SECTIONS.footer]: {
512
+ [VIEWPORTS.desktop]: snapshot.pageFooterDesktop,
513
+ [VIEWPORTS.mobile]: snapshot.pageFooterMobile,
514
+ },
515
+ },
516
+ });
517
+ // 2. Page-level nav structure (routes, orders).
518
+ pageNavigationStore.setNav({ nav: snapshot.nav });
519
+ // 3. Navigation STYLES (header/footer nav colors, alignment, etc.) —
520
+ // this is the bit that was being dropped before.
521
+ // Use function-form $patch so each nested style object is replaced as a
522
+ // whole reference. The object-form $patch (used by setState) deep-merges
523
+ // and would leave keys present in the live state but absent from the
524
+ // snapshot in place — e.g. switching button styles then undoing would
525
+ // leave the new style's borderRadius/borderStyle/borderWidth applied.
526
+ navigationStyleSettingsStore.$patch((state) => {
527
+ state.navigation[PAGE_SECTIONS.header][VIEWPORTS.desktop] =
528
+ new NavigationDesktop(snapshot.pageHeaderDesktop?.navigation);
529
+ state.navigation[PAGE_SECTIONS.header][VIEWPORTS.mobile] =
530
+ new NavigationMobile(snapshot.pageHeaderMobile?.navigation);
531
+ });
532
+ // 4. Global styles (logo, button, text, gallery). Same whole-reference
533
+ // replacement reasoning as step 3.
534
+ styleSettingsStore.$patch((state) => {
535
+ state.buttonStyles = snapshot.styles.buttonStyles;
536
+ state.logoStyles = snapshot.styles.logoStyles;
537
+ state.textStyles = snapshot.styles.textStyles;
538
+ state.galleryStyles = snapshot.styles.galleryStyles;
539
+ });
540
+ // 5. Background styles. Same whole-reference replacement reasoning as
541
+ // step 3 — `setBackgroundStyles` calls per-field setters that
542
+ // `Object.assign` partials onto the live `style` and
543
+ // `backgroundShapeStyle` objects, so keys from the previous mode
544
+ // (e.g. background image url, shape style props) would survive an
545
+ // undo back to a state that doesn't have them.
546
+ backgroundSettingsStore.$patch((state) => {
547
+ state.backgroundStyles = snapshot.styles.backgroundStyles;
548
+ });
549
+ backgroundSettingsStore.onBackgroundChanged();
550
+ // 6. Shop products are derived from shop-content blocks inside `pages`,
551
+ // so they're already implicitly restored at step 1. Re-run the shop
552
+ // store's derivation to keep `products` in sync with the snapshot
553
+ // pages. paymentConfig is intentionally NOT restored — selecting it is
554
+ // backend-confirmed (Stripe Connect / payment-provider linkage) per
555
+ // project-guardrails.md, so it must persist across undo. We pass the
556
+ // live paymentConfig back in to preserve it.
557
+ shopStore.initialiseShopStore({
558
+ paymentConfig: shopStore.paymentConfig,
559
+ pages: snapshot.pages ?? [],
560
+ });
561
+ // 7. Own-store scalar fields surfaced by the brandPageData getter.
562
+ if (snapshot.isModifiedAfterTemplateApplied !== undefined) {
563
+ this.isModifiedAfterTemplateApplied =
564
+ snapshot.isModifiedAfterTemplateApplied;
565
+ }
566
+ if (snapshot.brandPageType) {
567
+ this.setBrandPageType({ brandPageType: snapshot.brandPageType });
568
+ }
569
+ this.faviconUrl = snapshot.faviconUrl;
570
+ this.ogImageUrl = snapshot.ogImageUrl;
571
+ this.measurementID = snapshot.measurementID;
572
+ this.adsenseID = snapshot.adsenseID;
573
+ this.ogTitle = snapshot.ogTitle;
574
+ this.ogDescription = snapshot.ogDescription;
575
+ this.cookieOptions = snapshot.cookieOptions;
576
+ this.saveContactSettings = snapshot.saveContactSettings;
577
+ // 8. Re-sync the logo-settings sidebar's `selectedLogoImage` from the
578
+ // restored header logo. The preview rehydrates via the page contents,
579
+ // but `uiLogoSettings` holds its own copy that drives the sidebar
580
+ // "current logo" state — same pattern as `initialiseStoresByBrandPageModelAsync`.
581
+ // Also restores the variations grid + template asset for the
582
+ // snapshot's draft token (both are sidecars to `brandPageData` —
583
+ // BYO upload mutates them out of band). When the captured entry
584
+ // carries a `logoEdits` sidecar (pre-purchase logo-tab edits —
585
+ // text, support text, logo colors, fonts), `editableLogoStore.logoEdits`
586
+ // is restored from that string so the sidebar form fields and the
587
+ // save-time fabric-render POST both pick up the pre-edit state.
588
+ await this._syncLogoSettingsFromSnapshot(snapshot, logoEditsStr);
589
+ // 9. If the sidebar is editing a content item that no longer exists in
590
+ // the restored page, fall back to the Content tab so the user doesn't
591
+ // stare at a blank settings panel.
592
+ this._fallbackSidebarIfSelectedContentMissing(snapshot);
593
+ // 10. Switch to the page the user was viewing when this entry was
594
+ // captured (or the closest still-existing page if the captured
595
+ // page was the one being undone-away). The history store does the
596
+ // walk-back resolution and passes us a pageId that's guaranteed to
597
+ // exist in the restored nav — or undefined if no entry walking
598
+ // back has a viable id, in which case we fall through to the
599
+ // first/default route. Without this, the page-tabs carousel keeps
600
+ // highlighting whatever page slug is in the URL (which can no
601
+ // longer match any nav item after a page-add undo) and the
602
+ // sidebar's `currentPage` getter silently falls back to page 0.
603
+ this._navigateToActivePage(activePageId);
604
+ },
605
+ async _syncLogoSettingsFromSnapshot(snapshot, logoEditsStr) {
606
+ const logoSettingsStore = useUiLogoSettingsStore();
607
+ const editableLogoStore = useUiEditableLogoStore();
608
+ const logoStore = useLogoStore();
609
+ const containerStore = useBrandPageContainerStore();
610
+ // Pre-restore logo identity, used to short-circuit the
611
+ // fabric-render call when only non-logo state changed.
612
+ const prevLogoEditsStr = JSON.stringify(toRaw(editableLogoStore.logoEdits));
613
+ const prevDraftToken = editableLogoStore.logoDraftToken;
614
+ // Wholesale-replace via $patch so prior textObjects/colors don't
615
+ // leak across template switches.
616
+ if (logoEditsStr) {
617
+ try {
618
+ const parsed = JSON.parse(logoEditsStr);
619
+ editableLogoStore.$patch({ logoEdits: parsed });
620
+ }
621
+ catch (error) {
622
+ console.error('brandpage-maker-store: failed to restore logoEdits', error);
623
+ }
624
+ }
625
+ const logoImage = snapshot.brandPageType === BRAND_PAGE_TYPES.default
626
+ ? snapshot.pages?.[0]?.contents?.find((c) => c.type === 'logo')?.logoImage
627
+ : snapshot.pageHeaderDesktop?.logoImage;
628
+ if (!logoImage)
629
+ return;
630
+ logoSettingsStore.setState({
631
+ newState: { selectedLogoImage: logoImage },
632
+ });
633
+ const draftToken = logoImage.logoDraftToken;
634
+ if (!draftToken)
635
+ return;
636
+ // Re-derive enableEditMode + templateAsset from the draft registry
637
+ // (append-only for the session) instead of stashing on every entry.
638
+ const draft = logoStore.getLogoDraftAssetByToken(draftToken);
639
+ if (draft) {
640
+ editableLogoStore.setEnableEditMode(!draft.isByo);
641
+ if (draft.templateAsset) {
642
+ logoStore.setLogoTemplateAsset(draft.templateAsset);
643
+ }
644
+ }
645
+ editableLogoStore.setLogoDraftToken(draftToken);
646
+ // No logo change → cache is still correct; just stamp base64 back
647
+ // (snapshot doesn't carry logoImageBase64Url).
648
+ const logoUnchanged = prevDraftToken === draftToken &&
649
+ (logoEditsStr === undefined || logoEditsStr === prevLogoEditsStr);
650
+ if (logoUnchanged) {
651
+ editableLogoStore.stampLogoBase64IntoBrandPageData();
652
+ return;
653
+ }
654
+ const isByo = !!draft?.isByo;
655
+ if (isByo) {
656
+ // BYO mints a fresh draftToken per upload so the per-token
657
+ // cache always matches; no re-render needed.
658
+ if (editableLogoStore.restoreVariationsForDraftToken(draftToken)) {
659
+ editableLogoStore.stampLogoBase64IntoBrandPageData();
660
+ }
661
+ return;
662
+ }
663
+ // Designed: draft token is reused across edits, so the cache
664
+ // only holds the latest render. Re-issue fabric-render — same
665
+ // call as the live edit path. Awaited so concurrent undos
666
+ // serialize and the call sits inside the isApplyingSnapshot
667
+ // window (watcher guard suppresses the writeback).
668
+ if (containerStore.isPrePurchase &&
669
+ logoEditsStr &&
670
+ logoStore.logoTemplateAsset) {
671
+ // Stamp the cached (pre-undo) base64 onto brandPageData first
672
+ // so the canvas keeps showing the previous logo while the
673
+ // re-render is in flight. Without this the logoImageBase64Url
674
+ // fields are undefined (snapshot is stripped pre-purchase) and
675
+ // the canvas flickers blank for ~500-1500ms.
676
+ editableLogoStore.stampLogoBase64IntoBrandPageData();
677
+ try {
678
+ await editableLogoStore.updateEditableLogoImageUrlAsync();
679
+ }
680
+ catch (error) {
681
+ console.error('brandpage-maker-store: failed to re-render logo on history apply', error);
682
+ }
683
+ }
684
+ },
685
+ /**
686
+ * Restore the active page after a history apply. The id passed in is
687
+ * already validated against the restored nav by the history store; if
688
+ * it's undefined (no entry walking back had a viable page), fall back
689
+ * to the first/default route so the URL, `routeStore.currentRoute.params`,
690
+ * `pageNavigation.activePageId`, and the page-tab highlight all line up.
691
+ *
692
+ * `setCurrentActivePage` is called explicitly in addition to
693
+ * `navigateToPageByPageId` because `navigateToPageByPageId` is a no-op
694
+ * when the router instance is undefined (e.g. SSR / unit tests), but the
695
+ * Pinia state must still be updated so the sidebar's `currentPage`
696
+ * getter returns the right page.
697
+ */
698
+ _navigateToActivePage(activePageId) {
699
+ const pageNavigationStore = usePageNavigationStore();
700
+ let targetPageId = activePageId;
701
+ if (!targetPageId) {
702
+ const fallbackRoute = pageNavigationStore.routes.length
703
+ ? pageNavigationStore.getFirstOrDefaultRoute()
704
+ : undefined;
705
+ targetPageId = fallbackRoute?.pageId;
706
+ }
707
+ if (!targetPageId)
708
+ return;
709
+ // Skip both the Pinia write and the router push when the target page
710
+ // is already active. The router push fires `router.afterEach` even
711
+ // for same-page navigation, and BrandPageMaker.mixin's afterEach hook
712
+ // resets the content-settings modeStack — which would snap the
713
+ // sidebar back to the default Content tab on every undo/redo,
714
+ // regardless of whether the user was deep-editing a content item.
715
+ if (pageNavigationStore.activePageId === targetPageId)
716
+ return;
717
+ pageNavigationStore.setCurrentActivePage({ pageId: targetPageId });
718
+ navigateToPageByPageId(targetPageId);
719
+ },
720
+ _fallbackSidebarIfSelectedContentMissing(snapshot) {
721
+ const contentSettingsStore = useUiContentSettingsStore();
722
+ const sideBarStore = useUiSideBarStore();
723
+ const selectedItemId = contentSettingsStore.selectedItemId;
724
+ if (!selectedItemId)
725
+ return;
726
+ const existingContentIds = new Set();
727
+ snapshot.pages?.forEach((page) => {
728
+ page.contents?.forEach((content) => {
729
+ if (content?.id)
730
+ existingContentIds.add(content.id);
731
+ });
732
+ });
733
+ if (existingContentIds.has(selectedItemId))
734
+ return;
735
+ // The previously-selected content was undone away. Restore the
736
+ // Content tab's natural landing state — the same shape produced
737
+ // when the user clicks the Content tab fresh — instead of leaving
738
+ // the sidebar stuck rendering `<FocusedContentItemSettings>` for
739
+ // a missing item, which paints a blank panel.
740
+ //
741
+ // `resetMode()` pops the modeStack back to the base `edit` entry
742
+ // (the default landing mode); clearing `selectedItemId` releases
743
+ // the pointer to the now-deleted item.
744
+ sideBarStore.setSelectedTabName({
745
+ tabName: SIDE_BAR_TAB_NAMES.CONTENT_SETTINGS,
746
+ });
747
+ contentSettingsStore.resetMode();
748
+ contentSettingsStore.selectedItemId = null;
749
+ contentSettingsStore.selectedItemFieldName = null;
750
+ contentSettingsStore.selectedItemIndex = null;
751
+ contentSettingsStore.selectedItemValue = null;
450
752
  },
451
753
  export() {
452
754
  const data = this.brandPageData;
@@ -684,14 +986,6 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
684
986
  },
685
987
  },
686
988
  });
687
- if (userStore.isAdmin && !this.isUserDraft) {
688
- for (const viewport of [VIEWPORTS.desktop, VIEWPORTS.mobile]) {
689
- const hamburger = navigationStyleSettingsStore.navigation[PAGE_SECTIONS.header][viewport].hamburgerMenuStyle;
690
- if (isColorMatched(hamburger.subNavBackgroundColor)) {
691
- hamburger.subNavBackgroundColor = undefined;
692
- }
693
- }
694
- }
695
989
  uiStore.setThirdPartySettings({
696
990
  thirdPartySettings: {
697
991
  unsplashApplicationName,
@@ -0,0 +1,83 @@
1
+ /**
2
+ * A single history entry. `snapshot` is JSON-stringified up-front so Pinia
3
+ * treats it as opaque (no per-field reactivity) and `sizeBytes` is exact.
4
+ * Sidecar state not in `brandPageData` rides along on this entry —
5
+ * `activePageId` for page-tab restore, `logoEdits` for pre-purchase logo
6
+ * form state.
7
+ */
8
+ export interface HistoryEntry {
9
+ snapshot: string;
10
+ timestamp: string;
11
+ source: 'manual_edit' | 'template_switch' | 'ai_changeset' | 'rich_text';
12
+ actor: 'user' | 'ai_builder';
13
+ label?: string;
14
+ sizeBytes: number;
15
+ /** Active page id at capture time. Empty before first router push. */
16
+ activePageId: string;
17
+ /** JSON-stringified `editableLogoStore.logoEdits`. Undefined if logo tab never opened. */
18
+ logoEdits?: string;
19
+ }
20
+ export declare const useHistoryStore: import("pinia").StoreDefinition<"history", Pick<{
21
+ entries: import("vue").ShallowRef<HistoryEntry[], HistoryEntry[]>;
22
+ currentIndex: import("vue").Ref<number, number>;
23
+ isApplyingSnapshot: import("vue").Ref<boolean, boolean>;
24
+ baselineCaptured: import("vue").Ref<boolean, boolean>;
25
+ canUndo: import("vue").ComputedRef<boolean>;
26
+ canRedo: import("vue").ComputedRef<boolean>;
27
+ captureBaseline: () => void;
28
+ capture: (args: {
29
+ source: HistoryEntry['source'];
30
+ actor: HistoryEntry['actor'];
31
+ label?: string;
32
+ }) => 'committed' | 'oversized' | 'noop' | 'skipped';
33
+ captureTemplateSwitch: (label?: string) => 'committed' | 'oversized' | 'noop' | 'skipped';
34
+ captureAiChangeset: (label?: string) => 'committed' | 'oversized' | 'noop' | 'skipped';
35
+ mergeNextMutation: () => void;
36
+ undo: () => Promise<void>;
37
+ redo: () => Promise<void>;
38
+ reset: () => void;
39
+ getCurrentSizeBytes: () => number;
40
+ getCurrentEntryCount: () => number;
41
+ }, "entries" | "currentIndex" | "isApplyingSnapshot" | "baselineCaptured">, Pick<{
42
+ entries: import("vue").ShallowRef<HistoryEntry[], HistoryEntry[]>;
43
+ currentIndex: import("vue").Ref<number, number>;
44
+ isApplyingSnapshot: import("vue").Ref<boolean, boolean>;
45
+ baselineCaptured: import("vue").Ref<boolean, boolean>;
46
+ canUndo: import("vue").ComputedRef<boolean>;
47
+ canRedo: import("vue").ComputedRef<boolean>;
48
+ captureBaseline: () => void;
49
+ capture: (args: {
50
+ source: HistoryEntry['source'];
51
+ actor: HistoryEntry['actor'];
52
+ label?: string;
53
+ }) => 'committed' | 'oversized' | 'noop' | 'skipped';
54
+ captureTemplateSwitch: (label?: string) => 'committed' | 'oversized' | 'noop' | 'skipped';
55
+ captureAiChangeset: (label?: string) => 'committed' | 'oversized' | 'noop' | 'skipped';
56
+ mergeNextMutation: () => void;
57
+ undo: () => Promise<void>;
58
+ redo: () => Promise<void>;
59
+ reset: () => void;
60
+ getCurrentSizeBytes: () => number;
61
+ getCurrentEntryCount: () => number;
62
+ }, "canUndo" | "canRedo">, Pick<{
63
+ entries: import("vue").ShallowRef<HistoryEntry[], HistoryEntry[]>;
64
+ currentIndex: import("vue").Ref<number, number>;
65
+ isApplyingSnapshot: import("vue").Ref<boolean, boolean>;
66
+ baselineCaptured: import("vue").Ref<boolean, boolean>;
67
+ canUndo: import("vue").ComputedRef<boolean>;
68
+ canRedo: import("vue").ComputedRef<boolean>;
69
+ captureBaseline: () => void;
70
+ capture: (args: {
71
+ source: HistoryEntry['source'];
72
+ actor: HistoryEntry['actor'];
73
+ label?: string;
74
+ }) => 'committed' | 'oversized' | 'noop' | 'skipped';
75
+ captureTemplateSwitch: (label?: string) => 'committed' | 'oversized' | 'noop' | 'skipped';
76
+ captureAiChangeset: (label?: string) => 'committed' | 'oversized' | 'noop' | 'skipped';
77
+ mergeNextMutation: () => void;
78
+ undo: () => Promise<void>;
79
+ redo: () => Promise<void>;
80
+ reset: () => void;
81
+ getCurrentSizeBytes: () => number;
82
+ getCurrentEntryCount: () => number;
83
+ }, "reset" | "undo" | "redo" | "captureBaseline" | "capture" | "captureTemplateSwitch" | "captureAiChangeset" | "mergeNextMutation" | "getCurrentSizeBytes" | "getCurrentEntryCount">>;