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.umd.js CHANGED
@@ -7452,23 +7452,97 @@
7452
7452
  }
7453
7453
  };
7454
7454
  //#endregion
7455
- //#region src/file/paragraph/run/image-run.ts
7456
- const createImageData = (data, transformation, key, srcRect) => ({
7457
- data,
7458
- fileName: key,
7459
- srcRect,
7460
- transformation: {
7455
+ //#region src/file/media/media.ts
7456
+ /**
7457
+ * Converts user-facing transformation options (pixels) to internal
7458
+ * transformation data (pixels + EMUs).
7459
+ *
7460
+ * @param options - User-facing transformation in pixels
7461
+ * @returns Internal transformation data with both pixel and EMU values
7462
+ */
7463
+ const createTransformation = (options) => {
7464
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7465
+ return {
7461
7466
  emus: {
7462
- x: Math.round(transformation.width * 9525),
7463
- y: Math.round(transformation.height * 9525)
7467
+ x: Math.round(options.width * 9525),
7468
+ y: Math.round(options.height * 9525)
7469
+ },
7470
+ flip: options.flip,
7471
+ offset: {
7472
+ emus: {
7473
+ 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),
7474
+ 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)
7475
+ },
7476
+ pixels: {
7477
+ 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),
7478
+ 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)
7479
+ }
7464
7480
  },
7465
- flip: transformation.flip,
7466
7481
  pixels: {
7467
- x: Math.round(transformation.width),
7468
- y: Math.round(transformation.height)
7482
+ x: Math.round(options.width),
7483
+ y: Math.round(options.height)
7469
7484
  },
7470
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7485
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7486
+ };
7487
+ };
7488
+ /**
7489
+ * Manages embedded media (images) in a document.
7490
+ *
7491
+ * Media stores all images referenced in the document and provides
7492
+ * access to their data for packaging into the DOCX file. Each image
7493
+ * is stored with a unique key for retrieval.
7494
+ *
7495
+ * @example
7496
+ * ```typescript
7497
+ * const media = new Media();
7498
+ * media.addImage("image1", {
7499
+ * type: "png",
7500
+ * fileName: "image1.png",
7501
+ * transformation: {
7502
+ * pixels: { x: 200, y: 100 },
7503
+ * emus: { x: 1828800, y: 914400 }
7504
+ * },
7505
+ * data: imageBuffer
7506
+ * });
7507
+ * const allImages = media.Array;
7508
+ * ```
7509
+ */
7510
+ var Media = class {
7511
+ constructor() {
7512
+ _defineProperty(this, "map", void 0);
7513
+ this.map = /* @__PURE__ */ new Map();
7471
7514
  }
7515
+ /**
7516
+ * Adds an image to the media collection.
7517
+ *
7518
+ * @param key - Unique identifier for this image
7519
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7520
+ */
7521
+ addImage(key, mediaData) {
7522
+ this.map.set(key, mediaData);
7523
+ }
7524
+ /**
7525
+ * Gets all images as an array.
7526
+ *
7527
+ * @returns Read-only array of all media data in the collection
7528
+ */
7529
+ get Array() {
7530
+ return [...this.map.values()];
7531
+ }
7532
+ };
7533
+ //#endregion
7534
+ //#region src/file/media/data.ts
7535
+ /**
7536
+ * @ignore
7537
+ */
7538
+ const WORKAROUND2 = "";
7539
+ //#endregion
7540
+ //#region src/file/paragraph/run/image-run.ts
7541
+ const createImageData = (data, transformation, key, srcRect) => ({
7542
+ data,
7543
+ fileName: key,
7544
+ srcRect,
7545
+ transformation: createTransformation(transformation)
7472
7546
  });
7473
7547
  /**
7474
7548
  * Represents an image in a WordprocessingML document.
@@ -7527,31 +7601,6 @@
7527
7601
  };
7528
7602
  //#endregion
7529
7603
  //#region src/file/paragraph/run/wps-shape-run.ts
7530
- const createTransformation = (options) => {
7531
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7532
- return {
7533
- emus: {
7534
- x: Math.round(options.width * 9525),
7535
- y: Math.round(options.height * 9525)
7536
- },
7537
- flip: options.flip,
7538
- offset: {
7539
- emus: {
7540
- 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),
7541
- 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)
7542
- },
7543
- pixels: {
7544
- 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),
7545
- 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)
7546
- }
7547
- },
7548
- pixels: {
7549
- x: Math.round(options.width),
7550
- y: Math.round(options.height)
7551
- },
7552
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7553
- };
7554
- };
7555
7604
  /**
7556
7605
  * @publicApi
7557
7606
  */
@@ -16866,59 +16915,6 @@
16866
16915
  }
16867
16916
  };
16868
16917
  //#endregion
