@designcrowd/library.brand-page 5.18.3-undo-38 → 5.18.3

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 (112) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-ydEGYl5O.js → CreatedOnBrandCrowd-de-de-CkuAAwKQ.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-BiJ8RmwM.js → CreatedOnBrandCrowd-en-us-Coln5kSU.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-C8CyL1ny.js → CreatedOnBrandCrowd-es-es-raGyXChm.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-BMh0yIJJ.js → CreatedOnBrandCrowd-fr-ca-BT_WYYxW.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-BMh0yIJJ.js → CreatedOnBrandCrowd-fr-fr-BT_WYYxW.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-C0DghlQk.js → CreatedOnBrandCrowd-pt-br-BRbD_kiI.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-C0DghlQk.js → CreatedOnBrandCrowd-pt-pt-BRbD_kiI.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-CZEnW0qm.js → CreatedOnDcom-de-de-DetCIFxa.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-DPpRkfrD.js → CreatedOnDcom-en-us-D0LeF_V2.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-8yTtB23v.js → CreatedOnDcom-es-es-CHa4stWS.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-DdGwSBLy.js → CreatedOnDcom-fr-ca-ntW7A335.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-DRGbffC4.js → CreatedOnDcom-fr-fr-C6rQcclc.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-CWm_1vbQ.js → CreatedOnDcom-pt-br-Cn07ZK_m.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-DZBR79tn.js → CreatedOnDcom-pt-pt-CewmqYVY.js} +1 -1
  15. package/lib/src/brand-page-maker/components/action-bar/ActionBar.mixin.d.ts +2 -7
  16. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +2 -7
  17. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +0 -10
  18. package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMakerTemplateSettings.mixin.d.ts +2 -7
  19. package/lib/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.js +0 -1
  20. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +2 -87
  21. package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.js +0 -5
  22. package/lib/src/brand-page-maker/components/brandpage-settings/ReplaceImageSettingsForBrandPageSettings.mixin.d.ts +2 -7
  23. package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.d.ts +0 -3
  24. package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.js +0 -11
  25. package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +2 -7
  26. package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +2 -7
  27. package/lib/src/brand-page-maker/components/social-share/SocialShare.mixin.d.ts +2 -7
  28. package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +2 -7
  29. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +0 -9
  30. package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.js +1 -20
  31. package/lib/src/brand-page-maker/composables/useEventTracker.d.ts +0 -20
  32. package/lib/src/brand-page-maker/composables/useEventTracker.js +0 -17
  33. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.d.ts +2 -41
  34. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +5 -307
  35. package/lib/src/brand-page-maker/stores/logo-store/logo-store.d.ts +0 -1
  36. package/lib/src/brand-page-maker/stores/user/user-store.js +0 -1
  37. package/lib/src/bundled-translations-B5Fkt3qd.js +175 -0
  38. package/lib/src/bundles/bundled-translations.json +1 -3
  39. package/lib/src/constants/ui.d.ts +0 -1
  40. package/lib/src/css/library.brand-page-brandCrowd.min.css +15 -20
  41. package/lib/src/css/library.brand-page-brandPage.min.css +16 -20
  42. package/lib/src/css/library.brand-page-designCom.min.css +15 -20
  43. package/lib/src/css/library.brand-page-preview.min.css +15 -20
  44. package/lib/src/index.mjs +1 -1
  45. package/lib/src/{lib-BZlXQjdd.js → lib-CGfmcIBb.js} +29373 -29970
  46. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts +2 -87
  47. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.js +0 -5
  48. package/lib/src/shared/content-settings/components/content-settings/ContentSettings.stories.js +0 -1
  49. package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +2 -23
  50. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.d.ts +0 -16
  51. package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +2 -7
  52. package/lib/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.d.ts +0 -3
  53. package/lib/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.js +2 -19
  54. package/lib/src/shared/content-settings/components/form-fields-field/FormFieldsField.mixin.js +8 -18
  55. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +0 -64
  56. package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.js +0 -6
  57. package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.d.ts +0 -19
  58. package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.js +0 -11
  59. package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +2 -10
  60. package/lib/src/shared/logo-settings/store/editable-logo-store.d.ts +1 -5
  61. package/lib/src/shared/logo-settings/store/editable-logo-store.js +0 -31
  62. package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +2 -24
  63. package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +2 -10
  64. package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +2 -23
  65. package/lib/src/shared/side-bar/components/SideBarTabButton.mixin.d.ts +0 -16
  66. package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +2 -23
  67. package/lib/src/shared/template-settings/components/TemplatesSettings.mixin.d.ts +0 -16
  68. package/package.json +1 -1
  69. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +0 -11
  70. package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.vue +3 -2
  71. package/src/brand-page-maker/components/brand-page-maker/__fixtures__/brand-page-examples.ts +0 -1
  72. package/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.ts +0 -5
  73. package/src/brand-page-maker/components/cookie-collection/CookieSettings.vue +17 -18
  74. package/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.ts +0 -13
  75. package/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.vue +3 -26
  76. package/src/brand-page-maker/components/quick-link-bar/i18n/quick-link-bar.json +1 -3
  77. package/src/brand-page-maker/components/save-contact/SaveContact.vue +19 -12
  78. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +0 -10
  79. package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.ts +1 -24
  80. package/src/brand-page-maker/composables/useEventTracker.ts +0 -29
  81. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.test.ts +0 -335
  82. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +4 -371
  83. package/src/brand-page-maker/stores/logo-store/logo-store.ts +0 -5
  84. package/src/brand-page-maker/stores/user/user-store.ts +0 -1
  85. package/src/bundles/bundled-translations.json +1 -3
  86. package/src/constants/ui.ts +0 -1
  87. package/src/shared/content-settings/components/content-settings/ContentSettings.mixin.ts +0 -5
  88. package/src/shared/content-settings/components/content-settings/ContentSettings.stories.ts +0 -1
  89. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.mixin.ts +2 -19
  90. package/src/shared/content-settings/components/draggable-item-list/DraggableItemList.vue +1 -1
  91. package/src/shared/content-settings/components/form-fields-field/FormFieldsField.mixin.ts +10 -26
  92. package/src/shared/content-settings/components/logo-selection-field/LogoSelection.vue +48 -63
  93. package/src/shared/content-settings/components/page-dropdown-field/PageDropdownField.vue +0 -4
  94. package/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.ts +0 -7
  95. package/src/shared/content-settings/components/text-field/TextField.vue +0 -1
  96. package/src/shared/content-settings/components/text-image-field/TextImageField.vue +4 -33
  97. package/src/shared/logo-settings/components/EditLogoSettings.mixin.ts +0 -11
  98. package/src/shared/logo-settings/store/editable-logo-store.ts +1 -42
  99. package/lib/src/brand-page-maker/composables/useUndoRedoFlag.d.ts +0 -16
  100. package/lib/src/brand-page-maker/composables/useUndoRedoFlag.js +0 -22
  101. package/lib/src/brand-page-maker/stores/history/history-store.d.ts +0 -83
  102. package/lib/src/brand-page-maker/stores/history/history-store.js +0 -495
  103. package/lib/src/bundled-translations-D1q3rSEz.js +0 -175
  104. package/lib/src/metadata-builder/builders/reorder-pages-builder.d.ts +0 -13
  105. package/lib/src/metadata-builder/builders/reorder-pages-builder.js +0 -49
  106. package/src/brand-page-maker/components/quick-link-bar/RedoButton.vue +0 -66
  107. package/src/brand-page-maker/components/quick-link-bar/UndoButton.vue +0 -66
  108. package/src/brand-page-maker/components/quick-link-bar/undo-redo-buttons.test.ts +0 -116
  109. package/src/brand-page-maker/composables/useUndoRedoFlag.ts +0 -26
  110. package/src/brand-page-maker/stores/history/history-store.test.ts +0 -1120
  111. package/src/brand-page-maker/stores/history/history-store.ts +0 -660
  112. package/src/metadata-builder/builders/reorder-pages-builder.ts +0 -80
