docx-diff-editor 1.0.51 → 1.0.52

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.
package/dist/index.d.mts CHANGED
@@ -516,8 +516,12 @@ declare function createTrackDeleteMark(author?: TrackChangeAuthor, id?: string):
516
516
  *
517
517
  * Note: SuperDoc's parseFormatList requires all marks in before/after arrays
518
518
  * to have both `type` and `attrs` properties. Marks without `attrs` get filtered out,
519
- * causing empty values in track change bubbles. We normalize marks here to ensure
520
- * all have at least an empty `attrs` object.
519
+ * causing empty values in track change bubbles.
520
+ *
521
+ * We use normalizeMarksForTrackFormat which:
522
+ * 1. Ensures all marks have `attrs` property (required by parseFormatList)
523
+ * 2. Cleans attrs to remove null/undefined/empty values (prevents "Set X to undefined" bubbles)
524
+ * 3. Normalizes color values to valid CSS format
521
525
  */
522
526
  declare function createTrackFormatMark(before: ProseMirrorMark[], after: ProseMirrorMark[], author?: TrackChangeAuthor): ProseMirrorMark;
523
527
 
package/dist/index.d.ts CHANGED
@@ -516,8 +516,12 @@ declare function createTrackDeleteMark(author?: TrackChangeAuthor, id?: string):
516
516
  *
517
517
  * Note: SuperDoc's parseFormatList requires all marks in before/after arrays
518
518
  * to have both `type` and `attrs` properties. Marks without `attrs` get filtered out,
519
- * causing empty values in track change bubbles. We normalize marks here to ensure
520
- * all have at least an empty `attrs` object.
519
+ * causing empty values in track change bubbles.
520
+ *
521
+ * We use normalizeMarksForTrackFormat which:
522
+ * 1. Ensures all marks have `attrs` property (required by parseFormatList)
523
+ * 2. Cleans attrs to remove null/undefined/empty values (prevents "Set X to undefined" bubbles)
524
+ * 3. Normalizes color values to valid CSS format
521
525
  */
522
526
  declare function createTrackFormatMark(before: ProseMirrorMark[], after: ProseMirrorMark[], author?: TrackChangeAuthor): ProseMirrorMark;
523
527
 
package/dist/index.js CHANGED
@@ -541,6 +541,18 @@ function ensureValidCssColor(color) {
541
541
  }
542
542
 
543
543
  // src/services/trackChangeInjector.ts
544
+ function isMeaningfulValue(value) {
545
+ return value !== null && value !== void 0 && value !== "";
546
+ }
547
+ function cleanAttrs(attrs) {
548
+ const cleaned = {};
549
+ for (const [key, value] of Object.entries(attrs)) {
550
+ if (isMeaningfulValue(value)) {
551
+ cleaned[key] = value;
552
+ }
553
+ }
554
+ return cleaned;
555
+ }
544
556
  function normalizeMark(mark) {
545
557
  const attrs = { ...mark.attrs || {} };
546
558
  if (attrs.color !== void 0) {
@@ -551,9 +563,23 @@ function normalizeMark(mark) {
551
563
  attrs
552
564
  };
553
565
  }
566
+ function normalizeMarkForTrackFormat(mark) {
567
+ let attrs = { ...mark.attrs || {} };
568
+ if (attrs.color !== void 0) {
569
+ attrs.color = ensureValidCssColor(attrs.color);
570
+ }
571
+ attrs = cleanAttrs(attrs);
572
+ return {
573
+ type: mark.type,
574
+ attrs
575
+ };
576
+ }
554
577
  function normalizeMarks(marks) {
555
578
  return marks.map(normalizeMark);
556
579
  }
580
+ function normalizeMarksForTrackFormat(marks) {
581
+ return marks.map(normalizeMarkForTrackFormat);
582
+ }
557
583
  function normalizeMarksForRendering(marks) {
558
584
  return normalizeMarks(marks);
559
585
  }
@@ -582,8 +608,8 @@ function createTrackDeleteMark(author = DEFAULT_AUTHOR, id) {
582
608
  };
583
609
  }
584
610
  function createTrackFormatMark(before, after, author = DEFAULT_AUTHOR) {
585
- const normalizedBefore = normalizeMarks(before);
586
- const normalizedAfter = normalizeMarks(after);
611
+ const normalizedBefore = normalizeMarksForTrackFormat(before);
612
+ const normalizedAfter = normalizeMarksForTrackFormat(after);
587
613
  return {
588
614
  type: "trackFormat",
589
615
  attrs: {