docx-plus 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -11,21 +11,24 @@ Easily generate and modify .docx files with JS/TS. Works for Node and on the Bro
11
11
 
12
12
  ## What's Different from docx?
13
13
 
14
- | | docx | docx-plus |
15
- | ------------------- | ----------------------------------------- | ------------------------------------ |
16
- | ZIP handling | jszip | **fflate** (faster, smaller) |
17
- | Data conversion | Manual env detection (`Buffer.from` etc.) | **undio** (universal `toUint8Array`) |
18
- | `Packer.toStream()` | Removed (pseudo-streaming) | **Restored** with real streaming ZIP |
19
- | Test environment | jsdom | happy-dom |
20
- | OOXML compliance | ECMA-376 (legacy) | **ISO/IEC 29500-4** (latest) |
21
- | Theme support | Partial (missing `ThemeColor`/`ThemeFont`) | **Full** (`ThemeColor`, `ThemeFont` enums, theme attributes on `Color`, `Underline`, `Border`, `Shading`) |
22
- | CT_Ind | Twips-only indent | **Character-based** (`startChars`, `endChars`, `hangingChars`, `firstLineChars`) |
23
- | CT_Spacing | Missing `beforeLines`/`afterLines` | **Complete** (both twips & line-unit spacing) |
24
- | CT_Border | Missing `shadow`/`frame`/theme attrs | **Complete** (`shadow`, `frame`, `themeColor`, `themeTint`, `themeShade`) |
25
- | CT_Shd | Missing theme fill/color attrs | **Complete** (`themeColor`, `themeFill`, `themeTint`/`themeShade`) |
26
- | EG_RPrBase | Missing `outline`/`shadow`/`webHidden`/`fitText`/`cs` | **Complete** (all spec-defined elements) |
27
- | ST_Em | `dot` only | **Complete** (`none`, `comma`, `circle`, `dot`, `underDot`) |
28
- | ST_TabTlc | Missing `heavy` | **Complete** (`none`, `dot`, `hyphen`, `middleDot`, `underscore`, `heavy`) |
14
+ | | docx | docx-plus |
15
+ | ------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
16
+ | ZIP handling | jszip | **fflate** (faster, smaller) |
17
+ | Data conversion | Manual env detection (`Buffer.from` etc.) | **undio** (universal `toUint8Array`) |
18
+ | `Packer.toStream()` | Removed (pseudo-streaming) | **Restored** with real streaming ZIP |
19
+ | Test environment | jsdom | happy-dom |
20
+ | OOXML compliance | ECMA-376 (legacy) | **ISO/IEC 29500-4** (latest) |
21
+ | Theme support | Partial (missing `ThemeColor`/`ThemeFont`) | **Full** (`ThemeColor`, `ThemeFont` enums, theme attributes on `Color`, `Underline`, `Border`, `Shading`) |
22
+ | CT_Ind | Twips-only indent | **Character-based** (`startChars`, `endChars`, `hangingChars`, `firstLineChars`) |
23
+ | CT_Spacing | Missing `beforeLines`/`afterLines` | **Complete** (both twips & line-unit spacing) |
24
+ | CT_Border | Missing `shadow`/`frame`/theme attrs | **Complete** (`shadow`, `frame`, `themeColor`, `themeTint`, `themeShade`) |
25
+ | CT_Shd | Missing theme fill/color attrs | **Complete** (`themeColor`, `themeFill`, `themeTint`/`themeShade`) |
26
+ | EG_RPrBase | Missing `outline`/`shadow`/`webHidden`/`fitText`/`cs` | **Complete** (all spec-defined elements) |
27
+ | ST_Em | `dot` only | **Complete** (`none`, `comma`, `circle`, `dot`, `underDot`) |
28
+ | ST_TabTlc | Missing `heavy` | **Complete** (`none`, `dot`, `hyphen`, `middleDot`, `underscore`, `heavy`) |
29
+ | CT_PPrBase | Missing 9 paragraph props | **Complete** (`suppressAutoHyphens`, `adjustRightInd`, `snapToGrid`, `mirrorIndents`, East Asian typography, `textAlignment`, `textboxTightWrap`) |
30
+ | CT_SectPr | Missing `noEndnote`/`bidi`/`rtlGutter`/`paperSrc`/`footnotePr`/`endnotePr` | **Complete** (all spec-defined elements) |
31
+ | EG_RPrBase | Missing `eastAsianLayout` | **Complete** (`eastAsianLayout` with `combine`, `combineBrackets`, `vert`, `vertCompress`) |
29
32
 
