docx-diff-editor 1.0.50 → 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
@@ -452,66 +452,76 @@ var TIMEOUTS = {
452
452
  /** Cleanup delay (ms) */
453
453
  CLEANUP_DELAY: 100
454
454
  };
455
+
456
+ // src/services/colorUtils.ts
455
457
  var CSS_NAMED_COLORS = {
456
458
  // Basic colors
457
- black: "#000000",
458
- white: "#ffffff",
459
- red: "#ff0000",
460
- green: "#008000",
461
- blue: "#0000ff",
462
- yellow: "#ffff00",
463
- cyan: "#00ffff",
464
- magenta: "#ff00ff",
459
+ black: "000000",
460
+ white: "ffffff",
461
+ red: "ff0000",
462
+ green: "008000",
463
+ blue: "0000ff",
464
+ yellow: "ffff00",
465
+ cyan: "00ffff",
466
+ magenta: "ff00ff",
465
467
  // Extended colors
466
- orange: "#ffa500",
467
- pink: "#ffc0cb",
468
- purple: "#800080",
469
- violet: "#ee82ee",
470
- brown: "#a52a2a",
471
- gray: "#808080",
472
- grey: "#808080",
468
+ orange: "ffa500",
469
+ pink: "ffc0cb",
470
+ purple: "800080",
471
+ violet: "ee82ee",
472
+ brown: "a52a2a",
473
+ gray: "808080",
474
+ grey: "808080",
473
475
  // Light variants
474
- lightblue: "#add8e6",
475
- lightgreen: "#90ee90",
476
- lightgray: "#d3d3d3",
477
- lightgrey: "#d3d3d3",
478
- lightpink: "#ffb6c1",
479
- lightyellow: "#ffffe0",
476
+ lightblue: "add8e6",
477
+ lightgreen: "90ee90",
478
+ lightgray: "d3d3d3",
479
+ lightgrey: "d3d3d3",
480
+ lightpink: "ffb6c1",
481
+ lightyellow: "ffffe0",
480
482
  // Dark variants
481
- darkblue: "#00008b",
482
- darkgreen: "#006400",
483
- darkgray: "#a9a9a9",
484
- darkgrey: "#a9a9a9",
485
- darkred: "#8b0000",
483
+ darkblue: "00008b",
484
+ darkgreen: "006400",
485
+ darkgray: "a9a9a9",
486
+ darkgrey: "a9a9a9",
487
+ darkred: "8b0000",
486
488
  // Other common colors
487
- navy: "#000080",
488
- teal: "#008080",
489
- maroon: "#800000",
490
- olive: "#808000",
491
- silver: "#c0c0c0",
492
- aqua: "#00ffff",
493
- fuchsia: "#ff00ff",
494
- lime: "#00ff00",
495
- coral: "#ff7f50",
496
- salmon: "#fa8072",
497
- gold: "#ffd700",
498
- indigo: "#4b0082",
499
- crimson: "#dc143c",
500
- tomato: "#ff6347",
501
- chocolate: "#d2691e",
502
- tan: "#d2b48c",
503
- beige: "#f5f5dc",
504
- ivory: "#fffff0",
505
- khaki: "#f0e68c",
506
- lavender: "#e6e6fa",
507
- plum: "#dda0dd",
508
- orchid: "#da70d6",
509
- turquoise: "#40e0d0",
510
- skyblue: "#87ceeb",
511
- steelblue: "#4682b4",
512
- slategray: "#708090",
513
- slategrey: "#708090"
489
+ navy: "000080",
490
+ teal: "008080",
491
+ maroon: "800000",
492
+ olive: "808000",
493
+ silver: "c0c0c0",
494
+ aqua: "00ffff",
495
+ fuchsia: "ff00ff",
496
+ lime: "00ff00",
497
+ coral: "ff7f50",
498
+ salmon: "fa8072",
499
+ gold: "ffd700",
500
+ indigo: "4b0082",
501
+ crimson: "dc143c",
502
+ tomato: "ff6347",
503
+ chocolate: "d2691e",
504
+ tan: "d2b48c",
505
+ beige: "f5f5dc",
506
+ ivory: "fffff0",
507
+ khaki: "f0e68c",
508
+ lavender: "e6e6fa",
509
+ plum: "dda0dd",
510
+ orchid: "da70d6",
511
+ turquoise: "40e0d0",
512
+ skyblue: "87ceeb",
513
+ steelblue: "4682b4",
514
+ slategray: "708090",
515
+ slategrey: "708090"
514
516
  };
