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 CHANGED
@@ -7447,23 +7447,97 @@ var Drawing = class extends XmlComponent {
7447
7447
  }
7448
7448
  };
7449
7449
  //#endregion
7450
- //#region src/file/paragraph/run/image-run.ts
7451
- const createImageData = (data, transformation, key, srcRect) => ({
7452
- data,
7453
- fileName: key,
7454
- srcRect,
7455
- transformation: {
7450
+ //#region src/file/media/media.ts
7451
+ /**
7452
+ * Converts user-facing transformation options (pixels) to internal
7453
+ * transformation data (pixels + EMUs).
7454
+ *
7455
+ * @param options - User-facing transformation in pixels
7456
+ * @returns Internal transformation data with both pixel and EMU values
7457
+ */
7458
+ const createTransformation = (options) => {
7459
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7460
+ return {
7456
7461
  emus: {
7457
- x: Math.round(transformation.width * 9525),
7458
- y: Math.round(transformation.height * 9525)
7462
+ x: Math.round(options.width * 9525),
7463
+ y: Math.round(options.height * 9525)
7464
+ },
7465
+ flip: options.flip,
7466
+ offset: {
7467
+ emus: {
7468
+ 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),
7469
+ 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)
7470
+ },
7471
+ pixels: {
7472
+ 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),
7473
+ 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)
7474
+ }
7459
7475
  },
7460
- flip: transformation.flip,
7461
7476
  pixels: {
7462
- x: Math.round(transformation.width),
7463
- y: Math.round(transformation.height)
7477
+ x: Math.round(options.width),
7478
+ y: Math.round(options.height)
7464
7479
  },
7465
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7480
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7481
+ };
7482
+ };
7483
+ /**
7484
+ * Manages embedded media (images) in a document.
7485
+ *
7486
+ * Media stores all images referenced in the document and provides
7487
+ * access to their data for packaging into the DOCX file. Each image
7488
+ * is stored with a unique key for retrieval.
7489
+ *
7490
+ * @example
7491
+ * ```typescript
7492
+ * const media = new Media();
7493
+ * media.addImage("image1", {
7494
+ * type: "png",
7495
+ * fileName: "image1.png",
7496
+ * transformation: {
7497
+ * pixels: { x: 200, y: 100 },
7498
+ * emus: { x: 1828800, y: 914400 }
7499
+ * },
7500
+ * data: imageBuffer
7501
+ * });
7502
+ * const allImages = media.Array;
7503
+ * ```
7504
+ */
7505
+ var Media = class {
7506
+ constructor() {
7507
+ _defineProperty(this, "map", void 0);
7508
+ this.map = /* @__PURE__ */ new Map();
7466
7509
  }
7510
+ /**
7511
+ * Adds an image to the media collection.
7512
+ *
7513
+ * @param key - Unique identifier for this image
7514
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7515
+ */
7516
+ addImage(key, mediaData) {
7517
+ this.map.set(key, mediaData);
7518
+ }
7519
+ /**
7520
+ * Gets all images as an array.
7521
+ *
7522
+ * @returns Read-only array of all media data in the collection
7523
+ */
7524
+ get Array() {
7525
+ return [...this.map.values()];
7526
+ }
7527
+ };
7528
+ //#endregion
7529
+ //#region src/file/media/data.ts
7530
+ /**
7531
+ * @ignore
7532
+ */
7533
+ const WORKAROUND2 = "";
7534
+ //#endregion
7535
+ //#region src/file/paragraph/run/image-run.ts
7536
+ const createImageData = (data, transformation, key, srcRect) => ({
7537
+ data,
7538
+ fileName: key,
7539
+ srcRect,
7540
+ transformation: createTransformation(transformation)
7467
7541
  });
7468
7542
  /**
7469
7543
  * Represents an image in a WordprocessingML document.
@@ -7522,31 +7596,6 @@ var ImageRun = class extends Run {
7522
7596
  };
7523
7597
  //#endregion
7524
7598
  //#region src/file/paragraph/run/wps-shape-run.ts
7525
- const createTransformation = (options) => {
7526
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7527
- return {
7528
- emus: {
7529
- x: Math.round(options.width * 9525),
7530
- y: Math.round(options.height * 9525)
7531
- },
7532
- flip: options.flip,
7533
- offset: {
7534
- emus: {
7535
- 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),
7536
- 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)
7537
- },
7538
- pixels: {
7539
- 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),
7540
- 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)
7541
- }
7542
- },
7543
- pixels: {
7544
- x: Math.round(options.width),
7545
- y: Math.round(options.height)
7546
- },
7547
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7548
- };
7549
- };
7550
7599
  /**
7551
7600
  * @publicApi
7552
7601
  */