30
33
  ## Installation
31
34
 
package/dist/index.cjs CHANGED
@@ -2284,6 +2284,57 @@ var InsertionTrackChange = class extends XmlComponent {
2284
2284
  }
2285
2285
  };
2286
2286
  //#endregion
2287
+ //#region src/file/paragraph/run/east-asian-layout.ts
2288
+ /**
2289
+ * East Asian layout module for WordprocessingML run properties.
2290
+ *
2291
+ * Specifies East Asian typography settings for a run, including
2292
+ * character combination, vertical text, and compression.
2293
+ *
2294
+ * Reference: ISO/IEC 29500-4, CT_EastAsianLayout
2295
+ *
2296
+ * @module
2297
+ */
2298
+ /**
2299
+ * Creates an East Asian layout element (w:eastAsianLayout) for a run.
2300
+ *
2301
+ * ## XSD Schema
2302
+ * ```xml
2303
+ * <xsd:complexType name="CT_EastAsianLayout">
2304
+ * <xsd:attribute name="id" type="ST_DecimalNumber" use="optional"/>
2305
+ * <xsd:attribute name="combine" type="s:ST_OnOff" use="optional"/>
2306
+ * <xsd:attribute name="combineBrackets" type="ST_CombineBrackets" use="optional"/>
2307
+ * <xsd:attribute name="vert" type="s:ST_OnOff" use="optional"/>
2308
+ * <xsd:attribute name="vertCompress" type="s:ST_OnOff" use="optional"/>
2309
+ * </xsd:complexType>
2310
+ * ```
2311
+ */
2312
+ const createEastAsianLayout = ({ id, combine, combineBrackets, vert, vertCompress }) => new BuilderElement({
2313
+ attributes: {
2314
+ combine: {
2315
+ key: "w:combine",
2316
+ value: combine
2317
+ },
2318
+ combineBrackets: {
2319
+ key: "w:combineBrackets",
2320
+ value: combineBrackets
2321
+ },
2322
+ id: {
2323
+ key: "w:id",
2324
+ value: id === void 0 ? void 0 : decimalNumber(id)
2325
+ },
2326
+ vert: {
2327
+ key: "w:vert",
2328
+ value: vert
2329
+ },
2330
+ vertCompress: {
2331
+ key: "w:vertCompress",
2332
+ value: vertCompress
2333
+ }
2334
+ },
2335
+ name: "w:eastAsianLayout"
2336
+ });
2337
+ //#endregion
2287
2338
  //#region src/file/paragraph/run/emphasis-mark.ts
2288
2339
  /**
2289
2340
  * Emphasis mark module for WordprocessingML run properties.
@@ -3015,6 +3066,7 @@ var RunProperties = class extends IgnoreIfEmptyXmlComponent {
3015
3066
  if (options.math) this.push(new OnOffElement("w:oMath", options.math));
3016
3067
  if (options.fitText !== void 0) this.push(new NumberValueElement("w:fitText", options.fitText));
3017
3068
  if (options.complexScript !== void 0) this.push(new OnOffElement("w:cs", options.complexScript));
3069
+ if (options.eastAsianLayout) this.push(createEastAsianLayout(options.eastAsianLayout));
3018
3070
  if (options.revision) this.push(new RunPropertiesChange(options.revision));
3019
3071
  }
3020
3072
  push(item) {
@@ -8521,6 +8573,34 @@ const createFrameProperties = (options) => {
8521
8573
  * @module
8522
8574
  */
