@designcrowd/library.brand-page 5.17.25-undo-4 → 5.17.25-undo-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 (22) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-Bfno64hd.js → CreatedOnBrandCrowd-de-de-CHMMocnx.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-D_vCn5Pl.js → CreatedOnBrandCrowd-en-us-DHlWLkwc.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-Dbsv2mXS.js → CreatedOnBrandCrowd-es-es-DeoGQeBU.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-C7cjAdAT.js → CreatedOnBrandCrowd-fr-ca-DmZV08MV.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-C7cjAdAT.js → CreatedOnBrandCrowd-fr-fr-DmZV08MV.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-qkmkw32p.js → CreatedOnBrandCrowd-pt-br-COuMaj13.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-qkmkw32p.js → CreatedOnBrandCrowd-pt-pt-COuMaj13.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-CQUNS-WQ.js → CreatedOnDcom-de-de-C9XvdB6Y.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-DSTor88S.js → CreatedOnDcom-en-us-CSIczk-e.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-B_gzXzCR.js → CreatedOnDcom-es-es-B8PxGq85.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-DskYXGaJ.js → CreatedOnDcom-fr-ca-ClXbe4Tz.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-B3A-09VT.js → CreatedOnDcom-fr-fr-DvVB8qIo.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-EhBegIrb.js → CreatedOnDcom-pt-br-DmBFmt7n.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-BkWfCkfb.js → CreatedOnDcom-pt-pt-DdPrMHbl.js} +1 -1
  15. package/lib/src/brand-page-maker/stores/history/history-store.js +32 -1
  16. package/lib/src/brand-page-maker/stores/user/user-store.js +1 -1
  17. package/lib/src/index.mjs +1 -1
  18. package/lib/src/{lib-qbF5b3zi.js → lib-Cox69cyq.js} +2908 -2903
  19. package/package.json +1 -1
  20. package/src/brand-page-maker/stores/history/history-store.test.ts +105 -0
  21. package/src/brand-page-maker/stores/history/history-store.ts +37 -1
  22. package/src/brand-page-maker/stores/user/user-store.ts +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@designcrowd/library.brand-page",
3
3
  "description": "A collection of Maker/Designer applications",
4
- "version": "5.17.25-undo-4",
4
+ "version": "5.17.25-undo-5",
5
5
  "author": "Design.com Eng",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -261,6 +261,111 @@ describe('history-store (single stack + JSON-string snapshots)', () => {
261
261
  expect(store.entries.length).toBe(1);
262
262
  });
263
263
 
