docx-plus 0.0.13 → 0.0.14

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
@@ -8921,8 +8921,8 @@ const createHorizontalPosition = ({ relative, align, offset }) => new BuilderEle
8921
8921
  } },
8922
8922
  children: [(() => {
8923
8923
  if (align) return createAlign(align);
8924
- else if (offset !== void 0) return createPositionOffset(offset);
8925
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8924
+ if (offset !== void 0) return createPositionOffset(offset);
8925
+ return createAlign("LEFT");
8926
8926
  })()],
8927
8927
  name: "wp:positionH"
8928
8928
  });
@@ -8982,8 +8982,8 @@ const createVerticalPosition = ({ relative, align, offset }) => new BuilderEleme
8982
8982
  } },
8983
8983
  children: [(() => {
8984
8984
  if (align) return createAlign(align);
8985
- else if (offset !== void 0) return createPositionOffset(offset);
8986
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8985
+ if (offset !== void 0) return createPositionOffset(offset);
8986
+ return createAlign("TOP");
8987
8987
  })()],
8988
8988
  name: "wp:positionV"
8989
8989
  });
@@ -10562,10 +10562,13 @@ const LineJoin = {
10562
10562
  };
10563
10563
  /**
10564
10564
  * Creates the fill child element for an outline.
10565
+ *
10566
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
10565
10567
  */
10566
10568
  const createOutlineFill = (options) => {
10567
10569
  if (options.type === "noFill") return createNoFill();
10568
- return createSolidFill(options.color);
10570
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
10571
+ return null;
10569
10572
  };
10570
10573
  /**
10571
10574
  * Creates an outline element for DrawingML shapes.
@@ -10601,7 +10604,8 @@ const createOutlineFill = (options) => {
10601
10604
  */