8523
8575
  /**
8576
+ * Vertical text alignment types for paragraphs.
8577
+ *
8578
+ * Specifies the vertical alignment of text within the paragraph.
8579
+ *
8580
+ * @publicApi
8581
+ */
8582
+ const TextAlignmentType = {
8583
+ TOP: "top",
8584
+ CENTER: "center",
8585
+ BASELINE: "baseline",
8586
+ BOTTOM: "bottom",
8587
+ AUTO: "auto"
8588
+ };
8589
+ /**
8590
+ * Textbox tight wrap types for paragraphs.
8591
+ *
8592
+ * Specifies how tightly text wraps around a textbox.
8593
+ *
8594
+ * @publicApi
8595
+ */
8596
+ const TextboxTightWrapType = {
8597
+ NONE: "none",
8598
+ ALL_LINES: "allLines",
8599
+ FIRST_AND_LAST_LINE: "firstAndLastLine",
8600
+ FIRST_LINE_ONLY: "firstLineOnly",
8601
+ LAST_LINE_ONLY: "lastLineOnly"
8602
+ };
8603
+ /**
8524
8604
  * Represents paragraph properties (pPr) in a WordprocessingML document.
8525
8605
  *
8526
8606
  * The paragraph properties element specifies all formatting applied to a paragraph,
@@ -8683,6 +8763,27 @@ var ParagraphProperties = class extends IgnoreIfEmptyXmlComponent {
8683
8763
  if (options.outlineLevel !== void 0) this.push(createOutlineLevel(options.outlineLevel));
8684
8764
  if (options.suppressLineNumbers !== void 0) this.push(new OnOffElement("w:suppressLineNumbers", options.suppressLineNumbers));
8685
8765
  if (options.autoSpaceEastAsianText !== void 0) this.push(new OnOffElement("w:autoSpaceDN", options.autoSpaceEastAsianText));
8766
+ if (options.suppressAutoHyphens !== void 0) this.push(new OnOffElement("w:suppressAutoHyphens", options.suppressAutoHyphens));
8767
+ if (options.adjustRightInd !== void 0) this.push(new OnOffElement("w:adjustRightInd", options.adjustRightInd));
8768
+ if (options.snapToGrid !== void 0) this.push(new OnOffElement("w:snapToGrid", options.snapToGrid));
8769
+ if (options.mirrorIndents !== void 0) this.push(new OnOffElement("w:mirrorIndents", options.mirrorIndents));
8770
+ if (options.kinsoku !== void 0) this.push(new OnOffElement("w:kinsoku", options.kinsoku));
8771
+ if (options.topLinePunct !== void 0) this.push(new OnOffElement("w:topLinePunct", options.topLinePunct));
8772
+ if (options.autoSpaceDE !== void 0) this.push(new OnOffElement("w:autoSpaceDE", options.autoSpaceDE));
8773
+ if (options.textAlignment !== void 0) this.push(new BuilderElement({
8774
+ attributes: { val: {
8775
+ key: "w:val",
8776
+ value: options.textAlignment
8777
+ } },
8778
+ name: "w:textAlignment"
8779
+ }));
8780
+ if (options.textboxTightWrap !== void 0) this.push(new BuilderElement({
8781
+ attributes: { val: {
8782
+ key: "w:val",
8783
+ value: options.textboxTightWrap
8784
+ } },
8785
+ name: "w:textboxTightWrap"
8786
+ }));
8686
8787
  if (options.run) this.push(new ParagraphRunProperties(options.run));
8687
8788
  if (options.revision) this.push(new ParagraphPropertiesChange(options.revision));
8688
8789
  }
@@ -13052,6 +13153,137 @@ const createDocumentGrid = ({ type, linePitch, charSpace }) => new BuilderElemen
13052
13153
  name: "w:docGrid"
13053
13154
  });
13054
13155
  //#endregion
13156
+ //#region src/file/document/body/section-properties/properties/footnote-endnote-properties.ts
13157
+ /**
13158
+ * Footnote and endnote properties module for WordprocessingML section properties.
13159
+ *
13160
+ * Specifies footnote/endnote placement and numbering format within a section.
13161
+ *
13162
+ * Reference: ISO/IEC 29500-4, CT_FtnProps / CT_EdnProps
13163
+ *
13164
+ * @module
13165
+ */
13166
+ /**
13167
+ * Creates footnote properties element (w:footnotePr) for a section.
13168
+ *
13169
+ * ## XSD Schema
13170
+ * ```xml
13171
+ * <xsd:complexType name="CT_FtnProps">
13172
+ * <xsd:sequence>
13173
+ * <xsd:element name="pos" type="CT_FtnPos" minOccurs="0"/>
13174
+ * <xsd:element name="numFmt" type="CT_NumFmt" minOccurs="0"/>
13175
+ * <xsd:group ref="EG_FtnEdnNumProps" minOccurs="0"/>
13176
+ * </xsd:sequence>
13177
+ * </xsd:complexType>
13178
+ * ```
13179
+ */
13180
+ const createFootnoteProperties = ({ pos, formatType, format, numStart, numRestart }) => {
13181
+ const container = new FootnoteProperties();
13182
+ if (pos !== void 0) container.addChildElement(new BuilderElement({
13183
+ attributes: { val: {
13184
+ key: "w:val",
13185
+ value: pos
13186
+ } },
13187
+ name: "w:pos"
13188
+ }));
13189
+ if (formatType !== void 0 || format !== void 0) container.addChildElement(new BuilderElement({
13190
+ attributes: {
13191
+ format: {
13192
+ key: "w:format",
13193
+ value: format
13194
+ },
13195
+ val: {
13196
+ key: "w:fmt",
13197
+ value: formatType
13198
+ }
13199
+ },
13200
+ name: "w:numFmt"
13201
+ }));
13202
+ if (numStart !== void 0) container.addChildElement(new BuilderElement({
13203
+ attributes: { val: {
13204
+ key: "w:val",
13205
+ value: decimalNumber(numStart)
13206
+ } },
13207
+ name: "w:numStart"
13208
+ }));
13209
+ if (numRestart !== void 0) container.addChildElement(new BuilderElement({
13210
+ attributes: { val: {
13211
+ key: "w:val",
13212
+ value: numRestart
13213
+ } },
13214
+ name: "w:numRestart"
13215
+ }));
13216
+ return container;
13217
+ };
13218
+ /**
13219
+ * Footnote properties container element.
13220
+ */
13221
+ var FootnoteProperties = class extends IgnoreIfEmptyXmlComponent {
13222
+ constructor() {
13223
+ super("w:footnotePr", true);
13224
+ }
13225
+ };
13226
+ /**
13227
+ * Creates endnote properties element (w:endnotePr) for a section.
13228
+ *
13229
+ * ## XSD Schema
13230
+ * ```xml
13231
+ * <xsd:complexType name="CT_EdnProps">
13232
+ * <xsd:sequence>
13233
+ * <xsd:element name="pos" type="CT_EdnPos" minOccurs="0"/>
13234
+ * <xsd:element name="numFmt" type="CT_NumFmt" minOccurs="0"/>
13235
+ * <xsd:group ref="EG_FtnEdnNumProps" minOccurs="0"/>
13236
+ * </xsd:sequence>
13237
+ * </xsd:complexType>
13238
+ * ```
13239
+ */
13240
+ const createEndnoteProperties = ({ pos, formatType, format, numStart, numRestart }) => {
13241
+ const container = new EndnoteProperties();
13242
+ if (pos !== void 0) container.addChildElement(new BuilderElement({
13243
+ attributes: { val: {
13244
+ key: "w:val",
13245
+ value: pos
13246
+ } },
13247
+ name: "w:pos"
13248
+ }));
13249
+ if (formatType !== void 0 || format !== void 0) container.addChildElement(new BuilderElement({
13250
+ attributes: {
13251
+ format: {
13252
+ key: "w:format",
13253
+ value: format
13254
+ },
13255
+ val: {
13256
+ key: "w:fmt",
13257
+ value: formatType
13258
+ }
13259
+ },
13260
+ name: "w:numFmt"
13261
+ }));
13262
+ if (numStart !== void 0) container.addChildElement(new BuilderElement({
13263
+ attributes: { val: {
13264
+ key: "w:val",
13265
+ value: decimalNumber(numStart)
13266
+ } },
13267
+ name: "w:numStart"
13268
+ }));
13269
+ if (numRestart !== void 0) container.addChildElement(new BuilderElement({
13270
+ attributes: { val: {
13271
+ key: "w:val",
13272
+ value: numRestart
13273
+ } },
13274
+ name: "w:numRestart"
13275
+ }));
13276
+ return container;
13277
+ };
13278
+ /**
13279
+ * Endnote properties container element.
13280
+ */
13281
+ var EndnoteProperties = class extends IgnoreIfEmptyXmlComponent {
13282
+ constructor() {
13283
+ super("w:endnotePr", true);
13284
+ }
13285
+ };
13286
+ //#endregion
13055
13287
  //#region src/file/document/body/section-properties/properties/header-footer-reference.ts