@@ -19,7 +19,7 @@
19
19
  </div>
20
20
  <Toggle
21
21
  id="save-contact-enabled"
22
- :model-value="isSavingEnabled"
22
+ :model-value="data.isToggled"
23
23
  color="primary"
24
24
  @update:model-value="onSavingEnabled()"
25
25
  />
@@ -27,7 +27,7 @@
27
27
  </div>
28
28
  <div class="tw-flex-none tw-mt-4">
29
29
  <div
30
- v-if="!isAdmin && !isPrePurchase && isSavingEnabled"
30
+ v-if="!isAdmin && !isPrePurchase && data.isToggled"
31
31
  class="tw-flex tw-items-center tw-justify-between tw-cursor-pointer tw-gap-1"
32
32
  @click="onHideBranding"
33
33
  >
@@ -62,7 +62,7 @@
62
62
  </div>
63
63
  <Toggle
64
64
  id="show-preview-cookie-banner"
65
- :model-value="hideBranding"
65
+ :model-value="data.hideBranding"
66
66
  color="primary"
67
67
  @update:model-value="onHideBranding()"
68
68
  />
@@ -78,7 +78,7 @@ import {
78
78
  useBrandPageContainerStore,
79
79
  } from '@brand-page-maker/stores';
80
80
  import { saveContactSettingsTr } from '@src/composables/useTranslate';