16869
- //#region src/file/media/media.ts
16870
- /**
16871
- * Manages embedded media (images) in a document.
16872
- *
16873
- * Media stores all images referenced in the document and provides
16874
- * access to their data for packaging into the DOCX file. Each image
16875
- * is stored with a unique key for retrieval.
16876
- *
16877
- * @example
16878
- * ```typescript
16879
- * const media = new Media();
16880
- * media.addImage("image1", {
16881
- * type: "png",
16882
- * fileName: "image1.png",
16883
- * transformation: {
16884
- * pixels: { x: 200, y: 100 },
16885
- * emus: { x: 1828800, y: 914400 }
16886
- * },
16887
- * data: imageBuffer
16888
- * });
16889
- * const allImages = media.Array;
16890
- * ```
16891
- */
16892
- var Media = class {
16893
- constructor() {
16894
- _defineProperty(this, "map", void 0);
16895
- this.map = /* @__PURE__ */ new Map();
16896
- }
16897
- /**
16898
- * Adds an image to the media collection.
16899
- *
16900
- * @param key - Unique identifier for this image
16901
- * @param mediaData - Complete image data including file name, transformation, and raw data
16902
- */
16903
- addImage(key, mediaData) {
16904
- this.map.set(key, mediaData);
16905
- }
16906
- /**
16907
- * Gets all images as an array.
16908
- *
16909
- * @returns Read-only array of all media data in the collection
16910
- */
16911
- get Array() {
16912
- return [...this.map.values()];
16913
- }
16914
- };
16915
- //#endregion
16916
- //#region src/file/media/data.ts
16917
- /**
16918
- * @ignore
16919
- */
16920
- const WORKAROUND2 = "";
16921
- //#endregion
16922
16918
  //#region src/file/numbering/level.ts