264
+ it('treats RTE default-hydration wrapper around plain text as a no-op', async () => {
265
+ const store = useHistoryStore();
266
+
267
+ // Cold-start: titles/descriptions are plain strings (no <p> wrapper).
268
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
+ (mockMakerStore.brandPageData as any).pages = [
270
+ {
271
+ contents: [
272
+ {
273
+ type: 'banner',
274
+ title: 'Makeup Artist ✦ Eleanor Reeves',
275
+ description: 'Creating Flawless Looks',
276
+ },
277
+ {
278
+ type: 'about-section',
279
+ title: 'Passionate About Makeup',
280
+ paragraph:
281
+ 'Makeup is my art form, and I believe that everyone deserves to feel confident.',
282
+ },
283
+ ],
284
+ },
285
+ ];
286
+ await store.captureBaseline();
287
+
288
+ // Opening any content sidebar mounts every RTE editor on the page; each
289
+ // one writes back its plain-text input wrapped in TipTap's default
290
+ // <p>/<span>/<mark> hydration HTML. Same visible text, no real edit.
291
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
292
+ const banner = (mockMakerStore.brandPageData as any).pages[0].contents[0];
293
+
294
+ banner.title =
295
+ '<p style="text-align: center;"><span style="font-family: Belleza; font-size: 1.5625em; letter-spacing: 0.02em; line-height: 1.5; color: rgb(209, 128, 47);"><mark data-color="#fffde9" style="background-color: rgb(255, 253, 233); color: inherit;">Makeup Artist ✦ Eleanor Reeves</mark></span></p>';
296
+ banner.description =
297
+ '<p style="text-align: center;"><span style="font-family: Gloock; font-size: 4.6875em; letter-spacing: 0.05em; line-height: 1.4; color: rgb(209, 128, 47);"><mark data-color="#fffde9" style="background-color: rgb(255, 253, 233); color: inherit;">Creating Flawless Looks</mark></span></p>';
298
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
+ const about = (mockMakerStore.brandPageData as any).pages[0].contents[1];
300
+
301
+ about.title =
302
+ '<p style="text-align: left;"><span style="font-family: Gloock; font-size: 3.125em; letter-spacing: 0.05em; line-height: 1.3; color: rgb(255, 253, 233);">Passionate About Makeup</span></p>';
303
+ about.paragraph =
304
+ '<p style="text-align: left;"><span style="font-family: Belleza; font-size: 1.375em; letter-spacing: 0px; line-height: 1.5; color: rgb(255, 253, 233);">Makeup is my art form, and I believe that everyone deserves to feel confident.</span></p>';
305
+
306
+ const result = store.capture({ source: 'manual_edit', actor: 'user' });
307
+
308
+ expect(result).toBe('noop');
309
+ expect(store.entries.length).toBe(1);
310
+ });
311
+
312
+ it('treats bare <p>plain text</p> hydration as a no-op', async () => {
313
+ const store = useHistoryStore();
314
+
315
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
316
+ (mockMakerStore.brandPageData as any).pages = [
317
+ {
318
+ contents: [
319
+ {
320
+ type: 'contact-form',
321
+ successMessage:
322
+ "Thank you! We'll get in touch with you as soon as possible.",
323
+ },
324
+ ],
325
+ },
326
+ ];
327
+ await store.captureBaseline();
328
+
329
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
+ (
331
+ mockMakerStore.brandPageData as any
332
+ ).pages[0].contents[0].successMessage =
333
+ "<p>Thank you! We'll get in touch with you as soon as possible.</p>";
334
+
335
+ const result = store.capture({ source: 'manual_edit', actor: 'user' });
336
+
337
+ expect(result).toBe('noop');
338
+ expect(store.entries.length).toBe(1);
339
+ });
340
+
341
+ it('still commits when RTE content has real inline formatting tags', async () => {
342
+ const store = useHistoryStore();
343
+
344
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
345
+ (mockMakerStore.brandPageData as any).pages = [
346
+ {
347
+ contents: [
348
+ {
349
+ type: 'banner',
350
+ title: 'Hello world',
351
+ },
352
+ ],
353
+ },
354
+ ];
355
+ await store.captureBaseline();
356
+
357
+ // Real formatting (the <strong> tag) must NOT be collapsed to plain
358
+ // text — it represents a user-visible diff.
359
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
+ (mockMakerStore.brandPageData as any).pages[0].contents[0].title =
361
+ '<p>Hello <strong>world</strong></p>';
362
+
363
+ const result = store.capture({ source: 'manual_edit', actor: 'user' });
364
+
365
+ expect(result).toBe('committed');
366
+ expect(store.entries.length).toBe(2);
367
+ });
368
+
264
369
  it('still commits when a real edit accompanies a phantom field', async () => {
265
370
  const store = useHistoryStore();
266
371
 
@@ -149,10 +149,37 @@ export const useHistoryStore = defineStore('history', () => {
149
149
  // string. Treated as equivalent to `""` for dedup.
150
150
  const EMPTY_RTE_HTML = /^<p(\s[^>]*)?>(<br\s*\/?>)?<\/p>$/;
151
151
 
152
+ // TipTap's default-hydration shape: a single <p> (with optional align
153
+ // attr) containing the original plain text, optionally wrapped in
154
+ // default-styled <span> (font-family / font-size / color) and/or
155
+ // <mark> (highlight) tags. The inner capture intentionally rejects any
156
+ // string that itself contains `<` or `>` so that real formatting tags
157
+ // — `<strong>`, `<em>`, `<a>`, nested spans with non-default styles —
158
+ // are preserved as a real diff rather than collapsed.
159
+ const RTE_DEFAULT_HYDRATION =
160
+ /^<p(\s[^>]*)?>(<span(\s[^>]*)?>)?(<mark(\s[^>]*)?>)?([^<>]*)(<\/mark>)?(<\/span>)?<\/p>$/;
161
+
152
162
  function isEmptyRteHtml(value: unknown): boolean {
153
163
  return typeof value === 'string' && EMPTY_RTE_HTML.test(value);
154
164
  }
155
165
 
166
+ /**
167
+ * If `value` is TipTap's default-hydration wrapper around a plain text
168
+ * (no inline formatting tags), return the bare inner text. Otherwise
169
+ * return the original string. This collapses the BP-5506 phantom where
170
+ * opening a content sidebar mounts every RTE editor at once and writes
171
+ * back wrapped HTML with no user-visible delta.
172
+ */
173
+ function canonicalizeRteString(value: string): string {
174
+ if (EMPTY_RTE_HTML.test(value)) return '';
175
+
176
+ const match = value.match(RTE_DEFAULT_HYDRATION);
177
+
178
+ if (!match) return value;
179
+
180
+ return match[6] ?? '';
181
+ }
182
+
156
183
  function normalizeNode(node: unknown): unknown {
157
184
  if (Array.isArray(node)) return node.map(normalizeNode);
158
185
 
@@ -161,13 +188,22 @@ export const useHistoryStore = defineStore('history', () => {
161
188
  const out: Record<string, unknown> = {};
162
189
 
163
190
  for (const key of Object.keys(node as Record<string, unknown>)) {
164
- const v = (node as Record<string, unknown>)[key];
191
+ let v: unknown = (node as Record<string, unknown>)[key];
165
192
 
166
193
  // Strip the template-modified flag — it's meta-state that flips on
167
194
  // first edit gesture (e.g. clicking into a panel) and does not
168
195
  // represent a user-visible change.
169
196
  if (key === 'isModifiedAfterTemplateApplied') continue;
170
197
 
198
+ // Collapse RTE default-hydration wrappers down to the plain text
199
+ // they wrap. Plain "X" and `<p style="..."><span ...><mark ...>X
200
+ // </mark></span></p>` share the same canonical "X" so a sidebar
201
+ // open that mounts every editor at once doesn't generate phantom
202
+ // undo steps.
203
+ if (typeof v === 'string') {
204
+ v = canonicalizeRteString(v);
205
+ }
206
+
171
207
  // Empty TipTap paragraphs collapse to "" — and an empty string is
172
208
  // equivalent to the key being absent (JSON.stringify drops `undefined`),
173
209
  // so skip the key entirely. Otherwise the normalizer would emit
@@ -34,7 +34,7 @@ export const useBrandPageMakerUserStore = defineStore('brandPageMakerUser', {
34
34
  canUseAITextGenerator: false,
35
35
  canUseGoogleAdsense: false,
36
36
  googleAdsenseEnabled: false,
37
- canUseUndoRedo: false,
37
+ canUseUndoRedo: true,
38
38
  },
39
39
  emailAddress: '',
40
40
  hasPremiumSubscription: false,