81
- import { computed } from 'vue';
81
+ import { computed, reactive } from 'vue';
82
82
  import {
83
83
  EVENTS,
84
84
  useEventTracker,
@@ -107,6 +107,11 @@ const showBrandCrowdLogo = computed(
107
107
  () => brandPageMakerStore.showBrandCrowdLogo,
108
108
  );
109
109
 
110
+ const data = reactive({
111
+ isToggled: isSavingEnabled.value,
112
+ hideBranding: hideBranding.value,
113
+ });
114
+
110
115
  const siteName = computed((): string => {
111
116
  return props.isDesignCom ? 'Design.com' : 'BrandCrowd';
112
117
  });
@@ -122,28 +127,30 @@ const hideBrandingTooltip = computed((): string => {
122
127
  });
123
128
 
124
129
  const onSavingEnabled = () => {
125
- const next = !isSavingEnabled.value;
126
-
127
- brandPageMakerStore.setSavingEnabled({ isSavingEnabled: next });
130
+ data.isToggled = !data.isToggled;
131
+ brandPageMakerStore.setSavingEnabled({
132
+ isSavingEnabled: data.isToggled,
133
+ });
128
134
  eventTracker.sendWebsiteEvent({
129
135
  eventName: EVENTS.WEBSITE_MAKER_DIGITAL_BUSINESS_CARDS_SAVE_CONTACT_TOGGLE,
130
136
  eventProps: {
131
137
  cta_location: UPGRADE_CTA_LOCATIONS.SAVE_CONTACT_SETTINGS,
132
- toggle_value: next ? 'enabled' : 'disabled',
138
+ toggle_value: data.isToggled ? 'enabled' : 'disabled',
133
139
  },
134
140
  });
135
141
  };
136
142
 
137
143
  const onHideBranding = async () => {
138
144
  if (!showBrandCrowdLogo.value) {
139
- const next = !hideBranding.value;
140
-
141
- brandPageMakerStore.setHideBranding({ hideBranding: next });
145
+ data.hideBranding = !data.hideBranding;
146
+ brandPageMakerStore.setHideBranding({
147
+ hideBranding: data.hideBranding,
148
+ });
142
149
  eventTracker.sendWebsiteEvent({
143
150
  eventName: EVENTS.WEBSITE_MAKER_DIGITAL_BUSINESS_CARDS_HIDE_POPUP,
144
151
  eventProps: {
145
152
  cta_location: UPGRADE_CTA_LOCATIONS.SAVE_CONTACT_SETTINGS,
146
- toggle_value: next ? 'enabled' : 'disabled',
153
+ toggle_value: data.hideBranding ? 'enabled' : 'disabled',
147
154
  },
148
155
  });
149
156
  } else {
@@ -29,8 +29,6 @@ import {
29
29
  useUiStore,
30
30
  } from '../../stores';
31
31
  import { useBrandPageMakerStore } from '../../stores';
32
- import { useHistoryStore } from '../../stores/history/history-store';
33
- import { useUndoRedoFlag } from '../useUndoRedoFlag';
34
32
  import { useBrandPageMakerUserStore } from '../../stores/user/user-store';
35
33
  import { useAiMetadataBuilder } from './useAiMetadataBuilder';
36
34
  import {
@@ -57,8 +55,6 @@ export function useAiWebsiteBuilderChat(): UseAiChatResult {
57
55
  const aiThreadStore = useAiWebsiteBuilderThreadStore();
58
56
  const snapshotStore = useSnapshotStore();
59
57
  const brandPageMakerStore = useBrandPageMakerStore();
60
- const historyStore = useHistoryStore();
61
- const undoRedoEnabled = useUndoRedoFlag();
62
58
  const containerStore = useBrandPageContainerStore();
63
59
  const userStore = useBrandPageMakerUserStore();
64
60
  const uiStore = useUiStore();
@@ -445,12 +441,6 @@ export function useAiWebsiteBuilderChat(): UseAiChatResult {
445
441
 
446
442
  await nextTick();
447
443
 
448
- // One history entry per AI prompt (US-E1). `captureAiChangeset` cancels
449
- // the auto-watcher's pending flush so the apply doesn't double-capture.
450
- if (undoRedoEnabled.value) {
451
- historyStore.captureAiChangeset();
452
- }
453
-
454
444
  // Re-capture snapshot so subsequent messages reflect the updated page
455
445
  await snapshotStore.refreshSnapshotAsync();
456
446
 
@@ -47,7 +47,6 @@ import {
47
47
  backgroundColorConvertor,
48
48
  } from '@brand-page-maker/convertors';
49
49
  import { useUiContentSettingsStore } from '@shared/content-settings/store';
50
- import { useHistoryStore } from '@brand-page-maker/stores/history/history-store';
51
50
  import { AllSelection } from 'prosemirror-state';
52
51
  import { MaxLength } from './extensions/MaxLength';
53
52
  import { AutoLink } from './extensions/AutoLink';
@@ -209,12 +208,6 @@ export const useRichTextEditor = (
209
208
  isHyperlinkPopupOpen: Ref<boolean>,
210
209
  selectedLinkTypeValue: Ref<HyperlinkType>,
211
210
  ): UseRichTextEditorReturn => {
212
- const historyStore = useHistoryStore();
213
-
214
- // TipTap rehydrates and writes back canonical HTML on mount — fold
215
- // that into the current head instead of pushing a phantom entry.
216
- historyStore.mergeNextMutation();
217
-
218
211
  const editor = new Editor({
219
212
  content: model.value ?? '',
220
213
  editable: !props.readOnly,
@@ -463,16 +456,7 @@ export const useRichTextEditor = (
463
456
  watch(
464
457
  () => model.value,
465
458
  (newValue) => {
466
- // Re-seed the editor when the model has been mutated from outside
467
- // (history undo/redo, template switch, reorder). `!editor.isFocused`
468
- // distinguishes "external mutation" from "user is typing in me" — the
469
- // latter would wipe the user's cursor if we called setContent.
470
- // `updateRichTextEditor.value` is retained as an explicit override for
471
- // callers (reorder) that need to force a re-seed while focused.
472
- const isExternalMutation =
473
- updateRichTextEditor.value || !editor.isFocused;
474
-
475
- if (isExternalMutation && editor.getHTML() !== newValue) {
459
+ if (updateRichTextEditor.value && editor.getHTML() !== newValue) {
476
460
  editor.commands.setContent(newValue, false);
477
461
  updateRichTextEditor.value = false;
478
462
  //text style type is not switching when reordering
@@ -503,13 +487,6 @@ export const useRichTextEditor = (
503
487
  });
504
488
 
505
489
  editor.on('selectionUpdate', () => {
506
- // Skip while a history snapshot is being applied — `setContent` fires
507
- // selectionUpdate before the editor has fully rehydrated, which causes
508
- // toolbar buttons (alignment, letter-spacing) to flash through bogus
509
- // active states before settling. The editor emits a final selectionUpdate
510
- // after apply completes, which lands the correct values (BP-5506).
511
- if (historyStore.isApplyingSnapshot) return;
512
-
513
490
  const textStyleAttributes = editor.getAttributes('textStyle');
514
491
  const highlightAttributes = editor.getAttributes('highlight');
515
492
  const focusedAlignment = editor.getAttributes(
@@ -70,10 +70,6 @@ export const EVENTS = {
70
70
  'website_maker_digital_business_cards_hide_popup',
71
71
  WEBSITE_MAKER_GETTY_VIDEO: 'website_maker_getty_video',
72
72
  WEBSITE_MAKER_SHIPPING_TOGGLE: 'website_maker_shipping_toggle',
73
- WEBSITE_MAKER_UNDO: 'website_maker_undo',
74
- WEBSITE_MAKER_REDO: 'website_maker_redo',
75
- WEBSITE_MAKER_HISTORY_CAPPED: 'website_maker_history_capped',
76
- WEBSITE_MAKER_HISTORY_OVERSIZED: 'website_maker_history_oversized',
77
73
  };
78
74
 
79
75
  export const SELECT_LOCATIONS = {
@@ -424,31 +420,6 @@ const useEventTracker = () => {
424
420
  is_enabled: isEnabled,
425
421
  });
426
422
  },
427
- // Undo / Redo (BP-5506)
428
- sendUndoEvent: (props: {
429
- entries_count: number;
430
- actor: string | undefined;
431
- }) => {
432
- _publishEvent(EVENTS.WEBSITE_MAKER_UNDO, props);
433
- },
434
- sendRedoEvent: (props: {
435
- entries_count: number;
436
- actor: string | undefined;
437
- }) => {
438
- _publishEvent(EVENTS.WEBSITE_MAKER_REDO, props);
439
- },
440
- sendHistoryCappedEvent: (props: {
441
- entries_count: number;
442
- size_bytes: number;
443
- }) => {
444
- _publishEvent(EVENTS.WEBSITE_MAKER_HISTORY_CAPPED, props);
445
- },
446
- sendHistoryOversizedEvent: (props: {
447
- attempted_bytes: number;
448
- source: string;
449
- }) => {
450
- _publishEvent(EVENTS.WEBSITE_MAKER_HISTORY_OVERSIZED, props);
451
- },
452
423
  };
453
424
  };
454
425
 
@@ -40,14 +40,6 @@ import { useUiBackgroundSettingsStore } from '@shared/background-settings/store'
40
40
  import { useBrandPageMakerUserStore } from '../user';
41
41
  import { useBrandPageContainerStore } from '../brandpage-container';
42
42
  import { useUiTemplateSettingsStore } from '@shared/template-settings/store';
43
- import { useUiNavigationStyleSettingsStore } from '@shared/navigation-style-settings/store';
44
- import {
45
- CONTENT_SETTINGS_MODES,
46
- useUiContentSettingsStore,
47
- } from '@shared/content-settings/store';
48
- import { useUiSideBarStore } from '@shared/side-bar/store';
49
- import { useUiEditableLogoStore } from '@shared/logo-settings/store/editable-logo-store';
50
- import { SIDE_BAR_TAB_NAMES } from '@brand-page-maker/constants';
51
43
  import { PAGE_SECTIONS } from '@shared/page-settings/models';
52
44
  import { FabricRenderClient } from '../../../clients/fabric-render-client';
53
45
  import { setLocaleAsync } from '@src/composables/useTranslate';
@@ -568,331 +560,4 @@ describe('brand page maker store module', () => {
568
560
  // Assert
569
561
  expect(setDesignTemplateTokenSpy).not.toHaveBeenCalled();
570
562
  });
571
-
572
- // BP-5506 regression: applyHistorySnapshot must replace nested navigation
573
- // style refs as a whole, not deep-merge them. The previous bug was that
574
- // object-form $patch would leave keys present in the live state but absent
575
- // from the snapshot in place — e.g. switching nav button styles then
576
- // undoing would leave the new style's borderColor / borderRadius applied.
577
- test('applyHistorySnapshot replaces navigation styles wholesale (no key bleed across undo)', async () => {
578
- // Arrange — initialise the maker so `applyHistorySnapshot` has a
579
- // populated set of dependent stores to write into.
580
- const makerStore = useBrandPageMakerStore();
581
- const navigationStyleSettingsStore = useUiNavigationStyleSettingsStore();
582
-
583
- await makerStore.initialise(INITIALISE_PAYLOAD);
584
-
585
- // Build snapshot A — the "older" state we'll undo back to. Keep the
586
- // navigation simple: only borderRadius is set on selectedButtonStyle.
587
- const snapshotA = {
588
- ...makerStore.brandPageData,
589
- pageHeaderDesktop: {
590
- ...makerStore.brandPageData.pageHeaderDesktop,
591
- navigation: {
592
- ...makerStore.brandPageData.pageHeaderDesktop?.navigation,
593
- selectedButtonStyle: {
594
- borderRadius: '0px',
595
- },
596
- },
597
- },
598
- } as BrandPageModel;
599
-
600
- // Build snapshot B — the "newer" state with extra keys that the
601
- // older snapshot does NOT have. If $patch deep-merged, these would
602
- // survive an undo back to A.
603
- const snapshotB = {
604
- ...snapshotA,
605
- pageHeaderDesktop: {
606
- ...snapshotA.pageHeaderDesktop,
607
- navigation: {
608
- ...snapshotA.pageHeaderDesktop?.navigation,
609
- selectedButtonStyle: {
610
- borderRadius: '12px',
611
- borderColor: 'rgb(255, 0, 0)',
612
- borderStyle: 'dashed',
613
- borderWidth: '4px',
614
- },
615
- },
616
- },
617
- } as BrandPageModel;
618
-
619
- // Act — apply newer first (simulates the user making the edit), then
620
- // older (simulates the undo). NavigationDesktop's constructor folds
621
- // its input over a defaults object, so we read the resulting state
622
- // and assert against the keys that came from snapshotB but NOT from
623
- // snapshotA.
624
- await makerStore.applyHistorySnapshot(snapshotB);
625
- await makerStore.applyHistorySnapshot(snapshotA);
626
-
627
- // Assert — after the undo, no keys from B should bleed through onto
628
- // A's selectedButtonStyle. Specifically the values that are unique to
629
- // B (red dashed border) must not be present.
630
- const restored =
631
- navigationStyleSettingsStore.navigation[PAGE_SECTIONS.header][
632
- VIEWPORTS.desktop
633
- ];
634
- const restoredSelected = restored.selectedButtonStyle;
635
-
636
- expect(restoredSelected.borderRadius).toBe('0px');
637
- // The B-only values must not survive the undo. NavigationStyles'
638
- // constructor seeds defaults for selectedButtonStyle, so we assert
639
- // the *exact* B-only values are gone rather than a strict superset.
640
- expect(restoredSelected.borderColor).not.toBe('rgb(255, 0, 0)');
641
- expect(restoredSelected.borderStyle).not.toBe('dashed');
642
- expect(restoredSelected.borderWidth).not.toBe('4px');
643
- });
644
-
645
- // BP-5506 regression: undoing a page-add must clear the URL/active-page
646
- // back to a page that exists in the restored snapshot. The page-tabs
647
- // carousel keys "selected" off the route URL; after `setNav` removes the
648
- // added route, no nav item matches the URL slug and the highlight
649
- // disappears. `applyHistorySnapshot` accepts an `activePageId` and writes
650
- // it through `pageNavigationStore.setCurrentActivePage` so the routeStore
651
- // and `currentPage` getter realign.
652
- test('applyHistorySnapshot updates pageNavigation.activePageId when given a valid id', async () => {
653
- const makerStore = useBrandPageMakerStore();
654
- const pageNavigationStore = usePageNavigationStore();
655
-
656
- await makerStore.initialise(INITIALISE_PAYLOAD);
657
-
658
- const restoredPageId = pageNavigationStore.routes[0]?.pageId;
659
-
660
- expect(restoredPageId).toBeDefined();
661
-
662
- pageNavigationStore.activePageId = '';
663
-
664
- await makerStore.applyHistorySnapshot(
665
- makerStore.brandPageData,
666
- restoredPageId,
667
- );
668
-
669
- expect(pageNavigationStore.activePageId).toBe(restoredPageId);
670
- });
671
-
672
- test('applyHistorySnapshot falls back to first/default route when no activePageId is provided', async () => {
673
- const makerStore = useBrandPageMakerStore();
674
- const pageNavigationStore = usePageNavigationStore();
675
-
676
- await makerStore.initialise(INITIALISE_PAYLOAD);
677
-
678
- const expectedFirstId =
679
- pageNavigationStore.getFirstOrDefaultRoute()?.pageId;
680
-
681
- expect(expectedFirstId).toBeDefined();
682
-
683
- pageNavigationStore.activePageId = 'stale-page-id-not-in-nav';
684
-
685
- await makerStore.applyHistorySnapshot(makerStore.brandPageData);
686
-
687
- expect(pageNavigationStore.activePageId).toBe(expectedFirstId);
688
- });
689
-
690
- // BP-5506 follow-up: undoing a non-page-structural edit (e.g. a title
691
- // change) must NOT push a new route. The router push fires
692
- // `router.afterEach`, and BrandPageMaker.mixin's afterEach hook resets
693
- // the content-settings modeStack — which would snap the sidebar back
694
- // to the default Content tab on every undo, even when the user was
695
- // deep-editing a content item. Same-page navigation MUST be skipped.
696
- test('applyHistorySnapshot does NOT touch modeStack when active page is unchanged', async () => {
697
- const makerStore = useBrandPageMakerStore();
698
- const pageNavigationStore = usePageNavigationStore();
699
- const contentSettingsStore = useUiContentSettingsStore();
700
-
701
- await makerStore.initialise(INITIALISE_PAYLOAD);
702
-
703
- const activePageId = pageNavigationStore.routes[0]?.pageId;
704
-
705
- expect(activePageId).toBeDefined();
706
-
707
- pageNavigationStore.activePageId = activePageId!;
708
-
709
- // User is deep-editing a content item — focused mode pushed onto the stack.
710
- const realItemId = contentSettingsStore.items[0]?.id;
711
-
712
- expect(realItemId).toBeDefined();
713
-
714
- contentSettingsStore.pushMode({
715
- mode: CONTENT_SETTINGS_MODES.focusedContentItem,
716
- selectedItemId: realItemId,
717
- });
718
- contentSettingsStore.selectedItemId = realItemId;
719
-
720
- expect(contentSettingsStore.mode).toBe(
721
- CONTENT_SETTINGS_MODES.focusedContentItem,
722
- );
723
-
724
- // Apply a snapshot whose activePageId equals the current page (i.e.
725
- // a non-structural edit that didn't change pages — title edit, color
726
- // change, etc.).
727
- await makerStore.applyHistorySnapshot(
728
- makerStore.brandPageData,
729
- activePageId,
730
- );
731
-
732
- // Mode stack is preserved — no router.afterEach was triggered.
733
- expect(contentSettingsStore.mode).toBe(
734
- CONTENT_SETTINGS_MODES.focusedContentItem,
735
- );
736
- expect(contentSettingsStore.selectedItemId).toBe(realItemId);
737
- });
738
-
739
- // BP-5506 regression: when undoing a content add, the selected item
740
- // disappears. The fallback must restore the Content tab's natural
741
- // landing state (mode = edit, selectedItemId = null), not just switch
742
- // tabs — otherwise `<FocusedContentItemSettings>` keeps rendering for
743
- // a missing item and paints a blank panel.
744
- test('applyHistorySnapshot resets sidebar to default Content tab when selected item is gone', async () => {
745
- const makerStore = useBrandPageMakerStore();
746
- const contentSettingsStore = useUiContentSettingsStore();
747
- const sideBarStore = useUiSideBarStore();
748
-
749
- await makerStore.initialise(INITIALISE_PAYLOAD);
750
-
751
- // Simulate the user opening a content item's focused settings.
752
- const orphanItemId = 'orphan-content-id-not-in-snapshot';
753
-
754
- contentSettingsStore.pushMode({
755
- mode: CONTENT_SETTINGS_MODES.focusedContentItem,
756
- selectedItemId: orphanItemId,
757
- });
758
- contentSettingsStore.selectedItemId = orphanItemId;
759
- sideBarStore.setSelectedTabName({
760
- tabName: SIDE_BAR_TAB_NAMES.CONTENT_SETTINGS,
761
- });
762
-
763
- // Pre-condition: panel is showing the focused content item.
764
- expect(contentSettingsStore.mode).toBe(
765
- CONTENT_SETTINGS_MODES.focusedContentItem,
766
- );
767
- expect(contentSettingsStore.selectedItemId).toBe(orphanItemId);
768
-
769
- // Snapshot does NOT contain orphanItemId — simulates undo of an add.
770
- await makerStore.applyHistorySnapshot(makerStore.brandPageData);
771
-
772
- // Post-condition: same shape as a fresh Content tab click.
773
- expect(contentSettingsStore.mode).toBe(CONTENT_SETTINGS_MODES.edit);
774
- expect(contentSettingsStore.selectedItemId).toBeNull();
775
- expect(sideBarStore.selectedTabName).toBe(
776
- SIDE_BAR_TAB_NAMES.CONTENT_SETTINGS,
777
- );
778
- });
779
-
780
- // BP-5506 follow-up: applyHistorySnapshot accepts a `logoEdits` JSON
781
- // string (sidecar to brandPageData; pre-purchase logo-tab form-field
782
- // state). On undo it must wholesale-replace `editableLogoStore.logoEdits`
783
- // so the form fields reflect the pre-edit state. Wholesale replacement
784
- // matters because a previous entry's textObjects/colors must NOT leak
785
- // through (e.g. switching template A→B then undoing must NOT keep B's
786
- // textObject ids in A's restored state).
787
- test('applyHistorySnapshot restores editableLogoStore.logoEdits from sidecar', async () => {
788
- const makerStore = useBrandPageMakerStore();
789
- const editableLogoStore = useUiEditableLogoStore();
790
-
791
- await makerStore.initialise(INITIALISE_PAYLOAD);
792
-
793
- // User has typed "AcmeCo" — current logoEdits state.
794
- editableLogoStore.logoEdits.textObjects = [
795
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
796
- {
797
- id: 't1',
798
- role: 'primary-text',
799
- text: 'AcmeCo',
800
- textEnabled: true,
801
- } as any,
802
- ];
803
-
804
- // The history entry the user is undoing TO captured "Acme".
805
- const sidecar = JSON.stringify({
806
- backgroundObject: { id: 'bg', type: 'rect', role: 'background' },
807
- logoObject: {
808
- id: 'lg',
809
- type: 'group',
810
- role: 'logo',
811
- logoColors: [],
812
- logoStrokeColors: [],
813
- },
814
- textObjects: [
815
- { id: 't1', role: 'primary-text', text: 'Acme', textEnabled: true },
816
- ],
817
- });
818
-
819
- await makerStore.applyHistorySnapshot(
820
- makerStore.brandPageData,
821
- undefined,
822
- sidecar,
823
- );
824
-
825
- expect(editableLogoStore.logoEdits.textObjects).toEqual([
826
- { id: 't1', role: 'primary-text', text: 'Acme', textEnabled: true },
827
- ]);
828
- });
829
-
830
- test('applyHistorySnapshot wholesale-replaces logoEdits (no leak from prior state)', async () => {
831
- const makerStore = useBrandPageMakerStore();
832
- const editableLogoStore = useUiEditableLogoStore();
833
-
834
- await makerStore.initialise(INITIALISE_PAYLOAD);
835
-
836
- // Current state has TWO textObjects (e.g. user is on template B with a
837
- // logo + tagline).
838
- editableLogoStore.logoEdits.textObjects = [
839
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
840
- {
841
- id: 'b-1',
842
- role: 'primary-text',
843
- text: 'Brand B',
844
- textEnabled: true,
845
- } as any,
846
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
847
- { id: 'b-2', role: 'tagline', text: 'tagline', textEnabled: true } as any,
848
- ];
849
-
850
- // Undo target captured template A — only ONE textObject with a
851
- // different id. After restore, b-1 / b-2 must be gone.
852
- const sidecar = JSON.stringify({
853
- backgroundObject: { id: 'bg', type: 'rect', role: 'background' },
854
- logoObject: {
855
- id: 'lg',
856
- type: 'group',
857
- role: 'logo',
858
- logoColors: [],
859
- logoStrokeColors: [],
860
- },
861
- textObjects: [
862
- { id: 'a-1', role: 'primary-text', text: 'Brand A', textEnabled: true },
863
- ],
864
- });
865
-
866
- await makerStore.applyHistorySnapshot(
867
- makerStore.brandPageData,
868
- undefined,
869
- sidecar,
870
- );
871
-
872
- expect(editableLogoStore.logoEdits.textObjects).toHaveLength(1);
873
- expect(editableLogoStore.logoEdits.textObjects[0].id).toBe('a-1');
874
- });
875
-
876
- test('applyHistorySnapshot leaves logoEdits untouched when sidecar is undefined', async () => {
877
- const makerStore = useBrandPageMakerStore();
878
- const editableLogoStore = useUiEditableLogoStore();
879
-
880
- await makerStore.initialise(INITIALISE_PAYLOAD);
881
-
882
- editableLogoStore.logoEdits.textObjects = [
883
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
884
- {
885
- id: 't1',
886
- role: 'primary-text',
887
- text: 'Acme',
888
- textEnabled: true,
889
- } as any,
890
- ];
891
-
892
- // No third arg — pre-existing entries from before this feature shipped.
893
- await makerStore.applyHistorySnapshot(makerStore.brandPageData);
894
-
895
- // Still 'Acme' — no restore attempted.
896
- expect(editableLogoStore.logoEdits.textObjects[0].text).toBe('Acme');
897
- });
898
563
  });