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.
package/dist/index.umd.js CHANGED
@@ -394,6 +394,9 @@
394
394
  rsidSect: "w:rsidSect",
395
395
  space: "w:space",
396
396
  sz: "w:sz",
397
+ themeColor: "w:themeColor",
398
+ themeShade: "w:themeShade",
399
+ themeTint: "w:themeTint",
397
400
  top: "w:top",
398
401
  type: "w:type",
399
402
  val: "w:val",
@@ -920,6 +923,49 @@
920
923
  * ```
921
924
  */
922
925
  const dateTimeValue = (val) => val.toISOString();
926
+ /**
927
+ * Theme color values used throughout OOXML for referencing document theme colors.
928
+ *
929
+ * Reference: ST_ThemeColor in OOXML specification
930
+ *
931
+ * @publicApi
932
+ */
933
+ const ThemeColor = {
934
+ DARK1: "dark1",
935
+ LIGHT1: "light1",
936
+ DARK2: "dark2",
937
+ LIGHT2: "light2",
938
+ ACCENT1: "accent1",
939
+ ACCENT2: "accent2",
940
+ ACCENT3: "accent3",
941
+ ACCENT4: "accent4",
942
+ ACCENT5: "accent5",
943
+ ACCENT6: "accent6",
944
+ HYPERLINK: "hyperlink",
945
+ FOLLOWED_HYPERLINK: "followedHyperlink",
946
+ NONE: "none",
947
+ BACKGROUND1: "background1",
948
+ TEXT1: "text1",
949
+ BACKGROUND2: "background2",
950
+ TEXT2: "text2"
951
+ };
952
+ /**
953
+ * Theme font values used for referencing document theme fonts.
954
+ *
955
+ * Reference: ST_Theme in OOXML specification
956
+ *
957
+ * @publicApi
958
+ */
959
+ const ThemeFont = {
960
+ MAJOR_EAST_ASIA: "majorEastAsia",
961
+ MAJOR_BIDI: "majorBidi",
962
+ MAJOR_ASCII: "majorAscii",
963
+ MAJOR_H_ANSI: "majorHAnsi",
964
+ MINOR_EAST_ASIA: "minorEastAsia",
965
+ MINOR_BIDI: "minorBidi",
966
+ MINOR_ASCII: "minorAscii",
967
+ MINOR_H_ANSI: "minorHAnsi"
968
+ };
923
969
  //#endregion
924
970
  //#region src/file/xml-components/simple-elements.ts
925
971
  /**
@@ -1332,12 +1378,20 @@
1332
1378
  * });
1333
1379
  * ```
1334
1380
  */
