@office-open/docx 0.12.3 → 0.13.1

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.mjs CHANGED
@@ -362,6 +362,31 @@ const HighlightColor = {
362
362
  /** Yellow highlight */
363
363
  YELLOW: "yellow"
364
364
  };
365
+ /**
366
+ * Word's highlighter palette — the RGB each {@link HighlightColor} name shows
367
+ * as on screen. `w:highlight` accepts only these fixed names (an off-palette
368
+ * value makes Word refuse the file), so callers encoding an arbitrary color as
369
+ * a highlight must first map it through this table and fall back to run
370
+ * shading when it is off-palette.
371
+ */
372
+ const HIGHLIGHT_PALETTE_RGB = {
373
+ black: "000000",
374
+ blue: "0000FF",
375
+ cyan: "00FFFF",
376
+ green: "00FF00",
377
+ magenta: "FF00FF",
378
+ red: "FF0000",
379
+ yellow: "FFFF00",
380
+ white: "FFFFFF",
381
+ darkBlue: "000080",
382
+ darkCyan: "008080",
383
+ darkGreen: "008000",
384
+ darkMagenta: "800080",
385
+ darkRed: "800000",
386
+ darkYellow: "808000",
387
+ darkGray: "808080",
388
+ lightGray: "C0C0C0"
389
+ };
365
390
  //#endregion
366
391
  //#region src/shared/media/media.ts
367
392
  /**
@@ -381,7 +406,8 @@ const createTransformation = (options) => {
381
406
  x: widthEmu,
382
407
  y: heightEmu
383
408
  },
384
- flip: options.flip,
409
+ flipHorizontal: options.flipHorizontal,
410
+ flipVertical: options.flipVertical,
385
411
  offset: {
386
412
  emus: {
387
413
  x: offsetLeftEmu,
@@ -1003,46 +1029,9 @@ const TableLayoutType = {
1003
1029
  //#endregion
1004
1030
  //#region src/shared/border.ts
1005
1031
  /**
1006
- * Table borders are defined with the <w:tblBorders> element. Child elements of this element specify the kinds of `border`:
1007
- *
1008
- * `bottom`, `end` (`right` in the previous version of the standard), `insideH`, `insideV`, `start` (`left` in the previous version of the standard), and `top`.
1009
- *
1010
- * Reference: http://officeopenxml.com/WPtableBorders.php
1011
- *
1012
- * ## XSD Schema
1013
- * ```xml
1014
- * <xsd:simpleType name="ST_Border">
1015
- * <xsd:restriction base="xsd:string">
1016
- * <xsd:enumeration value="single"/>
1017
- * <xsd:enumeration value="dashDotStroked"/>
1018
- * <xsd:enumeration value="dashed"/>
1019
- * <xsd:enumeration value="dashSmallGap"/>
1020
- * <xsd:enumeration value="dotDash"/>
1021
- * <xsd:enumeration value="dotDotDash"/>
1022
- * <xsd:enumeration value="dotted"/>
1023
- * <xsd:enumeration value="double"/>
1024
- * <xsd:enumeration value="doubleWave"/>
1025
- * <xsd:enumeration value="inset"/>
1026
- * <xsd:enumeration value="nil"/>
1027
- * <xsd:enumeration value="none"/>
1028
- * <xsd:enumeration value="outset"/>
1029
- * <xsd:enumeration value="thick"/>
1030
- * <xsd:enumeration value="thickThinLargeGap"/>
1031
- * <xsd:enumeration value="thickThinMediumGap"/>
1032
- * <xsd:enumeration value="thickThinSmallGap"/>
1033
- * <xsd:enumeration value="thinThickLargeGap"/>
1034
- * <xsd:enumeration value="thinThickMediumGap"/>
1035
- * <xsd:enumeration value="thinThickSmallGap"/>
1036
- * <xsd:enumeration value="thinThickThinLargeGap"/>
1037
- * <xsd:enumeration value="thinThickThinMediumGap"/>
1038
- * <xsd:enumeration value="thinThickThinSmallGap"/>
1039
- * <xsd:enumeration value="threeDEmboss"/>
1040
- * <xsd:enumeration value="threeDEngrave"/>
1041
- * <xsd:enumeration value="triple"/>
1042
- * <xsd:enumeration value="wave"/>
1043
- * </xsd:restriction>
1044
- * </xsd:simpleType>
1045
- * ```
1032
+ * Border style tokens for the `style` field the common line styles Word
1033
+ * renders as line patterns. Child elements of w:tblBorders specify the sides:
1034
+ * `top`, `bottom`, `start`/`left`, `end`/`right`, `insideH`, `insideV`.
1046
1035
  *
1047
1036
  * @publicApi
1048
1037
  */
@@ -1102,15 +1091,15 @@ const BorderStyle = {
1102
1091
  /** A wavy line */
1103
1092
  WAVE: "wave"
1104
1093
  };
1105
- /** Valid border `@w:val` values (ST_Border). */
1106
- const BORDER_STYLES = Object.values(BorderStyle);
1107
1094
  /**
1108
1095
  * Parse one CT_Border side element. Returns undefined when the element is
1109
- * malformed (missing/unknown `@w:val`) so callers skip the side.
1096
+ * malformed (missing `@w:val`) so callers skip the side. Any ST_Border token
1097
+ * passes through — Word's artistic styles (apples, weavingBraid, …) keep the
1098
+ * whole side instead of being dropped.
1110
1099
  */
