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 +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +94 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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.
|
|
520
|
-
*
|
|
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.
|
|
520
|
-
*
|
|
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: "
|
|
458
|
-
white: "
|
|
459
|
-
red: "
|
|
460
|
-
green: "
|
|
461
|
-
blue: "
|
|
462
|
-
yellow: "
|
|
463
|
-
cyan: "
|
|
464
|
-
magenta: "
|
|
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: "
|
|
467
|
-
pink: "
|
|
468
|
-
purple: "
|
|
469
|
-
violet: "
|
|
470
|
-
brown: "
|
|
471
|
-
gray: "
|
|
472
|
-
grey: "
|
|
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: "
|
|
475
|
-
lightgreen: "
|
|
476
|
-
lightgray: "
|
|
477
|
-
lightgrey: "
|
|
478
|
-
lightpink: "
|
|
479
|
-
lightyellow: "
|
|
476
|
+
lightblue: "add8e6",
|
|
477
|
+
lightgreen: "90ee90",
|
|
478
|
+
lightgray: "d3d3d3",
|
|
479
|
+
lightgrey: "d3d3d3",
|
|
480
|
+
lightpink: "ffb6c1",
|
|
481
|
+
lightyellow: "ffffe0",
|
|
480
482
|
// Dark variants
|
|
481
|
-
darkblue: "
|
|
482
|
-
darkgreen: "
|
|
483
|
-
darkgray: "
|
|
484
|
-
darkgrey: "
|
|
485
|
-
darkred: "
|
|
483
|
+
darkblue: "00008b",
|
|
484
|
+
darkgreen: "006400",
|
|
485
|
+
darkgray: "a9a9a9",
|
|
486
|
+
darkgrey: "a9a9a9",
|
|
487
|
+
darkred: "8b0000",
|
|
486
488
|
// Other common colors
|
|
487
|
-
navy: "
|
|
488
|
-
teal: "
|
|
489
|
-
maroon: "
|
|
490
|
-
olive: "
|
|
491
|
-
silver: "
|
|
492
|
-
aqua: "
|
|
493
|
-
fuchsia: "
|
|
494
|
-
lime: "
|
|
495
|
-
coral: "
|
|
496
|
-
salmon: "
|
|
497
|
-
gold: "
|
|
498
|
-
indigo: "
|
|
499
|
-
crimson: "
|
|
500
|
-
tomato: "
|
|
501
|
-
chocolate: "
|
|
502
|
-
tan: "
|
|
503
|
-
beige: "
|
|
504
|
-
ivory: "
|
|
505
|
-
khaki: "
|
|
506
|
-
lavender: "
|
|
507
|
-
plum: "
|
|
508
|
-
orchid: "
|
|
509
|
-
turquoise: "
|
|
510
|
-
skyblue: "
|
|
511
|
-
steelblue: "
|
|
512
|
-
slategray: "
|
|
513
|
-
slategrey: "
|
|
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 =
|
|
574
|
-
const normalizedAfter =
|
|
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;
|