docx-plus 0.0.12 → 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
  }
@@ -23015,8 +23016,8 @@ var Numbering = class extends XmlComponent {
23015
23016
  /**
23016
23017
  * Creates a compatibility setting for a WordprocessingML document.
23017
23018
  *
23018
- * Currently hard-coded to set Microsoft Word compatibility mode version.
23019
- * This controls which Word version's formatting and layout behavior the document emulates.
23019
+ * This controls which Word version's formatting and layout behavior the document emulates,
23020
+ * as well as other compatibility behaviors.
23020
23021
  *
23021
23022
  * Common version values:
23022
23023
  * - 11: Word 2003
@@ -23038,25 +23039,25 @@ var Numbering = class extends XmlComponent {
23038
23039
  * @example
23039
23040
  * ```typescript
23040
23041
  * // Set compatibility mode to Word 2013+
23041
- * createCompatibilitySetting(15);
23042
+ * createCompatibilitySetting("compatibilityMode", 15);
23042
23043
  *
23043
- * // Set compatibility mode to Word 2010
23044
- * createCompatibilitySetting(14);
23044
+ * // Enable OpenType features
23045
+ * createCompatibilitySetting("enableOpenTypeFeatures", 1);
23045
23046
  * ```
23046
23047
  */
23047
- const createCompatibilitySetting = (version) => new BuilderElement({
23048
+ const createCompatibilitySetting = (name, val, uri = "http://schemas.microsoft.com/office/word") => new BuilderElement({
23048
23049
  attributes: {
23049
23050
  name: {
23050
23051
  key: "w:name",
23051
- value: "compatibilityMode"
23052
+ value: name
23052
23053
  },
23053
23054
  uri: {
23054
23055
  key: "w:uri",
23055
- value: "http://schemas.microsoft.com/office/word"
23056
+ value: uri
23056
23057
  },
23057
- version: {
23058
+ val: {
23058
23059
  key: "w:val",
23059
- value: version
23060
+ value: val
23060
23061
  }
23061
23062
  },
23062
23063
  name: "w:compatSetting"
@@ -23115,7 +23116,7 @@ const createCompatibilitySetting = (version) => new BuilderElement({
23115
23116
  var Compatibility = class extends XmlComponent {
23116
23117
  constructor(options) {
23117
23118
  super("w:compat");
23118
- if (options.version) this.root.push(createCompatibilitySetting(options.version));
23119
+ if (options.version) this.root.push(createCompatibilitySetting("compatibilityMode", options.version));
23119
23120
  if (options.useSingleBorderforContiguousCells) this.root.push(new OnOffElement("w:useSingleBorderforContiguousCells", options.useSingleBorderforContiguousCells));
23120
23121
  if (options.wordPerfectJustification) this.root.push(new OnOffElement("w:wpJustification", options.wordPerfectJustification));
23121
23122
  if (options.noTabStopForHangingIndent) this.root.push(new OnOffElement("w:noTabHangInd", options.noTabStopForHangingIndent));
@@ -23181,6 +23182,9 @@ var Compatibility = class extends XmlComponent {
23181
23182
  if (options.ignoreVerticalAlignmentInTextboxes) this.root.push(new OnOffElement("w:doNotVertAlignInTxbx", options.ignoreVerticalAlignmentInTextboxes));
23182
23183
  if (options.useAnsiKerningPairs) this.root.push(new OnOffElement("w:useAnsiKerningPairs", options.useAnsiKerningPairs));
23183
23184
  if (options.cachedColumnBalance) this.root.push(new OnOffElement("w:cachedColBalance", options.cachedColumnBalance));
23185
+ if (options.overrideTableStyleFontSizeAndJustification) this.root.push(createCompatibilitySetting("overrideTableStyleFontSizeAndJustification", 1));
23186
+ if (options.enableOpenTypeFeatures) this.root.push(createCompatibilitySetting("enableOpenTypeFeatures", 1));
23187
+ if (options.doNotFlipMirrorIndents) this.root.push(createCompatibilitySetting("doNotFlipMirrorIndents", 1));
23184
23188
  }
23185
23189
  };
23186
23190
  //#endregion
@@ -23276,7 +23280,7 @@ var SettingsAttributes = class extends XmlAttributeComponent {
23276
23280
  */
23277
23281
  var Settings = class extends XmlComponent {
23278
23282
  constructor(options) {
23279
- var _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _ref, _options$compatibilit, _options$compatibilit2;
23283
+ var _options$defaultTabSt, _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _options$characterSpa, _ref, _options$compatibilit, _options$compatibilit2, _options$compatibilit3, _options$compatibilit4, _options$compatibilit5, _options$compatibilit6, _options$compatibilit7, _options$compatibilit8, _options$compatibilit9, _options$compatibilit10, _options$compatibilit11, _options$compatibilit12, _options$compatibilit13, _options$compatibilit14, _options$compatibilit15, _options$compatibilit16, _options$compatibilit17, _options$compatibilit18, _options$compatibilit19, _options$compatibilit20, _options$compatibilit21, _options$compatibilit22;
23280
23284
  super("w:settings");
23281
23285
  this.root.push(new SettingsAttributes({
23282
23286
  Ignorable: "w14 w15 wp14",
@@ -23297,18 +23301,28 @@ var Settings = class extends XmlComponent {
23297
23301
  wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
23298
23302
  wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
23299
23303
  }));
23300
- this.root.push(new OnOffElement("w:displayBackgroundShape", true));
23301
23304
  if (options.trackRevisions !== void 0) this.root.push(new OnOffElement("w:trackRevisions", options.trackRevisions));
23302
23305
  if (options.evenAndOddHeaders !== void 0) this.root.push(new OnOffElement("w:evenAndOddHeaders", options.evenAndOddHeaders));
23303
23306
  if (options.updateFields !== void 0) this.root.push(new OnOffElement("w:updateFields", options.updateFields));
23304
- if (options.defaultTabStop !== void 0) this.root.push(new NumberValueElement("w:defaultTabStop", options.defaultTabStop));
23307
+ this.root.push(new NumberValueElement("w:defaultTabStop", (_options$defaultTabSt = options.defaultTabStop) !== null && _options$defaultTabSt !== void 0 ? _options$defaultTabSt : 420));
23305
23308
  if (((_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation) !== void 0) this.root.push(new OnOffElement("w:autoHyphenation", options.hyphenation.autoHyphenation));
23306
23309
  if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
23307
23310
  if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
23308
23311
  if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
23312
+ this.root.push(new StringValueElement("w:characterSpacingControl", (_options$characterSpa = options.characterSpacingControl) !== null && _options$characterSpa !== void 0 ? _options$characterSpa : "compressPunctuation"));
23309
23313
  this.root.push(new Compatibility({
23310
23314
  ...options.compatibility,
23311
- version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
23315
+ version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15,
23316
+ spaceForUnderline: (_options$compatibilit3 = (_options$compatibilit4 = options.compatibility) === null || _options$compatibilit4 === void 0 ? void 0 : _options$compatibilit4.spaceForUnderline) !== null && _options$compatibilit3 !== void 0 ? _options$compatibilit3 : true,
23317
+ balanceSingleByteDoubleByteWidth: (_options$compatibilit5 = (_options$compatibilit6 = options.compatibility) === null || _options$compatibilit6 === void 0 ? void 0 : _options$compatibilit6.balanceSingleByteDoubleByteWidth) !== null && _options$compatibilit5 !== void 0 ? _options$compatibilit5 : true,
23318
+ doNotLeaveBackslashAlone: (_options$compatibilit7 = (_options$compatibilit8 = options.compatibility) === null || _options$compatibilit8 === void 0 ? void 0 : _options$compatibilit8.doNotLeaveBackslashAlone) !== null && _options$compatibilit7 !== void 0 ? _options$compatibilit7 : true,
23319
+ underlineTrailingSpaces: (_options$compatibilit9 = (_options$compatibilit10 = options.compatibility) === null || _options$compatibilit10 === void 0 ? void 0 : _options$compatibilit10.underlineTrailingSpaces) !== null && _options$compatibilit9 !== void 0 ? _options$compatibilit9 : true,
23320
+ doNotExpandShiftReturn: (_options$compatibilit11 = (_options$compatibilit12 = options.compatibility) === null || _options$compatibilit12 === void 0 ? void 0 : _options$compatibilit12.doNotExpandShiftReturn) !== null && _options$compatibilit11 !== void 0 ? _options$compatibilit11 : true,
23321
+ adjustLineHeightInTable: (_options$compatibilit13 = (_options$compatibilit14 = options.compatibility) === null || _options$compatibilit14 === void 0 ? void 0 : _options$compatibilit14.adjustLineHeightInTable) !== null && _options$compatibilit13 !== void 0 ? _options$compatibilit13 : true,
23322
+ useFELayout: (_options$compatibilit15 = (_options$compatibilit16 = options.compatibility) === null || _options$compatibilit16 === void 0 ? void 0 : _options$compatibilit16.useFELayout) !== null && _options$compatibilit15 !== void 0 ? _options$compatibilit15 : true,
23323
+ overrideTableStyleFontSizeAndJustification: (_options$compatibilit17 = (_options$compatibilit18 = options.compatibility) === null || _options$compatibilit18 === void 0 ? void 0 : _options$compatibilit18.overrideTableStyleFontSizeAndJustification) !== null && _options$compatibilit17 !== void 0 ? _options$compatibilit17 : true,
23324
+ enableOpenTypeFeatures: (_options$compatibilit19 = (_options$compatibilit20 = options.compatibility) === null || _options$compatibilit20 === void 0 ? void 0 : _options$compatibilit20.enableOpenTypeFeatures) !== null && _options$compatibilit19 !== void 0 ? _options$compatibilit19 : true,
23325
+ doNotFlipMirrorIndents: (_options$compatibilit21 = (_options$compatibilit22 = options.compatibility) === null || _options$compatibilit22 === void 0 ? void 0 : _options$compatibilit22.doNotFlipMirrorIndents) !== null && _options$compatibilit21 !== void 0 ? _options$compatibilit21 : true
23312
23326
  }));
23313
23327
  }
23314
23328
  };
@@ -24123,7 +24137,10 @@ var ExternalStylesFactory = class {
24123
24137
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24124
24138
  let stylesXmlElement;
24125
24139
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24126
- 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
+ };
24127
24144
  return {
24128
24145
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24129
24146
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
@@ -24145,11 +24162,11 @@ var ExternalStylesFactory = class {
24145
24162
  * Factory for creating default document styles.
24146
24163
  *
24147
24164
  * This factory creates a complete set of default styles for common document elements
24148
- * such as headings, hyperlinks, and footnotes with sensible default formatting.
24165
+ * such as headings, hyperlinks, and footnotes.
24149
24166
  *
24150
24167
  * @example
24151
24168
  * ```typescript
24152
- * // Create default styles with custom heading colors
24169
+ * // Create default styles with custom heading formatting
24153
24170
  * const factory = new DefaultStylesFactory();
24154
24171
  * const styles = factory.newInstance({
24155
24172
  * heading1: {
@@ -24178,42 +24195,12 @@ var DefaultStylesFactory = class {
24178
24195
  run: { size: 56 },
24179
24196
  ...options.title
24180
24197
  }),
24181
- new Heading1Style({
24182
- run: {
24183
- color: "2E74B5",
24184
- size: 32
24185
- },
24186
- ...options.heading1
24187
- }),
24188
- new Heading2Style({
24189
- run: {
24190
- color: "2E74B5",
24191
- size: 26
24192
- },
24193
- ...options.heading2
24194
- }),
24195
- new Heading3Style({
24196
- run: {
24197
- color: "1F4D78",
24198
- size: 24
24199
- },
24200
- ...options.heading3
24201
- }),
24202
- new Heading4Style({
24203
- run: {
24204
- color: "2E74B5",
24205
- italics: true
24206
- },
24207
- ...options.heading4
24208
- }),
24209
- new Heading5Style({
24210
- run: { color: "2E74B5" },
24211
- ...options.heading5
24212
- }),
24213
- new Heading6Style({
24214
- run: { color: "1F4D78" },
24215
- ...options.heading6
24216
- }),
24198
+ new Heading1Style(options.heading1 || {}),
24199
+ new Heading2Style(options.heading2 || {}),
24200
+ new Heading3Style(options.heading3 || {}),
24201
+ new Heading4Style(options.heading4 || {}),
24202
+ new Heading5Style(options.heading5 || {}),
24203
+ new Heading6Style(options.heading6 || {}),
24217
24204
  new StrongStyle({
24218
24205
  run: { bold: true },
24219
24206
  ...options.strong
@@ -24355,6 +24342,7 @@ var File = class {
24355
24342
  compatibilityModeVersion: options.compatabilityModeVersion,
24356
24343
  defaultTabStop: options.defaultTabStop,
24357
24344
  evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,
24345
+ characterSpacingControl: options.characterSpacingControl,
24358
24346
  hyphenation: {
24359
24347
  autoHyphenation: (_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation,
24360
24348
  consecutiveHyphenLimit: (_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.consecutiveHyphenLimit,
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
@@ -2496,6 +2492,9 @@ interface ICompatibilityOptions {
2496
2492
  readonly ignoreVerticalAlignmentInTextboxes?: boolean;
2497
2493
  readonly useAnsiKerningPairs?: boolean;
2498
2494
  readonly cachedColumnBalance?: boolean;
2495
+ readonly overrideTableStyleFontSizeAndJustification?: boolean;
2496
+ readonly enableOpenTypeFeatures?: boolean;
2497
+ readonly doNotFlipMirrorIndents?: boolean;
2499
2498
  }
2500
2499
  //#endregion
2501
2500
  //#region src/file/settings/settings.d.ts
@@ -2507,6 +2506,7 @@ interface ISettingsOptions {
2507
2506
  readonly compatibility?: ICompatibilityOptions;
2508
2507
  readonly defaultTabStop?: number;
2509
2508
  readonly hyphenation?: IHyphenationOptions;
2509
+ readonly characterSpacingControl?: "compressPunctuation" | "doNotCompress";
2510
2510
  }
2511
2511
  interface IHyphenationOptions {
2512
2512
  readonly autoHyphenation?: boolean;
@@ -3063,6 +3063,7 @@ interface IPropertiesOptions {
3063
3063
  readonly defaultTabStop?: number;
3064
3064
  readonly fonts?: readonly FontOptions[];
3065
3065
  readonly hyphenation?: IHyphenationOptions;
3066
+ readonly characterSpacingControl?: "compressPunctuation" | "doNotCompress";
3066
3067
  }
3067
3068
  declare class CoreProperties extends XmlComponent {
3068
3069
  constructor(options: Omit<IPropertiesOptions, "sections">);
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
@@ -2498,6 +2494,9 @@ interface ICompatibilityOptions {
2498
2494
  readonly ignoreVerticalAlignmentInTextboxes?: boolean;
2499
2495
  readonly useAnsiKerningPairs?: boolean;
2500
2496
  readonly cachedColumnBalance?: boolean;
2497
+ readonly overrideTableStyleFontSizeAndJustification?: boolean;
2498
+ readonly enableOpenTypeFeatures?: boolean;
2499
+ readonly doNotFlipMirrorIndents?: boolean;
2501
2500
  }
2502
2501
  //#endregion
2503
2502
  //#region src/file/settings/settings.d.ts
@@ -2509,6 +2508,7 @@ interface ISettingsOptions {
2509
2508
  readonly compatibility?: ICompatibilityOptions;
2510
2509
  readonly defaultTabStop?: number;
2511
2510
  readonly hyphenation?: IHyphenationOptions;
2511
+ readonly characterSpacingControl?: "compressPunctuation" | "doNotCompress";
2512
2512
  }
2513
2513
  interface IHyphenationOptions {
2514
2514
  readonly autoHyphenation?: boolean;
@@ -3065,6 +3065,7 @@ interface IPropertiesOptions {
3065
3065
  readonly defaultTabStop?: number;
3066
3066
  readonly fonts?: readonly FontOptions[];
3067
3067
  readonly hyphenation?: IHyphenationOptions;
3068
+ readonly characterSpacingControl?: "compressPunctuation" | "doNotCompress";
3068
3069
  }
3069
3070
  declare class CoreProperties extends XmlComponent {
3070
3071
  constructor(options: Omit<IPropertiesOptions, "sections">);
@@ -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
  }
@@ -23012,8 +23013,8 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
23012
23013
  /**
23013
23014
  * Creates a compatibility setting for a WordprocessingML document.
23014
23015
  *
23015
- * Currently hard-coded to set Microsoft Word compatibility mode version.
23016
- * This controls which Word version's formatting and layout behavior the document emulates.
23016
+ * This controls which Word version's formatting and layout behavior the document emulates,
23017
+ * as well as other compatibility behaviors.
23017
23018
  *
23018
23019
  * Common version values:
23019
23020
  * - 11: Word 2003
@@ -23035,25 +23036,25 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
23035
23036
  * @example
23036
23037
  * ```typescript
23037
23038
  * // Set compatibility mode to Word 2013+
23038
- * createCompatibilitySetting(15);
23039
+ * createCompatibilitySetting("compatibilityMode", 15);
23039
23040
  *
23040
- * // Set compatibility mode to Word 2010
23041
- * createCompatibilitySetting(14);
23041
+ * // Enable OpenType features
23042
+ * createCompatibilitySetting("enableOpenTypeFeatures", 1);
23042
23043
  * ```
23043
23044
  */
23044
- const createCompatibilitySetting = (version) => new BuilderElement({
23045
+ const createCompatibilitySetting = (name, val, uri = "http://schemas.microsoft.com/office/word") => new BuilderElement({
23045
23046
  attributes: {
23046
23047
  name: {
23047
23048
  key: "w:name",
23048
- value: "compatibilityMode"
23049
+ value: name
23049
23050
  },
23050
23051
  uri: {
23051
23052
  key: "w:uri",
23052
- value: "http://schemas.microsoft.com/office/word"
23053
+ value: uri
23053
23054
  },
23054
- version: {
23055
+ val: {
23055
23056
  key: "w:val",
23056
- value: version
23057
+ value: val
23057
23058
  }
23058
23059
  },
23059
23060
  name: "w:compatSetting"
@@ -23112,7 +23113,7 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
23112
23113
  var Compatibility = class extends XmlComponent {
23113
23114
  constructor(options) {
23114
23115
  super("w:compat");
23115
- if (options.version) this.root.push(createCompatibilitySetting(options.version));
23116
+ if (options.version) this.root.push(createCompatibilitySetting("compatibilityMode", options.version));
23116
23117
  if (options.useSingleBorderforContiguousCells) this.root.push(new OnOffElement("w:useSingleBorderforContiguousCells", options.useSingleBorderforContiguousCells));
23117
23118
  if (options.wordPerfectJustification) this.root.push(new OnOffElement("w:wpJustification", options.wordPerfectJustification));
23118
23119
  if (options.noTabStopForHangingIndent) this.root.push(new OnOffElement("w:noTabHangInd", options.noTabStopForHangingIndent));
@@ -23178,6 +23179,9 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
23178
23179
  if (options.ignoreVerticalAlignmentInTextboxes) this.root.push(new OnOffElement("w:doNotVertAlignInTxbx", options.ignoreVerticalAlignmentInTextboxes));
23179
23180
  if (options.useAnsiKerningPairs) this.root.push(new OnOffElement("w:useAnsiKerningPairs", options.useAnsiKerningPairs));
23180
23181
  if (options.cachedColumnBalance) this.root.push(new OnOffElement("w:cachedColBalance", options.cachedColumnBalance));
23182
+ if (options.overrideTableStyleFontSizeAndJustification) this.root.push(createCompatibilitySetting("overrideTableStyleFontSizeAndJustification", 1));
23183
+ if (options.enableOpenTypeFeatures) this.root.push(createCompatibilitySetting("enableOpenTypeFeatures", 1));
23184
+ if (options.doNotFlipMirrorIndents) this.root.push(createCompatibilitySetting("doNotFlipMirrorIndents", 1));
23181
23185
  }
23182
23186
  };
23183
23187
  //#endregion
@@ -23273,7 +23277,7 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
23273
23277
  */
23274
23278
  var Settings = class extends XmlComponent {
23275
23279
  constructor(options) {
23276
- var _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _ref, _options$compatibilit, _options$compatibilit2;
23280
+ var _options$defaultTabSt, _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _options$characterSpa, _ref, _options$compatibilit, _options$compatibilit2, _options$compatibilit3, _options$compatibilit4, _options$compatibilit5, _options$compatibilit6, _options$compatibilit7, _options$compatibilit8, _options$compatibilit9, _options$compatibilit10, _options$compatibilit11, _options$compatibilit12, _options$compatibilit13, _options$compatibilit14, _options$compatibilit15, _options$compatibilit16, _options$compatibilit17, _options$compatibilit18, _options$compatibilit19, _options$compatibilit20, _options$compatibilit21, _options$compatibilit22;
23277
23281
  super("w:settings");
23278
23282
  this.root.push(new SettingsAttributes({
23279
23283
  Ignorable: "w14 w15 wp14",
@@ -23294,18 +23298,28 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
23294
23298
  wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
23295
23299
  wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
23296
23300
  }));
23297
- this.root.push(new OnOffElement("w:displayBackgroundShape", true));
23298
23301
  if (options.trackRevisions !== void 0) this.root.push(new OnOffElement("w:trackRevisions", options.trackRevisions));
23299
23302
  if (options.evenAndOddHeaders !== void 0) this.root.push(new OnOffElement("w:evenAndOddHeaders", options.evenAndOddHeaders));
23300
23303
  if (options.updateFields !== void 0) this.root.push(new OnOffElement("w:updateFields", options.updateFields));
23301
- if (options.defaultTabStop !== void 0) this.root.push(new NumberValueElement("w:defaultTabStop", options.defaultTabStop));
23304
+ this.root.push(new NumberValueElement("w:defaultTabStop", (_options$defaultTabSt = options.defaultTabStop) !== null && _options$defaultTabSt !== void 0 ? _options$defaultTabSt : 420));
23302
23305
  if (((_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation) !== void 0) this.root.push(new OnOffElement("w:autoHyphenation", options.hyphenation.autoHyphenation));
23303
23306
  if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
23304
23307
  if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
23305
23308
  if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
23309
+ this.root.push(new StringValueElement("w:characterSpacingControl", (_options$characterSpa = options.characterSpacingControl) !== null && _options$characterSpa !== void 0 ? _options$characterSpa : "compressPunctuation"));
23306
23310
  this.root.push(new Compatibility({
23307
23311
  ...options.compatibility,
23308
- version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
23312
+ version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15,
23313
+ spaceForUnderline: (_options$compatibilit3 = (_options$compatibilit4 = options.compatibility) === null || _options$compatibilit4 === void 0 ? void 0 : _options$compatibilit4.spaceForUnderline) !== null && _options$compatibilit3 !== void 0 ? _options$compatibilit3 : true,
23314
+ balanceSingleByteDoubleByteWidth: (_options$compatibilit5 = (_options$compatibilit6 = options.compatibility) === null || _options$compatibilit6 === void 0 ? void 0 : _options$compatibilit6.balanceSingleByteDoubleByteWidth) !== null && _options$compatibilit5 !== void 0 ? _options$compatibilit5 : true,
23315
+ doNotLeaveBackslashAlone: (_options$compatibilit7 = (_options$compatibilit8 = options.compatibility) === null || _options$compatibilit8 === void 0 ? void 0 : _options$compatibilit8.doNotLeaveBackslashAlone) !== null && _options$compatibilit7 !== void 0 ? _options$compatibilit7 : true,
23316
+ underlineTrailingSpaces: (_options$compatibilit9 = (_options$compatibilit10 = options.compatibility) === null || _options$compatibilit10 === void 0 ? void 0 : _options$compatibilit10.underlineTrailingSpaces) !== null && _options$compatibilit9 !== void 0 ? _options$compatibilit9 : true,
23317
+ doNotExpandShiftReturn: (_options$compatibilit11 = (_options$compatibilit12 = options.compatibility) === null || _options$compatibilit12 === void 0 ? void 0 : _options$compatibilit12.doNotExpandShiftReturn) !== null && _options$compatibilit11 !== void 0 ? _options$compatibilit11 : true,
23318
+ adjustLineHeightInTable: (_options$compatibilit13 = (_options$compatibilit14 = options.compatibility) === null || _options$compatibilit14 === void 0 ? void 0 : _options$compatibilit14.adjustLineHeightInTable) !== null && _options$compatibilit13 !== void 0 ? _options$compatibilit13 : true,
23319
+ useFELayout: (_options$compatibilit15 = (_options$compatibilit16 = options.compatibility) === null || _options$compatibilit16 === void 0 ? void 0 : _options$compatibilit16.useFELayout) !== null && _options$compatibilit15 !== void 0 ? _options$compatibilit15 : true,
23320
+ overrideTableStyleFontSizeAndJustification: (_options$compatibilit17 = (_options$compatibilit18 = options.compatibility) === null || _options$compatibilit18 === void 0 ? void 0 : _options$compatibilit18.overrideTableStyleFontSizeAndJustification) !== null && _options$compatibilit17 !== void 0 ? _options$compatibilit17 : true,
23321
+ enableOpenTypeFeatures: (_options$compatibilit19 = (_options$compatibilit20 = options.compatibility) === null || _options$compatibilit20 === void 0 ? void 0 : _options$compatibilit20.enableOpenTypeFeatures) !== null && _options$compatibilit19 !== void 0 ? _options$compatibilit19 : true,
23322
+ doNotFlipMirrorIndents: (_options$compatibilit21 = (_options$compatibilit22 = options.compatibility) === null || _options$compatibilit22 === void 0 ? void 0 : _options$compatibilit22.doNotFlipMirrorIndents) !== null && _options$compatibilit21 !== void 0 ? _options$compatibilit21 : true
23309
23323
  }));
23310
23324
  }
23311
23325
  };
@@ -24120,7 +24134,10 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
24120
24134
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24121
24135
  let stylesXmlElement;
24122
24136
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24123
- 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
+ };
24124
24141
  return {
24125
24142
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24126
24143
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
@@ -24142,11 +24159,11 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
24142
24159
  * Factory for creating default document styles.
24143
24160
  *
24144
24161
  * This factory creates a complete set of default styles for common document elements
24145
- * such as headings, hyperlinks, and footnotes with sensible default formatting.
24162
+ * such as headings, hyperlinks, and footnotes.
24146
24163
  *
24147
24164
  * @example
24148
24165
  * ```typescript
24149
- * // Create default styles with custom heading colors
24166
+ * // Create default styles with custom heading formatting
24150
24167
  * const factory = new DefaultStylesFactory();
24151
24168
  * const styles = factory.newInstance({
24152
24169
  * heading1: {
@@ -24175,42 +24192,12 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
24175
24192
  run: { size: 56 },
24176
24193
  ...options.title
24177
24194
  }),
24178
- new Heading1Style({
24179
- run: {
24180
- color: "2E74B5",
24181
- size: 32
24182
- },
24183
- ...options.heading1
24184
- }),
24185
- new Heading2Style({
24186
- run: {
24187
- color: "2E74B5",
24188
- size: 26
24189
- },
24190
- ...options.heading2
24191
- }),
24192
- new Heading3Style({
24193
- run: {
24194
- color: "1F4D78",
24195
- size: 24
24196
- },
24197
- ...options.heading3
24198
- }),
24199
- new Heading4Style({
24200
- run: {
24201
- color: "2E74B5",
24202
- italics: true
24203
- },
24204
- ...options.heading4
24205
- }),
24206
- new Heading5Style({
24207
- run: { color: "2E74B5" },
24208
- ...options.heading5
24209
- }),
24210
- new Heading6Style({
24211
- run: { color: "1F4D78" },
24212
- ...options.heading6
24213
- }),
24195
+ new Heading1Style(options.heading1 || {}),
24196
+ new Heading2Style(options.heading2 || {}),
24197
+ new Heading3Style(options.heading3 || {}),
24198
+ new Heading4Style(options.heading4 || {}),
24199
+ new Heading5Style(options.heading5 || {}),
24200
+ new Heading6Style(options.heading6 || {}),
24214
24201
  new StrongStyle({
24215
24202
  run: { bold: true },
24216
24203
  ...options.strong
@@ -24352,6 +24339,7 @@ var docx = (function(exports, hash_js, nanoid_non_secure, undio, fflate) {
24352
24339
  compatibilityModeVersion: options.compatabilityModeVersion,
24353
24340
  defaultTabStop: options.defaultTabStop,
24354
24341
  evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,
24342
+ characterSpacingControl: options.characterSpacingControl,
24355
24343
  hyphenation: {
24356
24344
  autoHyphenation: (_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation,
24357
24345
  consecutiveHyphenLimit: (_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.consecutiveHyphenLimit,
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
  }
@@ -23013,8 +23014,8 @@ var Numbering = class extends XmlComponent {
23013
23014
  /**
23014
23015
  * Creates a compatibility setting for a WordprocessingML document.
23015
23016
  *
23016
- * Currently hard-coded to set Microsoft Word compatibility mode version.
23017
- * This controls which Word version's formatting and layout behavior the document emulates.
23017
+ * This controls which Word version's formatting and layout behavior the document emulates,
23018
+ * as well as other compatibility behaviors.
23018
23019
  *
23019
23020
  * Common version values:
23020
23021
  * - 11: Word 2003
@@ -23036,25 +23037,25 @@ var Numbering = class extends XmlComponent {
23036
23037
  * @example
23037
23038
  * ```typescript
23038
23039
  * // Set compatibility mode to Word 2013+
23039
- * createCompatibilitySetting(15);
23040
+ * createCompatibilitySetting("compatibilityMode", 15);
23040
23041
  *
23041
- * // Set compatibility mode to Word 2010
23042
- * createCompatibilitySetting(14);
23042
+ * // Enable OpenType features
23043
+ * createCompatibilitySetting("enableOpenTypeFeatures", 1);
23043
23044
  * ```
23044
23045
  */
23045
- const createCompatibilitySetting = (version) => new BuilderElement({
23046
+ const createCompatibilitySetting = (name, val, uri = "http://schemas.microsoft.com/office/word") => new BuilderElement({
23046
23047
  attributes: {
23047
23048
  name: {
23048
23049
  key: "w:name",
23049
- value: "compatibilityMode"
23050
+ value: name
23050
23051
  },
23051
23052
  uri: {
23052
23053
  key: "w:uri",
23053
- value: "http://schemas.microsoft.com/office/word"
23054
+ value: uri
23054
23055
  },
23055
- version: {
23056
+ val: {
23056
23057
  key: "w:val",
23057
- value: version
23058
+ value: val
23058
23059
  }
23059
23060
  },
23060
23061
  name: "w:compatSetting"
@@ -23113,7 +23114,7 @@ const createCompatibilitySetting = (version) => new BuilderElement({
23113
23114
  var Compatibility = class extends XmlComponent {
23114
23115
  constructor(options) {
23115
23116
  super("w:compat");
23116
- if (options.version) this.root.push(createCompatibilitySetting(options.version));
23117
+ if (options.version) this.root.push(createCompatibilitySetting("compatibilityMode", options.version));
23117
23118
  if (options.useSingleBorderforContiguousCells) this.root.push(new OnOffElement("w:useSingleBorderforContiguousCells", options.useSingleBorderforContiguousCells));
23118
23119
  if (options.wordPerfectJustification) this.root.push(new OnOffElement("w:wpJustification", options.wordPerfectJustification));
23119
23120
  if (options.noTabStopForHangingIndent) this.root.push(new OnOffElement("w:noTabHangInd", options.noTabStopForHangingIndent));
@@ -23179,6 +23180,9 @@ var Compatibility = class extends XmlComponent {
23179
23180
  if (options.ignoreVerticalAlignmentInTextboxes) this.root.push(new OnOffElement("w:doNotVertAlignInTxbx", options.ignoreVerticalAlignmentInTextboxes));
23180
23181
  if (options.useAnsiKerningPairs) this.root.push(new OnOffElement("w:useAnsiKerningPairs", options.useAnsiKerningPairs));
23181
23182
  if (options.cachedColumnBalance) this.root.push(new OnOffElement("w:cachedColBalance", options.cachedColumnBalance));
23183
+ if (options.overrideTableStyleFontSizeAndJustification) this.root.push(createCompatibilitySetting("overrideTableStyleFontSizeAndJustification", 1));
23184
+ if (options.enableOpenTypeFeatures) this.root.push(createCompatibilitySetting("enableOpenTypeFeatures", 1));
23185
+ if (options.doNotFlipMirrorIndents) this.root.push(createCompatibilitySetting("doNotFlipMirrorIndents", 1));
23182
23186
  }
23183
23187
  };
23184
23188
  //#endregion
@@ -23274,7 +23278,7 @@ var SettingsAttributes = class extends XmlAttributeComponent {
23274
23278
  */
23275
23279
  var Settings = class extends XmlComponent {
23276
23280
  constructor(options) {
23277
- var _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _ref, _options$compatibilit, _options$compatibilit2;
23281
+ var _options$defaultTabSt, _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _options$characterSpa, _ref, _options$compatibilit, _options$compatibilit2, _options$compatibilit3, _options$compatibilit4, _options$compatibilit5, _options$compatibilit6, _options$compatibilit7, _options$compatibilit8, _options$compatibilit9, _options$compatibilit10, _options$compatibilit11, _options$compatibilit12, _options$compatibilit13, _options$compatibilit14, _options$compatibilit15, _options$compatibilit16, _options$compatibilit17, _options$compatibilit18, _options$compatibilit19, _options$compatibilit20, _options$compatibilit21, _options$compatibilit22;
23278
23282
  super("w:settings");
23279
23283
  this.root.push(new SettingsAttributes({
23280
23284
  Ignorable: "w14 w15 wp14",
@@ -23295,18 +23299,28 @@ var Settings = class extends XmlComponent {
23295
23299
  wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
23296
23300
  wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
23297
23301
  }));
23298
- this.root.push(new OnOffElement("w:displayBackgroundShape", true));
23299
23302
  if (options.trackRevisions !== void 0) this.root.push(new OnOffElement("w:trackRevisions", options.trackRevisions));
23300
23303
  if (options.evenAndOddHeaders !== void 0) this.root.push(new OnOffElement("w:evenAndOddHeaders", options.evenAndOddHeaders));
23301
23304
  if (options.updateFields !== void 0) this.root.push(new OnOffElement("w:updateFields", options.updateFields));
23302
- if (options.defaultTabStop !== void 0) this.root.push(new NumberValueElement("w:defaultTabStop", options.defaultTabStop));
23305
+ this.root.push(new NumberValueElement("w:defaultTabStop", (_options$defaultTabSt = options.defaultTabStop) !== null && _options$defaultTabSt !== void 0 ? _options$defaultTabSt : 420));
23303
23306
  if (((_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation) !== void 0) this.root.push(new OnOffElement("w:autoHyphenation", options.hyphenation.autoHyphenation));
23304
23307
  if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
23305
23308
  if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
23306
23309
  if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
23310
+ this.root.push(new StringValueElement("w:characterSpacingControl", (_options$characterSpa = options.characterSpacingControl) !== null && _options$characterSpa !== void 0 ? _options$characterSpa : "compressPunctuation"));
23307
23311
  this.root.push(new Compatibility({
23308
23312
  ...options.compatibility,
23309
- version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
23313
+ version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15,
23314
+ spaceForUnderline: (_options$compatibilit3 = (_options$compatibilit4 = options.compatibility) === null || _options$compatibilit4 === void 0 ? void 0 : _options$compatibilit4.spaceForUnderline) !== null && _options$compatibilit3 !== void 0 ? _options$compatibilit3 : true,
23315
+ balanceSingleByteDoubleByteWidth: (_options$compatibilit5 = (_options$compatibilit6 = options.compatibility) === null || _options$compatibilit6 === void 0 ? void 0 : _options$compatibilit6.balanceSingleByteDoubleByteWidth) !== null && _options$compatibilit5 !== void 0 ? _options$compatibilit5 : true,
23316
+ doNotLeaveBackslashAlone: (_options$compatibilit7 = (_options$compatibilit8 = options.compatibility) === null || _options$compatibilit8 === void 0 ? void 0 : _options$compatibilit8.doNotLeaveBackslashAlone) !== null && _options$compatibilit7 !== void 0 ? _options$compatibilit7 : true,
23317
+ underlineTrailingSpaces: (_options$compatibilit9 = (_options$compatibilit10 = options.compatibility) === null || _options$compatibilit10 === void 0 ? void 0 : _options$compatibilit10.underlineTrailingSpaces) !== null && _options$compatibilit9 !== void 0 ? _options$compatibilit9 : true,
23318
+ doNotExpandShiftReturn: (_options$compatibilit11 = (_options$compatibilit12 = options.compatibility) === null || _options$compatibilit12 === void 0 ? void 0 : _options$compatibilit12.doNotExpandShiftReturn) !== null && _options$compatibilit11 !== void 0 ? _options$compatibilit11 : true,
23319
+ adjustLineHeightInTable: (_options$compatibilit13 = (_options$compatibilit14 = options.compatibility) === null || _options$compatibilit14 === void 0 ? void 0 : _options$compatibilit14.adjustLineHeightInTable) !== null && _options$compatibilit13 !== void 0 ? _options$compatibilit13 : true,
23320
+ useFELayout: (_options$compatibilit15 = (_options$compatibilit16 = options.compatibility) === null || _options$compatibilit16 === void 0 ? void 0 : _options$compatibilit16.useFELayout) !== null && _options$compatibilit15 !== void 0 ? _options$compatibilit15 : true,
23321
+ overrideTableStyleFontSizeAndJustification: (_options$compatibilit17 = (_options$compatibilit18 = options.compatibility) === null || _options$compatibilit18 === void 0 ? void 0 : _options$compatibilit18.overrideTableStyleFontSizeAndJustification) !== null && _options$compatibilit17 !== void 0 ? _options$compatibilit17 : true,
23322
+ enableOpenTypeFeatures: (_options$compatibilit19 = (_options$compatibilit20 = options.compatibility) === null || _options$compatibilit20 === void 0 ? void 0 : _options$compatibilit20.enableOpenTypeFeatures) !== null && _options$compatibilit19 !== void 0 ? _options$compatibilit19 : true,
23323
+ doNotFlipMirrorIndents: (_options$compatibilit21 = (_options$compatibilit22 = options.compatibility) === null || _options$compatibilit22 === void 0 ? void 0 : _options$compatibilit22.doNotFlipMirrorIndents) !== null && _options$compatibilit21 !== void 0 ? _options$compatibilit21 : true
23310
23324
  }));
23311
23325
  }
23312
23326
  };
@@ -24121,7 +24135,10 @@ var ExternalStylesFactory = class {
24121
24135
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24122
24136
  let stylesXmlElement;
24123
24137
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24124
- 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
+ };
24125
24142
  return {
24126
24143
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24127
24144
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
@@ -24143,11 +24160,11 @@ var ExternalStylesFactory = class {
24143
24160
  * Factory for creating default document styles.
24144
24161
  *
24145
24162
  * This factory creates a complete set of default styles for common document elements
24146
- * such as headings, hyperlinks, and footnotes with sensible default formatting.
24163
+ * such as headings, hyperlinks, and footnotes.
24147
24164
  *
24148
24165
  * @example
24149
24166
  * ```typescript
24150
- * // Create default styles with custom heading colors
24167
+ * // Create default styles with custom heading formatting
24151
24168
  * const factory = new DefaultStylesFactory();
24152
24169
  * const styles = factory.newInstance({
24153
24170
  * heading1: {
@@ -24176,42 +24193,12 @@ var DefaultStylesFactory = class {
24176
24193
  run: { size: 56 },
24177
24194
  ...options.title
24178
24195
  }),
24179
- new Heading1Style({
24180
- run: {
24181
- color: "2E74B5",
24182
- size: 32
24183
- },
24184
- ...options.heading1
24185
- }),
24186
- new Heading2Style({
24187
- run: {
24188
- color: "2E74B5",
24189
- size: 26
24190
- },
24191
- ...options.heading2
24192
- }),
24193
- new Heading3Style({
24194
- run: {
24195
- color: "1F4D78",
24196
- size: 24
24197
- },
24198
- ...options.heading3
24199
- }),
24200
- new Heading4Style({
24201
- run: {
24202
- color: "2E74B5",
24203
- italics: true
24204
- },
24205
- ...options.heading4
24206
- }),
24207
- new Heading5Style({
24208
- run: { color: "2E74B5" },
24209
- ...options.heading5
24210
- }),
24211
- new Heading6Style({
24212
- run: { color: "1F4D78" },
24213
- ...options.heading6
24214
- }),
24196
+ new Heading1Style(options.heading1 || {}),
24197
+ new Heading2Style(options.heading2 || {}),
24198
+ new Heading3Style(options.heading3 || {}),
24199
+ new Heading4Style(options.heading4 || {}),
24200
+ new Heading5Style(options.heading5 || {}),
24201
+ new Heading6Style(options.heading6 || {}),
24215
24202
  new StrongStyle({
24216
24203
  run: { bold: true },
24217
24204
  ...options.strong
@@ -24353,6 +24340,7 @@ var File = class {
24353
24340
  compatibilityModeVersion: options.compatabilityModeVersion,
24354
24341
  defaultTabStop: options.defaultTabStop,
24355
24342
  evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,
24343
+ characterSpacingControl: options.characterSpacingControl,
24356
24344
  hyphenation: {
24357
24345
  autoHyphenation: (_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation,
24358
24346
  consecutiveHyphenLimit: (_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.consecutiveHyphenLimit,
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
  }
@@ -23020,8 +23021,8 @@
23020
23021
  /**
23021
23022
  * Creates a compatibility setting for a WordprocessingML document.
23022
23023
  *
23023
- * Currently hard-coded to set Microsoft Word compatibility mode version.
23024
- * This controls which Word version's formatting and layout behavior the document emulates.
23024
+ * This controls which Word version's formatting and layout behavior the document emulates,
23025
+ * as well as other compatibility behaviors.
23025
23026
  *
23026
23027
  * Common version values:
23027
23028
  * - 11: Word 2003
@@ -23043,25 +23044,25 @@
23043
23044
  * @example
23044
23045
  * ```typescript
23045
23046
  * // Set compatibility mode to Word 2013+
23046
- * createCompatibilitySetting(15);
23047
+ * createCompatibilitySetting("compatibilityMode", 15);
23047
23048
  *
23048
- * // Set compatibility mode to Word 2010
23049
- * createCompatibilitySetting(14);
23049
+ * // Enable OpenType features
23050
+ * createCompatibilitySetting("enableOpenTypeFeatures", 1);
23050
23051
  * ```
23051
23052
  */
23052
- const createCompatibilitySetting = (version) => new BuilderElement({
23053
+ const createCompatibilitySetting = (name, val, uri = "http://schemas.microsoft.com/office/word") => new BuilderElement({
23053
23054
  attributes: {
23054
23055
  name: {
23055
23056
  key: "w:name",
23056
- value: "compatibilityMode"
23057
+ value: name
23057
23058
  },
23058
23059
  uri: {
23059
23060
  key: "w:uri",
23060
- value: "http://schemas.microsoft.com/office/word"
23061
+ value: uri
23061
23062
  },
23062
- version: {
23063
+ val: {
23063
23064
  key: "w:val",
23064
- value: version
23065
+ value: val
23065
23066
  }
23066
23067
  },
23067
23068
  name: "w:compatSetting"
@@ -23120,7 +23121,7 @@
23120
23121
  var Compatibility = class extends XmlComponent {
23121
23122
  constructor(options) {
23122
23123
  super("w:compat");
23123
- if (options.version) this.root.push(createCompatibilitySetting(options.version));
23124
+ if (options.version) this.root.push(createCompatibilitySetting("compatibilityMode", options.version));
23124
23125
  if (options.useSingleBorderforContiguousCells) this.root.push(new OnOffElement("w:useSingleBorderforContiguousCells", options.useSingleBorderforContiguousCells));
23125
23126
  if (options.wordPerfectJustification) this.root.push(new OnOffElement("w:wpJustification", options.wordPerfectJustification));
23126
23127
  if (options.noTabStopForHangingIndent) this.root.push(new OnOffElement("w:noTabHangInd", options.noTabStopForHangingIndent));
@@ -23186,6 +23187,9 @@
23186
23187
  if (options.ignoreVerticalAlignmentInTextboxes) this.root.push(new OnOffElement("w:doNotVertAlignInTxbx", options.ignoreVerticalAlignmentInTextboxes));
23187
23188
  if (options.useAnsiKerningPairs) this.root.push(new OnOffElement("w:useAnsiKerningPairs", options.useAnsiKerningPairs));
23188
23189
  if (options.cachedColumnBalance) this.root.push(new OnOffElement("w:cachedColBalance", options.cachedColumnBalance));
23190
+ if (options.overrideTableStyleFontSizeAndJustification) this.root.push(createCompatibilitySetting("overrideTableStyleFontSizeAndJustification", 1));
23191
+ if (options.enableOpenTypeFeatures) this.root.push(createCompatibilitySetting("enableOpenTypeFeatures", 1));
23192
+ if (options.doNotFlipMirrorIndents) this.root.push(createCompatibilitySetting("doNotFlipMirrorIndents", 1));
23189
23193
  }
23190
23194
  };
23191
23195
  //#endregion
@@ -23281,7 +23285,7 @@
23281
23285
  */
23282
23286
  var Settings = class extends XmlComponent {
23283
23287
  constructor(options) {
23284
- var _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _ref, _options$compatibilit, _options$compatibilit2;
23288
+ var _options$defaultTabSt, _options$hyphenation, _options$hyphenation2, _options$hyphenation3, _options$hyphenation4, _options$characterSpa, _ref, _options$compatibilit, _options$compatibilit2, _options$compatibilit3, _options$compatibilit4, _options$compatibilit5, _options$compatibilit6, _options$compatibilit7, _options$compatibilit8, _options$compatibilit9, _options$compatibilit10, _options$compatibilit11, _options$compatibilit12, _options$compatibilit13, _options$compatibilit14, _options$compatibilit15, _options$compatibilit16, _options$compatibilit17, _options$compatibilit18, _options$compatibilit19, _options$compatibilit20, _options$compatibilit21, _options$compatibilit22;
23285
23289
  super("w:settings");
23286
23290
  this.root.push(new SettingsAttributes({
23287
23291
  Ignorable: "w14 w15 wp14",
@@ -23302,18 +23306,28 @@
23302
23306
  wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
23303
23307
  wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
23304
23308
  }));
23305
- this.root.push(new OnOffElement("w:displayBackgroundShape", true));
23306
23309
  if (options.trackRevisions !== void 0) this.root.push(new OnOffElement("w:trackRevisions", options.trackRevisions));
23307
23310
  if (options.evenAndOddHeaders !== void 0) this.root.push(new OnOffElement("w:evenAndOddHeaders", options.evenAndOddHeaders));
23308
23311
  if (options.updateFields !== void 0) this.root.push(new OnOffElement("w:updateFields", options.updateFields));
23309
- if (options.defaultTabStop !== void 0) this.root.push(new NumberValueElement("w:defaultTabStop", options.defaultTabStop));
23312
+ this.root.push(new NumberValueElement("w:defaultTabStop", (_options$defaultTabSt = options.defaultTabStop) !== null && _options$defaultTabSt !== void 0 ? _options$defaultTabSt : 420));
23310
23313
  if (((_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation) !== void 0) this.root.push(new OnOffElement("w:autoHyphenation", options.hyphenation.autoHyphenation));
23311
23314
  if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
23312
23315
  if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
23313
23316
  if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
23317
+ this.root.push(new StringValueElement("w:characterSpacingControl", (_options$characterSpa = options.characterSpacingControl) !== null && _options$characterSpa !== void 0 ? _options$characterSpa : "compressPunctuation"));
23314
23318
  this.root.push(new Compatibility({
23315
23319
  ...options.compatibility,
23316
- version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
23320
+ version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15,
23321
+ spaceForUnderline: (_options$compatibilit3 = (_options$compatibilit4 = options.compatibility) === null || _options$compatibilit4 === void 0 ? void 0 : _options$compatibilit4.spaceForUnderline) !== null && _options$compatibilit3 !== void 0 ? _options$compatibilit3 : true,
23322
+ balanceSingleByteDoubleByteWidth: (_options$compatibilit5 = (_options$compatibilit6 = options.compatibility) === null || _options$compatibilit6 === void 0 ? void 0 : _options$compatibilit6.balanceSingleByteDoubleByteWidth) !== null && _options$compatibilit5 !== void 0 ? _options$compatibilit5 : true,
23323
+ doNotLeaveBackslashAlone: (_options$compatibilit7 = (_options$compatibilit8 = options.compatibility) === null || _options$compatibilit8 === void 0 ? void 0 : _options$compatibilit8.doNotLeaveBackslashAlone) !== null && _options$compatibilit7 !== void 0 ? _options$compatibilit7 : true,
23324
+ underlineTrailingSpaces: (_options$compatibilit9 = (_options$compatibilit10 = options.compatibility) === null || _options$compatibilit10 === void 0 ? void 0 : _options$compatibilit10.underlineTrailingSpaces) !== null && _options$compatibilit9 !== void 0 ? _options$compatibilit9 : true,
23325
+ doNotExpandShiftReturn: (_options$compatibilit11 = (_options$compatibilit12 = options.compatibility) === null || _options$compatibilit12 === void 0 ? void 0 : _options$compatibilit12.doNotExpandShiftReturn) !== null && _options$compatibilit11 !== void 0 ? _options$compatibilit11 : true,
23326
+ adjustLineHeightInTable: (_options$compatibilit13 = (_options$compatibilit14 = options.compatibility) === null || _options$compatibilit14 === void 0 ? void 0 : _options$compatibilit14.adjustLineHeightInTable) !== null && _options$compatibilit13 !== void 0 ? _options$compatibilit13 : true,
23327
+ useFELayout: (_options$compatibilit15 = (_options$compatibilit16 = options.compatibility) === null || _options$compatibilit16 === void 0 ? void 0 : _options$compatibilit16.useFELayout) !== null && _options$compatibilit15 !== void 0 ? _options$compatibilit15 : true,
23328
+ overrideTableStyleFontSizeAndJustification: (_options$compatibilit17 = (_options$compatibilit18 = options.compatibility) === null || _options$compatibilit18 === void 0 ? void 0 : _options$compatibilit18.overrideTableStyleFontSizeAndJustification) !== null && _options$compatibilit17 !== void 0 ? _options$compatibilit17 : true,
23329
+ enableOpenTypeFeatures: (_options$compatibilit19 = (_options$compatibilit20 = options.compatibility) === null || _options$compatibilit20 === void 0 ? void 0 : _options$compatibilit20.enableOpenTypeFeatures) !== null && _options$compatibilit19 !== void 0 ? _options$compatibilit19 : true,
23330
+ doNotFlipMirrorIndents: (_options$compatibilit21 = (_options$compatibilit22 = options.compatibility) === null || _options$compatibilit22 === void 0 ? void 0 : _options$compatibilit22.doNotFlipMirrorIndents) !== null && _options$compatibilit21 !== void 0 ? _options$compatibilit21 : true
23317
23331
  }));
23318
23332
  }
23319
23333
  };
@@ -24128,7 +24142,10 @@
24128
24142
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24129
24143
  let stylesXmlElement;
24130
24144
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24131
- 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
+ };
24132
24149
  return {
24133
24150
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24134
24151
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)
@@ -24150,11 +24167,11 @@
24150
24167
  * Factory for creating default document styles.
24151
24168
  *
24152
24169
  * This factory creates a complete set of default styles for common document elements
24153
- * such as headings, hyperlinks, and footnotes with sensible default formatting.
24170
+ * such as headings, hyperlinks, and footnotes.
24154
24171
  *
24155
24172
  * @example
24156
24173
  * ```typescript
24157
- * // Create default styles with custom heading colors
24174
+ * // Create default styles with custom heading formatting
24158
24175
  * const factory = new DefaultStylesFactory();
24159
24176
  * const styles = factory.newInstance({
24160
24177
  * heading1: {
@@ -24183,42 +24200,12 @@
24183
24200
  run: { size: 56 },
24184
24201
  ...options.title
24185
24202
  }),
24186
- new Heading1Style({
24187
- run: {
24188
- color: "2E74B5",
24189
- size: 32
24190
- },
24191
- ...options.heading1
24192
- }),
24193
- new Heading2Style({
24194
- run: {
24195
- color: "2E74B5",
24196
- size: 26
24197
- },
24198
- ...options.heading2
24199
- }),
24200
- new Heading3Style({
24201
- run: {
24202
- color: "1F4D78",
24203
- size: 24
24204
- },
24205
- ...options.heading3
24206
- }),
24207
- new Heading4Style({
24208
- run: {
24209
- color: "2E74B5",
24210
- italics: true
24211
- },
24212
- ...options.heading4
24213
- }),
24214
- new Heading5Style({
24215
- run: { color: "2E74B5" },
24216
- ...options.heading5
24217
- }),
24218
- new Heading6Style({
24219
- run: { color: "1F4D78" },
24220
- ...options.heading6
24221
- }),
24203
+ new Heading1Style(options.heading1 || {}),
24204
+ new Heading2Style(options.heading2 || {}),
24205
+ new Heading3Style(options.heading3 || {}),
24206
+ new Heading4Style(options.heading4 || {}),
24207
+ new Heading5Style(options.heading5 || {}),
24208
+ new Heading6Style(options.heading6 || {}),
24222
24209
  new StrongStyle({
24223
24210
  run: { bold: true },
24224
24211
  ...options.strong
@@ -24360,6 +24347,7 @@
24360
24347
  compatibilityModeVersion: options.compatabilityModeVersion,
24361
24348
  defaultTabStop: options.defaultTabStop,
24362
24349
  evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,
24350
+ characterSpacingControl: options.characterSpacingControl,
24363
24351
  hyphenation: {
24364
24352
  autoHyphenation: (_options$hyphenation = options.hyphenation) === null || _options$hyphenation === void 0 ? void 0 : _options$hyphenation.autoHyphenation,
24365
24353
  consecutiveHyphenLimit: (_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.consecutiveHyphenLimit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-plus",
3
- "version": "0.0.12",
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",