16923
16919
  /**
16924
16920
  * Numbering level definitions module for WordprocessingML documents.
@@ -23630,7 +23626,7 @@
23630
23626
  viewWrapper: file.Document
23631
23627
  }), {
23632
23628
  declaration: {
23633
- encoding: "utf8",
23629
+ encoding: "UTF-8",
23634
23630
  standalone: "yes"
23635
23631
  },
23636
23632
  indent: prettify
@@ -23645,7 +23641,7 @@
23645
23641
  }
23646
23642
  }), {
23647
23643
  declaration: {
23648
- encoding: "utf8",
23644
+ encoding: "UTF-8",
23649
23645
  standalone: "yes"
23650
23646
  },
23651
23647
  indent: prettify
@@ -23657,7 +23653,7 @@
23657
23653
  viewWrapper: file.FootNotes
23658
23654
  }), {
23659
23655
  declaration: {
23660
- encoding: "utf8",
23656
+ encoding: "UTF-8",
23661
23657
  standalone: "yes"
23662
23658
  },
23663
23659
  indent: prettify
@@ -23673,7 +23669,7 @@
23673
23669
  viewWrapper: file.Document
23674
23670
  }), {
23675
23671
  declaration: {
23676
- encoding: "utf8",
23672
+ encoding: "UTF-8",
23677
23673
  standalone: "yes"
23678
23674
  },
23679
23675
  indent: prettify
@@ -23700,7 +23696,7 @@
23700
23696
  View: file.Comments
23701
23697
  }
23702
23698
  }), {
23703
- declaration: { encoding: "utf8" },
23699
+ declaration: { encoding: "UTF-8" },
23704
23700
  indent: prettify
23705
23701
  });
23706
23702
  })(),
@@ -23712,7 +23708,7 @@
23712
23708
  stack: [],
23713
23709
  viewWrapper: file.Document
23714
23710
  }), {
23715
- declaration: { encoding: "utf8" },
23711
+ declaration: { encoding: "UTF-8" },
23716
23712
  indent: prettify
23717
23713
  }),
23718
23714
  path: "[Content_Types].xml"
@@ -23724,7 +23720,7 @@
23724
23720
  viewWrapper: file.Document
23725
23721
  }), {
23726
23722
  declaration: {
23727
- encoding: "utf8",
23723
+ encoding: "UTF-8",
23728
23724
  standalone: "yes"
23729
23725
  },
23730
23726
  indent: prettify
@@ -23744,7 +23740,7 @@
23744
23740
  stack: [],
23745
23741
  viewWrapper: file.Endnotes
23746
23742
  }), {
23747
- declaration: { encoding: "utf8" },
23743
+ declaration: { encoding: "UTF-8" },
23748
23744
  indent: prettify
23749
23745
  }),
23750
23746
  path: "word/endnotes.xml"
@@ -23755,7 +23751,7 @@
23755
23751
  stack: [],
23756
23752
  viewWrapper: file.Endnotes
23757
23753
  }), {
23758
- declaration: { encoding: "utf8" },
23754
+ declaration: { encoding: "UTF-8" },
23759
23755
  indent: prettify
23760
23756
  }),
23761
23757
  path: "word/_rels/endnotes.xml.rels"
@@ -23766,7 +23762,7 @@
23766
23762
  stack: [],
23767
23763
  viewWrapper: file.Document
23768
23764
  }), {
23769
- declaration: { encoding: "utf8" },
23765
+ declaration: { encoding: "UTF-8" },
23770
23766
  indent: prettify
23771
23767
  }),
23772
23768
  path: "_rels/.rels"
@@ -23778,7 +23774,7 @@
23778
23774
  viewWrapper: file.Document
23779
23775
  }), {
23780
23776
  declaration: {
23781
- encoding: "utf8",
23777
+ encoding: "UTF-8",
23782
23778
  standalone: "yes"
23783
23779
  },
23784
23780
  indent: prettify
@@ -23791,7 +23787,7 @@
23791
23787
  stack: [],
23792
23788
  viewWrapper: file.Document
23793
23789
  }), {
23794
- declaration: { encoding: "utf8" },
23790
+ declaration: { encoding: "UTF-8" },
23795
23791
  indent: prettify
23796
23792
  }),
23797
23793
  path: "word/_rels/fontTable.xml.rels"
@@ -23813,7 +23809,7 @@
23813
23809
  stack: [],
23814
23810
  viewWrapper: file.FootNotes
23815
23811
  }), {
23816
- declaration: { encoding: "utf8" },
23812
+ declaration: { encoding: "UTF-8" },
23817
23813
  indent: prettify
23818
23814
  });
23819
23815
  })(),
@@ -23825,7 +23821,7 @@
23825
23821
  stack: [],
23826
23822
  viewWrapper: footerWrapper
23827
23823
  }), {
23828
- declaration: { encoding: "utf8" },
23824
+ declaration: { encoding: "UTF-8" },
23829
23825
  indent: prettify
23830
23826
  });
23831
23827
  footerFormattedViews.set(index, xmlData);
@@ -23838,7 +23834,7 @@
23838
23834
  stack: [],
23839
23835
  viewWrapper: footerWrapper
23840
23836
  }), {
23841
- declaration: { encoding: "utf8" },
23837
+ declaration: { encoding: "UTF-8" },
23842
23838
  indent: prettify
23843
23839
  }),
23844
23840
  path: `word/_rels/footer${index + 1}.xml.rels`
@@ -23859,7 +23855,7 @@
23859
23855
  stack: [],
23860
23856
  viewWrapper: headerWrapper
23861
23857
  }), {
23862
- declaration: { encoding: "utf8" },
23858
+ declaration: { encoding: "UTF-8" },
23863
23859
  indent: prettify
23864
23860
  });
23865
23861
  headerFormattedViews.set(index, xmlData);
@@ -23872,7 +23868,7 @@
23872
23868
  stack: [],
23873
23869
  viewWrapper: headerWrapper
23874
23870
  }), {
23875
- declaration: { encoding: "utf8" },
23871
+ declaration: { encoding: "UTF-8" },
23876
23872
  indent: prettify
23877
23873
  }),
23878
23874
  path: `word/_rels/header${index + 1}.xml.rels`
@@ -23894,7 +23890,7 @@
23894
23890
  viewWrapper: file.Document
23895
23891
  }), {
23896
23892
  declaration: {
23897
- encoding: "utf8",
23893
+ encoding: "UTF-8",
23898
23894
  standalone: "yes"
23899
23895
  },
23900
23896
  indent: prettify
@@ -23908,7 +23904,7 @@
23908
23904
  viewWrapper: file.Document
23909
23905
  }), {
23910
23906
  declaration: {
23911
- encoding: "utf8",
23907
+ encoding: "UTF-8",
23912
23908
  standalone: "yes"
23913
23909
  },
23914
23910
  indent: prettify
@@ -23926,7 +23922,7 @@
23926
23922
  stack: [],
23927
23923
  viewWrapper: file.Document
23928
23924
  }), {
23929
- declaration: { encoding: "utf8" },
23925
+ declaration: { encoding: "UTF-8" },
23930
23926
  indent: prettify
23931
23927
  });
23932
23928
  })(),
@@ -23939,7 +23935,7 @@
23939
23935
  viewWrapper: file.Document
23940
23936
  }), {
23941
23937
  declaration: {
23942
- encoding: "utf8",
23938
+ encoding: "UTF-8",
23943
23939
  standalone: "yes"
23944
23940
  },
23945
23941
  indent: prettify
@@ -23954,7 +23950,7 @@
23954
23950
  viewWrapper: file.Document
23955
23951
  }), {
23956
23952
  declaration: {
23957
- encoding: "utf8",
23953
+ encoding: "UTF-8",
23958
23954
  standalone: "yes"
23959
23955
  },
23960
23956
  indent: prettify
@@ -24892,7 +24888,7 @@
24892
24888
  };
24893
24889
  const createRelationshipFile = () => ({
24894
24890
  declaration: { attributes: {
24895
- encoding: "utf8",
24891
+ encoding: "UTF-8",
24896
24892
  standalone: "yes",
24897
24893
  version: "1.0"
24898
24894
  } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-plus",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
5
5
  "keywords": [
6
6
  "clippy",