@@ -16861,59 +16910,6 @@ var HeaderWrapper = class {
16861
16910
  }
16862
16911
  };
16863
16912
  //#endregion
16864
- //#region src/file/media/media.ts
16865
- /**
16866
- * Manages embedded media (images) in a document.
16867
- *
16868
- * Media stores all images referenced in the document and provides
16869
- * access to their data for packaging into the DOCX file. Each image
16870
- * is stored with a unique key for retrieval.
16871
- *
16872
- * @example
16873
- * ```typescript
16874
- * const media = new Media();
16875
- * media.addImage("image1", {
16876
- * type: "png",
16877
- * fileName: "image1.png",
16878
- * transformation: {
16879
- * pixels: { x: 200, y: 100 },
16880
- * emus: { x: 1828800, y: 914400 }
16881
- * },
16882
- * data: imageBuffer
16883
- * });
16884
- * const allImages = media.Array;
16885
- * ```
16886
- */
16887
- var Media = class {
16888
- constructor() {
16889
- _defineProperty(this, "map", void 0);
16890
- this.map = /* @__PURE__ */ new Map();
16891
- }
16892
- /**
16893
- * Adds an image to the media collection.
16894
- *
16895
- * @param key - Unique identifier for this image
16896
- * @param mediaData - Complete image data including file name, transformation, and raw data
16897
- */
16898
- addImage(key, mediaData) {
16899
- this.map.set(key, mediaData);
16900
- }
16901
- /**
16902
- * Gets all images as an array.
16903
- *
16904
- * @returns Read-only array of all media data in the collection
16905
- */
16906
- get Array() {
16907
- return [...this.map.values()];
16908
- }
16909
- };
16910
- //#endregion
16911
- //#region src/file/media/data.ts
16912
- /**
16913
- * @ignore
16914
- */
16915
- const WORKAROUND2 = "";
16916
- //#endregion
16917
16913
  //#region src/file/numbering/level.ts
