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 +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -533,6 +533,18 @@ function ensureValidCssColor(color) {
|
|
|
533
533
|
}
|
|
534
534
|
|
|
535
535
|
// src/services/trackChangeInjector.ts
|
|
536
|
+
function isMeaningfulValue(value) {
|
|
537
|
+
return value !== null && value !== void 0 && value !== "";
|
|
538
|
+
}
|
|
539
|
+
function cleanAttrs(attrs) {
|
|
540
|
+
const cleaned = {};
|
|
541
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
542
|
+
if (isMeaningfulValue(value)) {
|
|
543
|
+
cleaned[key] = value;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return cleaned;
|
|
547
|
+
}
|
|
536
548
|
function normalizeMark(mark) {
|
|
537
549
|
const attrs = { ...mark.attrs || {} };
|
|
538
550
|
if (attrs.color !== void 0) {
|
|
@@ -543,9 +555,23 @@ function normalizeMark(mark) {
|
|
|
543
555
|
attrs
|
|
544
556
|
};
|
|
545
557
|
}
|
|
558
|
+
function normalizeMarkForTrackFormat(mark) {
|
|
559
|
+
let attrs = { ...mark.attrs || {} };
|
|
560
|
+
if (attrs.color !== void 0) {
|
|
561
|
+
attrs.color = ensureValidCssColor(attrs.color);
|
|
562
|
+
}
|
|
563
|
+
attrs = cleanAttrs(attrs);
|
|
564
|
+
return {
|
|
565
|
+
type: mark.type,
|
|
566
|
+
attrs
|
|
567
|
+
};
|
|
568
|
+
}
|
|
546
569
|
function normalizeMarks(marks) {
|
|
547
570
|
return marks.map(normalizeMark);
|
|
548
571
|
}
|
|
572
|
+
function normalizeMarksForTrackFormat(marks) {
|
|
573
|
+
return marks.map(normalizeMarkForTrackFormat);
|
|
574
|
+
}
|
|
549
575
|
function normalizeMarksForRendering(marks) {
|
|
550
576
|
return normalizeMarks(marks);
|
|
551
577
|
}
|
|
@@ -574,8 +600,8 @@ function createTrackDeleteMark(author = DEFAULT_AUTHOR, id) {
|
|
|
574
600
|
};
|
|
575
601
|
}
|
|
576
602
|
function createTrackFormatMark(before, after, author = DEFAULT_AUTHOR) {
|
|
577
|
-
const normalizedBefore =
|
|
578
|
-
const normalizedAfter =
|
|
603
|
+
const normalizedBefore = normalizeMarksForTrackFormat(before);
|
|
604
|
+
const normalizedAfter = normalizeMarksForTrackFormat(after);
|
|
579
605
|
return {
|
|
580
606
|
type: "trackFormat",
|
|
581
607
|
attrs: {
|