1111
1100
  function parseBorderSide(sideEl) {
1112
1101
  const style = attr(sideEl, "w:val");
1113
- if (!style || !BORDER_STYLES.includes(style)) return void 0;
1102
+ if (!style) return void 0;
1114
1103
  const sideOpts = { style };
1115
1104
  const color = attr(sideEl, "w:color");
1116
1105
  if (color) sideOpts.color = color;
@@ -3038,7 +3027,7 @@ const altChunkDesc = {
3038
3027
  const partPath = `afchunks/afchunk${relId}.${extension}`;
3039
3028
  const rawData = typeof opts.data === "string" ? toUint8Array(opts.data) : opts.data;
3040
3029
  const data = opts.contentType === "text/html" && typeof opts.data === "string" ? toUint8Array(wrapHtmlDocument(opts.data)) : rawData;
3041
- ctx.fileData.document.relationships.addRelationship(relId, ALTCHUNK_REL_TYPE, partPath);
3030
+ ctx.fileData.document.relationships.addRelationship(`rId${relId}`, ALTCHUNK_REL_TYPE, partPath);
3042
3031
  ctx.fileData.altChunks.addAltChunk(relId, {
3043
3032
  key: relId,
3044
3033
  data,
@@ -3088,7 +3077,7 @@ const subDocDesc = {
3088
3077
  const relId = uniqueId();
3089
3078
  const partPath = `subdocs/subdoc${relId}.docx`;
3090
3079
  const data = toUint8Array(opts.data);
3091
- ctx.fileData.document.relationships.addRelationship(relId, SUBDOC_REL_TYPE, partPath);
3080
+ ctx.fileData.document.relationships.addRelationship(`rId${relId}`, SUBDOC_REL_TYPE, partPath);
3092
3081
  ctx.fileData.subDocs.addSubDoc(relId, {
3093
3082
  data,
3094
3083
  path: partPath
@@ -3324,7 +3313,7 @@ function buildCustomXmlPropertiesXml(pr) {
3324
3313
  function stringifyCustomXmlShell(opts, contentXml) {
3325
3314
  const attrs = [`w:element="${escapeXml(opts.element)}"`];
3326
3315
  if (opts.uri !== void 0) attrs.push(`w:uri="${escapeXml(opts.uri)}"`);
3327
- const prXml = opts.customXmlPr ? buildCustomXmlPropertiesXml(opts.customXmlPr) : "";
3316
+ const prXml = opts.properties ? buildCustomXmlPropertiesXml(opts.properties) : "";
3328
3317
  return `<w:customXml ${attrs.join(" ")}>${prXml}${contentXml}</w:customXml>`;
3329
3318
  }
3330
3319
  const customXmlBlockDesc = {
@@ -3342,7 +3331,7 @@ const customXmlBlockDesc = {
3342
3331
  const uri = attr(el, "w:uri");
3343
3332
  if (uri) opts.uri = uri;
3344
3333
  const xmlPr = findChild(el, "w:customXmlPr");
3345
- if (xmlPr) opts.customXmlPr = parseCustomXmlProperties(xmlPr);
3334
+ if (xmlPr) opts.properties = parseCustomXmlProperties(xmlPr);
3346
3335
  const childList = [];
3347
3336
  for (const child of el.elements ?? []) {
3348
3337
  if (child.name === "w:customXmlPr") continue;
@@ -6252,7 +6241,7 @@ function parseCustomXmlInline(el, ctx) {
6252
6241
  const pr = findChild(el, "w:customXmlPr");
6253
6242
  if (pr) {
6254
6243
  const parsed = parseCustomXmlProperties(pr);
6255
- if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.customXmlPr = parsed;
6244
+ if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.properties = parsed;
6256
6245
  }
6257
6246
  const content = parseContainerChildren(el, ctx);
6258
6247
  if (content.length > 0) cx.children = content;
@@ -6916,6 +6905,8 @@ function parsePictureRun(el, ctx) {
6916
6905
  if (info.altText) imageOpts.altText = info.altText;
6917
6906
  if (info.floating) imageOpts.floating = info.floating;
6918
6907
  if (info.graphicFrameLocks !== void 0) imageOpts.graphicFrameLocks = info.graphicFrameLocks;
6908
+ const cstate = attr(blip, "cstate");
6909
+ if (cstate !== void 0) imageOpts.compression = cstate;
6919
6910
  const blipFill = findFirst(el, "pic:blipFill");
6920
6911
  if (blipFill) {
6921
6912
  const srcRect = readSourceRectangle(blipFill);
@@ -6942,10 +6933,8 @@ function parsePictureRun(el, ctx) {
6942
6933
  if (rot !== void 0) transform.rotation = parseAngle(rot);
6943
6934
  const flipH = attrBool(xfrm, "flipH");
6944
6935
  const flipV = attrBool(xfrm, "flipV");
6945
- if (flipH !== void 0 || flipV !== void 0) transform.flip = {
6946
- ...flipH !== void 0 ? { horizontal: flipH } : {},
6947
- ...flipV !== void 0 ? { vertical: flipV } : {}
6948
- };
6936
+ if (flipH !== void 0) transform.flipHorizontal = flipH;
6937
+ if (flipV !== void 0) transform.flipVertical = flipV;
6949
6938
  }
6950
6939
  }
6951
6940
  const blipResult = blipDesc.parse(blip, ctx);
@@ -7066,16 +7055,29 @@ function readShapeFill(parent, ctx) {
7066
7055
  * the `idx` attribute plus an optional EG_ColorChoice color override.
7067
7056
  */
7068
7057
  function parseStyleRef(el, ctx) {
7069
- const idx = attr(el, "idx");
7058
+ const idx = attrNum(el, "idx");
7070
7059
  if (idx === void 0) return void 0;
7071
- const result = { idx };
7060
+ const result = { index: idx };
7061
+ const color = parseColorChoice(el, ctx);
7062
+ if (color && Object.keys(color).length > 0) result.color = color;
7063
+ return result;
7064
+ }
7065
+ /**
7066
+ * Parse a:fontRef — @idx is ST_FontCollectionIndex (major/minor/none), not a
7067
+ * number, so it reads as a collection slot instead of a matrix index. Off-XSD
7068
+ * tokens drop the reference (core parseFontReference precedent).
7069
+ */
7070
+ function parseFontRef(el, ctx) {
7071
+ const idx = attr(el, "idx");
7072
+ if (idx !== "major" && idx !== "minor" && idx !== "none") return void 0;
7073
+ const result = { collection: idx };
7072
7074
  const color = parseColorChoice(el, ctx);
7073
7075
  if (color && Object.keys(color).length > 0) result.color = color;
7074
7076
  return result;
7075
7077
  }
7076
7078
  /**
7077
7079
  * Parse a wps:style (CT_ShapeStyle): line/fill/effect/font references into the
7078
- * document theme. Delegates color to the shared core {@link parseColorChoice}.
7080
+ * document theme. Delegates color to the shared core parseColorChoice.
7079
7081
  */
7080
7082
  function parseShapeStyle(styleEl, ctx) {
7081
7083
  const result = {};
@@ -7086,7 +7088,7 @@ function parseShapeStyle(styleEl, ctx) {
7086
7088
  const effectRef = findChild(styleEl, "a:effectRef");
7087
7089
  if (effectRef) result.effectReference = parseStyleRef(effectRef, ctx);
7088
7090
  const fontRef = findChild(styleEl, "a:fontRef");
7089
- if (fontRef) result.fontReference = parseStyleRef(fontRef, ctx);
7091
+ if (fontRef) result.fontReference = parseFontRef(fontRef, ctx);
7090
7092
  return result;
7091
7093
  }
7092
7094
  /**
@@ -7161,7 +7163,7 @@ function parseWpsShapeCore(wspEl, ctx) {
7161
7163
  const custGeom = findChild(spPr, "a:custGeom");
7162
7164
  if (custGeom) result.customGeometry = customGeometryDesc.parse(custGeom, ctx);
7163
7165
  const prstGeom = findChild(spPr, "a:prstGeom");
7164
- if (prstGeom) result.presetGeometry = presetGeometryDesc.parse(prstGeom, ctx);
7166
+ if (prstGeom) result.geometry = presetGeometryDesc.parse(prstGeom, ctx);
7165
7167
  const scene3d = findChild(spPr, "a:scene3d");
7166
7168
  if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);
7167
7169
  const sp3d = findChild(spPr, "a:sp3d");
@@ -7224,12 +7226,8 @@ function readChildTransformation(spPr) {
7224
7226
  }
7225
7227
  const flipH = attrBool(xfrm, "flipH");
7226
7228
  const flipV = attrBool(xfrm, "flipV");
7227
- if (flipH !== void 0 || flipV !== void 0) {
7228
- const flip = {};
7229
- if (flipH !== void 0) flip.horizontal = flipH;
7230
- if (flipV !== void 0) flip.vertical = flipV;
7231
- result.flip = flip;
7232
- }
7229
+ if (flipH !== void 0) result.flipHorizontal = flipH;
7230
+ if (flipV !== void 0) result.flipVertical = flipV;
7233
7231
  const rot = attrNum(xfrm, "rot");
7234
7232
  if (rot !== void 0) result.rotation = rot;
7235
7233
  return result;
@@ -7375,7 +7373,7 @@ function parseWpgGroupDrawing(el, ctx) {
7375
7373
  if (!wgp) return void 0;
7376
7374
  const info = parseAnchorOrInline(el, ctx) ?? {};
7377
7375
  const grpSpPr = findChild(wgp, "wpg:grpSpPr");
7378
- const { childOffset, childExtent } = readGroupCoords(grpSpPr);
7376
+ const { childOffsetX, childOffsetY, childExtentWidth, childExtentHeight } = readGroupCoords(grpSpPr);
7379
7377
  const group = {
7380
7378
  children: parseGroupChildren(wgp, ctx),
7381
7379
  transformation: {
@@ -7384,8 +7382,10 @@ function parseWpgGroupDrawing(el, ctx) {
7384
7382
  ...info.effectExtent ? { effectExtent: info.effectExtent } : {}
7385
7383
  }
7386
7384
  };
7387
- if (childOffset) group.childOffset = childOffset;
7388
- if (childExtent) group.childExtent = childExtent;
7385
+ if (childOffsetX !== void 0) group.childOffsetX = childOffsetX;
7386
+ if (childOffsetY !== void 0) group.childOffsetY = childOffsetY;
7387
+ if (childExtentWidth !== void 0) group.childExtentWidth = childExtentWidth;
7388
+ if (childExtentHeight !== void 0) group.childExtentHeight = childExtentHeight;
7389
7389
  if (info.floating) group.floating = info.floating;
7390
7390
  if (info.altText) group.altText = info.altText;
7391
7391
  if (info.graphicFrameLocks !== void 0) group.graphicFrameLocks = info.graphicFrameLocks;
@@ -7407,22 +7407,18 @@ function readGroupCoords(grpSpPr) {
7407
7407
  if (!grpSpPr) return {};
7408
7408
  const xfrm = findChild(grpSpPr, "a:xfrm");
7409
7409
  if (!xfrm) return {};
7410
- let childOffset;
7411
- let childExtent;
7410
+ const result = {};
7412
7411
  const off = findChild(xfrm, "a:chOff");
7413
- if (off?.attributes) childOffset = {
7414
- x: Number(off.attributes["x"] ?? 0),
7415
- y: Number(off.attributes["y"] ?? 0)
7416
- };
7412
+ if (off?.attributes) {
7413
+ result.childOffsetX = Number(off.attributes["x"] ?? 0);
7414
+ result.childOffsetY = Number(off.attributes["y"] ?? 0);
7415
+ }
7417
7416
  const ext = findChild(xfrm, "a:chExt");
7418
- if (ext?.attributes) childExtent = {
7419
- cx: Number(ext.attributes["cx"] ?? 0),
7420
- cy: Number(ext.attributes["cy"] ?? 0)
7421
- };
7422
- return {
7423
- childOffset,
7424
- childExtent
7425
- };
7417
+ if (ext?.attributes) {
7418
+ result.childExtentWidth = Number(ext.attributes["cx"] ?? 0);
7419
+ result.childExtentHeight = Number(ext.attributes["cy"] ?? 0);
7420
+ }
7421
+ return result;
7426
7422
  }
7427
7423
  /**
7428
7424
  * Parse the children of a group element (CT_WordprocessingGroup choice):
@@ -7561,14 +7557,16 @@ function parseContentPart(el) {
7561
7557
  */
7562
7558
  function parseNestedGroup(grpSpEl, ctx) {
7563
7559
  const grpSpPr = findChild(grpSpEl, "wpg:grpSpPr");
7564
- const { childOffset, childExtent } = readGroupCoords(grpSpPr);
7560
+ const { childOffsetX, childOffsetY, childExtentWidth, childExtentHeight } = readGroupCoords(grpSpPr);
7565
7561
  const result = {
7566
7562
  type: "wpg",
7567
7563
  transformation: readChildTransformation(grpSpPr),
7568
7564
  children: parseGroupChildren(grpSpEl, ctx)
7569
7565
  };
7570
- if (childOffset) result.childOffset = childOffset;
7571
- if (childExtent) result.childExtent = childExtent;
7566
+ if (childOffsetX !== void 0) result.childOffsetX = childOffsetX;
7567
+ if (childOffsetY !== void 0) result.childOffsetY = childOffsetY;
7568
+ if (childExtentWidth !== void 0) result.childExtentWidth = childExtentWidth;
7569
+ if (childExtentHeight !== void 0) result.childExtentHeight = childExtentHeight;
7572
7570
  const grpSpLocks = readGrpSpLocks(findChild(grpSpEl, "wpg:cNvGrpSpPr"));
7573
7571
  if (grpSpLocks) result.groupShapeLocks = grpSpLocks;
7574
7572
  if (grpSpPr) {
@@ -7920,16 +7918,8 @@ function buildUseLocalDpiExt(useLocalDpi) {
7920
7918
  function registerHyperlinks(hyperlink, ctx) {
7921
7919
  if (!hyperlink) return {};
7922
7920
  const result = {};
7923
- if (hyperlink.click) {
7924
- const linkId = uniqueId();
7925
- ctx.viewWrapper.relationships.addRelationship(linkId, HYPERLINK_REL, hyperlink.click, TargetModeType.EXTERNAL);
7926
- result.clickId = `rId${linkId}`;
7927
- }
7928
- if (hyperlink.hover) {
7929
- const linkId = uniqueId();
7930
- ctx.viewWrapper.relationships.addRelationship(linkId, HYPERLINK_REL, hyperlink.hover, TargetModeType.EXTERNAL);
7931
- result.hoverId = `rId${linkId}`;
7932
- }
7921
+ if (hyperlink.click) result.clickId = `rId${ctx.viewWrapper.relationships.add(HYPERLINK_REL, hyperlink.click, TargetModeType.EXTERNAL)}`;
7922
+ if (hyperlink.hover) result.hoverId = `rId${ctx.viewWrapper.relationships.add(HYPERLINK_REL, hyperlink.hover, TargetModeType.EXTERNAL)}`;
7933
7923
  return result;
7934
7924
  }
7935
7925
  function buildHyperlinkChildren(ids) {
@@ -7958,6 +7948,7 @@ function stringifyBlipFill(mediaData, blipEffects, tile, ctx) {
7958
7948
  const parts = [];
7959
7949
  const blipAttrs = [];
7960
7950
  if (fileName !== void 0) blipAttrs.push(`r:embed="{${escapeXml(fileName)}}"`);
7951
+ if (mediaData.compression !== void 0) blipAttrs.push(`cstate="${escapeXml(mediaData.compression)}"`);
7961
7952
  if (mediaData.sourceUrl !== void 0 && ctx) {
7962
7953
  const linkId = ctx.viewWrapper.relationships.add(IMAGE_REL, mediaData.sourceUrl, TargetModeType.EXTERNAL);
7963
7954
  blipAttrs.push(`r:link="rId${linkId}"`);
@@ -7989,8 +7980,8 @@ function stringifyShapeProps(transform, outline, fill, effects, scene3d, shape3d
7989
7980
  y: transform.offset?.emus?.y ?? 0,
7990
7981
  width: transform.emus.x,
7991
7982
  height: transform.emus.y,
7992
- flipHorizontal: transform.flip?.horizontal,
7993
- flipVertical: transform.flip?.vertical,
7983
+ flipHorizontal: transform.flipHorizontal,
7984
+ flipVertical: transform.flipVertical,
7994
7985
  rotation: transform.rotation,
7995
7986
  geometry: "rect",
7996
7987
  fill,
@@ -8032,11 +8023,11 @@ function stringifyWpsShape(opts, ctx) {
8032
8023
  y: transform.offset?.emus?.y ?? 0,
8033
8024
  width: transform.emus.x,
8034
8025
  height: transform.emus.y,
8035
- flipHorizontal: transform.flip?.horizontal,
8036
- flipVertical: transform.flip?.vertical,
8026
+ flipHorizontal: transform.flipHorizontal,
8027
+ flipVertical: transform.flipVertical,
8037
8028
  rotation: transform.rotation,
8038
8029
  customGeometry: opts.customGeometry,
8039
- geometry: opts.customGeometry ? void 0 : opts.presetGeometry ?? "rect",
8030
+ geometry: opts.customGeometry ? void 0 : opts.geometry ?? "rect",
8040
8031
  fill: opts.fill,
8041
8032
  outline: opts.outline,
8042
8033
  effectDag: opts.effectDag,
@@ -8085,14 +8076,20 @@ function stringifyNonVisualShapeProperties(opts) {
8085
8076
  /** Stringify a single style-matrix reference (a:lnRef/a:fillRef/...). */
8086
8077
  function stringifyStyleRef(name, ref) {
8087
8078
  if (!ref) return "";
8088
- const idx = escapeXml(ref.idx);
8089
8079
  const colorXml = ref.color ? createColorElement(ref.color) : "";
8090
- if (colorXml) return `<${name} idx="${idx}">${colorXml}</${name}>`;
8091
- return `<${name} idx="${idx}"/>`;
8080
+ if (colorXml) return `<${name} idx="${ref.index}">${colorXml}</${name}>`;
8081
+ return `<${name} idx="${ref.index}"/>`;
8082
+ }
8083
+ /** Stringify a:fontRef — @idx is ST_FontCollectionIndex, not a number. */
8084
+ function stringifyFontRef(ref) {
8085
+ if (!ref) return "";
8086
+ const colorXml = ref.color ? createColorElement(ref.color) : "";
8087
+ if (colorXml) return `<a:fontRef idx="${escapeXml(ref.collection)}">${colorXml}</a:fontRef>`;
8088
+ return `<a:fontRef idx="${escapeXml(ref.collection)}"/>`;
8092
8089
  }
8093
8090
  /** Stringify a wps:style (CT_ShapeStyle): lnRef/fillRef/effectRef/fontRef. */
8094
8091
  function stringifyShapeStyle(opts) {
8095
- const inner = stringifyStyleRef("a:lnRef", opts.lineReference) + stringifyStyleRef("a:fillRef", opts.fillReference) + stringifyStyleRef("a:effectRef", opts.effectReference) + stringifyStyleRef("a:fontRef", opts.fontReference);
8092
+ const inner = stringifyStyleRef("a:lnRef", opts.lineReference) + stringifyStyleRef("a:fillRef", opts.fillReference) + stringifyStyleRef("a:effectRef", opts.effectReference) + stringifyFontRef(opts.fontReference);
8096
8093
  return inner ? `<wps:style>${inner}</wps:style>` : "";
8097
8094
  }
8098
8095
  function stringifyBodyPr(opts) {
@@ -8105,13 +8102,13 @@ function stringifyWpgGroup(opts, ctx) {
8105
8102
  y: transform.offset?.emus?.y ?? 0,
8106
8103
  width: transform.emus.x,
8107
8104
  height: transform.emus.y,
8108
- flipHorizontal: transform.flip?.horizontal,
8109
- flipVertical: transform.flip?.vertical,
8105
+ flipHorizontal: transform.flipHorizontal,
8106
+ flipVertical: transform.flipVertical,
8110
8107
  rotation: transform.rotation,
8111
- childOffsetX: opts.childOffset?.x,
8112
- childOffsetY: opts.childOffset?.y,
8113
- childExtentWidth: opts.childExtent?.cx,
8114
- childExtentHeight: opts.childExtent?.cy,
8108
+ childOffsetX: opts.childOffsetX,
8109
+ childOffsetY: opts.childOffsetY,
8110
+ childExtentWidth: opts.childExtentWidth,
8111
+ childExtentHeight: opts.childExtentHeight,
8115
8112
  fill: opts.fill,
8116
8113
  effects: opts.effects
8117
8114
  }, ctx) ?? "";
@@ -8187,7 +8184,7 @@ function stringifyCnvFrPr(locks) {
8187
8184
  function stringifyChildXfrm(prefix, t) {
8188
8185
  const x = t.offset?.emus?.x ?? 0;
8189
8186
  const y = t.offset?.emus?.y ?? 0;
8190
- return `<${prefix}:xfrm${(t.flip?.horizontal ? " flipH=\"1\"" : "") + (t.flip?.vertical ? " flipV=\"1\"" : "")}${t.rotation !== void 0 ? ` rot="${t.rotation}"` : ""}><a:off x="${x}" y="${y}"/><a:ext cx="${t.emus.x}" cy="${t.emus.y}"/></${prefix}:xfrm>`;
8187
+ return `<${prefix}:xfrm${(t.flipHorizontal ? " flipH=\"1\"" : "") + (t.flipVertical ? " flipV=\"1\"" : "")}${t.rotation !== void 0 ? ` rot="${t.rotation}"` : ""}><a:off x="${x}" y="${y}"/><a:ext cx="${t.emus.x}" cy="${t.emus.y}"/></${prefix}:xfrm>`;
8191
8188
  }
8192
8189
  /**
8193
8190
  * Stringify a wpg:contentPart child (CT_WordprocessingContentPart) inside a
@@ -8213,13 +8210,13 @@ function stringifyNestedGroup(grp, ctx) {
8213
8210
  y: grp.transformation.offset?.emus?.y ?? 0,
8214
8211
  width: grp.transformation.emus.x,
8215
8212
  height: grp.transformation.emus.y,
8216
- flipHorizontal: grp.transformation.flip?.horizontal,
8217
- flipVertical: grp.transformation.flip?.vertical,
8213
+ flipHorizontal: grp.transformation.flipHorizontal,
8214
+ flipVertical: grp.transformation.flipVertical,
8218
8215
  rotation: grp.transformation.rotation,
8219
- childOffsetX: grp.childOffset?.x,
8220
- childOffsetY: grp.childOffset?.y,
8221
- childExtentWidth: grp.childExtent?.cx,
8222
- childExtentHeight: grp.childExtent?.cy,
8216
+ childOffsetX: grp.childOffsetX,
8217
+ childOffsetY: grp.childOffsetY,
8218
+ childExtentWidth: grp.childExtentWidth,
8219
+ childExtentHeight: grp.childExtentHeight,
8223
8220
  fill: grp.fill,
8224
8221
  effects: grp.effects
8225
8222
  }, ctx) ?? "";
@@ -8248,8 +8245,10 @@ function stringifyGraphicDataContent(mediaData, opts, hlIds, ctx) {
8248
8245
  const wpgXml = stringifyWpgGroup({
8249
8246
  children: md.children,
8250
8247
  transformation: transform,
8251
- childOffset: md.childOffset,
8252
- childExtent: md.childExtent,
8248
+ childOffsetX: md.childOffsetX,
8249
+ childOffsetY: md.childOffsetY,
8250
+ childExtentWidth: md.childExtentWidth,
8251
+ childExtentHeight: md.childExtentHeight,
8253
8252
  fill: md.fill,
8254
8253
  effects: md.effects,
8255
8254
  groupShapeLocks: md.groupShapeLocks
@@ -8938,7 +8937,8 @@ function stringifyChildDispatch(child, ctx) {
8938
8937
  transformation: createTransformation(opts.transformation),
8939
8938
  sourceRectangle: opts.sourceRectangle,
8940
8939
  nonVisualProperties: opts.nonVisualProperties,
8941
- useLocalDpi: opts.useLocalDpi
8940
+ useLocalDpi: opts.useLocalDpi,
8941
+ compression: opts.compression
8942
8942
  },
8943
8943
  docProperties: opts.altText,
8944
8944
  floating: opts.floating,
@@ -8964,6 +8964,7 @@ function stringifyChildDispatch(child, ctx) {
8964
8964
  type: "svg",
8965
8965
  ...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
8966
8966
  useLocalDpi: opts.useLocalDpi,
8967
+ compression: opts.compression,
8967
8968
  fallback
8968
8969
  }), opts.fileName);
8969
8970
  } else {
@@ -8972,6 +8973,7 @@ function stringifyChildDispatch(child, ctx) {
8972
8973
  type,
8973
8974
  ...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
8974
8975
  useLocalDpi: opts.useLocalDpi,
8976
+ compression: opts.compression,
8975
8977
  sourceUrl: opts.sourceUrl
8976
8978
  }), opts.fileName);
8977
8979
  }
@@ -9099,8 +9101,10 @@ function stringifyChildDispatch(child, ctx) {
9099
9101
  const mediaData = {
9100
9102
  children: opts.children,
9101
9103
  transformation: createTransformation(opts.transformation),
9102
- childOffset: opts.childOffset,
9103
- childExtent: opts.childExtent,
9104
+ childOffsetX: opts.childOffsetX,
9105
+ childOffsetY: opts.childOffsetY,
9106
+ childExtentWidth: opts.childExtentWidth,
9107
+ childExtentHeight: opts.childExtentHeight,
9104
9108
  fill: opts.fill,
9105
9109
  effects: opts.effects,
9106
9110
  groupShapeLocks: opts.groupShapeLocks,
@@ -10524,7 +10528,7 @@ function parseTableRowEl(el, ctx) {
10524
10528
  const xmlPr = findChild(child, "w:customXmlPr");
10525
10529
  if (xmlPr) {
10526
10530
  const parsed = parseCustomXmlProperties(xmlPr);
10527
- if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.customXmlPr = parsed;
10531
+ if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.properties = parsed;
10528
10532
  }
10529
10533
  const cxCells = [];
10530
10534
  for (const sub of child.elements ?? []) if (sub.name === "w:tc") cxCells.push(parseTableCellEl(sub, ctx));
@@ -10577,7 +10581,7 @@ function parseTableEl(el, ctx) {
10577
10581
  const xmlPr = findChild(child, "w:customXmlPr");
10578
10582
  if (xmlPr) {
10579
10583
  const parsed = parseCustomXmlProperties(xmlPr);
10580
- if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.customXmlPr = parsed;
10584
+ if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.properties = parsed;
10581
10585
  }
10582
10586
  const cxRows = [];
10583
10587
  for (const sub of child.elements ?? []) if (sub.name === "w:tr") cxRows.push(parseTableRowEl(sub, ctx));
@@ -13983,7 +13987,7 @@ function parseCustomXmlBlock(el, ctx, parseChild) {
13983
13987
  const uri = attr(el, "w:uri");
13984
13988
  if (uri) opts.uri = uri;
13985
13989
  const xmlPr = findChild(el, "w:customXmlPr");
13986
- if (xmlPr) opts.customXmlPr = parseCustomXmlProperties(xmlPr);
13990
+ if (xmlPr) opts.properties = parseCustomXmlProperties(xmlPr);
13987
13991
  const children = [];
13988
13992
  for (const child of el.elements ?? []) {
13989
13993
  if (child.name === "w:customXmlPr") continue;
@@ -14217,6 +14221,7 @@ var DocxWriteContext = class {
14217
14221
  relationships: new Relationships(),
14218
14222
  partName: "word/document.xml"
14219
14223
  };
14224
+ this.document.relationships.reserveSourceRids("word/document.xml", options.passthroughRelationships ?? []);
14220
14225
  this._settingsOptions = {
14221
14226
  displayBackgroundShape: options.background?.image ? true : void 0,
14222
14227
  ...options.settings
@@ -15665,6 +15670,8 @@ const bibliographyDesc = {
15665
15670
  /** Gallery type for building blocks (ST_DocPartGallery) */
15666
15671
  const DocPartGallery = {
15667
15672
  PLACEHOLDER: "placeholder",
15673
+ /** Matches any gallery — used by docPartObj references without a specific gallery. */
15674
+ ANY: "any",
15668
15675
  DEFAULT: "default",
15669
15676
  DOC_PARTS: "docParts",
15670
15677
  COVER_PAGE: "coverPg",
@@ -19377,6 +19384,6 @@ function generateDocumentStream(options, packerOptions) {
19377
19384
  return Packer.toStream(options, packerOptions);
19378
19385
  }
19379
19386
  //#endregion
19380
- export { AlignmentType, AltChunkCollection, BorderStyle, BreakType, COMMENTS_NS, CharacterSet, DefaultStylesFactory, DocPartBehavior, DocPartGallery, DocPartType, DocumentAttributeNamespaces, DocumentGridType, DocxReadContext, DocxWriteContext, DropCapType, EMPTY_RUN_ELEMENTS, EditGroupType, EmphasisMarkType, FormFieldTextType, FrameAnchorType, FrameWrap, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HyperlinkType, LeaderType, LevelFormat, LevelSuffix, LineNumberRestartFormat, LineRuleType, Media, NumberFormat, Numbering, OverlapType, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageNumber, PageNumberSeparator, PageOrientation, PageTextDirectionType, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, ProofErrorType, RelativeHorizontalPosition, RelativeVerticalPosition, RubyAlign, SdtDateMappingType, SdtLock, SectionType, ShadingType, SpaceType, StyleLevel, Styles, SubDocCollection, TABLE_BORDERS_NONE, TabStopPosition, TabStopType, TableAnchorType, TableLayoutType, TargetScreenSize, TextAlignmentType, TextDirection, TextEffect, TextWrappingSide, TextWrappingType, TextboxTightWrapType, UnderlineType, VerticalAlignSection, VerticalAlignTable, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WidthType, altChunkDesc, appPropertiesDesc, bibliographyDesc, bodyPropertiesDesc, breakXml, buildBookmarkStartAttrs, buildMarkupRangeAttrs, buildNumIdCache, buildNumberingCache, buildStyleCache, checkboxSymbolRunInner, commentsDesc, commentsExtendedDesc, compileDocument, corePropertiesDesc, createBodyProperties, createDocumentGrid, createFormFieldData, createHorizontalPosition, createLineNumberType, createPageMargin, createPageNumberType, createPictureData, createSectionType, createTransformation, createVerticalPosition, createWrapThrough, createWrapTight, customPropertiesDesc, customXmlBlockDesc, documentNamespaceAttributes, documentNamespaceRecord, drawingDesc, endnotesDesc, extractStyleId, fontTableDesc, footnotesDesc, frameXml, framesetXml, generateDocument, generateDocumentStream, generateDocumentSync, glossaryDesc, keepTocClosingParagraph, objectDesc, parseArchive, parseBodyProperties, parseBorderSide, parseCustomXmlProperties, parseDocument, parseDocx, parseFormFieldData, parseNumberingDefinitions, parsePict, parseRegisteredBodyChild, parseSdtBlock, parseSdtProperties, parseSectionPropertiesEl, parseShading, parseStyleDefinitions, parseTableCellPropertiesEl, parseTablePropertiesEl, parseTableRowPropertiesEl, parseToc, parseTocFieldFromElements, parseTocFieldInstruction, patchDetector, patchDocument, peopleDesc, resetDrawingIdGen, sdtBlockDesc, sectionMarginDefaults, sectionPageSizeDefaults, sectionPropertiesDesc, selectTocEntryElements, setBodyParseChild, setTableParseChild, settingsDesc, stringifyCharacterStyle, stringifyChildDispatch, stringifyConditionalTableStyle, stringifyCustomXmlShell, stringifyDocDefaults, stringifyNumberingStyle, stringifyParagraphInline, stringifyParagraphStyle, stringifyPict, stringifyRunInline, stringifySdtPr, stringifySdtShell, stringifySectionProperties, stringifyTableOfContents, stringifyTableStyle, subDocDesc, tableDesc, webSettingsDesc, widthFiftiethsToPct, widthPctToFiftieths };
19387
+ export { AlignmentType, AltChunkCollection, BorderStyle, BreakType, COMMENTS_NS, CharacterSet, DefaultStylesFactory, DocPartBehavior, DocPartGallery, DocPartType, DocumentAttributeNamespaces, DocumentGridType, DocxReadContext, DocxWriteContext, DropCapType, EMPTY_RUN_ELEMENTS, EditGroupType, EmphasisMarkType, FormFieldTextType, FrameAnchorType, FrameWrap, HIGHLIGHT_PALETTE_RGB, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HyperlinkType, LeaderType, LevelFormat, LevelSuffix, LineNumberRestartFormat, LineRuleType, Media, NumberFormat, Numbering, OverlapType, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageNumber, PageNumberSeparator, PageOrientation, PageTextDirectionType, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, ProofErrorType, RelativeHorizontalPosition, RelativeVerticalPosition, RubyAlign, SdtDateMappingType, SdtLock, SectionType, ShadingType, SpaceType, StyleLevel, Styles, SubDocCollection, TABLE_BORDERS_NONE, TabStopPosition, TabStopType, TableAnchorType, TableLayoutType, TargetScreenSize, TextAlignmentType, TextDirection, TextEffect, TextWrappingSide, TextWrappingType, TextboxTightWrapType, UnderlineType, VerticalAlignSection, VerticalAlignTable, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WidthType, altChunkDesc, appPropertiesDesc, bibliographyDesc, bodyPropertiesDesc, breakXml, buildBookmarkStartAttrs, buildMarkupRangeAttrs, buildNumIdCache, buildNumberingCache, buildStyleCache, checkboxSymbolRunInner, commentsDesc, commentsExtendedDesc, compileDocument, corePropertiesDesc, createBodyProperties, createDocumentGrid, createFormFieldData, createHorizontalPosition, createLineNumberType, createPageMargin, createPageNumberType, createPictureData, createSectionType, createTransformation, createVerticalPosition, createWrapThrough, createWrapTight, customPropertiesDesc, customXmlBlockDesc, documentNamespaceAttributes, documentNamespaceRecord, drawingDesc, endnotesDesc, extractStyleId, fontTableDesc, footnotesDesc, frameXml, framesetXml, generateDocument, generateDocumentStream, generateDocumentSync, glossaryDesc, keepTocClosingParagraph, objectDesc, parseArchive, parseBodyProperties, parseBorderSide, parseCustomXmlProperties, parseDocument, parseDocx, parseFormFieldData, parseNumberingDefinitions, parsePict, parseRegisteredBodyChild, parseSdtBlock, parseSdtProperties, parseSectionPropertiesEl, parseShading, parseStyleDefinitions, parseTableCellPropertiesEl, parseTablePropertiesEl, parseTableRowPropertiesEl, parseToc, parseTocFieldFromElements, parseTocFieldInstruction, patchDetector, patchDocument, peopleDesc, resetDrawingIdGen, sdtBlockDesc, sectionMarginDefaults, sectionPageSizeDefaults, sectionPropertiesDesc, selectTocEntryElements, setBodyParseChild, setTableParseChild, settingsDesc, stringifyCharacterStyle, stringifyChildDispatch, stringifyConditionalTableStyle, stringifyCustomXmlShell, stringifyDocDefaults, stringifyNumberingStyle, stringifyParagraphInline, stringifyParagraphStyle, stringifyPict, stringifyRunInline, stringifySdtPr, stringifySdtShell, stringifySectionProperties, stringifyTableOfContents, stringifyTableStyle, subDocDesc, tableDesc, webSettingsDesc, widthFiftiethsToPct, widthPctToFiftieths };
19381
19388
 
19382
19389
  //# sourceMappingURL=index.mjs.map