16918
16914
  /**
16919
16915
  * Numbering level definitions module for WordprocessingML documents.
@@ -23625,7 +23621,7 @@ var Compiler = class {
23625
23621
  viewWrapper: file.Document
23626
23622
  }), {
23627
23623
  declaration: {
23628
- encoding: "utf8",
23624
+ encoding: "UTF-8",
23629
23625
  standalone: "yes"
23630
23626
  },
23631
23627
  indent: prettify
@@ -23640,7 +23636,7 @@ var Compiler = class {
23640
23636
  }
23641
23637
  }), {
23642
23638
  declaration: {
23643
- encoding: "utf8",
23639
+ encoding: "UTF-8",
23644
23640
  standalone: "yes"
23645
23641
  },
23646
23642
  indent: prettify
@@ -23652,7 +23648,7 @@ var Compiler = class {
23652
23648
  viewWrapper: file.FootNotes
23653
23649
  }), {
23654
23650
  declaration: {
23655
- encoding: "utf8",
23651
+ encoding: "UTF-8",
23656
23652
  standalone: "yes"
23657
23653
  },
23658
23654
  indent: prettify
@@ -23668,7 +23664,7 @@ var Compiler = class {
23668
23664
  viewWrapper: file.Document
23669
23665
  }), {
23670
23666
  declaration: {
23671
- encoding: "utf8",
23667
+ encoding: "UTF-8",
23672
23668
  standalone: "yes"
23673
23669
  },
23674
23670
  indent: prettify
@@ -23695,7 +23691,7 @@ var Compiler = class {
23695
23691
  View: file.Comments
23696
23692
  }
23697
23693
  }), {
23698
- declaration: { encoding: "utf8" },
23694
+ declaration: { encoding: "UTF-8" },
23699
23695
  indent: prettify
23700
23696
  });
23701
23697
  })(),
@@ -23707,7 +23703,7 @@ var Compiler = class {
23707
23703
  stack: [],
23708
23704
  viewWrapper: file.Document
23709
23705
  }), {
23710
- declaration: { encoding: "utf8" },
23706
+ declaration: { encoding: "UTF-8" },
23711
23707
  indent: prettify
23712
23708
  }),
23713
23709
  path: "[Content_Types].xml"
@@ -23719,7 +23715,7 @@ var Compiler = class {
23719
23715
  viewWrapper: file.Document
23720
23716
  }), {
23721
23717
  declaration: {
23722
- encoding: "utf8",
23718
+ encoding: "UTF-8",
23723
23719
  standalone: "yes"
23724
23720
  },
23725
23721
  indent: prettify
@@ -23739,7 +23735,7 @@ var Compiler = class {
23739
23735
  stack: [],
23740
23736
  viewWrapper: file.Endnotes
23741
23737
  }), {
23742
- declaration: { encoding: "utf8" },
23738
+ declaration: { encoding: "UTF-8" },
23743
23739
  indent: prettify
23744
23740
  }),
23745
23741
  path: "word/endnotes.xml"
@@ -23750,7 +23746,7 @@ var Compiler = class {
23750
23746
  stack: [],
23751
23747
  viewWrapper: file.Endnotes
23752
23748
  }), {
23753
- declaration: { encoding: "utf8" },
23749
+ declaration: { encoding: "UTF-8" },
23754
23750
  indent: prettify
23755
23751
  }),
23756
23752
  path: "word/_rels/endnotes.xml.rels"
@@ -23761,7 +23757,7 @@ var Compiler = class {
23761
23757
  stack: [],
23762
23758
  viewWrapper: file.Document
23763
23759
  }), {
23764
- declaration: { encoding: "utf8" },
23760
+ declaration: { encoding: "UTF-8" },
23765
23761
  indent: prettify
23766
23762
  }),
23767
23763
  path: "_rels/.rels"
@@ -23773,7 +23769,7 @@ var Compiler = class {
23773
23769
  viewWrapper: file.Document
23774
23770
  }), {
23775
23771
  declaration: {
23776
- encoding: "utf8",
23772
+ encoding: "UTF-8",
23777
23773
  standalone: "yes"
23778
23774
  },
23779
23775
  indent: prettify
@@ -23786,7 +23782,7 @@ var Compiler = class {
23786
23782
  stack: [],
23787
23783
  viewWrapper: file.Document
23788
23784
  }), {
23789
- declaration: { encoding: "utf8" },
23785
+ declaration: { encoding: "UTF-8" },
23790
23786
  indent: prettify
23791
23787
  }),
23792
23788
  path: "word/_rels/fontTable.xml.rels"
@@ -23808,7 +23804,7 @@ var Compiler = class {
23808
23804
  stack: [],
23809
23805
  viewWrapper: file.FootNotes
23810
23806
  }), {
23811
- declaration: { encoding: "utf8" },
23807
+ declaration: { encoding: "UTF-8" },
23812
23808
  indent: prettify
23813
23809
  });
23814
23810
  })(),
@@ -23820,7 +23816,7 @@ var Compiler = class {
23820
23816
  stack: [],
23821
23817
  viewWrapper: footerWrapper
23822
23818
  }), {
23823
- declaration: { encoding: "utf8" },
23819
+ declaration: { encoding: "UTF-8" },
23824
23820
  indent: prettify
23825
23821
  });
23826
23822
  footerFormattedViews.set(index, xmlData);
@@ -23833,7 +23829,7 @@ var Compiler = class {
23833
23829
  stack: [],
23834
23830
  viewWrapper: footerWrapper
23835
23831
  }), {
23836
- declaration: { encoding: "utf8" },
23832
+ declaration: { encoding: "UTF-8" },
23837
23833
  indent: prettify
23838
23834
  }),
23839
23835
  path: `word/_rels/footer${index + 1}.xml.rels`
@@ -23854,7 +23850,7 @@ var Compiler = class {
23854
23850
  stack: [],
23855
23851
  viewWrapper: headerWrapper
23856
23852
  }), {
23857
- declaration: { encoding: "utf8" },
23853
+ declaration: { encoding: "UTF-8" },
23858
23854
  indent: prettify
23859
23855
  });
23860
23856
  headerFormattedViews.set(index, xmlData);
@@ -23867,7 +23863,7 @@ var Compiler = class {
23867
23863
  stack: [],
23868
23864
  viewWrapper: headerWrapper
23869
23865
  }), {
23870
- declaration: { encoding: "utf8" },
23866
+ declaration: { encoding: "UTF-8" },
23871
23867
  indent: prettify
23872
23868
  }),
23873
23869
  path: `word/_rels/header${index + 1}.xml.rels`
@@ -23889,7 +23885,7 @@ var Compiler = class {
23889
23885
  viewWrapper: file.Document
23890
23886
  }), {
23891
23887
  declaration: {
23892
- encoding: "utf8",
23888
+ encoding: "UTF-8",
23893
23889
  standalone: "yes"
23894
23890
  },
23895
23891
  indent: prettify
@@ -23903,7 +23899,7 @@ var Compiler = class {
23903
23899
  viewWrapper: file.Document
23904
23900
  }), {
23905
23901
  declaration: {
23906
- encoding: "utf8",
23902
+ encoding: "UTF-8",
23907
23903
  standalone: "yes"
23908
23904
  },
23909
23905
  indent: prettify
@@ -23921,7 +23917,7 @@ var Compiler = class {
23921
23917
  stack: [],
23922
23918
  viewWrapper: file.Document
23923
23919
  }), {
23924
- declaration: { encoding: "utf8" },
23920
+ declaration: { encoding: "UTF-8" },
23925
23921
  indent: prettify
23926
23922
  });
23927
23923
  })(),
@@ -23934,7 +23930,7 @@ var Compiler = class {
23934
23930
  viewWrapper: file.Document
23935
23931
  }), {
23936
23932
  declaration: {
23937
- encoding: "utf8",
23933
+ encoding: "UTF-8",
23938
23934
  standalone: "yes"
23939
23935
  },
23940
23936
  indent: prettify
@@ -23949,7 +23945,7 @@ var Compiler = class {
23949
23945
  viewWrapper: file.Document
23950
23946
  }), {
23951
23947
  declaration: {
23952
- encoding: "utf8",
23948
+ encoding: "UTF-8",
23953
23949
  standalone: "yes"
23954
23950
  },
23955
23951
  indent: prettify
@@ -24887,7 +24883,7 @@ const toXml = (jsonObj) => {
24887
24883
  };
24888
24884
  const createRelationshipFile = () => ({
24889
24885
  declaration: { attributes: {
24890
- encoding: "utf8",
24886
+ encoding: "UTF-8",
24891
24887
  standalone: "yes",
24892
24888
  version: "1.0"
24893
24889
  } },
package/dist/index.d.cts CHANGED
@@ -1287,6 +1287,7 @@ interface IMediaTransformation {
1287
1287
  };
1288
1288
  readonly rotation?: number;
1289
1289
  }
1290
+ declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1290
1291
  declare class Media {
1291
1292
  private readonly map;
1292
1293
  constructor();
@@ -1345,7 +1346,6 @@ interface CoreShapeOptions {
1345
1346
  type IWpsShapeOptions = WpsShapeCoreOptions & {
1346
1347
  readonly type: "wps";
1347
1348
  } & CoreShapeOptions;
1348
- declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1349
1349
  declare class WpsShapeRun extends Run {
1350
1350
  private readonly wpsShapeData;
1351
1351
  constructor(options: IWpsShapeOptions);
package/dist/index.d.mts CHANGED
@@ -1289,6 +1289,7 @@ interface IMediaTransformation {
1289
1289
  };
1290
1290
  readonly rotation?: number;
1291
1291
  }
1292
+ declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1292
1293
  declare class Media {
1293
1294
  private readonly map;
1294
1295
  constructor();
@@ -1347,7 +1348,6 @@ interface CoreShapeOptions {
1347
1348
  type IWpsShapeOptions = WpsShapeCoreOptions & {
1348
1349
  readonly type: "wps";
1349
1350
  } & CoreShapeOptions;
1350
- declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1351
1351
  declare class WpsShapeRun extends Run {
1352
1352
  private readonly wpsShapeData;
1353
1353
  constructor(options: IWpsShapeOptions);