1335
- const createBorderElement = (elementName, { color, size, space, style }) => new BuilderElement({
1381
+ const createBorderElement = (elementName, { color, size, space, style, themeColor, themeTint, themeShade, shadow, frame }) => new BuilderElement({
1336
1382
  attributes: {
1337
1383
  color: {
1338
1384
  key: "w:color",
1339
1385
  value: color === void 0 ? void 0 : hexColorValue(color)
1340
1386
  },
1387
+ frame: {
1388
+ key: "w:frame",
1389
+ value: frame
1390
+ },
1391
+ shadow: {
1392
+ key: "w:shadow",
1393
+ value: shadow
1394
+ },
1341
1395
  size: {
1342
1396
  key: "w:sz",
1343
1397
  value: size === void 0 ? void 0 : eighthPointMeasureValue(size)
@@ -1349,6 +1403,18 @@
1349
1403
  style: {
1350
1404
  key: "w:val",
1351
1405
  value: style
1406
+ },
1407
+ themeColor: {
1408
+ key: "w:themeColor",
1409
+ value: themeColor
1410
+ },
1411
+ themeShade: {
1412
+ key: "w:themeShade",
1413
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
1414
+ },
1415
+ themeTint: {
1416
+ key: "w:themeTint",
1417
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
1352
1418
  }
1353
1419
  },
1354
1420
  name: elementName
@@ -1552,20 +1618,32 @@
1552
1618
  * </xsd:complexType>
1553
1619
  * ```
1554
1620
  */
1555
- const createIndent = ({ start, end, left, right, hanging, firstLine }) => new BuilderElement({
1621
+ const createIndent = ({ start, startChars, end, endChars, left, right, hanging, hangingChars, firstLine, firstLineChars }) => new BuilderElement({
1556
1622
  attributes: {
1557
1623
  end: {
1558
1624
  key: "w:end",
1559
1625
  value: end === void 0 ? void 0 : signedTwipsMeasureValue(end)
1560
1626
  },
1627
+ endChars: {
1628
+ key: "w:endChars",
1629
+ value: endChars === void 0 ? void 0 : decimalNumber(endChars)
1630
+ },
1561
1631
  firstLine: {
1562
1632
  key: "w:firstLine",
1563
1633
  value: firstLine === void 0 ? void 0 : twipsMeasureValue(firstLine)
1564
1634
  },
1635
+ firstLineChars: {
1636
+ key: "w:firstLineChars",
1637
+ value: firstLineChars === void 0 ? void 0 : decimalNumber(firstLineChars)
1638
+ },
1565
1639
  hanging: {
1566
1640
  key: "w:hanging",
1567
1641
  value: hanging === void 0 ? void 0 : twipsMeasureValue(hanging)
1568
1642
  },
1643
+ hangingChars: {
1644
+ key: "w:hangingChars",
1645
+ value: hangingChars === void 0 ? void 0 : decimalNumber(hangingChars)
1646
+ },
1569
1647
  left: {
1570
1648
  key: "w:left",
1571
1649
  value: left === void 0 ? void 0 : signedTwipsMeasureValue(left)
@@ -1577,6 +1655,10 @@
1577
1655
  start: {
1578
1656
  key: "w:start",
1579
1657
  value: start === void 0 ? void 0 : signedTwipsMeasureValue(start)
1658
+ },
1659
+ startChars: {
1660
+ key: "w:startChars",
1661
+ value: startChars === void 0 ? void 0 : decimalNumber(startChars)
1580
1662
  }
1581
1663
  },
1582
1664
  name: "w:ind"
@@ -2027,7 +2109,7 @@
2027
2109
  *
2028
2110
  * Reference: http://officeopenxml.com/WPshading.php
2029
2111
  */
2030
- const createShading = ({ fill, color, type }) => new BuilderElement({
2112
+ const createShading = ({ fill, color, type, themeColor, themeTint, themeShade, themeFill, themeFillTint, themeFillShade }) => new BuilderElement({
2031
2113
  attributes: {
2032
2114
  color: {
2033
2115
  key: "w:color",
@@ -2037,6 +2119,30 @@
2037
2119
  key: "w:fill",
2038
2120
  value: fill === void 0 ? void 0 : hexColorValue(fill)
2039
2121
  },
2122
+ themeColor: {
2123
+ key: "w:themeColor",
2124
+ value: themeColor
2125
+ },
2126
+ themeFill: {
2127
+ key: "w:themeFill",
2128
+ value: themeFill
2129
+ },
2130
+ themeFillShade: {
2131
+ key: "w:themeFillShade",
2132
+ value: themeFillShade === void 0 ? void 0 : uCharHexNumber(themeFillShade)
2133
+ },
2134
+ themeFillTint: {
2135
+ key: "w:themeFillTint",
2136
+ value: themeFillTint === void 0 ? void 0 : uCharHexNumber(themeFillTint)
2137
+ },
2138
+ themeShade: {
2139
+ key: "w:themeShade",
2140
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2141
+ },
2142
+ themeTint: {
2143
+ key: "w:themeTint",
2144
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2145
+ },
2040
2146
  type: {
2041
2147
  key: "w:val",
2042
2148
  value: type
@@ -2215,7 +2321,13 @@
2215
2321
  *
2216
2322
  * @publicApi
2217
2323
  */
2218
- const EmphasisMarkType = { DOT: "dot" };
2324
+ const EmphasisMarkType = {
2325
+ NONE: "none",
2326
+ COMMA: "comma",
2327
+ CIRCLE: "circle",
2328
+ DOT: "dot",
2329
+ UNDER_DOT: "underDot"
2330
+ };
2219
2331
  /**
2220
2332
  * Creates an emphasis mark element for a WordprocessingML document.
2221
2333
  *
@@ -2306,16 +2418,27 @@
2306
2418
  *
2307
2419
  * @example
2308
2420
  * ```typescript
2309
- * new Color("FF0000"); // Red text
2421
+ * new Color("FF0000"); // Red text (backward compatible)
2310
2422
  * new Color("auto"); // Automatic color
2423
+ * new Color({ themeColor: ThemeColor.ACCENT1, themeTint: "99" }); // Theme color with tint
2311
2424
  * ```
2312
2425
  *
2313
2426
  * @internal
2314
2427
  */
2315
2428
  var Color = class extends XmlComponent {
2316
- constructor(color) {
2429
+ constructor(colorOrOptions) {
2317
2430
  super("w:color");
2318
- this.root.push(new Attributes({ val: hexColorValue(color) }));
2431
+ if (typeof colorOrOptions === "string") {
2432
+ this.root.push(new Attributes({ val: hexColorValue(colorOrOptions) }));
2433
+ return;
2434
+ }
2435
+ const opts = colorOrOptions;
2436
+ this.root.push(new Attributes({
2437
+ val: opts.val === void 0 ? void 0 : hexColorValue(opts.val),
2438
+ themeColor: opts.themeColor,
2439
+ themeTint: opts.themeTint === void 0 ? void 0 : uCharHexNumber(opts.themeTint),
2440
+ themeShade: opts.themeShade === void 0 ? void 0 : uCharHexNumber(opts.themeShade)
2441
+ }));
2319
2442
  }
2320
2443
  };
2321
2444
  /**
@@ -2514,18 +2637,34 @@
2514
2637
  key: "w:ascii",
2515
2638
  value: attrs.ascii
2516
2639
  },
2640
+ asciiTheme: {
2641
+ key: "w:asciiTheme",
2642
+ value: attrs.asciiTheme
2643
+ },
2517
2644
  cs: {
2518
2645
  key: "w:cs",
2519
2646
  value: attrs.cs
2520
2647
  },
2648
+ cstheme: {
2649
+ key: "w:cstheme",
2650
+ value: attrs.cstheme
2651
+ },
2521
2652
  eastAsia: {
2522
2653
  key: "w:eastAsia",
2523
2654
  value: attrs.eastAsia
2524
2655
  },
2656
+ eastAsiaTheme: {
2657
+ key: "w:eastAsiaTheme",
2658
+ value: attrs.eastAsiaTheme
2659
+ },
2525
2660
  hAnsi: {
2526
2661
  key: "w:hAnsi",
2527
2662
  value: attrs.hAnsi
2528
2663
  },
2664
+ hAnsiTheme: {
2665
+ key: "w:hAnsiTheme",
2666
+ value: attrs.hAnsiTheme
2667
+ },
2529
2668
  hint: {
2530
2669
  key: "w:hint",
2531
2670
  value: attrs.hint
@@ -2682,12 +2821,24 @@
2682
2821
  * createUnderline(UnderlineType.WAVE, "FF0000");
2683
2822
  * ```
2684
2823
  */
2685
- const createUnderline = (underlineType = UnderlineType.SINGLE, color) => new BuilderElement({
2824
+ const createUnderline = (underlineType = UnderlineType.SINGLE, color, themeColor, themeTint, themeShade) => new BuilderElement({
2686
2825
  attributes: {
2687
2826
  color: {
2688
2827
  key: "w:color",
2689
2828
  value: color === void 0 ? void 0 : hexColorValue(color)
2690
2829
  },
2830
+ themeColor: {
2831
+ key: "w:themeColor",
2832
+ value: themeColor
2833
+ },
2834
+ themeShade: {
2835
+ key: "w:themeShade",
2836
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2837
+ },
2838
+ themeTint: {
2839
+ key: "w:themeTint",
2840
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2841
+ },
2691
2842
  val: {
2692
2843
  key: "w:val",
2693
2844
  value: underlineType
@@ -2839,6 +2990,9 @@
2839
2990
  if (options.doubleStrike !== void 0) this.push(new OnOffElement("w:dstrike", options.doubleStrike));
2840
2991
  if (options.emboss !== void 0) this.push(new OnOffElement("w:emboss", options.emboss));
2841
2992
  if (options.imprint !== void 0) this.push(new OnOffElement("w:imprint", options.imprint));
2993
+ if (options.outline !== void 0) this.push(new OnOffElement("w:outline", options.outline));
2994
+ if (options.shadow !== void 0) this.push(new OnOffElement("w:shadow", options.shadow));
2995
+ if (options.webHidden !== void 0) this.push(new OnOffElement("w:webHidden", options.webHidden));
2842
2996
  if (options.noProof !== void 0) this.push(new OnOffElement("w:noProof", options.noProof));
2843
2997
  if (options.snapToGrid !== void 0) this.push(new OnOffElement("w:snapToGrid", options.snapToGrid));
2844
2998
  if (options.vanish) this.push(new OnOffElement("w:vanish", options.vanish));
@@ -2864,6 +3018,8 @@
2864
3018
  if (options.language) this.push(createLanguageComponent(options.language));
2865
3019
  if (options.specVanish) this.push(new OnOffElement("w:specVanish", options.vanish));
2866
3020
  if (options.math) this.push(new OnOffElement("w:oMath", options.math));
3021
+ if (options.fitText !== void 0) this.push(new NumberValueElement("w:fitText", options.fitText));
3022
+ if (options.complexScript !== void 0) this.push(new OnOffElement("w:cs", options.complexScript));
2867
3023
  if (options.revision) this.push(new RunPropertiesChange(options.revision));
2868
3024
  }
2869
3025
  push(item) {
@@ -3299,18 +3455,6 @@
3299
3455
  * ```
3300
3456
  */
3301
3457
  const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
3302
- /**
3303
- * Encode a string to UTF-8 bytes.
3304
- *
3305
- * This is used to pre-encode XML content before passing to fflate's zipSync,
3306
- * which expects Uint8Array input for text content.
3307
- *
3308
- * The copy via `new Uint8Array()` ensures the returned array uses the
3309
- * current module's Uint8Array constructor, avoiding cross-realm issues
3310
- * in test environments (happy-dom) where TextEncoder returns a different
3311
- * realm's Uint8Array.
3312
- */
3313
- const encodeUtf8 = (str) => new Uint8Array(new TextEncoder().encode(str));
3314
3458
  //#endregion
3315
3459
  //#region src/file/drawing/floating/floating-position.ts
3316
3460
  /**
@@ -6973,7 +7117,7 @@
6973
7117
  * });
6974
7118
  * ```
6975
7119
  */
6976
- const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing }) => new BuilderElement({
7120
+ const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing, beforeLines, afterLines }) => new BuilderElement({
6977
7121
  attributes: {
6978
7122
  after: {
6979
7123
  key: "w:after",
@@ -6983,6 +7127,10 @@
6983
7127
  key: "w:afterAutospacing",
6984
7128
  value: afterAutoSpacing
6985
7129
  },
7130
+ afterLines: {
7131
+ key: "w:afterLines",
7132
+ value: afterLines === void 0 ? void 0 : decimalNumber(afterLines)
7133
+ },
6986
7134
  before: {
6987
7135
  key: "w:before",
6988
7136
  value: before
@@ -6991,6 +7139,10 @@
6991
7139
  key: "w:beforeAutospacing",
6992
7140
  value: beforeAutoSpacing
6993
7141
  },
7142
+ beforeLines: {
7143
+ key: "w:beforeLines",
7144
+ value: beforeLines === void 0 ? void 0 : decimalNumber(beforeLines)
7145
+ },
6994
7146
  line: {
6995
7147
  key: "w:line",
6996
7148
  value: line
@@ -7101,6 +7253,7 @@
7101
7253
  */
7102
7254
  const LeaderType = {
7103
7255
  DOT: "dot",
7256
+ HEAVY: "heavy",
7104
7257
  HYPHEN: "hyphen",
7105
7258
  MIDDLE_DOT: "middleDot",
7106
7259
  NONE: "none",
@@ -21711,13 +21864,12 @@
21711
21864
  const footerFormattedViews = /* @__PURE__ */ new Map();
21712
21865
  const xmlifiedFileMapping = this.xmlifyFile(file, headerFormattedViews, footerFormattedViews, prettifyXml);
21713
21866
  const map = new Map(Object.entries(xmlifiedFileMapping));
21714
- for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = encodeUtf8(subFile.data);
21715
- else files[obj.path] = encodeUtf8(obj.data);
21716
- for (const subFile of overrides) files[subFile.path] = encodeUtf8(subFile.data);
21717
- for (const mediaData of file.Media.Array) if (mediaData.type !== "svg") files[`word/media/${mediaData.fileName}`] = [(0, undio.toUint8Array)(mediaData.data), { level: 0 }];
21718
- else {
21867
+ for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = (0, undio.textToUint8Array)(subFile.data);
21868
+ else files[obj.path] = (0, undio.textToUint8Array)(obj.data);
21869
+ for (const subFile of overrides) files[subFile.path] = (0, undio.textToUint8Array)(subFile.data);
21870
+ for (const mediaData of file.Media.Array) {
21719
21871
  files[`word/media/${mediaData.fileName}`] = [(0, undio.toUint8Array)(mediaData.data), { level: 0 }];
21720
- files[`word/media/${mediaData.fallback.fileName}`] = [(0, undio.toUint8Array)(mediaData.fallback.data), { level: 0 }];
21872
+ if (mediaData.type === "svg") files[`word/media/${mediaData.fallback.fileName}`] = [(0, undio.toUint8Array)(mediaData.fallback.data), { level: 0 }];
21721
21873
  }
21722
21874
  for (const { data: buffer, name, fontKey } of file.FontTable.fontOptionsWithKey) {
21723
21875
  const [nameWithoutExtension] = name.split(".");
@@ -23260,6 +23412,8 @@
23260
23412
  exports.TextWrappingType = TextWrappingType;
23261
23413
  exports.Textbox = Textbox;
23262
23414
  exports.ThematicBreak = ThematicBreak;
23415
+ exports.ThemeColor = ThemeColor;
23416
+ exports.ThemeFont = ThemeFont;
23263
23417
  exports.UnderlineType = UnderlineType;
23264
23418
  exports.VerticalAlign = VerticalAlign;
23265
23419
  exports.VerticalAlignSection = VerticalAlignSection;
@@ -23338,7 +23492,6 @@
23338
23492
  exports.decimalNumber = decimalNumber;
23339
23493
  exports.docPropertiesUniqueNumericIdGen = docPropertiesUniqueNumericIdGen;
23340
23494
  exports.eighthPointMeasureValue = eighthPointMeasureValue;
23341
- exports.encodeUtf8 = encodeUtf8;
23342
23495
  exports.hashedId = hashedId;
23343
23496
  exports.hexColorValue = hexColorValue;
23344
23497
  exports.hpsMeasureValue = hpsMeasureValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-plus",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
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",