10602
10605
  const createOutline = (options) => {
10603
10606
  const children = [];
10604
- children.push(createOutlineFill(options));
10607
+ const fill = createOutlineFill(options);
10608
+ if (fill) children.push(fill);
10605
10609
  if (options.dash !== void 0) children.push(new BuilderElement({
10606
10610
  attributes: { val: {
10607
10611
  key: "val",
@@ -10992,7 +10996,6 @@ var ShapeProperties = class extends XmlComponent {
10992
10996
  if (noFill) this.root.push(createNoFill());
10993
10997
  else if (solidFill) this.root.push(createSolidFill(solidFill));
10994
10998
  else if (gradientFill) this.root.push(createGradientFill(gradientFill));
10995
- else if (outline) this.root.push(createNoFill());
10996
10999
  if (outline) this.root.push(createOutline(outline));
10997
11000
  if (effects) this.root.push(createEffectList(effects));
10998
11001
  if (shape3d) this.root.push(createShape3D(shape3d));
@@ -14209,8 +14212,7 @@ var NumberProperties = class extends XmlComponent {
14209
14212
  var IndentLevel = class extends XmlComponent {
14210
14213
  constructor(level) {
14211
14214
  super("w:ilvl");
14212
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
14213
- this.root.push(new Attributes({ val: level }));
14215
+ this.root.push(new Attributes({ val: Math.min(level, 9) }));
14214
14216
  }
14215
14217
  };
14216
14218
  /**
@@ -22379,9 +22381,8 @@ var LevelBase = class extends XmlComponent {
22379
22381
  this.runProperties = new RunProperties(style && style.run);
22380
22382
  this.root.push(this.paragraphProperties);
22381
22383
  this.root.push(this.runProperties);
22382
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
22383
22384
  this.root.push(new LevelAttributes({
22384
- ilvl: decimalNumber(level),
22385
+ ilvl: decimalNumber(Math.min(level, 9)),
22385
22386
  tentative: 1
22386
22387
  }));
22387
22388
  }
@@ -24136,7 +24137,10 @@ var ExternalStylesFactory = class {
24136
24137
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24137
24138
  let stylesXmlElement;
24138
24139
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24139
- if (stylesXmlElement === void 0) throw new Error("can not find styles element");
24140
+ if (stylesXmlElement === void 0) return {
24141
+ importedStyles: [],
24142
+ initialStyles: new ImportedRootElementAttributes({})
24143
+ };
24140
24144
  return {
24141
24145
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24142
24146
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
package/dist/index.d.cts CHANGED
@@ -966,14 +966,10 @@ interface OutlineAttributes {
966
966
  readonly join?: keyof typeof LineJoin;
967
967
  readonly miterLimit?: number;
968
968
  }
969
- interface OutlineNoFill {
970
- readonly type: "noFill";
969
+ interface OutlineFillProperties {
970
+ readonly type?: "noFill" | "solidFill";
971
+ readonly color?: SolidFillOptions;
971
972
  }
972
- interface OutlineSolidFill {
973
- readonly type: "solidFill";
974
- readonly color: SolidFillOptions;
975
- }
976
- type OutlineFillProperties = OutlineNoFill | OutlineSolidFill;
977
973
  type OutlineOptions = OutlineAttributes & OutlineFillProperties;
978
974
  //#endregion
979
975
  //#region src/file/drawing/inline/graphic/graphic-data/wpg/wpg-group.d.ts
package/dist/index.d.mts CHANGED
@@ -968,14 +968,10 @@ interface OutlineAttributes {
968
968
  readonly join?: keyof typeof LineJoin;
969
969
  readonly miterLimit?: number;
970
970
  }
971
- interface OutlineNoFill {
972
- readonly type: "noFill";
971
+ interface OutlineFillProperties {
972
+ readonly type?: "noFill" | "solidFill";
973
+ readonly color?: SolidFillOptions;
973
974
  }
974
- interface OutlineSolidFill {
975
- readonly type: "solidFill";
976
- readonly color: SolidFillOptions;
977
- }
978
- type OutlineFillProperties = OutlineNoFill | OutlineSolidFill;
979
975
  type OutlineOptions = OutlineAttributes & OutlineFillProperties;
980
976
  //#endregion
981
977
  //#region src/file/drawing/inline/graphic/graphic-data/wpg/wpg-group.d.ts
@@ -8918,8 +8918,8 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
8918
8918
  } },
8919
8919
  children: [(() => {
8920
8920
  if (align) return createAlign(align);
8921
- else if (offset !== void 0) return createPositionOffset(offset);
8922
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8921
+ if (offset !== void 0) return createPositionOffset(offset);
8922
+ return createAlign("LEFT");
8923
8923
  })()],
8924
8924
  name: "wp:positionH"
8925
8925
  });
@@ -8979,8 +8979,8 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
8979
8979
  } },
8980
8980
  children: [(() => {
8981
8981
  if (align) return createAlign(align);
8982
- else if (offset !== void 0) return createPositionOffset(offset);
8983
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8982
+ if (offset !== void 0) return createPositionOffset(offset);
8983
+ return createAlign("TOP");
8984
8984
  })()],
8985
8985
  name: "wp:positionV"
8986
8986
  });
@@ -10559,10 +10559,13 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
10559
10559
  };
10560
10560
  /**
10561
10561
  * Creates the fill child element for an outline.
10562
+ *
10563
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
10562
10564
  */
10563
10565
  const createOutlineFill = (options) => {
10564
10566
  if (options.type === "noFill") return createNoFill();
10565
- return createSolidFill(options.color);
10567
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
10568
+ return null;
10566
10569
  };
10567
10570
  /**
10568
10571
  * Creates an outline element for DrawingML shapes.
@@ -10598,7 +10601,8 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
10598
10601
  */
10599
10602
  const createOutline = (options) => {
10600
10603
  const children = [];
10601
- children.push(createOutlineFill(options));
10604
+ const fill = createOutlineFill(options);
10605
+ if (fill) children.push(fill);
10602
10606
  if (options.dash !== void 0) children.push(new BuilderElement({
10603
10607
  attributes: { val: {
10604
10608
  key: "val",
@@ -10989,7 +10993,6 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
10989
10993
  if (noFill) this.root.push(createNoFill());
10990
10994
  else if (solidFill) this.root.push(createSolidFill(solidFill));
10991
10995
  else if (gradientFill) this.root.push(createGradientFill(gradientFill));
10992
- else if (outline) this.root.push(createNoFill());
10993
10996
  if (outline) this.root.push(createOutline(outline));
10994
10997
  if (effects) this.root.push(createEffectList(effects));
10995
10998
  if (shape3d) this.root.push(createShape3D(shape3d));
@@ -14206,8 +14209,7 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
14206
14209
  var IndentLevel = class extends XmlComponent {
14207
14210
  constructor(level) {
14208
14211
  super("w:ilvl");
14209
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
14210
- this.root.push(new Attributes({ val: level }));
14212
+ this.root.push(new Attributes({ val: Math.min(level, 9) }));
14211
14213
  }
14212
14214
  };
14213
14215
  /**
@@ -22376,9 +22378,8 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
22376
22378
  this.runProperties = new RunProperties(style && style.run);
22377
22379
  this.root.push(this.paragraphProperties);
22378
22380
  this.root.push(this.runProperties);
22379
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
22380
22381
  this.root.push(new LevelAttributes({
22381
- ilvl: decimalNumber(level),
22382
+ ilvl: decimalNumber(Math.min(level, 9)),
22382
22383
  tentative: 1
22383
22384
  }));
22384
22385
  }
@@ -24133,7 +24134,10 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
24133
24134
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24134
24135
  let stylesXmlElement;
24135
24136
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24136
- if (stylesXmlElement === void 0) throw new Error("can not find styles element");
24137
+ if (stylesXmlElement === void 0) return {
24138
+ importedStyles: [],
24139
+ initialStyles: new ImportedRootElementAttributes({})
24140
+ };
24137
24141
  return {
24138
24142
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24139
24143
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
package/dist/index.mjs CHANGED
@@ -8919,8 +8919,8 @@ const createHorizontalPosition = ({ relative, align, offset }) => new BuilderEle
8919
8919
  } },
8920
8920
  children: [(() => {
8921
8921
  if (align) return createAlign(align);
8922
- else if (offset !== void 0) return createPositionOffset(offset);
8923
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8922
+ if (offset !== void 0) return createPositionOffset(offset);
8923
+ return createAlign("LEFT");
8924
8924
  })()],
8925
8925
  name: "wp:positionH"
8926
8926
  });
@@ -8980,8 +8980,8 @@ const createVerticalPosition = ({ relative, align, offset }) => new BuilderEleme
8980
8980
  } },
8981
8981
  children: [(() => {
8982
8982
  if (align) return createAlign(align);
8983
- else if (offset !== void 0) return createPositionOffset(offset);
8984
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8983
+ if (offset !== void 0) return createPositionOffset(offset);
8984
+ return createAlign("TOP");
8985
8985
  })()],
8986
8986
  name: "wp:positionV"
8987
8987
  });
@@ -10560,10 +10560,13 @@ const LineJoin = {
10560
10560
  };
10561
10561
  /**
10562
10562
  * Creates the fill child element for an outline.
10563
+ *
10564
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
10563
10565
  */
10564
10566
  const createOutlineFill = (options) => {
10565
10567
  if (options.type === "noFill") return createNoFill();
10566
- return createSolidFill(options.color);
10568
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
10569
+ return null;
10567
10570
  };
10568
10571
  /**
10569
10572
  * Creates an outline element for DrawingML shapes.
@@ -10599,7 +10602,8 @@ const createOutlineFill = (options) => {
10599
10602
  */
10600
10603
  const createOutline = (options) => {
10601
10604
  const children = [];
10602
- children.push(createOutlineFill(options));
10605
+ const fill = createOutlineFill(options);
10606
+ if (fill) children.push(fill);
10603
10607
  if (options.dash !== void 0) children.push(new BuilderElement({
10604
10608
  attributes: { val: {
10605
10609
  key: "val",
@@ -10990,7 +10994,6 @@ var ShapeProperties = class extends XmlComponent {
10990
10994
  if (noFill) this.root.push(createNoFill());
10991
10995
  else if (solidFill) this.root.push(createSolidFill(solidFill));
10992
10996
  else if (gradientFill) this.root.push(createGradientFill(gradientFill));
10993
- else if (outline) this.root.push(createNoFill());
10994
10997
  if (outline) this.root.push(createOutline(outline));
10995
10998
  if (effects) this.root.push(createEffectList(effects));
10996
10999
  if (shape3d) this.root.push(createShape3D(shape3d));
@@ -14207,8 +14210,7 @@ var NumberProperties = class extends XmlComponent {
14207
14210
  var IndentLevel = class extends XmlComponent {
14208
14211
  constructor(level) {
14209
14212
  super("w:ilvl");
14210
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
14211
- this.root.push(new Attributes({ val: level }));
14213
+ this.root.push(new Attributes({ val: Math.min(level, 9) }));
14212
14214
  }
14213
14215
  };
14214
14216
  /**
@@ -22377,9 +22379,8 @@ var LevelBase = class extends XmlComponent {
22377
22379
  this.runProperties = new RunProperties(style && style.run);
22378
22380
  this.root.push(this.paragraphProperties);
22379
22381
  this.root.push(this.runProperties);
22380
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
22381
22382
  this.root.push(new LevelAttributes({
22382
- ilvl: decimalNumber(level),
22383
+ ilvl: decimalNumber(Math.min(level, 9)),
22383
22384
  tentative: 1
22384
22385
  }));
22385
22386
  }
@@ -24134,7 +24135,10 @@ var ExternalStylesFactory = class {
24134
24135
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24135
24136
  let stylesXmlElement;
24136
24137
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24137
- if (stylesXmlElement === void 0) throw new Error("can not find styles element");
24138
+ if (stylesXmlElement === void 0) return {
24139
+ importedStyles: [],
24140
+ initialStyles: new ImportedRootElementAttributes({})
24141
+ };
24138
24142
  return {
24139
24143
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24140
24144
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
package/dist/index.umd.js CHANGED
@@ -8926,8 +8926,8 @@
8926
8926
  } },
8927
8927
  children: [(() => {
8928
8928
  if (align) return createAlign(align);
8929
- else if (offset !== void 0) return createPositionOffset(offset);
8930
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8929
+ if (offset !== void 0) return createPositionOffset(offset);
8930
+ return createAlign("LEFT");
8931
8931
  })()],
8932
8932
  name: "wp:positionH"
8933
8933
  });
@@ -8987,8 +8987,8 @@
8987
8987
  } },
8988
8988
  children: [(() => {
8989
8989
  if (align) return createAlign(align);
8990
- else if (offset !== void 0) return createPositionOffset(offset);
8991
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8990
+ if (offset !== void 0) return createPositionOffset(offset);
8991
+ return createAlign("TOP");
8992
8992
  })()],
8993
8993
  name: "wp:positionV"
8994
8994
  });
@@ -10567,10 +10567,13 @@
10567
10567
  };
10568
10568
  /**
10569
10569
  * Creates the fill child element for an outline.
10570
+ *
10571
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
10570
10572
  */
10571
10573
  const createOutlineFill = (options) => {
10572
10574
  if (options.type === "noFill") return createNoFill();
10573
- return createSolidFill(options.color);
10575
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
10576
+ return null;
10574
10577
  };
10575
10578
  /**
10576
10579
  * Creates an outline element for DrawingML shapes.
@@ -10606,7 +10609,8 @@
10606
10609
  */
10607
10610
  const createOutline = (options) => {
10608
10611
  const children = [];
10609
- children.push(createOutlineFill(options));
10612
+ const fill = createOutlineFill(options);
10613
+ if (fill) children.push(fill);
10610
10614
  if (options.dash !== void 0) children.push(new BuilderElement({
10611
10615
  attributes: { val: {
10612
10616
  key: "val",
@@ -10997,7 +11001,6 @@
10997
11001
  if (noFill) this.root.push(createNoFill());
10998
11002
  else if (solidFill) this.root.push(createSolidFill(solidFill));
10999
11003
  else if (gradientFill) this.root.push(createGradientFill(gradientFill));
11000
- else if (outline) this.root.push(createNoFill());
11001
11004
  if (outline) this.root.push(createOutline(outline));
11002
11005
  if (effects) this.root.push(createEffectList(effects));
11003
11006
  if (shape3d) this.root.push(createShape3D(shape3d));
@@ -14214,8 +14217,7 @@
14214
14217
  var IndentLevel = class extends XmlComponent {
14215
14218
  constructor(level) {
14216
14219
  super("w:ilvl");
14217
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
14218
- this.root.push(new Attributes({ val: level }));
14220
+ this.root.push(new Attributes({ val: Math.min(level, 9) }));
14219
14221
  }
14220
14222
  };
14221
14223
  /**
@@ -22384,9 +22386,8 @@
22384
22386
  this.runProperties = new RunProperties(style && style.run);
22385
22387
  this.root.push(this.paragraphProperties);
22386
22388
  this.root.push(this.runProperties);
22387
- if (level > 9) throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");
22388
22389
  this.root.push(new LevelAttributes({
22389
- ilvl: decimalNumber(level),
22390
+ ilvl: decimalNumber(Math.min(level, 9)),
22390
22391
  tentative: 1
22391
22392
  }));
22392
22393
  }
@@ -24141,7 +24142,10 @@
24141
24142
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24142
24143
  let stylesXmlElement;
24143
24144
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24144
- if (stylesXmlElement === void 0) throw new Error("can not find styles element");
24145
+ if (stylesXmlElement === void 0) return {
24146
+ importedStyles: [],
24147
+ initialStyles: new ImportedRootElementAttributes({})
24148
+ };
24145
24149
  return {
24146
24150
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24147
24151
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-plus",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
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",