517
+ function colorToHexWithoutHash(color) {
518
+ const trimmed = color.trim();
519
+ const lowerColor = trimmed.toLowerCase();
520
+ if (CSS_NAMED_COLORS[lowerColor]) {
521
+ return CSS_NAMED_COLORS[lowerColor];
522
+ }
523
+ return trimmed.replace(/^#/, "");
524
+ }
515
525
  function ensureValidCssColor(color) {
516
526
  if (typeof color !== "string" || !color) {
517
527
  return void 0;
@@ -519,7 +529,7 @@ function ensureValidCssColor(color) {
519
529
  const trimmed = color.trim();
520
530
  const lowerColor = trimmed.toLowerCase();
521
531
  if (CSS_NAMED_COLORS[lowerColor]) {
522
- return CSS_NAMED_COLORS[lowerColor];
532
+ return `#${CSS_NAMED_COLORS[lowerColor]}`;
523
533
  }
524
534
  if (/^[0-9a-fA-F]{6}$/.test(trimmed)) {
525
535
  return `#${trimmed}`;
@@ -529,6 +539,20 @@ function ensureValidCssColor(color) {
529
539
  }
530
540
  return trimmed;
531
541
  }
542
+
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
+ }
532
556
  function normalizeMark(mark) {
533
557
  const attrs = { ...mark.attrs || {} };
534
558
  if (attrs.color !== void 0) {
@@ -539,9 +563,23 @@ function normalizeMark(mark) {
539
563
  attrs
540
564
  };
541
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
+ }
542
577
  function normalizeMarks(marks) {
543
578
  return marks.map(normalizeMark);
544
579
  }
580
+ function normalizeMarksForTrackFormat(marks) {
581
+ return marks.map(normalizeMarkForTrackFormat);
582
+ }
545
583
  function normalizeMarksForRendering(marks) {
546
584
  return normalizeMarks(marks);
547
585
  }
@@ -570,8 +608,8 @@ function createTrackDeleteMark(author = DEFAULT_AUTHOR, id) {
570
608
  };
571
609
  }
572
610
  function createTrackFormatMark(before, after, author = DEFAULT_AUTHOR) {
573
- const normalizedBefore = normalizeMarks(before);
574
- const normalizedAfter = normalizeMarks(after);
611
+ const normalizedBefore = normalizeMarksForTrackFormat(before);
612
+ const normalizedAfter = normalizeMarksForTrackFormat(after);
575
613
  return {
576
614
  type: "trackFormat",
577
615
  attrs: {
@@ -588,77 +626,9 @@ function createTrackFormatMark(before, after, author = DEFAULT_AUTHOR) {
588
626
 
589
627
  // src/services/runPropertiesSync.ts
590
628
  var PT_TO_TWIPS = 20;
591
- var CSS_NAMED_COLORS_HEX = {
592
- // Basic colors
593
- black: "000000",
594
- white: "ffffff",
595
- red: "ff0000",
596
- green: "008000",
597
- blue: "0000ff",
598
- yellow: "ffff00",
599
- cyan: "00ffff",
600
- magenta: "ff00ff",
601
- // Extended colors
602
- orange: "ffa500",
603
- pink: "ffc0cb",
604
- purple: "800080",
605
- violet: "ee82ee",
606
- brown: "a52a2a",
607
- gray: "808080",
608
- grey: "808080",
609
- // Light variants
610
- lightblue: "add8e6",
611
- lightgreen: "90ee90",
612
- lightgray: "d3d3d3",
613
- lightgrey: "d3d3d3",
614
- lightpink: "ffb6c1",
615
- lightyellow: "ffffe0",
616
- // Dark variants
617
- darkblue: "00008b",
618
- darkgreen: "006400",
619
- darkgray: "a9a9a9",
620
- darkgrey: "a9a9a9",
621
- darkred: "8b0000",
622
- // Other common colors
623
- navy: "000080",
624
- teal: "008080",
625
- maroon: "800000",
626
- olive: "808000",
627
- silver: "c0c0c0",
628
- aqua: "00ffff",
629
- fuchsia: "ff00ff",
630
- lime: "00ff00",
631
- coral: "ff7f50",
632
- salmon: "fa8072",
633
- gold: "ffd700",
634
- indigo: "4b0082",
635
- crimson: "dc143c",
636
- tomato: "ff6347",
637
- chocolate: "d2691e",
638
- tan: "d2b48c",
639
- beige: "f5f5dc",
640
- ivory: "fffff0",
641
- khaki: "f0e68c",
642
- lavender: "e6e6fa",
643
- plum: "dda0dd",
644
- orchid: "da70d6",
645
- turquoise: "40e0d0",
646
- skyblue: "87ceeb",
647
- steelblue: "4682b4",
648
- slategray: "708090",
649
- slategrey: "708090"
650
- };
651
629
  function ptToTwips(ptValue) {
652
630
  return Math.round(ptValue * PT_TO_TWIPS);
653
631
  }
654
- function colorToHexWithoutHash(color) {
655
- const trimmed = color.trim();
656
- const lowerColor = trimmed.toLowerCase();
657
- if (CSS_NAMED_COLORS_HEX[lowerColor]) {
658
- return CSS_NAMED_COLORS_HEX[lowerColor];
659
- }
660
- return trimmed.replace(/^#/, "");
661
- }
662
632
  function parseFontSizeToPoints(fontSize) {
663
633
  if (typeof fontSize === "number") {
664
634
  return fontSize;