docx 9.2.0 → 9.4.0
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/README.md +7 -0
- package/dist/index.cjs +567 -436
- package/dist/index.d.cts +92 -79
- package/dist/index.d.ts +92 -79
- package/dist/index.iife.js +567 -436
- package/dist/index.mjs +567 -436
- package/dist/index.umd.cjs +567 -436
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -9374,32 +9374,59 @@ class BordersAttributes extends XmlAttributeComponent {
|
|
|
9374
9374
|
}
|
|
9375
9375
|
}
|
|
9376
9376
|
const BorderStyle = {
|
|
9377
|
+
/** a single line */
|
|
9377
9378
|
SINGLE: "single",
|
|
9379
|
+
/** a line with a series of alternating thin and thick strokes */
|
|
9378
9380
|
DASH_DOT_STROKED: "dashDotStroked",
|
|
9381
|
+
/** a dashed line */
|
|
9379
9382
|
DASHED: "dashed",
|
|
9383
|
+
/** a dashed line with small gaps */
|
|
9380
9384
|
DASH_SMALL_GAP: "dashSmallGap",
|
|
9385
|
+
/** a line with alternating dots and dashes */
|
|
9381
9386
|
DOT_DASH: "dotDash",
|
|
9387
|
+
/** a line with a repeating dot - dot - dash sequence */
|
|
9382
9388
|
DOT_DOT_DASH: "dotDotDash",
|
|
9389
|
+
/** a dotted line */
|
|
9383
9390
|
DOTTED: "dotted",
|
|
9391
|
+
/** a double line */
|
|
9384
9392
|
DOUBLE: "double",
|
|
9393
|
+
/** a double wavy line */
|
|
9385
9394
|
DOUBLE_WAVE: "doubleWave",
|
|
9395
|
+
/** an inset set of lines */
|
|
9386
9396
|
INSET: "inset",
|
|
9397
|
+
/** no border */
|
|
9387
9398
|
NIL: "nil",
|
|
9399
|
+
/** no border */
|
|
9388
9400
|
NONE: "none",
|
|
9401
|
+
/** an outset set of lines */
|
|
9389
9402
|
OUTSET: "outset",
|
|
9403
|
+
/** a single line */
|
|
9390
9404
|
THICK: "thick",
|
|
9405
|
+
/** a thick line contained within a thin line with a large-sized intermediate gap */
|
|
9391
9406
|
THICK_THIN_LARGE_GAP: "thickThinLargeGap",
|
|
9407
|
+
/** a thick line contained within a thin line with a medium-sized intermediate gap */
|
|
9392
9408
|
THICK_THIN_MEDIUM_GAP: "thickThinMediumGap",
|
|
9409
|
+
/** a thick line contained within a thin line with a small intermediate gap */
|
|
9393
9410
|
THICK_THIN_SMALL_GAP: "thickThinSmallGap",
|
|
9411
|
+
/** a thin line contained within a thick line with a large-sized intermediate gap */
|
|
9394
9412
|
THIN_THICK_LARGE_GAP: "thinThickLargeGap",
|
|
9413
|
+
/** a thick line contained within a thin line with a medium-sized intermediate gap */
|
|
9395
9414
|
THIN_THICK_MEDIUM_GAP: "thinThickMediumGap",
|
|
9415
|
+
/** a thick line contained within a thin line with a small intermediate gap */
|
|
9396
9416
|
THIN_THICK_SMALL_GAP: "thinThickSmallGap",
|
|
9417
|
+
/** a thin-thick-thin line with a large gap */
|
|
9397
9418
|
THIN_THICK_THIN_LARGE_GAP: "thinThickThinLargeGap",
|
|
9419
|
+
/** a thin-thick-thin line with a medium gap */
|
|
9398
9420
|
THIN_THICK_THIN_MEDIUM_GAP: "thinThickThinMediumGap",
|
|
9421
|
+
/** a thin-thick-thin line with a small gap */
|
|
9399
9422
|
THIN_THICK_THIN_SMALL_GAP: "thinThickThinSmallGap",
|
|
9423
|
+
/** a three-staged gradient line, getting darker towards the paragraph */
|
|
9400
9424
|
THREE_D_EMBOSS: "threeDEmboss",
|
|
9425
|
+
/** a three-staged gradient like, getting darker away from the paragraph */
|
|
9401
9426
|
THREE_D_ENGRAVE: "threeDEngrave",
|
|
9427
|
+
/** a triple line */
|
|
9402
9428
|
TRIPLE: "triple",
|
|
9429
|
+
/** a wavy line */
|
|
9403
9430
|
WAVE: "wave"
|
|
9404
9431
|
};
|
|
9405
9432
|
class Border extends IgnoreIfEmptyXmlComponent {
|
|
@@ -11799,107 +11826,157 @@ const hashedId = (data) => hash.sha1().update(data instanceof ArrayBuffer ? new
|
|
|
11799
11826
|
const generateUuidPart = (count) => customAlphabet("1234567890abcdef", count)();
|
|
11800
11827
|
const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
|
|
11801
11828
|
const HorizontalPositionRelativeFrom = {
|
|
11829
|
+
/**
|
|
11830
|
+
* ## Character
|
|
11831
|
+
*
|
|
11832
|
+
* Specifies that the horizontal positioning shall be relative to the position of the anchor within its run content.
|
|
11833
|
+
*/
|
|
11802
11834
|
CHARACTER: "character",
|
|
11835
|
+
/**
|
|
11836
|
+
* ## Column
|
|
11837
|
+
*
|
|
11838
|
+
* Specifies that the horizontal positioning shall be relative to the extents of the column which contains its anchor.
|
|
11839
|
+
*/
|
|
11803
11840
|
COLUMN: "column",
|
|
11841
|
+
/**
|
|
11842
|
+
* ## Inside Margin
|
|
11843
|
+
*
|
|
11844
|
+
* Specifies that the horizontal positioning shall be relative to the inside margin of the current page (the left margin on odd pages, right on even pages).
|
|
11845
|
+
*/
|
|
11804
11846
|
INSIDE_MARGIN: "insideMargin",
|
|
11847
|
+
/**
|
|
11848
|
+
* ## Left Margin
|
|
11849
|
+
*
|
|
11850
|
+
* Specifies that the horizontal positioning shall be relative to the left margin of the page.
|
|
11851
|
+
*/
|
|
11805
11852
|
LEFT_MARGIN: "leftMargin",
|
|
11853
|
+
/**
|
|
11854
|
+
* ## Page Margin
|
|
11855
|
+
*
|
|
11856
|
+
* Specifies that the horizontal positioning shall be relative to the page margins.
|
|
11857
|
+
*/
|
|
11806
11858
|
MARGIN: "margin",
|
|
11859
|
+
/**
|
|
11860
|
+
* ## Outside Margin
|
|
11861
|
+
*
|
|
11862
|
+
* Specifies that the horizontal positioning shall be relative to the outside margin of the current page (the right margin on odd pages, left on even pages).
|
|
11863
|
+
*/
|
|
11807
11864
|
OUTSIDE_MARGIN: "outsideMargin",
|
|
11865
|
+
/**
|
|
11866
|
+
* ## Page Edge
|
|
11867
|
+
*
|
|
11868
|
+
* Specifies that the horizontal positioning shall be relative to the edge of the page.
|
|
11869
|
+
*/
|
|
11808
11870
|
PAGE: "page",
|
|
11871
|
+
/**
|
|
11872
|
+
* ## Right Margin
|
|
11873
|
+
*
|
|
11874
|
+
* Specifies that the horizontal positioning shall be relative to the right margin of the page.
|
|
11875
|
+
*/
|
|
11809
11876
|
RIGHT_MARGIN: "rightMargin"
|
|
11810
11877
|
};
|
|
11811
11878
|
const VerticalPositionRelativeFrom = {
|
|
11879
|
+
/**
|
|
11880
|
+
* ## Bottom Margin
|
|
11881
|
+
*
|
|
11882
|
+
* Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
|
|
11883
|
+
*/
|
|
11812
11884
|
BOTTOM_MARGIN: "bottomMargin",
|
|
11885
|
+
/**
|
|
11886
|
+
* ## Inside Margin
|
|
11887
|
+
*
|
|
11888
|
+
* Specifies that the vertical positioning shall be relative to the inside margin of the current page.
|
|
11889
|
+
*/
|
|
11813
11890
|
INSIDE_MARGIN: "insideMargin",
|
|
11891
|
+
/**
|
|
11892
|
+
* ## Line
|
|
11893
|
+
*
|
|
11894
|
+
* Specifies that the vertical positioning shall be relative to the line containing the anchor character.
|
|
11895
|
+
*/
|
|
11814
11896
|
LINE: "line",
|
|
11897
|
+
/**
|
|
11898
|
+
* ## Page Margin
|
|
11899
|
+
*
|
|
11900
|
+
* Specifies that the vertical positioning shall be relative to the page margins.
|
|
11901
|
+
*/
|
|
11815
11902
|
MARGIN: "margin",
|
|
11903
|
+
/**
|
|
11904
|
+
* ## Outside Margin
|
|
11905
|
+
*
|
|
11906
|
+
* Specifies that the vertical positioning shall be relative to the outside margin of the current page.
|
|
11907
|
+
*/
|
|
11816
11908
|
OUTSIDE_MARGIN: "outsideMargin",
|
|
11909
|
+
/**
|
|
11910
|
+
* ## Page Edge
|
|
11911
|
+
*
|
|
11912
|
+
* Specifies that the vertical positioning shall be relative to the edge of the page.
|
|
11913
|
+
*/
|
|
11817
11914
|
PAGE: "page",
|
|
11915
|
+
/**
|
|
11916
|
+
* ## Paragraph
|
|
11917
|
+
*
|
|
11918
|
+
* Specifies that the vertical positioning shall be relative to the paragraph which contains the drawing anchor.
|
|
11919
|
+
*/
|
|
11818
11920
|
PARAGRAPH: "paragraph",
|
|
11921
|
+
/**
|
|
11922
|
+
* ## Top Margin
|
|
11923
|
+
*
|
|
11924
|
+
* Specifies that the vertical positioning shall be relative to the top margin of the current page.
|
|
11925
|
+
*/
|
|
11819
11926
|
TOP_MARGIN: "topMargin"
|
|
11820
11927
|
};
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
});
|
|
11828
|
-
}
|
|
11829
|
-
}
|
|
11830
|
-
class SimplePos extends XmlComponent {
|
|
11831
|
-
constructor() {
|
|
11832
|
-
super("wp:simplePos");
|
|
11833
|
-
this.root.push(
|
|
11834
|
-
new SimplePosAttributes({
|
|
11835
|
-
x: 0,
|
|
11836
|
-
y: 0
|
|
11837
|
-
})
|
|
11838
|
-
);
|
|
11839
|
-
}
|
|
11840
|
-
}
|
|
11841
|
-
class Align extends XmlComponent {
|
|
11842
|
-
constructor(value) {
|
|
11843
|
-
super("wp:align");
|
|
11844
|
-
this.root.push(value);
|
|
11845
|
-
}
|
|
11846
|
-
}
|
|
11847
|
-
class PositionOffset extends XmlComponent {
|
|
11848
|
-
constructor(offsetValue) {
|
|
11849
|
-
super("wp:posOffset");
|
|
11850
|
-
this.root.push(offsetValue.toString());
|
|
11851
|
-
}
|
|
11852
|
-
}
|
|
11853
|
-
class HorizontalPositionAttributes extends XmlAttributeComponent {
|
|
11854
|
-
constructor() {
|
|
11855
|
-
super(...arguments);
|
|
11856
|
-
__publicField(this, "xmlKeys", {
|
|
11857
|
-
relativeFrom: "relativeFrom"
|
|
11858
|
-
});
|
|
11859
|
-
}
|
|
11860
|
-
}
|
|
11861
|
-
class HorizontalPosition extends XmlComponent {
|
|
11862
|
-
constructor(horizontalPosition) {
|
|
11863
|
-
super("wp:positionH");
|
|
11864
|
-
this.root.push(
|
|
11865
|
-
new HorizontalPositionAttributes({
|
|
11866
|
-
relativeFrom: horizontalPosition.relative || HorizontalPositionRelativeFrom.PAGE
|
|
11867
|
-
})
|
|
11868
|
-
);
|
|
11869
|
-
if (horizontalPosition.align) {
|
|
11870
|
-
this.root.push(new Align(horizontalPosition.align));
|
|
11871
|
-
} else if (horizontalPosition.offset !== void 0) {
|
|
11872
|
-
this.root.push(new PositionOffset(horizontalPosition.offset));
|
|
11873
|
-
} else {
|
|
11874
|
-
throw new Error("There is no configuration provided for floating position (Align or offset)");
|
|
11875
|
-
}
|
|
11876
|
-
}
|
|
11877
|
-
}
|
|
11878
|
-
class VerticalPositionAttributes extends XmlAttributeComponent {
|
|
11879
|
-
constructor() {
|
|
11880
|
-
super(...arguments);
|
|
11881
|
-
__publicField(this, "xmlKeys", {
|
|
11882
|
-
relativeFrom: "relativeFrom"
|
|
11883
|
-
});
|
|
11884
|
-
}
|
|
11885
|
-
}
|
|
11886
|
-
class VerticalPosition extends XmlComponent {
|
|
11887
|
-
constructor(verticalPosition) {
|
|
11888
|
-
super("wp:positionV");
|
|
11889
|
-
this.root.push(
|
|
11890
|
-
new VerticalPositionAttributes({
|
|
11891
|
-
relativeFrom: verticalPosition.relative || VerticalPositionRelativeFrom.PAGE
|
|
11892
|
-
})
|
|
11893
|
-
);
|
|
11894
|
-
if (verticalPosition.align) {
|
|
11895
|
-
this.root.push(new Align(verticalPosition.align));
|
|
11896
|
-
} else if (verticalPosition.offset !== void 0) {
|
|
11897
|
-
this.root.push(new PositionOffset(verticalPosition.offset));
|
|
11898
|
-
} else {
|
|
11899
|
-
throw new Error("There is no configuration provided for floating position (Align or offset)");
|
|
11900
|
-
}
|
|
11928
|
+
const createSimplePos = () => new BuilderElement({
|
|
11929
|
+
name: "wp:simplePos",
|
|
11930
|
+
// NOTE: It's not fully supported in Microsoft Word, but this element is needed anyway
|
|
11931
|
+
attributes: {
|
|
11932
|
+
x: { key: "x", value: 0 },
|
|
11933
|
+
y: { key: "y", value: 0 }
|
|
11901
11934
|
}
|
|
11902
|
-
}
|
|
11935
|
+
});
|
|
11936
|
+
const createAlign = (value) => new BuilderElement({
|
|
11937
|
+
name: "wp:align",
|
|
11938
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11939
|
+
children: [value]
|
|
11940
|
+
});
|
|
11941
|
+
const createPositionOffset = (offsetValue) => new BuilderElement({
|
|
11942
|
+
name: "wp:posOffset",
|
|
11943
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11944
|
+
children: [offsetValue.toString()]
|
|
11945
|
+
});
|
|
11946
|
+
const createHorizontalPosition = ({ relative, align, offset }) => new BuilderElement({
|
|
11947
|
+
name: "wp:positionH",
|
|
11948
|
+
attributes: {
|
|
11949
|
+
relativeFrom: { key: "relativeFrom", value: relative != null ? relative : HorizontalPositionRelativeFrom.PAGE }
|
|
11950
|
+
},
|
|
11951
|
+
children: [
|
|
11952
|
+
(() => {
|
|
11953
|
+
if (align) {
|
|
11954
|
+
return createAlign(align);
|
|
11955
|
+
} else if (offset !== void 0) {
|
|
11956
|
+
return createPositionOffset(offset);
|
|
11957
|
+
} else {
|
|
11958
|
+
throw new Error("There is no configuration provided for floating position (Align or offset)");
|
|
11959
|
+
}
|
|
11960
|
+
})()
|
|
11961
|
+
]
|
|
11962
|
+
});
|
|
11963
|
+
const createVerticalPosition = ({ relative, align, offset }) => new BuilderElement({
|
|
11964
|
+
name: "wp:positionV",
|
|
11965
|
+
attributes: {
|
|
11966
|
+
relativeFrom: { key: "relativeFrom", value: relative != null ? relative : VerticalPositionRelativeFrom.PAGE }
|
|
11967
|
+
},
|
|
11968
|
+
children: [
|
|
11969
|
+
(() => {
|
|
11970
|
+
if (align) {
|
|
11971
|
+
return createAlign(align);
|
|
11972
|
+
} else if (offset !== void 0) {
|
|
11973
|
+
return createPositionOffset(offset);
|
|
11974
|
+
} else {
|
|
11975
|
+
throw new Error("There is no configuration provided for floating position (Align or offset)");
|
|
11976
|
+
}
|
|
11977
|
+
})()
|
|
11978
|
+
]
|
|
11979
|
+
});
|
|
11903
11980
|
class GraphicDataAttributes extends XmlAttributeComponent {
|
|
11904
11981
|
constructor() {
|
|
11905
11982
|
super(...arguments);
|
|
@@ -12442,26 +12519,13 @@ const createEffectExtent = ({ top, right, bottom, left }) => new BuilderElement(
|
|
|
12442
12519
|
}
|
|
12443
12520
|
}
|
|
12444
12521
|
});
|
|
12445
|
-
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
cy: "cy"
|
|
12451
|
-
});
|
|
12452
|
-
}
|
|
12453
|
-
}
|
|
12454
|
-
class Extent extends XmlComponent {
|
|
12455
|
-
constructor(x, y) {
|
|
12456
|
-
super("wp:extent");
|
|
12457
|
-
__publicField(this, "attributes");
|
|
12458
|
-
this.attributes = new ExtentAttributes({
|
|
12459
|
-
cx: x,
|
|
12460
|
-
cy: y
|
|
12461
|
-
});
|
|
12462
|
-
this.root.push(this.attributes);
|
|
12522
|
+
const createExtent = ({ x, y }) => new BuilderElement({
|
|
12523
|
+
name: "wp:extent",
|
|
12524
|
+
attributes: {
|
|
12525
|
+
x: { key: "cx", value: x },
|
|
12526
|
+
y: { key: "cy", value: y }
|
|
12463
12527
|
}
|
|
12464
|
-
}
|
|
12528
|
+
});
|
|
12465
12529
|
class GraphicFrameLockAttributes extends XmlAttributeComponent {
|
|
12466
12530
|
constructor() {
|
|
12467
12531
|
super(...arguments);
|
|
@@ -12482,12 +12546,10 @@ class GraphicFrameLocks extends XmlComponent {
|
|
|
12482
12546
|
);
|
|
12483
12547
|
}
|
|
12484
12548
|
}
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
}
|
|
12490
|
-
}
|
|
12549
|
+
const createGraphicFrameProperties = () => new BuilderElement({
|
|
12550
|
+
name: "wp:cNvGraphicFramePr",
|
|
12551
|
+
children: [new GraphicFrameLocks()]
|
|
12552
|
+
});
|
|
12491
12553
|
class AnchorAttributes extends XmlAttributeComponent {
|
|
12492
12554
|
constructor() {
|
|
12493
12555
|
super(...arguments);
|
|
@@ -12535,10 +12597,10 @@ class Anchor extends XmlComponent {
|
|
|
12535
12597
|
relativeHeight: floating.zIndex ? floating.zIndex : transform.emus.y
|
|
12536
12598
|
})
|
|
12537
12599
|
);
|
|
12538
|
-
this.root.push(
|
|
12539
|
-
this.root.push(
|
|
12540
|
-
this.root.push(
|
|
12541
|
-
this.root.push(
|
|
12600
|
+
this.root.push(createSimplePos());
|
|
12601
|
+
this.root.push(createHorizontalPosition(floating.horizontalPosition));
|
|
12602
|
+
this.root.push(createVerticalPosition(floating.verticalPosition));
|
|
12603
|
+
this.root.push(createExtent({ x: transform.emus.x, y: transform.emus.y }));
|
|
12542
12604
|
this.root.push(createEffectExtent({ top: 0, right: 0, bottom: 0, left: 0 }));
|
|
12543
12605
|
if (drawingOptions.floating !== void 0 && drawingOptions.floating.wrap !== void 0) {
|
|
12544
12606
|
switch (drawingOptions.floating.wrap.type) {
|
|
@@ -12559,7 +12621,7 @@ class Anchor extends XmlComponent {
|
|
|
12559
12621
|
this.root.push(new WrapNone());
|
|
12560
12622
|
}
|
|
12561
12623
|
this.root.push(new DocProperties(drawingOptions.docProperties));
|
|
12562
|
-
this.root.push(
|
|
12624
|
+
this.root.push(createGraphicFrameProperties());
|
|
12563
12625
|
this.root.push(new Graphic({ mediaData, transform, outline: drawingOptions.outline }));
|
|
12564
12626
|
}
|
|
12565
12627
|
}
|
|
@@ -12586,7 +12648,7 @@ const createInline = ({ mediaData, transform, docProperties, outline }) => {
|
|
|
12586
12648
|
}
|
|
12587
12649
|
},
|
|
12588
12650
|
children: [
|
|
12589
|
-
|
|
12651
|
+
createExtent({ x: transform.emus.x, y: transform.emus.y }),
|
|
12590
12652
|
createEffectExtent(
|
|
12591
12653
|
outline ? {
|
|
12592
12654
|
top: ((_a = outline.width) != null ? _a : 9525) * 2,
|
|
@@ -12596,7 +12658,7 @@ const createInline = ({ mediaData, transform, docProperties, outline }) => {
|
|
|
12596
12658
|
} : { top: 0, right: 0, bottom: 0, left: 0 }
|
|
12597
12659
|
),
|
|
12598
12660
|
new DocProperties(docProperties),
|
|
12599
|
-
|
|
12661
|
+
createGraphicFrameProperties(),
|
|
12600
12662
|
new Graphic({ mediaData, transform, outline })
|
|
12601
12663
|
]
|
|
12602
12664
|
});
|
|
@@ -12719,6 +12781,59 @@ class SimpleMailMergeField extends SimpleField {
|
|
|
12719
12781
|
super(` MERGEFIELD ${fieldName} `, `«${fieldName}»`);
|
|
12720
12782
|
}
|
|
12721
12783
|
}
|
|
12784
|
+
class RelationshipsAttributes extends XmlAttributeComponent {
|
|
12785
|
+
constructor() {
|
|
12786
|
+
super(...arguments);
|
|
12787
|
+
__publicField(this, "xmlKeys", {
|
|
12788
|
+
xmlns: "xmlns"
|
|
12789
|
+
});
|
|
12790
|
+
}
|
|
12791
|
+
}
|
|
12792
|
+
class RelationshipAttributes extends XmlAttributeComponent {
|
|
12793
|
+
constructor() {
|
|
12794
|
+
super(...arguments);
|
|
12795
|
+
__publicField(this, "xmlKeys", {
|
|
12796
|
+
id: "Id",
|
|
12797
|
+
type: "Type",
|
|
12798
|
+
target: "Target",
|
|
12799
|
+
targetMode: "TargetMode"
|
|
12800
|
+
});
|
|
12801
|
+
}
|
|
12802
|
+
}
|
|
12803
|
+
const TargetModeType = {
|
|
12804
|
+
EXTERNAL: "External"
|
|
12805
|
+
};
|
|
12806
|
+
class Relationship extends XmlComponent {
|
|
12807
|
+
constructor(id, type2, target, targetMode) {
|
|
12808
|
+
super("Relationship");
|
|
12809
|
+
this.root.push(
|
|
12810
|
+
new RelationshipAttributes({
|
|
12811
|
+
id,
|
|
12812
|
+
type: type2,
|
|
12813
|
+
target,
|
|
12814
|
+
targetMode
|
|
12815
|
+
})
|
|
12816
|
+
);
|
|
12817
|
+
}
|
|
12818
|
+
}
|
|
12819
|
+
class Relationships extends XmlComponent {
|
|
12820
|
+
constructor() {
|
|
12821
|
+
super("Relationships");
|
|
12822
|
+
this.root.push(
|
|
12823
|
+
new RelationshipsAttributes({
|
|
12824
|
+
xmlns: "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
12825
|
+
})
|
|
12826
|
+
);
|
|
12827
|
+
}
|
|
12828
|
+
createRelationship(id, type2, target, targetMode) {
|
|
12829
|
+
const relationship = new Relationship(`rId${id}`, type2, target, targetMode);
|
|
12830
|
+
this.root.push(relationship);
|
|
12831
|
+
return relationship;
|
|
12832
|
+
}
|
|
12833
|
+
get RelationshipCount() {
|
|
12834
|
+
return this.root.length - 1;
|
|
12835
|
+
}
|
|
12836
|
+
}
|
|
12722
12837
|
class CommentAttributes extends XmlAttributeComponent {
|
|
12723
12838
|
constructor() {
|
|
12724
12839
|
super(...arguments);
|
|
@@ -12806,6 +12921,7 @@ class Comment extends XmlComponent {
|
|
|
12806
12921
|
class Comments extends XmlComponent {
|
|
12807
12922
|
constructor({ children }) {
|
|
12808
12923
|
super("w:comments");
|
|
12924
|
+
__publicField(this, "relationships");
|
|
12809
12925
|
this.root.push(
|
|
12810
12926
|
new RootCommentsAttributes({
|
|
12811
12927
|
"xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
@@ -12844,6 +12960,10 @@ class Comments extends XmlComponent {
|
|
|
12844
12960
|
for (const child of children) {
|
|
12845
12961
|
this.root.push(new Comment(child));
|
|
12846
12962
|
}
|
|
12963
|
+
this.relationships = new Relationships();
|
|
12964
|
+
}
|
|
12965
|
+
get Relationships() {
|
|
12966
|
+
return this.relationships;
|
|
12847
12967
|
}
|
|
12848
12968
|
}
|
|
12849
12969
|
class NoBreakHyphen extends EmptyElement {
|
|
@@ -13015,7 +13135,7 @@ class SpacingAttributes extends XmlAttributeComponent {
|
|
|
13015
13135
|
line: "w:line",
|
|
13016
13136
|
lineRule: "w:lineRule",
|
|
13017
13137
|
beforeAutoSpacing: "w:beforeAutospacing",
|
|
13018
|
-
afterAutoSpacing: "w:
|
|
13138
|
+
afterAutoSpacing: "w:afterAutospacing"
|
|
13019
13139
|
});
|
|
13020
13140
|
}
|
|
13021
13141
|
}
|
|
@@ -13129,33 +13249,6 @@ class FileChild extends XmlComponent {
|
|
|
13129
13249
|
__publicField(this, "fileChild", Symbol());
|
|
13130
13250
|
}
|
|
13131
13251
|
}
|
|
13132
|
-
class RelationshipAttributes extends XmlAttributeComponent {
|
|
13133
|
-
constructor() {
|
|
13134
|
-
super(...arguments);
|
|
13135
|
-
__publicField(this, "xmlKeys", {
|
|
13136
|
-
id: "Id",
|
|
13137
|
-
type: "Type",
|
|
13138
|
-
target: "Target",
|
|
13139
|
-
targetMode: "TargetMode"
|
|
13140
|
-
});
|
|
13141
|
-
}
|
|
13142
|
-
}
|
|
13143
|
-
const TargetModeType = {
|
|
13144
|
-
EXTERNAL: "External"
|
|
13145
|
-
};
|
|
13146
|
-
class Relationship extends XmlComponent {
|
|
13147
|
-
constructor(id, type2, target, targetMode) {
|
|
13148
|
-
super("Relationship");
|
|
13149
|
-
this.root.push(
|
|
13150
|
-
new RelationshipAttributes({
|
|
13151
|
-
id,
|
|
13152
|
-
type: type2,
|
|
13153
|
-
target,
|
|
13154
|
-
targetMode
|
|
13155
|
-
})
|
|
13156
|
-
);
|
|
13157
|
-
}
|
|
13158
|
-
}
|
|
13159
13252
|
class HyperlinkAttributes extends XmlAttributeComponent {
|
|
13160
13253
|
constructor() {
|
|
13161
13254
|
super(...arguments);
|
|
@@ -13314,36 +13407,40 @@ class Columns extends XmlComponent {
|
|
|
13314
13407
|
}
|
|
13315
13408
|
}
|
|
13316
13409
|
const DocumentGridType = {
|
|
13410
|
+
/**
|
|
13411
|
+
* Specifies that no document grid shall be applied to the contents of the current section in the document.
|
|
13412
|
+
*/
|
|
13317
13413
|
DEFAULT: "default",
|
|
13414
|
+
/**
|
|
13415
|
+
* Specifies that the parent section shall have additional line pitch added to each line within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain the specified number of lines per page.
|
|
13416
|
+
*/
|
|
13318
13417
|
LINES: "lines",
|
|
13418
|
+
/**
|
|
13419
|
+
* Specifies that the parent section shall have both the additional line pitch and character pitch added to each line and character within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain a specific number of lines per page and characters per line.
|
|
13420
|
+
*
|
|
13421
|
+
* When this value is set, the input specified via the user interface may be allowed in exact number of line/character pitch units. */
|
|
13319
13422
|
LINES_AND_CHARS: "linesAndChars",
|
|
13423
|
+
/**
|
|
13424
|
+
* Specifies that the parent section shall have both the additional line pitch and character pitch added to each line and character within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain a specific number of lines per page and characters per line.
|
|
13425
|
+
*
|
|
13426
|
+
* When this value is set, the input specified via the user interface may be restricted to the number of lines per page and characters per line, with the consumer or producer translating this information based on the current font data to get the resulting line and character pitch values
|
|
13427
|
+
*/
|
|
13320
13428
|
SNAP_TO_CHARS: "snapToChars"
|
|
13321
13429
|
};
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
charSpace: "w:charSpace"
|
|
13329
|
-
});
|
|
13330
|
-
}
|
|
13331
|
-
}
|
|
13332
|
-
class DocumentGrid extends XmlComponent {
|
|
13333
|
-
constructor(linePitch, charSpace, type2) {
|
|
13334
|
-
super("w:docGrid");
|
|
13335
|
-
this.root.push(
|
|
13336
|
-
new DocGridAttributes({
|
|
13337
|
-
type: type2,
|
|
13338
|
-
linePitch: decimalNumber(linePitch),
|
|
13339
|
-
charSpace: charSpace ? decimalNumber(charSpace) : void 0
|
|
13340
|
-
})
|
|
13341
|
-
);
|
|
13430
|
+
const createDocumentGrid = ({ type: type2, linePitch, charSpace }) => new BuilderElement({
|
|
13431
|
+
name: "w:docGrid",
|
|
13432
|
+
attributes: {
|
|
13433
|
+
type: { key: "w:type", value: type2 },
|
|
13434
|
+
linePitch: { key: "w:linePitch", value: decimalNumber(linePitch) },
|
|
13435
|
+
charSpace: { key: "w:charSpace", value: charSpace ? decimalNumber(charSpace) : void 0 }
|
|
13342
13436
|
}
|
|
13343
|
-
}
|
|
13437
|
+
});
|
|
13344
13438
|
const HeaderFooterReferenceType = {
|
|
13439
|
+
/** Specifies that this header or footer shall appear on every page in this section which is not overridden with a specific `even` or `first` page header/footer. In a section with all three types specified, this type shall be used on all odd numbered pages (counting from the `first` page in the section, not the section numbering). */
|
|
13345
13440
|
DEFAULT: "default",
|
|
13441
|
+
/** Specifies that this header or footer shall appear on the first page in this section. The appearance of this header or footer is contingent on the setting of the `titlePg` element (§2.10.6). */
|
|
13346
13442
|
FIRST: "first",
|
|
13443
|
+
/** Specifies that this header or footer shall appear on all even numbered pages in this section (counting from the first page in the section, not the section numbering). The appearance of this header or footer is contingent on the setting of the `evenAndOddHeaders` element (§2.10.1). */
|
|
13347
13444
|
EVEN: "even"
|
|
13348
13445
|
};
|
|
13349
13446
|
class FooterReferenceAttributes extends XmlAttributeComponent {
|
|
@@ -13371,8 +13468,23 @@ class HeaderFooterReference extends XmlComponent {
|
|
|
13371
13468
|
}
|
|
13372
13469
|
}
|
|
13373
13470
|
const LineNumberRestartFormat = {
|
|
13471
|
+
/**
|
|
13472
|
+
* ## Restart Line Numbering on Each Page
|
|
13473
|
+
*
|
|
13474
|
+
* Specifies that line numbering for the parent section shall restart to the starting value whenever a new page is displayed.
|
|
13475
|
+
*/
|
|
13374
13476
|
NEW_PAGE: "newPage",
|
|
13477
|
+
/**
|
|
13478
|
+
* ## Restart Line Numbering for Each Section
|
|
13479
|
+
*
|
|
13480
|
+
* Specifies that line numbering for the parent section shall restart to the starting value whenever the parent begins.
|
|
13481
|
+
*/
|
|
13375
13482
|
NEW_SECTION: "newSection",
|
|
13483
|
+
/**
|
|
13484
|
+
* ## Continue Line Numbering From Previous Section
|
|
13485
|
+
*
|
|
13486
|
+
* Specifies that line numbering for the parent section shall continue from the line numbering from the end of the previous section, if any.
|
|
13487
|
+
*/
|
|
13376
13488
|
CONTINUOUS: "continuous"
|
|
13377
13489
|
};
|
|
13378
13490
|
const createLineNumberType = ({ countBy, start, restart, distance }) => new BuilderElement({
|
|
@@ -13487,24 +13599,32 @@ class PageNumberType extends XmlComponent {
|
|
|
13487
13599
|
}
|
|
13488
13600
|
}
|
|
13489
13601
|
const PageOrientation = {
|
|
13602
|
+
/**
|
|
13603
|
+
* ## Portrait Mode
|
|
13604
|
+
*
|
|
13605
|
+
* Specifies that pages in this section shall be printed in portrait mode.
|
|
13606
|
+
*/
|
|
13490
13607
|
PORTRAIT: "portrait",
|
|
13608
|
+
/**
|
|
13609
|
+
* ## Landscape Mode
|
|
13610
|
+
*
|
|
13611
|
+
* Specifies that pages in this section shall be printed in landscape mode, which prints the page contents with a 90 degree rotation with respect to the normal page orientation.
|
|
13612
|
+
*/
|
|
13491
13613
|
LANDSCAPE: "landscape"
|
|
13492
13614
|
};
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
}
|
|
13507
|
-
}
|
|
13615
|
+
const createPageSize = ({ width, height, orientation, code }) => {
|
|
13616
|
+
const widthTwips = twipsMeasureValue(width);
|
|
13617
|
+
const heightTwips = twipsMeasureValue(height);
|
|
13618
|
+
return new BuilderElement({
|
|
13619
|
+
name: "w:pgSz",
|
|
13620
|
+
attributes: {
|
|
13621
|
+
width: { key: "w:w", value: orientation === PageOrientation.LANDSCAPE ? heightTwips : widthTwips },
|
|
13622
|
+
height: { key: "w:h", value: orientation === PageOrientation.LANDSCAPE ? widthTwips : heightTwips },
|
|
13623
|
+
orientation: { key: "w:orient", value: orientation },
|
|
13624
|
+
code: { key: "w:code", value: code }
|
|
13625
|
+
}
|
|
13626
|
+
});
|
|
13627
|
+
};
|
|
13508
13628
|
const PageTextDirectionType = {
|
|
13509
13629
|
LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb",
|
|
13510
13630
|
TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl"
|
|
@@ -13596,7 +13716,7 @@ class SectionProperties extends XmlComponent {
|
|
|
13596
13716
|
if (type2) {
|
|
13597
13717
|
this.root.push(new Type(type2));
|
|
13598
13718
|
}
|
|
13599
|
-
this.root.push(
|
|
13719
|
+
this.root.push(createPageSize({ width, height, orientation }));
|
|
13600
13720
|
this.root.push(new PageMargin(top, right, bottom, left, header, footer, gutter));
|
|
13601
13721
|
if (borders) {
|
|
13602
13722
|
this.root.push(new PageBorders(borders));
|
|
@@ -13617,7 +13737,7 @@ class SectionProperties extends XmlComponent {
|
|
|
13617
13737
|
if (textDirection) {
|
|
13618
13738
|
this.root.push(new PageTextDirection(textDirection));
|
|
13619
13739
|
}
|
|
13620
|
-
this.root.push(
|
|
13740
|
+
this.root.push(createDocumentGrid({ linePitch, charSpace, type: gridType }));
|
|
13621
13741
|
}
|
|
13622
13742
|
addHeaderFooterGroup(type2, group) {
|
|
13623
13743
|
if (group.default) {
|
|
@@ -13823,32 +13943,6 @@ class Document extends XmlComponent {
|
|
|
13823
13943
|
return this.body;
|
|
13824
13944
|
}
|
|
13825
13945
|
}
|
|
13826
|
-
class RelationshipsAttributes extends XmlAttributeComponent {
|
|
13827
|
-
constructor() {
|
|
13828
|
-
super(...arguments);
|
|
13829
|
-
__publicField(this, "xmlKeys", {
|
|
13830
|
-
xmlns: "xmlns"
|
|
13831
|
-
});
|
|
13832
|
-
}
|
|
13833
|
-
}
|
|
13834
|
-
class Relationships extends XmlComponent {
|
|
13835
|
-
constructor() {
|
|
13836
|
-
super("Relationships");
|
|
13837
|
-
this.root.push(
|
|
13838
|
-
new RelationshipsAttributes({
|
|
13839
|
-
xmlns: "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
13840
|
-
})
|
|
13841
|
-
);
|
|
13842
|
-
}
|
|
13843
|
-
createRelationship(id, type2, target, targetMode) {
|
|
13844
|
-
const relationship = new Relationship(`rId${id}`, type2, target, targetMode);
|
|
13845
|
-
this.root.push(relationship);
|
|
13846
|
-
return relationship;
|
|
13847
|
-
}
|
|
13848
|
-
get RelationshipCount() {
|
|
13849
|
-
return this.root.length - 1;
|
|
13850
|
-
}
|
|
13851
|
-
}
|
|
13852
13946
|
class DocumentWrapper {
|
|
13853
13947
|
constructor(options) {
|
|
13854
13948
|
__publicField(this, "document");
|
|
@@ -14169,117 +14263,93 @@ class MathFraction extends XmlComponent {
|
|
|
14169
14263
|
this.root.push(new MathDenominator(options.denominator));
|
|
14170
14264
|
}
|
|
14171
14265
|
}
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
}
|
|
14177
|
-
}
|
|
14178
|
-
class MathAccentCharacter extends XmlComponent {
|
|
14179
|
-
constructor(accent) {
|
|
14180
|
-
super("m:chr");
|
|
14181
|
-
this.root.push(new MathAccentCharacterAttributes({ accent }));
|
|
14182
|
-
}
|
|
14183
|
-
}
|
|
14184
|
-
class MathBase extends XmlComponent {
|
|
14185
|
-
constructor(children) {
|
|
14186
|
-
super("m:e");
|
|
14187
|
-
for (const child of children) {
|
|
14188
|
-
this.root.push(child);
|
|
14189
|
-
}
|
|
14190
|
-
}
|
|
14191
|
-
}
|
|
14192
|
-
class MathLimitLocationAttributes extends XmlAttributeComponent {
|
|
14193
|
-
constructor() {
|
|
14194
|
-
super(...arguments);
|
|
14195
|
-
__publicField(this, "xmlKeys", { value: "m:val" });
|
|
14196
|
-
}
|
|
14197
|
-
}
|
|
14198
|
-
class MathLimitLocation extends XmlComponent {
|
|
14199
|
-
constructor(value) {
|
|
14200
|
-
super("m:limLoc");
|
|
14201
|
-
this.root.push(new MathLimitLocationAttributes({ value: value || "undOvr" }));
|
|
14202
|
-
}
|
|
14203
|
-
}
|
|
14204
|
-
class MathSubScriptHideAttributes extends XmlAttributeComponent {
|
|
14205
|
-
constructor() {
|
|
14206
|
-
super(...arguments);
|
|
14207
|
-
__publicField(this, "xmlKeys", { hide: "m:val" });
|
|
14208
|
-
}
|
|
14209
|
-
}
|
|
14210
|
-
class MathSubScriptHide extends XmlComponent {
|
|
14211
|
-
constructor() {
|
|
14212
|
-
super("m:subHide");
|
|
14213
|
-
this.root.push(new MathSubScriptHideAttributes({ hide: 1 }));
|
|
14214
|
-
}
|
|
14215
|
-
}
|
|
14216
|
-
class MathSuperScriptHideAttributes extends XmlAttributeComponent {
|
|
14217
|
-
constructor() {
|
|
14218
|
-
super(...arguments);
|
|
14219
|
-
__publicField(this, "xmlKeys", { hide: "m:val" });
|
|
14220
|
-
}
|
|
14221
|
-
}
|
|
14222
|
-
class MathSuperScriptHide extends XmlComponent {
|
|
14223
|
-
constructor() {
|
|
14224
|
-
super("m:supHide");
|
|
14225
|
-
this.root.push(new MathSuperScriptHideAttributes({ hide: 1 }));
|
|
14266
|
+
const createMathAccentCharacter = ({ accent }) => new BuilderElement({
|
|
14267
|
+
name: "m:chr",
|
|
14268
|
+
attributes: {
|
|
14269
|
+
accent: { key: "m:val", value: accent }
|
|
14226
14270
|
}
|
|
14227
|
-
}
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
this.root.push(new MathSuperScriptHide());
|
|
14237
|
-
}
|
|
14238
|
-
if (!hasSubScript) {
|
|
14239
|
-
this.root.push(new MathSubScriptHide());
|
|
14240
|
-
}
|
|
14271
|
+
});
|
|
14272
|
+
const createMathBase = ({ children }) => new BuilderElement({
|
|
14273
|
+
name: "m:e",
|
|
14274
|
+
children
|
|
14275
|
+
});
|
|
14276
|
+
const createMathLimitLocation = ({ value }) => new BuilderElement({
|
|
14277
|
+
name: "m:limLoc",
|
|
14278
|
+
attributes: {
|
|
14279
|
+
value: { key: "m:val", value: value || "undOvr" }
|
|
14241
14280
|
}
|
|
14242
|
-
}
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
this.root.push(child);
|
|
14248
|
-
}
|
|
14281
|
+
});
|
|
14282
|
+
const createMathSubScriptHide = () => new BuilderElement({
|
|
14283
|
+
name: "m:subHide",
|
|
14284
|
+
attributes: {
|
|
14285
|
+
hide: { key: "m:val", value: 1 }
|
|
14249
14286
|
}
|
|
14250
|
-
}
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
this.root.push(child);
|
|
14256
|
-
}
|
|
14287
|
+
});
|
|
14288
|
+
const createMathSuperScriptHide = () => new BuilderElement({
|
|
14289
|
+
name: "m:supHide",
|
|
14290
|
+
attributes: {
|
|
14291
|
+
hide: { key: "m:val", value: 1 }
|
|
14257
14292
|
}
|
|
14258
|
-
}
|
|
14293
|
+
});
|
|
14294
|
+
const createMathNAryProperties = ({
|
|
14295
|
+
accent,
|
|
14296
|
+
hasSuperScript,
|
|
14297
|
+
hasSubScript,
|
|
14298
|
+
limitLocationVal
|
|
14299
|
+
}) => new BuilderElement({
|
|
14300
|
+
name: "m:naryPr",
|
|
14301
|
+
children: [
|
|
14302
|
+
...!!accent ? [createMathAccentCharacter({ accent })] : [],
|
|
14303
|
+
createMathLimitLocation({ value: limitLocationVal }),
|
|
14304
|
+
...!hasSuperScript ? [createMathSuperScriptHide()] : [],
|
|
14305
|
+
...!hasSubScript ? [createMathSubScriptHide()] : []
|
|
14306
|
+
]
|
|
14307
|
+
});
|
|
14308
|
+
const createMathSubScriptElement = ({ children }) => new BuilderElement({
|
|
14309
|
+
name: "m:sub",
|
|
14310
|
+
children
|
|
14311
|
+
});
|
|
14312
|
+
const createMathSuperScriptElement = ({ children }) => new BuilderElement({
|
|
14313
|
+
name: "m:sup",
|
|
14314
|
+
children
|
|
14315
|
+
});
|
|
14259
14316
|
class MathSum extends XmlComponent {
|
|
14260
14317
|
constructor(options) {
|
|
14261
14318
|
super("m:nary");
|
|
14262
|
-
this.root.push(
|
|
14319
|
+
this.root.push(
|
|
14320
|
+
createMathNAryProperties({
|
|
14321
|
+
accent: "∑",
|
|
14322
|
+
hasSuperScript: !!options.superScript,
|
|
14323
|
+
hasSubScript: !!options.subScript
|
|
14324
|
+
})
|
|
14325
|
+
);
|
|
14263
14326
|
if (!!options.subScript) {
|
|
14264
|
-
this.root.push(
|
|
14327
|
+
this.root.push(createMathSubScriptElement({ children: options.subScript }));
|
|
14265
14328
|
}
|
|
14266
14329
|
if (!!options.superScript) {
|
|
14267
|
-
this.root.push(
|
|
14330
|
+
this.root.push(createMathSuperScriptElement({ children: options.superScript }));
|
|
14268
14331
|
}
|
|
14269
|
-
this.root.push(
|
|
14332
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14270
14333
|
}
|
|
14271
14334
|
}
|
|
14272
14335
|
class MathIntegral extends XmlComponent {
|
|
14273
14336
|
constructor(options) {
|
|
14274
14337
|
super("m:nary");
|
|
14275
|
-
this.root.push(
|
|
14338
|
+
this.root.push(
|
|
14339
|
+
createMathNAryProperties({
|
|
14340
|
+
accent: "",
|
|
14341
|
+
hasSuperScript: !!options.superScript,
|
|
14342
|
+
hasSubScript: !!options.subScript,
|
|
14343
|
+
limitLocationVal: "subSup"
|
|
14344
|
+
})
|
|
14345
|
+
);
|
|
14276
14346
|
if (!!options.subScript) {
|
|
14277
|
-
this.root.push(
|
|
14347
|
+
this.root.push(createMathSubScriptElement({ children: options.subScript }));
|
|
14278
14348
|
}
|
|
14279
14349
|
if (!!options.superScript) {
|
|
14280
|
-
this.root.push(
|
|
14350
|
+
this.root.push(createMathSuperScriptElement({ children: options.superScript }));
|
|
14281
14351
|
}
|
|
14282
|
-
this.root.push(
|
|
14352
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14283
14353
|
}
|
|
14284
14354
|
}
|
|
14285
14355
|
class MathLimit extends XmlComponent {
|
|
@@ -14293,69 +14363,65 @@ class MathLimit extends XmlComponent {
|
|
|
14293
14363
|
class MathLimitUpper extends XmlComponent {
|
|
14294
14364
|
constructor(options) {
|
|
14295
14365
|
super("m:limUpp");
|
|
14296
|
-
this.root.push(
|
|
14366
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14297
14367
|
this.root.push(new MathLimit(options.limit));
|
|
14298
14368
|
}
|
|
14299
14369
|
}
|
|
14300
14370
|
class MathLimitLower extends XmlComponent {
|
|
14301
14371
|
constructor(options) {
|
|
14302
14372
|
super("m:limLow");
|
|
14303
|
-
this.root.push(
|
|
14373
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14304
14374
|
this.root.push(new MathLimit(options.limit));
|
|
14305
14375
|
}
|
|
14306
14376
|
}
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
}
|
|
14311
|
-
}
|
|
14377
|
+
const createMathSuperScriptProperties = () => new BuilderElement({
|
|
14378
|
+
name: "m:sSupPr"
|
|
14379
|
+
});
|
|
14312
14380
|
class MathSuperScript extends XmlComponent {
|
|
14313
14381
|
constructor(options) {
|
|
14314
14382
|
super("m:sSup");
|
|
14315
|
-
this.root.push(
|
|
14316
|
-
this.root.push(
|
|
14317
|
-
this.root.push(
|
|
14318
|
-
}
|
|
14319
|
-
}
|
|
14320
|
-
class MathSubScriptProperties extends XmlComponent {
|
|
14321
|
-
constructor() {
|
|
14322
|
-
super("m:sSubPr");
|
|
14383
|
+
this.root.push(createMathSuperScriptProperties());
|
|
14384
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14385
|
+
this.root.push(createMathSuperScriptElement({ children: options.superScript }));
|
|
14323
14386
|
}
|
|
14324
14387
|
}
|
|
14388
|
+
const createMathSubScriptProperties = () => new BuilderElement({
|
|
14389
|
+
name: "m:sSubPr"
|
|
14390
|
+
});
|
|
14325
14391
|
class MathSubScript extends XmlComponent {
|
|
14326
14392
|
constructor(options) {
|
|
14327
14393
|
super("m:sSub");
|
|
14328
|
-
this.root.push(
|
|
14329
|
-
this.root.push(
|
|
14330
|
-
this.root.push(
|
|
14331
|
-
}
|
|
14332
|
-
}
|
|
14333
|
-
class MathSubSuperScriptProperties extends XmlComponent {
|
|
14334
|
-
constructor() {
|
|
14335
|
-
super("m:sSubSupPr");
|
|
14394
|
+
this.root.push(createMathSubScriptProperties());
|
|
14395
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14396
|
+
this.root.push(createMathSubScriptElement({ children: options.subScript }));
|
|
14336
14397
|
}
|
|
14337
14398
|
}
|
|
14399
|
+
const createMathSubSuperScriptProperties = () => new BuilderElement({
|
|
14400
|
+
name: "m:sSubSupPr"
|
|
14401
|
+
});
|
|
14338
14402
|
class MathSubSuperScript extends XmlComponent {
|
|
14339
14403
|
constructor(options) {
|
|
14340
14404
|
super("m:sSubSup");
|
|
14341
|
-
this.root.push(
|
|
14342
|
-
this.root.push(
|
|
14343
|
-
this.root.push(
|
|
14344
|
-
this.root.push(
|
|
14405
|
+
this.root.push(createMathSubSuperScriptProperties());
|
|
14406
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14407
|
+
this.root.push(createMathSubScriptElement({ children: options.subScript }));
|
|
14408
|
+
this.root.push(createMathSuperScriptElement({ children: options.superScript }));
|
|
14345
14409
|
}
|
|
14346
14410
|
}
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
}
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14411
|
+
const createMathPreSubSuperScriptProperties = () => new BuilderElement({
|
|
14412
|
+
name: "m:sPrePr"
|
|
14413
|
+
});
|
|
14414
|
+
class MathPreSubSuperScript extends BuilderElement {
|
|
14415
|
+
constructor({ children, subScript, superScript }) {
|
|
14416
|
+
super({
|
|
14417
|
+
name: "m:sPre",
|
|
14418
|
+
children: [
|
|
14419
|
+
createMathPreSubSuperScriptProperties(),
|
|
14420
|
+
createMathBase({ children }),
|
|
14421
|
+
createMathSubScriptElement({ children: subScript }),
|
|
14422
|
+
createMathSuperScriptElement({ children: superScript })
|
|
14423
|
+
]
|
|
14424
|
+
});
|
|
14359
14425
|
}
|
|
14360
14426
|
}
|
|
14361
14427
|
const WORKAROUND4 = "";
|
|
@@ -14394,7 +14460,7 @@ class MathRadical extends XmlComponent {
|
|
|
14394
14460
|
super("m:rad");
|
|
14395
14461
|
this.root.push(new MathRadicalProperties(!!options.degree));
|
|
14396
14462
|
this.root.push(new MathDegree(options.degree));
|
|
14397
|
-
this.root.push(
|
|
14463
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14398
14464
|
}
|
|
14399
14465
|
}
|
|
14400
14466
|
class MathFunctionName extends XmlComponent {
|
|
@@ -14415,83 +14481,75 @@ class MathFunction extends XmlComponent {
|
|
|
14415
14481
|
super("m:func");
|
|
14416
14482
|
this.root.push(new MathFunctionProperties());
|
|
14417
14483
|
this.root.push(new MathFunctionName(options.name));
|
|
14418
|
-
this.root.push(
|
|
14419
|
-
}
|
|
14420
|
-
}
|
|
14421
|
-
class MathBeginningCharacterAttributes extends XmlAttributeComponent {
|
|
14422
|
-
constructor() {
|
|
14423
|
-
super(...arguments);
|
|
14424
|
-
__publicField(this, "xmlKeys", { character: "m:val" });
|
|
14425
|
-
}
|
|
14426
|
-
}
|
|
14427
|
-
class MathBeginningCharacter extends XmlComponent {
|
|
14428
|
-
constructor(character) {
|
|
14429
|
-
super("m:begChr");
|
|
14430
|
-
this.root.push(new MathBeginningCharacterAttributes({ character }));
|
|
14431
|
-
}
|
|
14432
|
-
}
|
|
14433
|
-
class MathEndingCharacterAttributes extends XmlAttributeComponent {
|
|
14434
|
-
constructor() {
|
|
14435
|
-
super(...arguments);
|
|
14436
|
-
__publicField(this, "xmlKeys", { character: "m:val" });
|
|
14484
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14437
14485
|
}
|
|
14438
14486
|
}
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14487
|
+
const createMathBeginningCharacter = ({ character }) => new BuilderElement({
|
|
14488
|
+
name: "m:begChr",
|
|
14489
|
+
attributes: {
|
|
14490
|
+
character: { key: "m:val", value: character }
|
|
14443
14491
|
}
|
|
14444
|
-
}
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
this.root.push(new MathBeginningCharacter(options.beginningCharacter));
|
|
14450
|
-
this.root.push(new MathEndingCharacter(options.endingCharacter));
|
|
14451
|
-
}
|
|
14492
|
+
});
|
|
14493
|
+
const createMathEndingCharacter = ({ character }) => new BuilderElement({
|
|
14494
|
+
name: "m:endChr",
|
|
14495
|
+
attributes: {
|
|
14496
|
+
character: { key: "m:val", value: character }
|
|
14452
14497
|
}
|
|
14453
|
-
}
|
|
14498
|
+
});
|
|
14499
|
+
const createMathBracketProperties = ({ characters }) => new BuilderElement({
|
|
14500
|
+
name: "m:dPr",
|
|
14501
|
+
children: !!characters ? [
|
|
14502
|
+
createMathBeginningCharacter({ character: characters.beginningCharacter }),
|
|
14503
|
+
createMathEndingCharacter({ character: characters.endingCharacter })
|
|
14504
|
+
] : []
|
|
14505
|
+
});
|
|
14454
14506
|
class MathRoundBrackets extends XmlComponent {
|
|
14455
14507
|
constructor(options) {
|
|
14456
14508
|
super("m:d");
|
|
14457
|
-
this.root.push(
|
|
14458
|
-
this.root.push(
|
|
14509
|
+
this.root.push(createMathBracketProperties({}));
|
|
14510
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14459
14511
|
}
|
|
14460
14512
|
}
|
|
14461
14513
|
class MathSquareBrackets extends XmlComponent {
|
|
14462
14514
|
constructor(options) {
|
|
14463
14515
|
super("m:d");
|
|
14464
14516
|
this.root.push(
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14517
|
+
createMathBracketProperties({
|
|
14518
|
+
characters: {
|
|
14519
|
+
beginningCharacter: "[",
|
|
14520
|
+
endingCharacter: "]"
|
|
14521
|
+
}
|
|
14468
14522
|
})
|
|
14469
14523
|
);
|
|
14470
|
-
this.root.push(
|
|
14524
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14471
14525
|
}
|
|
14472
14526
|
}
|
|
14473
14527
|
class MathCurlyBrackets extends XmlComponent {
|
|
14474
14528
|
constructor(options) {
|
|
14475
14529
|
super("m:d");
|
|
14476
14530
|
this.root.push(
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14531
|
+
createMathBracketProperties({
|
|
14532
|
+
characters: {
|
|
14533
|
+
beginningCharacter: "{",
|
|
14534
|
+
endingCharacter: "}"
|
|
14535
|
+
}
|
|
14480
14536
|
})
|
|
14481
14537
|
);
|
|
14482
|
-
this.root.push(
|
|
14538
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14483
14539
|
}
|
|
14484
14540
|
}
|
|
14485
14541
|
class MathAngledBrackets extends XmlComponent {
|
|
14486
14542
|
constructor(options) {
|
|
14487
14543
|
super("m:d");
|
|
14488
14544
|
this.root.push(
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14545
|
+
createMathBracketProperties({
|
|
14546
|
+
characters: {
|
|
14547
|
+
beginningCharacter: "〈",
|
|
14548
|
+
endingCharacter: "〉"
|
|
14549
|
+
}
|
|
14492
14550
|
})
|
|
14493
14551
|
);
|
|
14494
|
-
this.root.push(
|
|
14552
|
+
this.root.push(createMathBase({ children: options.children }));
|
|
14495
14553
|
}
|
|
14496
14554
|
}
|
|
14497
14555
|
class TableGrid extends XmlComponent {
|
|
@@ -14850,6 +14908,21 @@ class TableLayout extends XmlComponent {
|
|
|
14850
14908
|
this.root.push(new TableLayoutAttributes({ type: type2 }));
|
|
14851
14909
|
}
|
|
14852
14910
|
}
|
|
14911
|
+
const CellSpacingType = {
|
|
14912
|
+
/** Value is in twentieths of a point */
|
|
14913
|
+
DXA: "dxa"
|
|
14914
|
+
};
|
|
14915
|
+
class TableCellSpacingElement extends XmlComponent {
|
|
14916
|
+
constructor({ type: type2 = CellSpacingType.DXA, value }) {
|
|
14917
|
+
super("w:tblCellSpacing");
|
|
14918
|
+
this.root.push(
|
|
14919
|
+
new NextAttributeComponent({
|
|
14920
|
+
type: { key: "w:type", value: type2 },
|
|
14921
|
+
value: { key: "w:w", value: measurementOrPercentValue(value) }
|
|
14922
|
+
})
|
|
14923
|
+
);
|
|
14924
|
+
}
|
|
14925
|
+
}
|
|
14853
14926
|
class TableProperties extends IgnoreIfEmptyXmlComponent {
|
|
14854
14927
|
constructor(options) {
|
|
14855
14928
|
super("w:tblPr");
|
|
@@ -14883,6 +14956,9 @@ class TableProperties extends IgnoreIfEmptyXmlComponent {
|
|
|
14883
14956
|
if (options.cellMargin) {
|
|
14884
14957
|
this.root.push(new TableCellMargin(TableCellMarginElementType.TABLE, options.cellMargin));
|
|
14885
14958
|
}
|
|
14959
|
+
if (options.cellSpacing) {
|
|
14960
|
+
this.root.push(new TableCellSpacingElement(options.cellSpacing));
|
|
14961
|
+
}
|
|
14886
14962
|
}
|
|
14887
14963
|
}
|
|
14888
14964
|
class Table extends FileChild {
|
|
@@ -14898,7 +14974,8 @@ class Table extends FileChild {
|
|
|
14898
14974
|
style,
|
|
14899
14975
|
borders,
|
|
14900
14976
|
alignment,
|
|
14901
|
-
visuallyRightToLeft
|
|
14977
|
+
visuallyRightToLeft,
|
|
14978
|
+
cellSpacing
|
|
14902
14979
|
}) {
|
|
14903
14980
|
super("w:tbl");
|
|
14904
14981
|
this.root.push(
|
|
@@ -14911,7 +14988,8 @@ class Table extends FileChild {
|
|
|
14911
14988
|
style,
|
|
14912
14989
|
alignment,
|
|
14913
14990
|
cellMargin: margins,
|
|
14914
|
-
visuallyRightToLeft
|
|
14991
|
+
visuallyRightToLeft,
|
|
14992
|
+
cellSpacing
|
|
14915
14993
|
})
|
|
14916
14994
|
);
|
|
14917
14995
|
this.root.push(new TableGrid(columnWidths));
|
|
@@ -14977,6 +15055,9 @@ class TableRowProperties extends IgnoreIfEmptyXmlComponent {
|
|
|
14977
15055
|
if (options.height) {
|
|
14978
15056
|
this.root.push(new TableRowHeight(options.height.value, options.height.rule));
|
|
14979
15057
|
}
|
|
15058
|
+
if (options.cellSpacing) {
|
|
15059
|
+
this.root.push(new TableCellSpacingElement(options.cellSpacing));
|
|
15060
|
+
}
|
|
14980
15061
|
}
|
|
14981
15062
|
}
|
|
14982
15063
|
class TableRow extends XmlComponent {
|
|
@@ -15308,10 +15389,10 @@ const createFont = ({
|
|
|
15308
15389
|
// http://www.datypic.com/sc/ooxml/e-w_charset-1.html
|
|
15309
15390
|
...charset ? [createStringElement("w:charset", charset)] : [],
|
|
15310
15391
|
// http://www.datypic.com/sc/ooxml/e-w_family-1.html
|
|
15311
|
-
...
|
|
15392
|
+
...[createStringElement("w:family", family)],
|
|
15312
15393
|
// http://www.datypic.com/sc/ooxml/e-w_notTrueType-1.html
|
|
15313
15394
|
...notTrueType ? [new OnOffElement("w:notTrueType", notTrueType)] : [],
|
|
15314
|
-
...
|
|
15395
|
+
...[createStringElement("w:pitch", pitch)],
|
|
15315
15396
|
// http://www.datypic.com/sc/ooxml/e-w_sig-1.html
|
|
15316
15397
|
...sig ? [
|
|
15317
15398
|
new BuilderElement({
|
|
@@ -17522,12 +17603,7 @@ const styleToKeyMap = {
|
|
|
17522
17603
|
zIndex: "z-index"
|
|
17523
17604
|
};
|
|
17524
17605
|
const formatShapeStyle = (style) => style ? Object.entries(style).map(([key, value]) => `${styleToKeyMap[key]}:${value}`).join(";") : void 0;
|
|
17525
|
-
const createShape = ({
|
|
17526
|
-
id,
|
|
17527
|
-
children,
|
|
17528
|
-
type: type2 = SHAPE_TYPE,
|
|
17529
|
-
style
|
|
17530
|
-
}) => new BuilderElement({
|
|
17606
|
+
const createShape = ({ id, children, type: type2 = SHAPE_TYPE, style }) => new BuilderElement({
|
|
17531
17607
|
name: "v:shape",
|
|
17532
17608
|
attributes: {
|
|
17533
17609
|
id: {
|
|
@@ -20244,7 +20320,26 @@ class Compiler {
|
|
|
20244
20320
|
}
|
|
20245
20321
|
}
|
|
20246
20322
|
);
|
|
20323
|
+
const commentRelationshipCount = file.Comments.Relationships.RelationshipCount + 1;
|
|
20324
|
+
const commentXmlData = xml(
|
|
20325
|
+
this.formatter.format(file.Comments, {
|
|
20326
|
+
viewWrapper: {
|
|
20327
|
+
View: file.Comments,
|
|
20328
|
+
Relationships: file.Comments.Relationships
|
|
20329
|
+
},
|
|
20330
|
+
file,
|
|
20331
|
+
stack: []
|
|
20332
|
+
}),
|
|
20333
|
+
{
|
|
20334
|
+
indent: prettify,
|
|
20335
|
+
declaration: {
|
|
20336
|
+
standalone: "yes",
|
|
20337
|
+
encoding: "UTF-8"
|
|
20338
|
+
}
|
|
20339
|
+
}
|
|
20340
|
+
);
|
|
20247
20341
|
const documentMediaDatas = this.imageReplacer.getMediaData(documentXmlData, file.Media);
|
|
20342
|
+
const commentMediaDatas = this.imageReplacer.getMediaData(commentXmlData, file.Media);
|
|
20248
20343
|
return {
|
|
20249
20344
|
Relationships: {
|
|
20250
20345
|
data: (() => {
|
|
@@ -20577,22 +20672,41 @@ class Compiler {
|
|
|
20577
20672
|
path: "word/settings.xml"
|
|
20578
20673
|
},
|
|
20579
20674
|
Comments: {
|
|
20580
|
-
data:
|
|
20581
|
-
this.
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
}),
|
|
20586
|
-
{
|
|
20587
|
-
indent: prettify,
|
|
20588
|
-
declaration: {
|
|
20589
|
-
standalone: "yes",
|
|
20590
|
-
encoding: "UTF-8"
|
|
20591
|
-
}
|
|
20592
|
-
}
|
|
20593
|
-
),
|
|
20675
|
+
data: (() => {
|
|
20676
|
+
const xmlData = this.imageReplacer.replace(commentXmlData, commentMediaDatas, commentRelationshipCount);
|
|
20677
|
+
const referenedXmlData = this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
|
|
20678
|
+
return referenedXmlData;
|
|
20679
|
+
})(),
|
|
20594
20680
|
path: "word/comments.xml"
|
|
20595
20681
|
},
|
|
20682
|
+
CommentsRelationships: {
|
|
20683
|
+
data: (() => {
|
|
20684
|
+
commentMediaDatas.forEach((mediaData, i) => {
|
|
20685
|
+
file.Comments.Relationships.createRelationship(
|
|
20686
|
+
commentRelationshipCount + i,
|
|
20687
|
+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
20688
|
+
`media/${mediaData.fileName}`
|
|
20689
|
+
);
|
|
20690
|
+
});
|
|
20691
|
+
return xml(
|
|
20692
|
+
this.formatter.format(file.Comments.Relationships, {
|
|
20693
|
+
viewWrapper: {
|
|
20694
|
+
View: file.Comments,
|
|
20695
|
+
Relationships: file.Comments.Relationships
|
|
20696
|
+
},
|
|
20697
|
+
file,
|
|
20698
|
+
stack: []
|
|
20699
|
+
}),
|
|
20700
|
+
{
|
|
20701
|
+
indent: prettify,
|
|
20702
|
+
declaration: {
|
|
20703
|
+
encoding: "UTF-8"
|
|
20704
|
+
}
|
|
20705
|
+
}
|
|
20706
|
+
);
|
|
20707
|
+
})(),
|
|
20708
|
+
path: "word/_rels/comments.xml.rels"
|
|
20709
|
+
},
|
|
20596
20710
|
FontTable: {
|
|
20597
20711
|
data: xml(
|
|
20598
20712
|
this.formatter.format(file.FontTable.View, {
|
|
@@ -20921,9 +21035,8 @@ const traverse = (node) => {
|
|
|
20921
21035
|
currentNode = queue2.shift();
|
|
20922
21036
|
if (currentNode.element.name === "w:p") {
|
|
20923
21037
|
renderedParagraphs = [...renderedParagraphs, renderParagraphNode(currentNode)];
|
|
20924
|
-
} else {
|
|
20925
|
-
queue2.push(...elementsToWrapper(currentNode));
|
|
20926
21038
|
}
|
|
21039
|
+
queue2.push(...elementsToWrapper(currentNode));
|
|
20927
21040
|
}
|
|
20928
21041
|
return renderedParagraphs;
|
|
20929
21042
|
};
|
|
@@ -21001,14 +21114,21 @@ const PatchType = {
|
|
|
21001
21114
|
PARAGRAPH: "paragraph"
|
|
21002
21115
|
};
|
|
21003
21116
|
const imageReplacer = new ImageReplacer();
|
|
21117
|
+
const UTF16LE = Buffer.from([255, 254]);
|
|
21118
|
+
const UTF16BE = Buffer.from([254, 255]);
|
|
21004
21119
|
const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
21005
21120
|
outputType,
|
|
21006
21121
|
data,
|
|
21007
21122
|
patches,
|
|
21008
|
-
keepOriginalStyles
|
|
21123
|
+
keepOriginalStyles,
|
|
21124
|
+
placeholderDelimiters = { start: "{{", end: "}}" },
|
|
21125
|
+
/**
|
|
21126
|
+
* Search for occurrences over patched document
|
|
21127
|
+
*/
|
|
21128
|
+
recursive = true
|
|
21009
21129
|
}) {
|
|
21010
|
-
var _a, _b, _c
|
|
21011
|
-
const zipContent = yield JSZip.loadAsync(data);
|
|
21130
|
+
var _a, _b, _c;
|
|
21131
|
+
const zipContent = data instanceof JSZip ? data : yield JSZip.loadAsync(data);
|
|
21012
21132
|
const contexts = /* @__PURE__ */ new Map();
|
|
21013
21133
|
const file = {
|
|
21014
21134
|
Media: new Media()
|
|
@@ -21019,15 +21139,20 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
|
21019
21139
|
let hasMedia = false;
|
|
21020
21140
|
const binaryContentMap = /* @__PURE__ */ new Map();
|
|
21021
21141
|
for (const [key, value] of Object.entries(zipContent.files)) {
|
|
21142
|
+
const binaryValue = yield value.async("uint8array");
|
|
21143
|
+
const startBytes = binaryValue.slice(0, 2);
|
|
21144
|
+
if (UTF16LE.equals(startBytes) || UTF16BE.equals(startBytes)) {
|
|
21145
|
+
binaryContentMap.set(key, binaryValue);
|
|
21146
|
+
continue;
|
|
21147
|
+
}
|
|
21022
21148
|
if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
|
|
21023
|
-
binaryContentMap.set(key,
|
|
21149
|
+
binaryContentMap.set(key, binaryValue);
|
|
21024
21150
|
continue;
|
|
21025
21151
|
}
|
|
21026
21152
|
const json = toJson(yield value.async("text"));
|
|
21027
21153
|
if (key === "word/document.xml") {
|
|
21028
21154
|
const document2 = (_a = json.elements) == null ? void 0 : _a.find((i) => i.name === "w:document");
|
|
21029
|
-
if (document2) {
|
|
21030
|
-
document2.attributes = (_b = document2.attributes) != null ? _b : {};
|
|
21155
|
+
if (document2 && document2.attributes) {
|
|
21031
21156
|
for (const ns of ["mc", "wp", "r", "w15", "m"]) {
|
|
21032
21157
|
document2.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
|
|
21033
21158
|
}
|
|
@@ -21053,8 +21178,12 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
|
21053
21178
|
stack: []
|
|
21054
21179
|
};
|
|
21055
21180
|
contexts.set(key, context);
|
|
21181
|
+
if (!(placeholderDelimiters == null ? void 0 : placeholderDelimiters.start.trim()) || !(placeholderDelimiters == null ? void 0 : placeholderDelimiters.end.trim())) {
|
|
21182
|
+
throw new Error("Both start and end delimiters must be non-empty strings.");
|
|
21183
|
+
}
|
|
21184
|
+
const { start, end } = placeholderDelimiters;
|
|
21056
21185
|
for (const [patchKey, patchValue] of Object.entries(patches)) {
|
|
21057
|
-
const patchText =
|
|
21186
|
+
const patchText = `${start}${patchKey}${end}`;
|
|
21058
21187
|
while (true) {
|
|
21059
21188
|
const { didFindOccurrence } = replacer({
|
|
21060
21189
|
json,
|
|
@@ -21080,7 +21209,7 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
|
21080
21209
|
context,
|
|
21081
21210
|
keepOriginalStyles
|
|
21082
21211
|
});
|
|
21083
|
-
if (!didFindOccurrence) {
|
|
21212
|
+
if (!recursive || !didFindOccurrence) {
|
|
21084
21213
|
break;
|
|
21085
21214
|
}
|
|
21086
21215
|
}
|
|
@@ -21098,7 +21227,7 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
|
21098
21227
|
}
|
|
21099
21228
|
for (const { key, mediaDatas } of imageRelationshipAdditions) {
|
|
21100
21229
|
const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
|
|
21101
|
-
const relationshipsJson = (
|
|
21230
|
+
const relationshipsJson = (_b = map.get(relationshipKey)) != null ? _b : createRelationshipFile();
|
|
21102
21231
|
map.set(relationshipKey, relationshipsJson);
|
|
21103
21232
|
const index = getNextRelationshipIndex(relationshipsJson);
|
|
21104
21233
|
const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
|
|
@@ -21115,7 +21244,7 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
|
21115
21244
|
}
|
|
21116
21245
|
for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
|
|
21117
21246
|
const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
|
|
21118
|
-
const relationshipsJson = (
|
|
21247
|
+
const relationshipsJson = (_c = map.get(relationshipKey)) != null ? _c : createRelationshipFile();
|
|
21119
21248
|
map.set(relationshipKey, relationshipsJson);
|
|
21120
21249
|
appendRelationship(
|
|
21121
21250
|
relationshipsJson,
|
|
@@ -21155,7 +21284,10 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
|
|
|
21155
21284
|
});
|
|
21156
21285
|
});
|
|
21157
21286
|
const toXml = (jsonObj) => {
|
|
21158
|
-
const output = libExports.js2xml(jsonObj
|
|
21287
|
+
const output = libExports.js2xml(jsonObj, {
|
|
21288
|
+
attributeValueFn: (str) => String(str).replace(/&(?!amp;|lt;|gt;|quot;|apos;)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'")
|
|
21289
|
+
// cspell:words apos
|
|
21290
|
+
});
|
|
21159
21291
|
return output;
|
|
21160
21292
|
};
|
|
21161
21293
|
const createRelationshipFile = () => ({
|
|
@@ -21178,7 +21310,7 @@ const createRelationshipFile = () => ({
|
|
|
21178
21310
|
]
|
|
21179
21311
|
});
|
|
21180
21312
|
const patchDetector = (_0) => __async(void 0, [_0], function* ({ data }) {
|
|
21181
|
-
const zipContent = yield JSZip.loadAsync(data);
|
|
21313
|
+
const zipContent = data instanceof JSZip ? data : yield JSZip.loadAsync(data);
|
|
21182
21314
|
const patches = /* @__PURE__ */ new Set();
|
|
21183
21315
|
for (const [key, value] of Object.entries(zipContent.files)) {
|
|
21184
21316
|
if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
|
|
@@ -21232,14 +21364,12 @@ export {
|
|
|
21232
21364
|
DayLong,
|
|
21233
21365
|
DayShort,
|
|
21234
21366
|
DeletedTextRun,
|
|
21235
|
-
DocGridAttributes,
|
|
21236
21367
|
File as Document,
|
|
21237
21368
|
DocumentAttributeNamespaces,
|
|
21238
21369
|
DocumentAttributes,
|
|
21239
21370
|
DocumentBackground,
|
|
21240
21371
|
DocumentBackgroundAttributes,
|
|
21241
21372
|
DocumentDefaults,
|
|
21242
|
-
DocumentGrid,
|
|
21243
21373
|
DocumentGridType,
|
|
21244
21374
|
DotEmphasisMark,
|
|
21245
21375
|
Drawing,
|
|
@@ -21270,7 +21400,6 @@ export {
|
|
|
21270
21400
|
HeadingLevel,
|
|
21271
21401
|
HeightRule,
|
|
21272
21402
|
HighlightColor,
|
|
21273
|
-
HorizontalPosition,
|
|
21274
21403
|
HorizontalPositionAlign,
|
|
21275
21404
|
HorizontalPositionRelativeFrom,
|
|
21276
21405
|
HpsMeasureElement,
|
|
@@ -21294,9 +21423,7 @@ export {
|
|
|
21294
21423
|
LineNumberRestartFormat,
|
|
21295
21424
|
LineRuleType,
|
|
21296
21425
|
Math$1 as Math,
|
|
21297
|
-
MathAccentCharacter,
|
|
21298
21426
|
MathAngledBrackets,
|
|
21299
|
-
MathBase,
|
|
21300
21427
|
MathCurlyBrackets,
|
|
21301
21428
|
MathDegree,
|
|
21302
21429
|
MathDenominator,
|
|
@@ -21306,27 +21433,19 @@ export {
|
|
|
21306
21433
|
MathFunctionProperties,
|
|
21307
21434
|
MathIntegral,
|
|
21308
21435
|
MathLimit,
|
|
21309
|
-
MathLimitLocation,
|
|
21310
21436
|
MathLimitLower,
|
|
21311
21437
|
MathLimitUpper,
|
|
21312
|
-
MathNAryProperties,
|
|
21313
21438
|
MathNumerator,
|
|
21314
21439
|
MathPreSubSuperScript,
|
|
21315
|
-
MathPreSubSuperScriptProperties,
|
|
21316
21440
|
MathRadical,
|
|
21317
21441
|
MathRadicalProperties,
|
|
21318
21442
|
MathRoundBrackets,
|
|
21319
21443
|
MathRun,
|
|
21320
21444
|
MathSquareBrackets,
|
|
21321
21445
|
MathSubScript,
|
|
21322
|
-
MathSubScriptElement,
|
|
21323
|
-
MathSubScriptProperties,
|
|
21324
21446
|
MathSubSuperScript,
|
|
21325
|
-
MathSubSuperScriptProperties,
|
|
21326
21447
|
MathSum,
|
|
21327
21448
|
MathSuperScript,
|
|
21328
|
-
MathSuperScriptElement,
|
|
21329
|
-
MathSuperScriptProperties,
|
|
21330
21449
|
Media,
|
|
21331
21450
|
MonthLong,
|
|
21332
21451
|
MonthShort,
|
|
@@ -21354,7 +21473,6 @@ export {
|
|
|
21354
21473
|
PageNumberTypeAttributes,
|
|
21355
21474
|
PageOrientation,
|
|
21356
21475
|
PageReference,
|
|
21357
|
-
PageSize,
|
|
21358
21476
|
PageTextDirection,
|
|
21359
21477
|
PageTextDirectionType,
|
|
21360
21478
|
Paragraph,
|
|
@@ -21382,7 +21500,6 @@ export {
|
|
|
21382
21500
|
ShadingType,
|
|
21383
21501
|
SimpleField,
|
|
21384
21502
|
SimpleMailMergeField,
|
|
21385
|
-
SimplePos,
|
|
21386
21503
|
SoftHyphen,
|
|
21387
21504
|
SpaceType,
|
|
21388
21505
|
Spacing,
|
|
@@ -21432,7 +21549,6 @@ export {
|
|
|
21432
21549
|
VerticalAlignElement,
|
|
21433
21550
|
VerticalMerge,
|
|
21434
21551
|
VerticalMergeType,
|
|
21435
|
-
VerticalPosition,
|
|
21436
21552
|
VerticalPositionAlign,
|
|
21437
21553
|
VerticalPositionRelativeFrom,
|
|
21438
21554
|
WORKAROUND2,
|
|
@@ -21453,9 +21569,24 @@ export {
|
|
|
21453
21569
|
convertInchesToTwip,
|
|
21454
21570
|
convertMillimetersToTwip,
|
|
21455
21571
|
convertToXmlComponent,
|
|
21572
|
+
createDocumentGrid,
|
|
21456
21573
|
createFrameProperties,
|
|
21574
|
+
createHorizontalPosition,
|
|
21457
21575
|
createLineNumberType,
|
|
21576
|
+
createMathAccentCharacter,
|
|
21577
|
+
createMathBase,
|
|
21578
|
+
createMathLimitLocation,
|
|
21579
|
+
createMathNAryProperties,
|
|
21580
|
+
createMathPreSubSuperScriptProperties,
|
|
21581
|
+
createMathSubScriptElement,
|
|
21582
|
+
createMathSubScriptProperties,
|
|
21583
|
+
createMathSubSuperScriptProperties,
|
|
21584
|
+
createMathSuperScriptElement,
|
|
21585
|
+
createMathSuperScriptProperties,
|
|
21586
|
+
createPageSize,
|
|
21587
|
+
createSimplePos,
|
|
21458
21588
|
createStringElement,
|
|
21589
|
+
createVerticalPosition,
|
|
21459
21590
|
dateTimeValue,
|
|
21460
21591
|
decimalNumber,
|
|
21461
21592
|
docPropertiesUniqueNumericIdGen,
|