docx-plus 0.0.4 → 0.0.5

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.
@@ -384,6 +384,9 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
384
384
  rsidSect: "w:rsidSect",
385
385
  space: "w:space",
386
386
  sz: "w:sz",
387
+ themeColor: "w:themeColor",
388
+ themeShade: "w:themeShade",
389
+ themeTint: "w:themeTint",
387
390
  top: "w:top",
388
391
  type: "w:type",
389
392
  val: "w:val",
@@ -910,6 +913,49 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
910
913
  * ```
911
914
  */
912
915
  const dateTimeValue = (val) => val.toISOString();
916
+ /**
917
+ * Theme color values used throughout OOXML for referencing document theme colors.
918
+ *
919
+ * Reference: ST_ThemeColor in OOXML specification
920
+ *
921
+ * @publicApi
922
+ */
923
+ const ThemeColor = {
924
+ DARK1: "dark1",
925
+ LIGHT1: "light1",
926
+ DARK2: "dark2",
927
+ LIGHT2: "light2",
928
+ ACCENT1: "accent1",
929
+ ACCENT2: "accent2",
930
+ ACCENT3: "accent3",
931
+ ACCENT4: "accent4",
932
+ ACCENT5: "accent5",
933
+ ACCENT6: "accent6",
934
+ HYPERLINK: "hyperlink",
935
+ FOLLOWED_HYPERLINK: "followedHyperlink",
936
+ NONE: "none",
937
+ BACKGROUND1: "background1",
938
+ TEXT1: "text1",
939
+ BACKGROUND2: "background2",
940
+ TEXT2: "text2"
941
+ };
942
+ /**
943
+ * Theme font values used for referencing document theme fonts.
944
+ *
945
+ * Reference: ST_Theme in OOXML specification
946
+ *
947
+ * @publicApi
948
+ */
949
+ const ThemeFont = {
950
+ MAJOR_EAST_ASIA: "majorEastAsia",
951
+ MAJOR_BIDI: "majorBidi",
952
+ MAJOR_ASCII: "majorAscii",
953
+ MAJOR_H_ANSI: "majorHAnsi",
954
+ MINOR_EAST_ASIA: "minorEastAsia",
955
+ MINOR_BIDI: "minorBidi",
956
+ MINOR_ASCII: "minorAscii",
957
+ MINOR_H_ANSI: "minorHAnsi"
958
+ };
913
959
  //#endregion
914
960
  //#region src/file/xml-components/simple-elements.ts
915
961
  /**
@@ -1322,12 +1368,20 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
1322
1368
  * });
1323
1369
  * ```
1324
1370
  */
