docx-plus 0.1.1 → 0.1.3
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.cjs +275 -20
- package/dist/index.d.cts +16 -6
- package/dist/index.d.mts +16 -6
- package/dist/index.iife.js +275 -20
- package/dist/index.mjs +275 -21
- package/dist/index.umd.js +275 -20
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -11456,27 +11456,27 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
11456
11456
|
* @example
|
|
11457
11457
|
* ```typescript
|
|
11458
11458
|
* // Crop 10% from left and right
|
|
11459
|
-
* createSourceRectangle({
|
|
11459
|
+
* createSourceRectangle({ left: 10000, right: 10000 });
|
|
11460
11460
|
* ```
|
|
11461
11461
|
*/
|
|
11462
11462
|
const createSourceRectangle = (options) => {
|
|
11463
11463
|
if (!options) return new BuilderElement({ name: "a:srcRect" });
|
|
11464
11464
|
const attributes = {};
|
|
11465
|
-
if (options.
|
|
11465
|
+
if (options.left !== void 0) attributes.l = {
|
|
11466
11466
|
key: "l",
|
|
11467
|
-
value: options.
|
|
11467
|
+
value: options.left
|
|
11468
11468
|
};
|
|
11469
|
-
if (options.
|
|
11469
|
+
if (options.top !== void 0) attributes.t = {
|
|
11470
11470
|
key: "t",
|
|
11471
|
-
value: options.
|
|
11471
|
+
value: options.top
|
|
11472
11472
|
};
|
|
11473
|
-
if (options.
|
|
11473
|
+
if (options.right !== void 0) attributes.r = {
|
|
11474
11474
|
key: "r",
|
|
11475
|
-
value: options.
|
|
11475
|
+
value: options.right
|
|
11476
11476
|
};
|
|
11477
|
-
if (options.
|
|
11477
|
+
if (options.bottom !== void 0) attributes.b = {
|
|
11478
11478
|
key: "b",
|
|
11479
|
-
value: options.
|
|
11479
|
+
value: options.bottom
|
|
11480
11480
|
};
|
|
11481
11481
|
return new BuilderElement({
|
|
11482
11482
|
attributes,
|
|
@@ -12407,7 +12407,8 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
12407
12407
|
NONE: 0,
|
|
12408
12408
|
SQUARE: 1,
|
|
12409
12409
|
TIGHT: 2,
|
|
12410
|
-
TOP_AND_BOTTOM: 3
|
|
12410
|
+
TOP_AND_BOTTOM: 3,
|
|
12411
|
+
THROUGH: 4
|
|
12411
12412
|
};
|
|
12412
12413
|
/**
|
|
12413
12414
|
* Enumeration of text wrapping sides for floating drawings.
|
|
@@ -12522,10 +12523,101 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
12522
12523
|
* @module
|
|
12523
12524
|
*/
|
|
12524
12525
|
/**
|
|
12526
|
+
* Creates a default rectangular wrap polygon matching the image extent.
|
|
12527
|
+
*
|
|
12528
|
+
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
12529
|
+
*
|
|
12530
|
+
* ## XSD Schema
|
|
12531
|
+
* ```xml
|
|
12532
|
+
* <xsd:complexType name="CT_WrapPath">
|
|
12533
|
+
* <xsd:sequence>
|
|
12534
|
+
* <xsd:element name="start" type="a:CT_Point2D" minOccurs="1" maxOccurs="1"/>
|
|
12535
|
+
* <xsd:element name="lineTo" type="a:CT_Point2D" minOccurs="2" maxOccurs="unbounded"/>
|
|
12536
|
+
* </xsd:sequence>
|
|
12537
|
+
* <xsd:attribute name="edited" type="xsd:boolean" use="optional"/>
|
|
12538
|
+
* </xsd:complexType>
|
|
12539
|
+
* ```
|
|
12540
|
+
*/
|
|
12541
|
+
const createWrapPolygon$1 = (cx, cy) => new BuilderElement({
|
|
12542
|
+
attributes: { edited: {
|
|
12543
|
+
key: "edited",
|
|
12544
|
+
value: "0"
|
|
12545
|
+
} },
|
|
12546
|
+
children: [
|
|
12547
|
+
new BuilderElement({
|
|
12548
|
+
attributes: {
|
|
12549
|
+
x: {
|
|
12550
|
+
key: "x",
|
|
12551
|
+
value: 0
|
|
12552
|
+
},
|
|
12553
|
+
y: {
|
|
12554
|
+
key: "y",
|
|
12555
|
+
value: 0
|
|
12556
|
+
}
|
|
12557
|
+
},
|
|
12558
|
+
name: "wp:start"
|
|
12559
|
+
}),
|
|
12560
|
+
new BuilderElement({
|
|
12561
|
+
attributes: {
|
|
12562
|
+
x: {
|
|
12563
|
+
key: "x",
|
|
12564
|
+
value: cx
|
|
12565
|
+
},
|
|
12566
|
+
y: {
|
|
12567
|
+
key: "y",
|
|
12568
|
+
value: 0
|
|
12569
|
+
}
|
|
12570
|
+
},
|
|
12571
|
+
name: "wp:lineTo"
|
|
12572
|
+
}),
|
|
12573
|
+
new BuilderElement({
|
|
12574
|
+
attributes: {
|
|
12575
|
+
x: {
|
|
12576
|
+
key: "x",
|
|
12577
|
+
value: cx
|
|
12578
|
+
},
|
|
12579
|
+
y: {
|
|
12580
|
+
key: "y",
|
|
12581
|
+
value: cy
|
|
12582
|
+
}
|
|
12583
|
+
},
|
|
12584
|
+
name: "wp:lineTo"
|
|
12585
|
+
}),
|
|
12586
|
+
new BuilderElement({
|
|
12587
|
+
attributes: {
|
|
12588
|
+
x: {
|
|
12589
|
+
key: "x",
|
|
12590
|
+
value: 0
|
|
12591
|
+
},
|
|
12592
|
+
y: {
|
|
12593
|
+
key: "y",
|
|
12594
|
+
value: cy
|
|
12595
|
+
}
|
|
12596
|
+
},
|
|
12597
|
+
name: "wp:lineTo"
|
|
12598
|
+
}),
|
|
12599
|
+
new BuilderElement({
|
|
12600
|
+
attributes: {
|
|
12601
|
+
x: {
|
|
12602
|
+
key: "x",
|
|
12603
|
+
value: 0
|
|
12604
|
+
},
|
|
12605
|
+
y: {
|
|
12606
|
+
key: "y",
|
|
12607
|
+
value: 0
|
|
12608
|
+
}
|
|
12609
|
+
},
|
|
12610
|
+
name: "wp:lineTo"
|
|
12611
|
+
})
|
|
12612
|
+
],
|
|
12613
|
+
name: "wp:wrapPolygon"
|
|
12614
|
+
});
|
|
12615
|
+
/**
|
|
12525
12616
|
* Creates tight text wrapping for a floating drawing.
|
|
12526
12617
|
*
|
|
12527
12618
|
* WrapTight causes text to wrap closely around the contours
|
|
12528
12619
|
* of the drawing rather than its rectangular bounding box.
|
|
12620
|
+
* A default rectangular wrap polygon matching the image extent is generated.
|
|
12529
12621
|
*
|
|
12530
12622
|
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
12531
12623
|
*
|
|
@@ -12533,7 +12625,7 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
12533
12625
|
* ```xml
|
|
12534
12626
|
* <xsd:complexType name="CT_WrapTight">
|
|
12535
12627
|
* <xsd:sequence>
|
|
12536
|
-
* <xsd:element name="wrapPolygon" type="CT_WrapPath"/>
|
|
12628
|
+
* <xsd:element name="wrapPolygon" type="CT_WrapPath" minOccurs="1" maxOccurs="1"/>
|
|
12537
12629
|
* </xsd:sequence>
|
|
12538
12630
|
* <xsd:attribute name="wrapText" type="ST_WrapText" use="required"/>
|
|
12539
12631
|
* <xsd:attribute name="distL" type="ST_WrapDistance"/>
|
|
@@ -12541,23 +12633,176 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
12541
12633
|
* </xsd:complexType>
|
|
12542
12634
|
* ```
|
|
12543
12635
|
*/
|
|
12544
|
-
const createWrapTight = (margins = {
|
|
12636
|
+
const createWrapTight = (textWrapping, margins = {
|
|
12545
12637
|
bottom: 0,
|
|
12638
|
+
left: 0,
|
|
12639
|
+
right: 0,
|
|
12546
12640
|
top: 0
|
|
12547
|
-
}) => new BuilderElement({
|
|
12641
|
+
}, extent) => new BuilderElement({
|
|
12548
12642
|
attributes: {
|
|
12549
|
-
|
|
12550
|
-
key: "
|
|
12551
|
-
value: margins.
|
|
12643
|
+
distL: {
|
|
12644
|
+
key: "distL",
|
|
12645
|
+
value: margins.left
|
|
12552
12646
|
},
|
|
12553
|
-
|
|
12554
|
-
key: "
|
|
12555
|
-
value: margins.
|
|
12647
|
+
distR: {
|
|
12648
|
+
key: "distR",
|
|
12649
|
+
value: margins.right
|
|
12650
|
+
},
|
|
12651
|
+
wrapText: {
|
|
12652
|
+
key: "wrapText",
|
|
12653
|
+
value: textWrapping.side || TextWrappingSide.BOTH_SIDES
|
|
12556
12654
|
}
|
|
12557
12655
|
},
|
|
12656
|
+
children: [createWrapPolygon$1(extent.x, extent.y)],
|
|
12558
12657
|
name: "wp:wrapTight"
|
|
12559
12658
|
});
|
|
12560
12659
|
//#endregion
|
|
12660
|
+
//#region src/file/drawing/text-wrap/wrap-through.ts
|
|
12661
|
+
/**
|
|
12662
|
+
* Wrap Through module for DrawingML text wrapping.
|
|
12663
|
+
*
|
|
12664
|
+
* This module provides "through" text wrapping for floating drawings
|
|
12665
|
+
* where text wraps through the image contours, filling any concave areas.
|
|
12666
|
+
*
|
|
12667
|
+
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
12668
|
+
*
|
|
12669
|
+
* @module
|
|
12670
|
+
*/
|
|
12671
|
+
/**
|
|
12672
|
+
* Creates a default rectangular wrap polygon matching the image extent.
|
|
12673
|
+
*
|
|
12674
|
+
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
12675
|
+
*
|
|
12676
|
+
* ## XSD Schema
|
|
12677
|
+
* ```xml
|
|
12678
|
+
* <xsd:complexType name="CT_WrapPath">
|
|
12679
|
+
* <xsd:sequence>
|
|
12680
|
+
* <xsd:element name="start" type="a:CT_Point2D" minOccurs="1" maxOccurs="1"/>
|
|
12681
|
+
* <xsd:element name="lineTo" type="a:CT_Point2D" minOccurs="2" maxOccurs="unbounded"/>
|
|
12682
|
+
* </xsd:sequence>
|
|
12683
|
+
* <xsd:attribute name="edited" type="xsd:boolean" use="optional"/>
|
|
12684
|
+
* </xsd:complexType>
|
|
12685
|
+
* ```
|
|
12686
|
+
*/
|
|
12687
|
+
const createWrapPolygon = (cx, cy) => new BuilderElement({
|
|
12688
|
+
attributes: { edited: {
|
|
12689
|
+
key: "edited",
|
|
12690
|
+
value: "0"
|
|
12691
|
+
} },
|
|
12692
|
+
children: [
|
|
12693
|
+
new BuilderElement({
|
|
12694
|
+
attributes: {
|
|
12695
|
+
x: {
|
|
12696
|
+
key: "x",
|
|
12697
|
+
value: 0
|
|
12698
|
+
},
|
|
12699
|
+
y: {
|
|
12700
|
+
key: "y",
|
|
12701
|
+
value: 0
|
|
12702
|
+
}
|
|
12703
|
+
},
|
|
12704
|
+
name: "wp:start"
|
|
12705
|
+
}),
|
|
12706
|
+
new BuilderElement({
|
|
12707
|
+
attributes: {
|
|
12708
|
+
x: {
|
|
12709
|
+
key: "x",
|
|
12710
|
+
value: cx
|
|
12711
|
+
},
|
|
12712
|
+
y: {
|
|
12713
|
+
key: "y",
|
|
12714
|
+
value: 0
|
|
12715
|
+
}
|
|
12716
|
+
},
|
|
12717
|
+
name: "wp:lineTo"
|
|
12718
|
+
}),
|
|
12719
|
+
new BuilderElement({
|
|
12720
|
+
attributes: {
|
|
12721
|
+
x: {
|
|
12722
|
+
key: "x",
|
|
12723
|
+
value: cx
|
|
12724
|
+
},
|
|
12725
|
+
y: {
|
|
12726
|
+
key: "y",
|
|
12727
|
+
value: cy
|
|
12728
|
+
}
|
|
12729
|
+
},
|
|
12730
|
+
name: "wp:lineTo"
|
|
12731
|
+
}),
|
|
12732
|
+
new BuilderElement({
|
|
12733
|
+
attributes: {
|
|
12734
|
+
x: {
|
|
12735
|
+
key: "x",
|
|
12736
|
+
value: 0
|
|
12737
|
+
},
|
|
12738
|
+
y: {
|
|
12739
|
+
key: "y",
|
|
12740
|
+
value: cy
|
|
12741
|
+
}
|
|
12742
|
+
},
|
|
12743
|
+
name: "wp:lineTo"
|
|
12744
|
+
}),
|
|
12745
|
+
new BuilderElement({
|
|
12746
|
+
attributes: {
|
|
12747
|
+
x: {
|
|
12748
|
+
key: "x",
|
|
12749
|
+
value: 0
|
|
12750
|
+
},
|
|
12751
|
+
y: {
|
|
12752
|
+
key: "y",
|
|
12753
|
+
value: 0
|
|
12754
|
+
}
|
|
12755
|
+
},
|
|
12756
|
+
name: "wp:lineTo"
|
|
12757
|
+
})
|
|
12758
|
+
],
|
|
12759
|
+
name: "wp:wrapPolygon"
|
|
12760
|
+
});
|
|
12761
|
+
/**
|
|
12762
|
+
* Creates "through" text wrapping for a floating drawing.
|
|
12763
|
+
*
|
|
12764
|
+
* WrapThrough is similar to WrapTight but allows text to wrap through
|
|
12765
|
+
* the concave portions of the drawing shape (e.g., the inside of the letter "O").
|
|
12766
|
+
* A default rectangular wrap polygon matching the image extent is generated.
|
|
12767
|
+
*
|
|
12768
|
+
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
12769
|
+
*
|
|
12770
|
+
* ## XSD Schema
|
|
12771
|
+
* ```xml
|
|
12772
|
+
* <xsd:complexType name="CT_WrapThrough">
|
|
12773
|
+
* <xsd:sequence>
|
|
12774
|
+
* <xsd:element name="wrapPolygon" type="CT_WrapPath" minOccurs="1" maxOccurs="1"/>
|
|
12775
|
+
* </xsd:sequence>
|
|
12776
|
+
* <xsd:attribute name="wrapText" type="ST_WrapText" use="required"/>
|
|
12777
|
+
* <xsd:attribute name="distL" type="ST_WrapDistance"/>
|
|
12778
|
+
* <xsd:attribute name="distR" type="ST_WrapDistance"/>
|
|
12779
|
+
* </xsd:complexType>
|
|
12780
|
+
* ```
|
|
12781
|
+
*/
|
|
12782
|
+
const createWrapThrough = (textWrapping, margins = {
|
|
12783
|
+
bottom: 0,
|
|
12784
|
+
left: 0,
|
|
12785
|
+
right: 0,
|
|
12786
|
+
top: 0
|
|
12787
|
+
}, extent) => new BuilderElement({
|
|
12788
|
+
attributes: {
|
|
12789
|
+
distL: {
|
|
12790
|
+
key: "distL",
|
|
12791
|
+
value: margins.left
|
|
12792
|
+
},
|
|
12793
|
+
distR: {
|
|
12794
|
+
key: "distR",
|
|
12795
|
+
value: margins.right
|
|
12796
|
+
},
|
|
12797
|
+
wrapText: {
|
|
12798
|
+
key: "wrapText",
|
|
12799
|
+
value: textWrapping.side || TextWrappingSide.BOTH_SIDES
|
|
12800
|
+
}
|
|
12801
|
+
},
|
|
12802
|
+
children: [createWrapPolygon(extent.x, extent.y)],
|
|
12803
|
+
name: "wp:wrapThrough"
|
|
12804
|
+
});
|
|
12805
|
+
//#endregion
|
|
12561
12806
|
//#region src/file/drawing/text-wrap/wrap-top-and-bottom.ts
|
|
12562
12807
|
/**
|
|
12563
12808
|
* Wrap Top and Bottom module for DrawingML text wrapping.
|
|
@@ -13007,7 +13252,16 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
13007
13252
|
this.root.push(createWrapSquare(drawingOptions.floating.wrap, drawingOptions.floating.margins));
|
|
13008
13253
|
break;
|
|
13009
13254
|
case TextWrappingType.TIGHT:
|
|
13010
|
-
this.root.push(createWrapTight(drawingOptions.floating.margins
|
|
13255
|
+
this.root.push(createWrapTight(drawingOptions.floating.wrap, drawingOptions.floating.margins, {
|
|
13256
|
+
x: transform.emus.x,
|
|
13257
|
+
y: transform.emus.y
|
|
13258
|
+
}));
|
|
13259
|
+
break;
|
|
13260
|
+
case TextWrappingType.THROUGH:
|
|
13261
|
+
this.root.push(createWrapThrough(drawingOptions.floating.wrap, drawingOptions.floating.margins, {
|
|
13262
|
+
x: transform.emus.x,
|
|
13263
|
+
y: transform.emus.y
|
|
13264
|
+
}));
|
|
13011
13265
|
break;
|
|
13012
13266
|
case TextWrappingType.TOP_AND_BOTTOM:
|
|
13013
13267
|
this.root.push(createWrapTopAndBottom(drawingOptions.floating.margins));
|
|
@@ -27910,6 +28164,7 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
|
|
|
27910
28164
|
exports.createVerticalPosition = createVerticalPosition;
|
|
27911
28165
|
exports.createWrapNone = createWrapNone;
|
|
27912
28166
|
exports.createWrapSquare = createWrapSquare;
|
|
28167
|
+
exports.createWrapThrough = createWrapThrough;
|
|
27913
28168
|
exports.createWrapTight = createWrapTight;
|
|
27914
28169
|
exports.createWrapTopAndBottom = createWrapTopAndBottom;
|
|
27915
28170
|
exports.dateTimeValue = dateTimeValue;
|