13056
13288
  /**
13057
13289
  * This simple type specifies the possible types of headers and footers which may be specified for a given header or footer reference in a document. This value determines the page(s) on which the current header or footer shall be displayed.
@@ -13414,8 +13646,12 @@ const PageNumberSeparator = {
13414
13646
  * });
13415
13647
  * ```
13416
13648
  */
13417
- const createPageNumberType = ({ start, formatType, separator }) => new BuilderElement({
13649
+ const createPageNumberType = ({ start, formatType, separator, chapStyle }) => new BuilderElement({
13418
13650
  attributes: {
13651
+ chapStyle: {
13652
+ key: "w:chapStyle",
13653
+ value: chapStyle === void 0 ? void 0 : decimalNumber(chapStyle)
13654
+ },
13419
13655
  formatType: {
13420
13656
  key: "w:fmt",
13421
13657
  value: formatType
@@ -13704,7 +13940,7 @@ const sectionPageSizeDefaults = {
13704
13940
  * ```
13705
13941
  */
13706
13942
  var SectionProperties = class extends XmlComponent {
13707
- constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 360, charSpace, type: gridType } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision } = {}) {
13943
+ constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 360, charSpace, type: gridType } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
13708
13944
  super("w:sectPr");
13709
13945
  this.addHeaderFooterGroup(HeaderFooterType.HEADER, headerWrapperGroup);
13710
13946
  this.addHeaderFooterGroup(HeaderFooterType.FOOTER, footerWrapperGroup);
@@ -13723,6 +13959,24 @@ var SectionProperties = class extends XmlComponent {
13723
13959
  if (titlePage !== void 0) this.root.push(new OnOffElement("w:titlePg", titlePage));
13724
13960
  if (textDirection) this.root.push(new PageTextDirection(textDirection));
13725
13961
  if (revision) this.root.push(new SectionPropertiesChange(revision));
13962
+ if (noEndnote !== void 0) this.root.push(new OnOffElement("w:noEndnote", noEndnote));
13963
+ if (bidi !== void 0) this.root.push(new OnOffElement("w:bidi", bidi));
13964
+ if (rtlGutter !== void 0) this.root.push(new OnOffElement("w:rtlGutter", rtlGutter));
13965
+ if (paperSrc) this.root.push(new BuilderElement({
13966
+ attributes: {
13967
+ first: {
13968
+ key: "w:first",
13969
+ value: paperSrc.first === void 0 ? void 0 : decimalNumber(paperSrc.first)
13970
+ },
13971
+ other: {
13972
+ key: "w:other",
13973
+ value: paperSrc.other === void 0 ? void 0 : decimalNumber(paperSrc.other)
13974
+ }
13975
+ },
13976
+ name: "w:paperSrc"
13977
+ }));
13978
+ if (footnotePr) this.root.push(createFootnoteProperties(footnotePr));
13979
+ if (endnotePr) this.root.push(createEndnoteProperties(endnotePr));
13726
13980
  this.root.push(createDocumentGrid({
13727
13981
  charSpace,
13728
13982
  linePitch,
@@ -23400,12 +23654,14 @@ exports.TableProperties = TableProperties;
23400
23654
  exports.TableRow = TableRow;
23401
23655
  exports.TableRowProperties = TableRowProperties;
23402
23656
  exports.TableRowPropertiesChange = TableRowPropertiesChange;
23657
+ exports.TextAlignmentType = TextAlignmentType;
23403
23658
  exports.TextDirection = TextDirection;
23404
23659
  exports.TextEffect = TextEffect;
23405
23660
  exports.TextRun = TextRun;
23406
23661
  exports.TextWrappingSide = TextWrappingSide;
23407
23662
  exports.TextWrappingType = TextWrappingType;
23408
23663
  exports.Textbox = Textbox;
23664
+ exports.TextboxTightWrapType = TextboxTightWrapType;
23409
23665
  exports.ThematicBreak = ThematicBreak;
23410
23666
  exports.ThemeColor = ThemeColor;
23411
23667
  exports.ThemeFont = ThemeFont;