1325
- const createBorderElement = (elementName, { color, size, space, style }) => new BuilderElement({
1371
+ const createBorderElement = (elementName, { color, size, space, style, themeColor, themeTint, themeShade, shadow, frame }) => new BuilderElement({
1326
1372
  attributes: {
1327
1373
  color: {
1328
1374
  key: "w:color",
1329
1375
  value: color === void 0 ? void 0 : hexColorValue(color)
1330
1376
  },
1377
+ frame: {
1378
+ key: "w:frame",
1379
+ value: frame
1380
+ },
1381
+ shadow: {
1382
+ key: "w:shadow",
1383
+ value: shadow
1384
+ },
1331
1385
  size: {
1332
1386
  key: "w:sz",
1333
1387
  value: size === void 0 ? void 0 : eighthPointMeasureValue(size)
@@ -1339,6 +1393,18 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
1339
1393
  style: {
1340
1394
  key: "w:val",
1341
1395
  value: style
1396
+ },
1397
+ themeColor: {
1398
+ key: "w:themeColor",
1399
+ value: themeColor
1400
+ },
1401
+ themeShade: {
1402
+ key: "w:themeShade",
1403
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
1404
+ },
1405
+ themeTint: {
1406
+ key: "w:themeTint",
1407
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
1342
1408
  }
1343
1409
  },
1344
1410
  name: elementName
@@ -1542,20 +1608,32 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
1542
1608
  * </xsd:complexType>
1543
1609
  * ```
1544
1610
  */
1545
- const createIndent = ({ start, end, left, right, hanging, firstLine }) => new BuilderElement({
1611
+ const createIndent = ({ start, startChars, end, endChars, left, right, hanging, hangingChars, firstLine, firstLineChars }) => new BuilderElement({
1546
1612
  attributes: {
1547
1613
  end: {
1548
1614
  key: "w:end",
1549
1615
  value: end === void 0 ? void 0 : signedTwipsMeasureValue(end)
1550
1616
  },
1617
+ endChars: {
1618
+ key: "w:endChars",
1619
+ value: endChars === void 0 ? void 0 : decimalNumber(endChars)
1620
+ },
1551
1621
  firstLine: {
1552
1622
  key: "w:firstLine",
1553
1623
  value: firstLine === void 0 ? void 0 : twipsMeasureValue(firstLine)
1554
1624
  },
1625
+ firstLineChars: {
1626
+ key: "w:firstLineChars",
1627
+ value: firstLineChars === void 0 ? void 0 : decimalNumber(firstLineChars)
1628
+ },
1555
1629
  hanging: {
1556
1630
  key: "w:hanging",
1557
1631
  value: hanging === void 0 ? void 0 : twipsMeasureValue(hanging)
1558
1632
  },
1633
+ hangingChars: {
1634
+ key: "w:hangingChars",
1635
+ value: hangingChars === void 0 ? void 0 : decimalNumber(hangingChars)
1636
+ },
1559
1637
  left: {
1560
1638
  key: "w:left",
1561
1639
  value: left === void 0 ? void 0 : signedTwipsMeasureValue(left)
@@ -1567,6 +1645,10 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
1567
1645
  start: {
1568
1646
  key: "w:start",
1569
1647
  value: start === void 0 ? void 0 : signedTwipsMeasureValue(start)
1648
+ },
1649
+ startChars: {
1650
+ key: "w:startChars",
1651
+ value: startChars === void 0 ? void 0 : decimalNumber(startChars)
1570
1652
  }
1571
1653
  },
1572
1654
  name: "w:ind"
@@ -2017,7 +2099,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2017
2099
  *
2018
2100
  * Reference: http://officeopenxml.com/WPshading.php
2019
2101
  */
2020
- const createShading = ({ fill, color, type }) => new BuilderElement({
2102
+ const createShading = ({ fill, color, type, themeColor, themeTint, themeShade, themeFill, themeFillTint, themeFillShade }) => new BuilderElement({
2021
2103
  attributes: {
2022
2104
  color: {
2023
2105
  key: "w:color",
@@ -2027,6 +2109,30 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2027
2109
  key: "w:fill",
2028
2110
  value: fill === void 0 ? void 0 : hexColorValue(fill)
2029
2111
  },
2112
+ themeColor: {
2113
+ key: "w:themeColor",
2114
+ value: themeColor
2115
+ },
2116
+ themeFill: {
2117
+ key: "w:themeFill",
2118
+ value: themeFill
2119
+ },
2120
+ themeFillShade: {
2121
+ key: "w:themeFillShade",
2122
+ value: themeFillShade === void 0 ? void 0 : uCharHexNumber(themeFillShade)
2123
+ },
2124
+ themeFillTint: {
2125
+ key: "w:themeFillTint",
2126
+ value: themeFillTint === void 0 ? void 0 : uCharHexNumber(themeFillTint)
2127
+ },
2128
+ themeShade: {
2129
+ key: "w:themeShade",
2130
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2131
+ },
2132
+ themeTint: {
2133
+ key: "w:themeTint",
2134
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2135
+ },
2030
2136
  type: {
2031
2137
  key: "w:val",
2032
2138
  value: type
@@ -2205,7 +2311,13 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2205
2311
  *
2206
2312
  * @publicApi
2207
2313
  */
2208
- const EmphasisMarkType = { DOT: "dot" };
2314
+ const EmphasisMarkType = {
2315
+ NONE: "none",
2316
+ COMMA: "comma",
2317
+ CIRCLE: "circle",
2318
+ DOT: "dot",
2319
+ UNDER_DOT: "underDot"
2320
+ };
2209
2321
  /**
2210
2322
  * Creates an emphasis mark element for a WordprocessingML document.
2211
2323
  *
@@ -2296,16 +2408,27 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2296
2408
  *
2297
2409
  * @example
2298
2410
  * ```typescript
2299
- * new Color("FF0000"); // Red text
2411
+ * new Color("FF0000"); // Red text (backward compatible)
2300
2412
  * new Color("auto"); // Automatic color
2413
+ * new Color({ themeColor: ThemeColor.ACCENT1, themeTint: "99" }); // Theme color with tint
2301
2414
  * ```
2302
2415
  *
2303
2416
  * @internal
2304
2417
  */
2305
2418
  var Color = class extends XmlComponent {
2306
- constructor(color) {
2419
+ constructor(colorOrOptions) {
2307
2420
  super("w:color");
2308
- this.root.push(new Attributes({ val: hexColorValue(color) }));
2421
+ if (typeof colorOrOptions === "string") {
2422
+ this.root.push(new Attributes({ val: hexColorValue(colorOrOptions) }));
2423
+ return;
2424
+ }
2425
+ const opts = colorOrOptions;
2426
+ this.root.push(new Attributes({
2427
+ val: opts.val === void 0 ? void 0 : hexColorValue(opts.val),
2428
+ themeColor: opts.themeColor,
2429
+ themeTint: opts.themeTint === void 0 ? void 0 : uCharHexNumber(opts.themeTint),
2430
+ themeShade: opts.themeShade === void 0 ? void 0 : uCharHexNumber(opts.themeShade)
2431
+ }));
2309
2432
  }
2310
2433
  };
2311
2434
  /**
@@ -2504,18 +2627,34 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2504
2627
  key: "w:ascii",
2505
2628
  value: attrs.ascii
2506
2629
  },
2630
+ asciiTheme: {
2631
+ key: "w:asciiTheme",
2632
+ value: attrs.asciiTheme
2633
+ },
2507
2634
  cs: {
2508
2635
  key: "w:cs",
2509
2636
  value: attrs.cs
2510
2637
  },
2638
+ cstheme: {
2639
+ key: "w:cstheme",
2640
+ value: attrs.cstheme
2641
+ },
2511
2642
  eastAsia: {
2512
2643
  key: "w:eastAsia",
2513
2644
  value: attrs.eastAsia
2514
2645
  },
2646
+ eastAsiaTheme: {
2647
+ key: "w:eastAsiaTheme",
2648
+ value: attrs.eastAsiaTheme
2649
+ },
2515
2650
  hAnsi: {
2516
2651
  key: "w:hAnsi",
2517
2652
  value: attrs.hAnsi
2518
2653
  },
2654
+ hAnsiTheme: {
2655
+ key: "w:hAnsiTheme",
2656
+ value: attrs.hAnsiTheme
2657
+ },
2519
2658
  hint: {
2520
2659
  key: "w:hint",
2521
2660
  value: attrs.hint
@@ -2672,12 +2811,24 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2672
2811
  * createUnderline(UnderlineType.WAVE, "FF0000");
2673
2812
  * ```
2674
2813
  */
2675
- const createUnderline = (underlineType = UnderlineType.SINGLE, color) => new BuilderElement({
2814
+ const createUnderline = (underlineType = UnderlineType.SINGLE, color, themeColor, themeTint, themeShade) => new BuilderElement({
2676
2815
  attributes: {
2677
2816
  color: {
2678
2817
  key: "w:color",
2679
2818
  value: color === void 0 ? void 0 : hexColorValue(color)
2680
2819
  },
2820
+ themeColor: {
2821
+ key: "w:themeColor",
2822
+ value: themeColor
2823
+ },
2824
+ themeShade: {
2825
+ key: "w:themeShade",
2826
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2827
+ },
2828
+ themeTint: {
2829
+ key: "w:themeTint",
2830
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2831
+ },
2681
2832
  val: {
2682
2833
  key: "w:val",
2683
2834
  value: underlineType
@@ -2829,6 +2980,9 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2829
2980
  if (options.doubleStrike !== void 0) this.push(new OnOffElement("w:dstrike", options.doubleStrike));
2830
2981
  if (options.emboss !== void 0) this.push(new OnOffElement("w:emboss", options.emboss));
2831
2982
  if (options.imprint !== void 0) this.push(new OnOffElement("w:imprint", options.imprint));
2983
+ if (options.outline !== void 0) this.push(new OnOffElement("w:outline", options.outline));
2984
+ if (options.shadow !== void 0) this.push(new OnOffElement("w:shadow", options.shadow));
2985
+ if (options.webHidden !== void 0) this.push(new OnOffElement("w:webHidden", options.webHidden));
2832
2986
  if (options.noProof !== void 0) this.push(new OnOffElement("w:noProof", options.noProof));
2833
2987
  if (options.snapToGrid !== void 0) this.push(new OnOffElement("w:snapToGrid", options.snapToGrid));
2834
2988
  if (options.vanish) this.push(new OnOffElement("w:vanish", options.vanish));
@@ -2854,6 +3008,8 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
2854
3008
  if (options.language) this.push(createLanguageComponent(options.language));
2855
3009
  if (options.specVanish) this.push(new OnOffElement("w:specVanish", options.vanish));
2856
3010
  if (options.math) this.push(new OnOffElement("w:oMath", options.math));
3011
+ if (options.fitText !== void 0) this.push(new NumberValueElement("w:fitText", options.fitText));
3012
+ if (options.complexScript !== void 0) this.push(new OnOffElement("w:cs", options.complexScript));
2857
3013
  if (options.revision) this.push(new RunPropertiesChange(options.revision));
2858
3014
  }
2859
3015
  push(item) {
@@ -3289,18 +3445,6 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
3289
3445
  * ```
3290
3446
  */
3291
3447
  const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
3292
- /**
3293
- * Encode a string to UTF-8 bytes.
3294
- *
3295
- * This is used to pre-encode XML content before passing to fflate's zipSync,
3296
- * which expects Uint8Array input for text content.
3297
- *
3298
- * The copy via `new Uint8Array()` ensures the returned array uses the
3299
- * current module's Uint8Array constructor, avoiding cross-realm issues
3300
- * in test environments (happy-dom) where TextEncoder returns a different
3301
- * realm's Uint8Array.
3302
- */
3303
- const encodeUtf8 = (str) => new Uint8Array(new TextEncoder().encode(str));
3304
3448
  //#endregion
3305
3449
  //#region src/file/drawing/floating/floating-position.ts
3306
3450
  /**
@@ -6963,7 +7107,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
6963
7107
  * });
6964
7108
  * ```
6965
7109
  */
6966
- const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing }) => new BuilderElement({
7110
+ const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing, beforeLines, afterLines }) => new BuilderElement({
6967
7111
  attributes: {
6968
7112
  after: {
6969
7113
  key: "w:after",
@@ -6973,6 +7117,10 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
6973
7117
  key: "w:afterAutospacing",
6974
7118
  value: afterAutoSpacing
6975
7119
  },
7120
+ afterLines: {
7121
+ key: "w:afterLines",
7122
+ value: afterLines === void 0 ? void 0 : decimalNumber(afterLines)
7123
+ },
6976
7124
  before: {
6977
7125
  key: "w:before",
6978
7126
  value: before
@@ -6981,6 +7129,10 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
6981
7129
  key: "w:beforeAutospacing",
6982
7130
  value: beforeAutoSpacing
6983
7131
  },
7132
+ beforeLines: {
7133
+ key: "w:beforeLines",
7134
+ value: beforeLines === void 0 ? void 0 : decimalNumber(beforeLines)
7135
+ },
6984
7136
  line: {
6985
7137
  key: "w:line",
6986
7138
  value: line
@@ -7091,6 +7243,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
7091
7243
  */
7092
7244
  const LeaderType = {
7093
7245
  DOT: "dot",
7246
+ HEAVY: "heavy",
7094
7247
  HYPHEN: "hyphen",
7095
7248
  MIDDLE_DOT: "middleDot",
7096
7249
  NONE: "none",
@@ -21701,13 +21854,12 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
21701
21854
  const footerFormattedViews = /* @__PURE__ */ new Map();
21702
21855
  const xmlifiedFileMapping = this.xmlifyFile(file, headerFormattedViews, footerFormattedViews, prettifyXml);
21703
21856
  const map = new Map(Object.entries(xmlifiedFileMapping));
21704
- for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = encodeUtf8(subFile.data);
21705
- else files[obj.path] = encodeUtf8(obj.data);
21706
- for (const subFile of overrides) files[subFile.path] = encodeUtf8(subFile.data);
21707
- for (const mediaData of file.Media.Array) if (mediaData.type !== "svg") files[`word/media/${mediaData.fileName}`] = [(0, undio.toUint8Array)(mediaData.data), { level: 0 }];
21708
- else {
21857
+ for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = (0, undio.textToUint8Array)(subFile.data);
21858
+ else files[obj.path] = (0, undio.textToUint8Array)(obj.data);
21859
+ for (const subFile of overrides) files[subFile.path] = (0, undio.textToUint8Array)(subFile.data);
21860
+ for (const mediaData of file.Media.Array) {
21709
21861
  files[`word/media/${mediaData.fileName}`] = [(0, undio.toUint8Array)(mediaData.data), { level: 0 }];
21710
- files[`word/media/${mediaData.fallback.fileName}`] = [(0, undio.toUint8Array)(mediaData.fallback.data), { level: 0 }];
21862
+ if (mediaData.type === "svg") files[`word/media/${mediaData.fallback.fileName}`] = [(0, undio.toUint8Array)(mediaData.fallback.data), { level: 0 }];
21711
21863
  }
21712
21864
  for (const { data: buffer, name, fontKey } of file.FontTable.fontOptionsWithKey) {
21713
21865
  const [nameWithoutExtension] = name.split(".");
@@ -23250,6 +23402,8 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23250
23402
  exports.TextWrappingType = TextWrappingType;
23251
23403
  exports.Textbox = Textbox;
23252
23404
  exports.ThematicBreak = ThematicBreak;
23405
+ exports.ThemeColor = ThemeColor;
23406
+ exports.ThemeFont = ThemeFont;
23253
23407
  exports.UnderlineType = UnderlineType;
23254
23408
  exports.VerticalAlign = VerticalAlign;
23255
23409
  exports.VerticalAlignSection = VerticalAlignSection;
@@ -23328,7 +23482,6 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23328
23482
  exports.decimalNumber = decimalNumber;
23329
23483
  exports.docPropertiesUniqueNumericIdGen = docPropertiesUniqueNumericIdGen;
23330
23484
  exports.eighthPointMeasureValue = eighthPointMeasureValue;
23331
- exports.encodeUtf8 = encodeUtf8;
23332
23485
  exports.hashedId = hashedId;
23333
23486
  exports.hexColorValue = hexColorValue;
23334
23487
  exports.hpsMeasureValue = hpsMeasureValue;