@designcrowd/library.brand-page 6.1.1-json-prereq-3 → 6.1.1-json-prereq-4

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 (21) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-hj_ievMc.js → CreatedOnBrandCrowd-de-de-Dk-G3RbI.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-jAOSpfCw.js → CreatedOnBrandCrowd-en-us-AVAWRjbj.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-DZMVc-y3.js → CreatedOnBrandCrowd-es-es-C5Xq4Jln.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-DvB54H38.js → CreatedOnBrandCrowd-fr-ca-BQXjmcrr.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-DvB54H38.js → CreatedOnBrandCrowd-fr-fr-BQXjmcrr.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-bf-x1xhi.js → CreatedOnBrandCrowd-pt-br-DRMRc1Zk.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-bf-x1xhi.js → CreatedOnBrandCrowd-pt-pt-DRMRc1Zk.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-B-NY1B44.js → CreatedOnDcom-de-de-Dd9-oQ34.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-Cd4C6KQf.js → CreatedOnDcom-en-us-CnDfLzF4.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-DONlsQsm.js → CreatedOnDcom-es-es-bvqvI9gT.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-Dsv3FRpZ.js → CreatedOnDcom-fr-ca-BG7UGFe8.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-DOgyvY5C.js → CreatedOnDcom-fr-fr-xdz35O_B.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-DX66MhJS.js → CreatedOnDcom-pt-br-CLfHnCkk.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-COe2G0bU.js → CreatedOnDcom-pt-pt-Z7FY0BXt.js} +1 -1
  15. package/lib/src/brand-page-maker/utils/rich-text-editor.util.d.ts +8 -0
  16. package/lib/src/brand-page-maker/utils/rich-text-editor.util.js +18 -1
  17. package/lib/src/index.mjs +1 -1
  18. package/lib/src/{lib-scDtk-Pi.js → lib-uYwxz8qR.js} +4519 -4511
  19. package/package.json +1 -1
  20. package/src/brand-page-maker/utils/rich-text-editor.util.test.ts +25 -0
  21. package/src/brand-page-maker/utils/rich-text-editor.util.ts +21 -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": "6.1.1-json-prereq-3",
4
+ "version": "6.1.1-json-prereq-4",
5
5
  "author": "Design.com Eng",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -101,6 +101,31 @@ describe('getRteTextLength', () => {
101
101
  expect(getRteTextLength(doc)).toBe(11);
102
102
  });
103
103
 
104
+ it('counts adjacent split nodes with no phantom separator (BP-5787)', () => {
105
+ // Hyperlinking (or bolding) a word splits its text node. Length must match
106
+ // the editor's textContent — "clickhere" = 9 — NOT a space-joined
107
+ // "click here" = 10, which would fire the max-length indicator one char
108
+ // early and flicker as content settles.
109
+ const doc = {
110
+ type: 'doc',
111
+ content: [
112
+ {
113
+ type: 'paragraph',
114
+ content: [
115
+ { type: 'text', text: 'click' },
116
+ {
117
+ type: 'text',
118
+ text: 'here',
119
+ marks: [{ type: 'link', attrs: { href: 'https://x.com' } }],
120
+ },
121
+ ],
122
+ },
123
+ ],
124
+ };
125
+
126
+ expect(getRteTextLength(doc)).toBe(9);
127
+ });
128
+
104
129
  it('returns 0 for null/undefined and an empty doc', () => {
105
130
  expect(getRteTextLength(null)).toBe(0);
106
131
  expect(getRteTextLength(undefined)).toBe(0);
@@ -316,13 +316,33 @@ export const getPlainTextFromRTE = (content: unknown): string => {
316
316
  * concatenated visible text. Without this, `doc.length` is `undefined` (silently
317
317
  * disabling the check) and `doc.trim()` throws — the class of bug that survived
318
318
  * the `RichTextValue` widening because Vue Options-API `this`/item access is `any`.
319
+ *
320
+ * The JSON branch concatenates text nodes with NO separator, matching the
321
+ * editor's own char count (ProseMirror textContent) — the metric the MaxLength
322
+ * extension gates on. It deliberately does NOT reuse getRteJsonPlainText, whose
323
+ * space-join + trim (for readable plain-text extraction) over-counts by one per
324
+ * inline mark boundary — so hyperlinking or formatting a word made the item's
325
+ * max-length indicator disagree with the gate and fire at content that was
326
+ * actually under the cap (BP-5787).
319
327
  */
320
328
  export const getRteTextLength = (
321
329
  value: RichTextValue | null | undefined,
322
330
  ): number => {
323
331
  if (typeof value === 'string') return value.length;
324
332
 
325
- return value ? getRteJsonPlainText(value).length : 0;
333
+ if (!value) return 0;
334
+
335
+ let length = 0;
336
+
337
+ const walk = (node: JSONContent): void => {
338
+ if (typeof node.text === 'string') length += node.text.length;
339
+
340
+ node.content?.forEach(walk);
341
+ };
342
+
343
+ walk(value);
344
+
345
+ return length;
326
346
  };
327
347
 
328
348
  export const replaceTextInRTE = (