docx-plus 0.0.8 → 0.0.10
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 +109 -113
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.iife.js +109 -113
- package/dist/index.mjs +109 -113
- package/dist/index.umd.js +109 -113
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7422,23 +7422,97 @@ var Drawing = class extends XmlComponent {
|
|
|
7422
7422
|
}
|
|
7423
7423
|
};
|
|
7424
7424
|
//#endregion
|
|
7425
|
-
//#region src/file/
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7425
|
+
//#region src/file/media/media.ts
|
|
7426
|
+
/**
|
|
7427
|
+
* Converts user-facing transformation options (pixels) to internal
|
|
7428
|
+
* transformation data (pixels + EMUs).
|
|
7429
|
+
*
|
|
7430
|
+
* @param options - User-facing transformation in pixels
|
|
7431
|
+
* @returns Internal transformation data with both pixel and EMU values
|
|
7432
|
+
*/
|
|
7433
|
+
const createTransformation = (options) => {
|
|
7434
|
+
var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
|
|
7435
|
+
return {
|
|
7431
7436
|
emus: {
|
|
7432
|
-
x: Math.round(
|
|
7433
|
-
y: Math.round(
|
|
7437
|
+
x: Math.round(options.width * 9525),
|
|
7438
|
+
y: Math.round(options.height * 9525)
|
|
7439
|
+
},
|
|
7440
|
+
flip: options.flip,
|
|
7441
|
+
offset: {
|
|
7442
|
+
emus: {
|
|
7443
|
+
x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
|
|
7444
|
+
y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
|
|
7445
|
+
},
|
|
7446
|
+
pixels: {
|
|
7447
|
+
x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
|
|
7448
|
+
y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
|
|
7449
|
+
}
|
|
7434
7450
|
},
|
|
7435
|
-
flip: transformation.flip,
|
|
7436
7451
|
pixels: {
|
|
7437
|
-
x: Math.round(
|
|
7438
|
-
y: Math.round(
|
|
7452
|
+
x: Math.round(options.width),
|
|
7453
|
+
y: Math.round(options.height)
|
|
7439
7454
|
},
|
|
7440
|
-
rotation:
|
|
7455
|
+
rotation: options.rotation ? options.rotation * 6e4 : void 0
|
|
7456
|
+
};
|
|
7457
|
+
};
|
|
7458
|
+
/**
|
|
7459
|
+
* Manages embedded media (images) in a document.
|
|
7460
|
+
*
|
|
7461
|
+
* Media stores all images referenced in the document and provides
|
|
7462
|
+
* access to their data for packaging into the DOCX file. Each image
|
|
7463
|
+
* is stored with a unique key for retrieval.
|
|
7464
|
+
*
|
|
7465
|
+
* @example
|
|
7466
|
+
* ```typescript
|
|
7467
|
+
* const media = new Media();
|
|
7468
|
+
* media.addImage("image1", {
|
|
7469
|
+
* type: "png",
|
|
7470
|
+
* fileName: "image1.png",
|
|
7471
|
+
* transformation: {
|
|
7472
|
+
* pixels: { x: 200, y: 100 },
|
|
7473
|
+
* emus: { x: 1828800, y: 914400 }
|
|
7474
|
+
* },
|
|
7475
|
+
* data: imageBuffer
|
|
7476
|
+
* });
|
|
7477
|
+
* const allImages = media.Array;
|
|
7478
|
+
* ```
|
|
7479
|
+
*/
|
|
7480
|
+
var Media = class {
|
|
7481
|
+
constructor() {
|
|
7482
|
+
_defineProperty(this, "map", void 0);
|
|
7483
|
+
this.map = /* @__PURE__ */ new Map();
|
|
7441
7484
|
}
|
|
7485
|
+
/**
|
|
7486
|
+
* Adds an image to the media collection.
|
|
7487
|
+
*
|
|
7488
|
+
* @param key - Unique identifier for this image
|
|
7489
|
+
* @param mediaData - Complete image data including file name, transformation, and raw data
|
|
7490
|
+
*/
|
|
7491
|
+
addImage(key, mediaData) {
|
|
7492
|
+
this.map.set(key, mediaData);
|
|
7493
|
+
}
|
|
7494
|
+
/**
|
|
7495
|
+
* Gets all images as an array.
|
|
7496
|
+
*
|
|
7497
|
+
* @returns Read-only array of all media data in the collection
|
|
7498
|
+
*/
|
|
7499
|
+
get Array() {
|
|
7500
|
+
return [...this.map.values()];
|
|
7501
|
+
}
|
|
7502
|
+
};
|
|
7503
|
+
//#endregion
|
|
7504
|
+
//#region src/file/media/data.ts
|
|
7505
|
+
/**
|
|
7506
|
+
* @ignore
|
|
7507
|
+
*/
|
|
7508
|
+
const WORKAROUND2 = "";
|
|
7509
|
+
//#endregion
|
|
7510
|
+
//#region src/file/paragraph/run/image-run.ts
|
|
7511
|
+
const createImageData = (data, transformation, key, srcRect) => ({
|
|
7512
|
+
data,
|
|
7513
|
+
fileName: key,
|
|
7514
|
+
srcRect,
|
|
7515
|
+
transformation: createTransformation(transformation)
|
|
7442
7516
|
});
|
|
7443
7517
|
/**
|
|
7444
7518
|
* Represents an image in a WordprocessingML document.
|
|
@@ -7497,31 +7571,6 @@ var ImageRun = class extends Run {
|
|
|
7497
7571
|
};
|
|
7498
7572
|
//#endregion
|
|
7499
7573
|
//#region src/file/paragraph/run/wps-shape-run.ts
|
|
7500
|
-
const createTransformation = (options) => {
|
|
7501
|
-
var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
|
|
7502
|
-
return {
|
|
7503
|
-
emus: {
|
|
7504
|
-
x: Math.round(options.width * 9525),
|
|
7505
|
-
y: Math.round(options.height * 9525)
|
|
7506
|
-
},
|
|
7507
|
-
flip: options.flip,
|
|
7508
|
-
offset: {
|
|
7509
|
-
emus: {
|
|
7510
|
-
x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
|
|
7511
|
-
y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
|
|
7512
|
-
},
|
|
7513
|
-
pixels: {
|
|
7514
|
-
x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
|
|
7515
|
-
y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
|
|
7516
|
-
}
|
|
7517
|
-
},
|
|
7518
|
-
pixels: {
|
|
7519
|
-
x: Math.round(options.width),
|
|
7520
|
-
y: Math.round(options.height)
|
|
7521
|
-
},
|
|
7522
|
-
rotation: options.rotation ? options.rotation * 6e4 : void 0
|
|
7523
|
-
};
|
|
7524
|
-
};
|
|
7525
7574
|
/**
|
|
7526
7575
|
* @publicApi
|
|
7527
7576
|
*/
|
|
@@ -16836,59 +16885,6 @@ var HeaderWrapper = class {
|
|
|
16836
16885
|
}
|
|
16837
16886
|
};
|
|
16838
16887
|
//#endregion
|
|
16839
|
-
//#region src/file/media/media.ts
|
|
16840
|
-
/**
|
|
16841
|
-
* Manages embedded media (images) in a document.
|
|
16842
|
-
*
|
|
16843
|
-
* Media stores all images referenced in the document and provides
|
|
16844
|
-
* access to their data for packaging into the DOCX file. Each image
|
|
16845
|
-
* is stored with a unique key for retrieval.
|
|
16846
|
-
*
|
|
16847
|
-
* @example
|
|
16848
|
-
* ```typescript
|
|
16849
|
-
* const media = new Media();
|
|
16850
|
-
* media.addImage("image1", {
|
|
16851
|
-
* type: "png",
|
|
16852
|
-
* fileName: "image1.png",
|
|
16853
|
-
* transformation: {
|
|
16854
|
-
* pixels: { x: 200, y: 100 },
|
|
16855
|
-
* emus: { x: 1828800, y: 914400 }
|
|
16856
|
-
* },
|
|
16857
|
-
* data: imageBuffer
|
|
16858
|
-
* });
|
|
16859
|
-
* const allImages = media.Array;
|
|
16860
|
-
* ```
|
|
16861
|
-
*/
|
|
16862
|
-
var Media = class {
|
|
16863
|
-
constructor() {
|
|
16864
|
-
_defineProperty(this, "map", void 0);
|
|
16865
|
-
this.map = /* @__PURE__ */ new Map();
|
|
16866
|
-
}
|
|
16867
|
-
/**
|
|
16868
|
-
* Adds an image to the media collection.
|
|
16869
|
-
*
|
|
16870
|
-
* @param key - Unique identifier for this image
|
|
16871
|
-
* @param mediaData - Complete image data including file name, transformation, and raw data
|
|
16872
|
-
*/
|
|
16873
|
-
addImage(key, mediaData) {
|
|
16874
|
-
this.map.set(key, mediaData);
|
|
16875
|
-
}
|
|
16876
|
-
/**
|
|
16877
|
-
* Gets all images as an array.
|
|
16878
|
-
*
|
|
16879
|
-
* @returns Read-only array of all media data in the collection
|
|
16880
|
-
*/
|
|
16881
|
-
get Array() {
|
|
16882
|
-
return [...this.map.values()];
|
|
16883
|
-
}
|
|
16884
|
-
};
|
|
16885
|
-
//#endregion
|
|
16886
|
-
//#region src/file/media/data.ts
|
|
16887
|
-
/**
|
|
16888
|
-
* @ignore
|
|
16889
|
-
*/
|
|
16890
|
-
const WORKAROUND2 = "";
|
|
16891
|
-
//#endregion
|
|
16892
16888
|
//#region src/file/numbering/level.ts
|
|
16893
16889
|
/**
|
|
16894
16890
|
* Numbering level definitions module for WordprocessingML documents.
|
|
@@ -23600,7 +23596,7 @@ var Compiler = class {
|
|
|
23600
23596
|
viewWrapper: file.Document
|
|
23601
23597
|
}), {
|
|
23602
23598
|
declaration: {
|
|
23603
|
-
encoding: "
|
|
23599
|
+
encoding: "UTF-8",
|
|
23604
23600
|
standalone: "yes"
|
|
23605
23601
|
},
|
|
23606
23602
|
indent: prettify
|
|
@@ -23615,7 +23611,7 @@ var Compiler = class {
|
|
|
23615
23611
|
}
|
|
23616
23612
|
}), {
|
|
23617
23613
|
declaration: {
|
|
23618
|
-
encoding: "
|
|
23614
|
+
encoding: "UTF-8",
|
|
23619
23615
|
standalone: "yes"
|
|
23620
23616
|
},
|
|
23621
23617
|
indent: prettify
|
|
@@ -23627,7 +23623,7 @@ var Compiler = class {
|
|
|
23627
23623
|
viewWrapper: file.FootNotes
|
|
23628
23624
|
}), {
|
|
23629
23625
|
declaration: {
|
|
23630
|
-
encoding: "
|
|
23626
|
+
encoding: "UTF-8",
|
|
23631
23627
|
standalone: "yes"
|
|
23632
23628
|
},
|
|
23633
23629
|
indent: prettify
|
|
@@ -23643,7 +23639,7 @@ var Compiler = class {
|
|
|
23643
23639
|
viewWrapper: file.Document
|
|
23644
23640
|
}), {
|
|
23645
23641
|
declaration: {
|
|
23646
|
-
encoding: "
|
|
23642
|
+
encoding: "UTF-8",
|
|
23647
23643
|
standalone: "yes"
|
|
23648
23644
|
},
|
|
23649
23645
|
indent: prettify
|
|
@@ -23670,7 +23666,7 @@ var Compiler = class {
|
|
|
23670
23666
|
View: file.Comments
|
|
23671
23667
|
}
|
|
23672
23668
|
}), {
|
|
23673
|
-
declaration: { encoding: "
|
|
23669
|
+
declaration: { encoding: "UTF-8" },
|
|
23674
23670
|
indent: prettify
|
|
23675
23671
|
});
|
|
23676
23672
|
})(),
|
|
@@ -23682,7 +23678,7 @@ var Compiler = class {
|
|
|
23682
23678
|
stack: [],
|
|
23683
23679
|
viewWrapper: file.Document
|
|
23684
23680
|
}), {
|
|
23685
|
-
declaration: { encoding: "
|
|
23681
|
+
declaration: { encoding: "UTF-8" },
|
|
23686
23682
|
indent: prettify
|
|
23687
23683
|
}),
|
|
23688
23684
|
path: "[Content_Types].xml"
|
|
@@ -23694,7 +23690,7 @@ var Compiler = class {
|
|
|
23694
23690
|
viewWrapper: file.Document
|
|
23695
23691
|
}), {
|
|
23696
23692
|
declaration: {
|
|
23697
|
-
encoding: "
|
|
23693
|
+
encoding: "UTF-8",
|
|
23698
23694
|
standalone: "yes"
|
|
23699
23695
|
},
|
|
23700
23696
|
indent: prettify
|
|
@@ -23714,7 +23710,7 @@ var Compiler = class {
|
|
|
23714
23710
|
stack: [],
|
|
23715
23711
|
viewWrapper: file.Endnotes
|
|
23716
23712
|
}), {
|
|
23717
|
-
declaration: { encoding: "
|
|
23713
|
+
declaration: { encoding: "UTF-8" },
|
|
23718
23714
|
indent: prettify
|
|
23719
23715
|
}),
|
|
23720
23716
|
path: "word/endnotes.xml"
|
|
@@ -23725,7 +23721,7 @@ var Compiler = class {
|
|
|
23725
23721
|
stack: [],
|
|
23726
23722
|
viewWrapper: file.Endnotes
|
|
23727
23723
|
}), {
|
|
23728
|
-
declaration: { encoding: "
|
|
23724
|
+
declaration: { encoding: "UTF-8" },
|
|
23729
23725
|
indent: prettify
|
|
23730
23726
|
}),
|
|
23731
23727
|
path: "word/_rels/endnotes.xml.rels"
|
|
@@ -23736,7 +23732,7 @@ var Compiler = class {
|
|
|
23736
23732
|
stack: [],
|
|
23737
23733
|
viewWrapper: file.Document
|
|
23738
23734
|
}), {
|
|
23739
|
-
declaration: { encoding: "
|
|
23735
|
+
declaration: { encoding: "UTF-8" },
|
|
23740
23736
|
indent: prettify
|
|
23741
23737
|
}),
|
|
23742
23738
|
path: "_rels/.rels"
|
|
@@ -23748,7 +23744,7 @@ var Compiler = class {
|
|
|
23748
23744
|
viewWrapper: file.Document
|
|
23749
23745
|
}), {
|
|
23750
23746
|
declaration: {
|
|
23751
|
-
encoding: "
|
|
23747
|
+
encoding: "UTF-8",
|
|
23752
23748
|
standalone: "yes"
|
|
23753
23749
|
},
|
|
23754
23750
|
indent: prettify
|
|
@@ -23761,7 +23757,7 @@ var Compiler = class {
|
|
|
23761
23757
|
stack: [],
|
|
23762
23758
|
viewWrapper: file.Document
|
|
23763
23759
|
}), {
|
|
23764
|
-
declaration: { encoding: "
|
|
23760
|
+
declaration: { encoding: "UTF-8" },
|
|
23765
23761
|
indent: prettify
|
|
23766
23762
|
}),
|
|
23767
23763
|
path: "word/_rels/fontTable.xml.rels"
|
|
@@ -23783,7 +23779,7 @@ var Compiler = class {
|
|
|
23783
23779
|
stack: [],
|
|
23784
23780
|
viewWrapper: file.FootNotes
|
|
23785
23781
|
}), {
|
|
23786
|
-
declaration: { encoding: "
|
|
23782
|
+
declaration: { encoding: "UTF-8" },
|
|
23787
23783
|
indent: prettify
|
|
23788
23784
|
});
|
|
23789
23785
|
})(),
|
|
@@ -23795,7 +23791,7 @@ var Compiler = class {
|
|
|
23795
23791
|
stack: [],
|
|
23796
23792
|
viewWrapper: footerWrapper
|
|
23797
23793
|
}), {
|
|
23798
|
-
declaration: { encoding: "
|
|
23794
|
+
declaration: { encoding: "UTF-8" },
|
|
23799
23795
|
indent: prettify
|
|
23800
23796
|
});
|
|
23801
23797
|
footerFormattedViews.set(index, xmlData);
|
|
@@ -23808,7 +23804,7 @@ var Compiler = class {
|
|
|
23808
23804
|
stack: [],
|
|
23809
23805
|
viewWrapper: footerWrapper
|
|
23810
23806
|
}), {
|
|
23811
|
-
declaration: { encoding: "
|
|
23807
|
+
declaration: { encoding: "UTF-8" },
|
|
23812
23808
|
indent: prettify
|
|
23813
23809
|
}),
|
|
23814
23810
|
path: `word/_rels/footer${index + 1}.xml.rels`
|
|
@@ -23829,7 +23825,7 @@ var Compiler = class {
|
|
|
23829
23825
|
stack: [],
|
|
23830
23826
|
viewWrapper: headerWrapper
|
|
23831
23827
|
}), {
|
|
23832
|
-
declaration: { encoding: "
|
|
23828
|
+
declaration: { encoding: "UTF-8" },
|
|
23833
23829
|
indent: prettify
|
|
23834
23830
|
});
|
|
23835
23831
|
headerFormattedViews.set(index, xmlData);
|
|
@@ -23842,7 +23838,7 @@ var Compiler = class {
|
|
|
23842
23838
|
stack: [],
|
|
23843
23839
|
viewWrapper: headerWrapper
|
|
23844
23840
|
}), {
|
|
23845
|
-
declaration: { encoding: "
|
|
23841
|
+
declaration: { encoding: "UTF-8" },
|
|
23846
23842
|
indent: prettify
|
|
23847
23843
|
}),
|
|
23848
23844
|
path: `word/_rels/header${index + 1}.xml.rels`
|
|
@@ -23864,7 +23860,7 @@ var Compiler = class {
|
|
|
23864
23860
|
viewWrapper: file.Document
|
|
23865
23861
|
}), {
|
|
23866
23862
|
declaration: {
|
|
23867
|
-
encoding: "
|
|
23863
|
+
encoding: "UTF-8",
|
|
23868
23864
|
standalone: "yes"
|
|
23869
23865
|
},
|
|
23870
23866
|
indent: prettify
|
|
@@ -23878,7 +23874,7 @@ var Compiler = class {
|
|
|
23878
23874
|
viewWrapper: file.Document
|
|
23879
23875
|
}), {
|
|
23880
23876
|
declaration: {
|
|
23881
|
-
encoding: "
|
|
23877
|
+
encoding: "UTF-8",
|
|
23882
23878
|
standalone: "yes"
|
|
23883
23879
|
},
|
|
23884
23880
|
indent: prettify
|
|
@@ -23896,7 +23892,7 @@ var Compiler = class {
|
|
|
23896
23892
|
stack: [],
|
|
23897
23893
|
viewWrapper: file.Document
|
|
23898
23894
|
}), {
|
|
23899
|
-
declaration: { encoding: "
|
|
23895
|
+
declaration: { encoding: "UTF-8" },
|
|
23900
23896
|
indent: prettify
|
|
23901
23897
|
});
|
|
23902
23898
|
})(),
|
|
@@ -23909,7 +23905,7 @@ var Compiler = class {
|
|
|
23909
23905
|
viewWrapper: file.Document
|
|
23910
23906
|
}), {
|
|
23911
23907
|
declaration: {
|
|
23912
|
-
encoding: "
|
|
23908
|
+
encoding: "UTF-8",
|
|
23913
23909
|
standalone: "yes"
|
|
23914
23910
|
},
|
|
23915
23911
|
indent: prettify
|
|
@@ -23924,7 +23920,7 @@ var Compiler = class {
|
|
|
23924
23920
|
viewWrapper: file.Document
|
|
23925
23921
|
}), {
|
|
23926
23922
|
declaration: {
|
|
23927
|
-
encoding: "
|
|
23923
|
+
encoding: "UTF-8",
|
|
23928
23924
|
standalone: "yes"
|
|
23929
23925
|
},
|
|
23930
23926
|
indent: prettify
|
|
@@ -24862,7 +24858,7 @@ const toXml = (jsonObj) => {
|
|
|
24862
24858
|
};
|
|
24863
24859
|
const createRelationshipFile = () => ({
|
|
24864
24860
|
declaration: { attributes: {
|
|
24865
|
-
encoding: "
|
|
24861
|
+
encoding: "UTF-8",
|
|
24866
24862
|
standalone: "yes",
|
|
24867
24863
|
version: "1.0"
|
|
24868
24864
|
} },
|