docx-plus 0.0.13 → 0.1.0

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(HorizontalPositionAlign.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(VerticalPositionAlign.TOP);
8987
8987
  })()],
8988
8988
  name: "wp:positionV"
8989
8989
  });
@@ -9697,6 +9697,44 @@ const createSolidFill = (options) => new BuilderElement({
9697
9697
  name: "a:solidFill"
9698
9698
  });
9699
9699
  //#endregion
9700
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/fill-overlay.ts
9701
+ /**
9702
+ * Fill overlay effect for DrawingML shapes.
9703
+ *
9704
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_FillOverlayEffect
9705
+ *
9706
+ * @module
9707
+ */
9708
+ /**
9709
+ * Creates a fill overlay effect element.
9710
+ *
9711
+ * ## XSD Schema
9712
+ * ```xml
9713
+ * <xsd:complexType name="CT_FillOverlayEffect">
9714
+ * <xsd:sequence>
9715
+ * <xsd:group ref="EG_FillProperties" minOccurs="1" maxOccurs="1"/>
9716
+ * </xsd:sequence>
9717
+ * <xsd:attribute name="blend" type="ST_BlendMode" use="required"/>
9718
+ * </xsd:complexType>
9719
+ * ```
9720
+ *
9721
+ * @example
9722
+ * ```typescript
9723
+ * const fillOverlay = createFillOverlayEffect({
9724
+ * blend: BlendMode.MULTIPLY,
9725
+ * color: { value: "FF0000" },
9726
+ * });
9727
+ * ```
9728
+ */
9729
+ const createFillOverlayEffect = (options) => new BuilderElement({
9730
+ attributes: { blend: {
9731
+ key: "blend",
9732
+ value: options.blend
9733
+ } },
9734
+ children: [createSolidFill(options.color)],
9735
+ name: "a:fillOverlay"
9736
+ });
9737
+ //#endregion
9700
9738
  //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/glow.ts
9701
9739
  /**
9702
9740
  * Glow effect for DrawingML shapes.
@@ -9733,7 +9771,7 @@ const createGlowEffect = (options) => {
9733
9771
  });
9734
9772
  };
9735
9773
  //#endregion
9736
- //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/inner-shdw.ts
9774
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/inner-shadow.ts
9737
9775
  /**
9738
9776
  * Inner shadow effect for DrawingML shapes.
9739
9777
  *
@@ -9781,7 +9819,7 @@ const createInnerShadowEffect = (options) => {
9781
9819
  });
9782
9820
  };
9783
9821
  //#endregion
9784
- //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/outer-shdw.ts
9822
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/outer-shadow.ts
9785
9823
  /**
9786
9824
  * Outer shadow effect for DrawingML shapes.
9787
9825
  *
@@ -9869,7 +9907,7 @@ const createOuterShadowEffect = (options) => {
9869
9907
  });
9870
9908
  };
9871
9909
  //#endregion
9872
- //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/prst-shdw.ts
9910
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/preset-shadow.ts
9873
9911
  /**
9874
9912
  * Preset shadow effect for DrawingML shapes.
9875
9913
  *
@@ -10123,10 +10161,11 @@ const createBlurEffect = (options) => {
10123
10161
  const createEffectList = (options) => {
10124
10162
  const children = [];
10125
10163
  if (options.blur) children.push(createBlurEffect(options.blur));
10164
+ if (options.fillOverlay) children.push(createFillOverlayEffect(options.fillOverlay));
10126
10165
  if (options.glow) children.push(createGlowEffect(options.glow));
10127
- if (options.innerShdw) children.push(createInnerShadowEffect(options.innerShdw));
10128
- if (options.outerShdw) children.push(createOuterShadowEffect(options.outerShdw));
10129
- if (options.prstShdw) children.push(createPresetShadowEffect(options.prstShdw));
10166
+ if (options.innerShadow) children.push(createInnerShadowEffect(options.innerShadow));
10167
+ if (options.outerShadow) children.push(createOuterShadowEffect(options.outerShadow));
10168
+ if (options.presetShadow) children.push(createPresetShadowEffect(options.presetShadow));
10130
10169
  if (options.reflection) children.push(createReflectionEffect(options.reflection === true ? void 0 : options.reflection));
10131
10170
  if (options.softEdge !== void 0) children.push(createSoftEdgeEffect(options.softEdge));
10132
10171
  return new BuilderElement({
@@ -10562,10 +10601,13 @@ const LineJoin = {
10562
10601
  };
10563
10602
  /**
10564
10603
  * Creates the fill child element for an outline.
10604
+ *
10605
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
10565
10606
  */
10566
10607
  const createOutlineFill = (options) => {
10567
10608
  if (options.type === "noFill") return createNoFill();
10568
- return createSolidFill(options.color);
10609
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
10610
+ return null;
10569
10611
  };
10570
10612
  /**
10571
10613
  * Creates an outline element for DrawingML shapes.
@@ -10601,7 +10643,8 @@ const createOutlineFill = (options) => {
10601
10643
  */
10602
10644
  const createOutline = (options) => {
10603
10645
  const children = [];
10604
- children.push(createOutlineFill(options));
10646
+ const fill = createOutlineFill(options);
10647
+ if (fill) children.push(fill);
10605
10648
  if (options.dash !== void 0) children.push(new BuilderElement({
10606
10649
  attributes: { val: {
10607
10650
  key: "val",
@@ -10913,12 +10956,12 @@ const createShape3D = (options) => {
10913
10956
  const children = [];
10914
10957
  if (options.bevelT) children.push(createBevel(options.bevelT));
10915
10958
  if (options.bevelB) children.push(createBottomBevel(options.bevelB));
10916
- if (options.extrusionClr) children.push(new BuilderElement({
10917
- children: [createColorElement(options.extrusionClr)],
10959
+ if (options.extrusionColor) children.push(new BuilderElement({
10960
+ children: [createColorElement(options.extrusionColor)],
10918
10961
  name: "a:extrusionClr"
10919
10962
  }));
10920
- if (options.contourClr) children.push(new BuilderElement({
10921
- children: [createColorElement(options.contourClr)],
10963
+ if (options.contourColor) children.push(new BuilderElement({
10964
+ children: [createColorElement(options.contourColor)],
10922
10965
  name: "a:contourClr"
10923
10966
  }));
10924
10967
  return new BuilderElement({
@@ -10992,7 +11035,6 @@ var ShapeProperties = class extends XmlComponent {
10992
11035
  if (noFill) this.root.push(createNoFill());
10993
11036
  else if (solidFill) this.root.push(createSolidFill(solidFill));
10994
11037
  else if (gradientFill) this.root.push(createGradientFill(gradientFill));
10995
- else if (outline) this.root.push(createNoFill());
10996
11038
  if (outline) this.root.push(createOutline(outline));
10997
11039
  if (effects) this.root.push(createEffectList(effects));
10998
11040
  if (shape3d) this.root.push(createShape3D(shape3d));
@@ -11105,6 +11147,158 @@ var GraphicDataAttributes = class extends XmlAttributeComponent {
11105
11147
  }
11106
11148
  };
11107
11149
  //#endregion
11150
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-effects.ts
11151
+ /**
11152
+ * Blip image adjustment effects for DrawingML.
11153
+ *
11154
+ * These effects are applied directly to the image data within the `<a:blip>` element,
11155
+ * corresponding to Word's "Picture Format > Adjust" features (brightness, contrast,
11156
+ * grayscale, tint, duotone, etc.).
11157
+ *
11158
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Blip children
11159
+ *
11160
+ * @module
11161
+ */
11162
+ /**
11163
+ * Creates blip effect elements from BlipEffectsOptions.
11164
+ *
11165
+ * @returns Array of XML components representing blip effects
11166
+ */
11167
+ const createBlipEffects = (options) => {
11168
+ const children = [];
11169
+ if (options.grayscale) children.push(new BuilderElement({ name: "a:grayscl" }));
11170
+ if (options.luminance) {
11171
+ const attrs = {};
11172
+ if (options.luminance.bright !== void 0) attrs.bright = {
11173
+ key: "bright",
11174
+ value: `${options.luminance.bright}%`
11175
+ };
11176
+ if (options.luminance.contrast !== void 0) attrs.contrast = {
11177
+ key: "contrast",
11178
+ value: `${options.luminance.contrast}%`
11179
+ };
11180
+ children.push(new BuilderElement({
11181
+ attributes: attrs,
11182
+ name: "a:lum"
11183
+ }));
11184
+ }
11185
+ if (options.hsl) {
11186
+ const attrs = {};
11187
+ if (options.hsl.hue !== void 0) attrs.hue = {
11188
+ key: "hue",
11189
+ value: String(options.hsl.hue)
11190
+ };
11191
+ if (options.hsl.sat !== void 0) attrs.sat = {
11192
+ key: "sat",
11193
+ value: `${options.hsl.sat}%`
11194
+ };
11195
+ if (options.hsl.lum !== void 0) attrs.lum = {
11196
+ key: "lum",
11197
+ value: `${options.hsl.lum}%`
11198
+ };
11199
+ children.push(new BuilderElement({
11200
+ attributes: attrs,
11201
+ name: "a:hsl"
11202
+ }));
11203
+ }
11204
+ if (options.tint) {
11205
+ const attrs = {};
11206
+ if (options.tint.hue !== void 0) attrs.hue = {
11207
+ key: "hue",
11208
+ value: String(options.tint.hue)
11209
+ };
11210
+ if (options.tint.amt !== void 0) attrs.amt = {
11211
+ key: "amt",
11212
+ value: `${options.tint.amt}%`
11213
+ };
11214
+ children.push(new BuilderElement({
11215
+ attributes: attrs,
11216
+ name: "a:tint"
11217
+ }));
11218
+ }
11219
+ if (options.duotone) children.push(new BuilderElement({
11220
+ children: [createColorElement(options.duotone.color1), createColorElement(options.duotone.color2)],
11221
+ name: "a:duotone"
11222
+ }));
11223
+ if (options.biLevel) children.push(new BuilderElement({
11224
+ attributes: { thresh: {
11225
+ key: "thresh",
11226
+ value: `${options.biLevel.thresh}%`
11227
+ } },
11228
+ name: "a:biLevel"
11229
+ }));
11230
+ if (options.alphaCeiling) children.push(new BuilderElement({ name: "a:alphaCeiling" }));
11231
+ if (options.alphaFloor) children.push(new BuilderElement({ name: "a:alphaFloor" }));
11232
+ if (options.alphaInverse !== void 0) if (typeof options.alphaInverse === "boolean") children.push(new BuilderElement({ name: "a:alphaInv" }));
11233
+ else children.push(new BuilderElement({
11234
+ children: [createColorElement(options.alphaInverse)],
11235
+ name: "a:alphaInv"
11236
+ }));
11237
+ if (options.alphaModFix) {
11238
+ var _options$alphaModFix$;
11239
+ const amt = (_options$alphaModFix$ = options.alphaModFix.amount) !== null && _options$alphaModFix$ !== void 0 ? _options$alphaModFix$ : 100;
11240
+ children.push(new BuilderElement({
11241
+ attributes: { amt: {
11242
+ key: "amt",
11243
+ value: `${amt}%`
11244
+ } },
11245
+ name: "a:alphaModFix"
11246
+ }));
11247
+ }
11248
+ if (options.alphaRepl) children.push(new BuilderElement({
11249
+ attributes: { a: {
11250
+ key: "a",
11251
+ value: `${options.alphaRepl.amount}%`
11252
+ } },
11253
+ name: "a:alphaRepl"
11254
+ }));
11255
+ if (options.alphaBiLevel) children.push(new BuilderElement({
11256
+ attributes: { thresh: {
11257
+ key: "thresh",
11258
+ value: `${options.alphaBiLevel.thresh}%`
11259
+ } },
11260
+ name: "a:alphaBiLevel"
11261
+ }));
11262
+ if (options.colorChange) {
11263
+ const attrs = {};
11264
+ if (options.colorChange.useAlpha === false) attrs.useA = {
11265
+ key: "useA",
11266
+ value: "0"
11267
+ };
11268
+ children.push(new BuilderElement({
11269
+ attributes: attrs,
11270
+ children: [new BuilderElement({
11271
+ children: [createColorElement(options.colorChange.from)],
11272
+ name: "a:clrFrom"
11273
+ }), new BuilderElement({
11274
+ children: [createColorElement(options.colorChange.to)],
11275
+ name: "a:clrTo"
11276
+ })],
11277
+ name: "a:clrChange"
11278
+ }));
11279
+ }
11280
+ if (options.colorRepl) children.push(new BuilderElement({
11281
+ children: [createColorElement(options.colorRepl.color)],
11282
+ name: "a:clrRepl"
11283
+ }));
11284
+ if (options.blur) {
11285
+ const attrs = {};
11286
+ if (options.blur.rad !== void 0) attrs.rad = {
11287
+ key: "rad",
11288
+ value: options.blur.rad
11289
+ };
11290
+ if (options.blur.grow === false) attrs.grow = {
11291
+ key: "grow",
11292
+ value: 0
11293
+ };
11294
+ children.push(new BuilderElement({
11295
+ attributes: attrs,
11296
+ name: "a:blur"
11297
+ }));
11298
+ }
11299
+ return children;
11300
+ };
11301
+ //#endregion
11108
11302
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts
11109
11303
  /**
11110
11304
  * Creates an SVG blip element for embedding SVG images.
@@ -11214,20 +11408,25 @@ const createExtentionList = (mediaData) => new BuilderElement({
11214
11408
  * @param mediaData - The media data containing the image information
11215
11409
  * @returns An XML component representing the blip element
11216
11410
  */
11217
- const createBlip = (mediaData) => new BuilderElement({
11218
- attributes: {
11219
- cstate: {
11220
- key: "cstate",
11221
- value: "none"
11411
+ const createBlip = (mediaData, blipEffects) => {
11412
+ const children = [];
11413
+ if (blipEffects) children.push(...createBlipEffects(blipEffects));
11414
+ if (mediaData.type === "svg") children.push(createExtentionList(mediaData));
11415
+ return new BuilderElement({
11416
+ attributes: {
11417
+ cstate: {
11418
+ key: "cstate",
11419
+ value: "none"
11420
+ },
11421
+ embed: {
11422
+ key: "r:embed",
11423
+ value: `rId{${mediaData.type === "svg" ? mediaData.fallback.fileName : mediaData.fileName}}`
11424
+ }
11222
11425
  },
11223
- embed: {
11224
- key: "r:embed",
11225
- value: `rId{${mediaData.type === "svg" ? mediaData.fallback.fileName : mediaData.fileName}}`
11226
- }
11227
- },
11228
- children: mediaData.type === "svg" ? [createExtentionList(mediaData)] : [],
11229
- name: "a:blip"
11230
- });
11426
+ children,
11427
+ name: "a:blip"
11428
+ });
11429
+ };
11231
11430
  //#endregion
11232
11431
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts
11233
11432
  /**
@@ -11351,6 +11550,106 @@ var Stretch = class extends XmlComponent {
11351
11550
  }
11352
11551
  };
11353
11552
  //#endregion
11553
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/tile.ts
11554
+ /**
11555
+ * Tile fill module for blip fills.
11556
+ *
11557
+ * This module defines how images are tiled (repeated) to fill shapes.
11558
+ *
11559
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
11560
+ *
11561
+ * @module
11562
+ */
11563
+ /**
11564
+ * Tile flip mode for tiling images.
11565
+ *
11566
+ * Specifies whether the image is flipped along the x-axis, y-axis,
11567
+ * both axes, or not at all when tiling.
11568
+ */
11569
+ const TileFlipMode = {
11570
+ NONE: "none",
11571
+ X: "x",
11572
+ Y: "y",
11573
+ XY: "xy"
11574
+ };
11575
+ /**
11576
+ * Tile alignment within the shape.
11577
+ *
11578
+ * Specifies the anchor position of the first tile relative to the shape.
11579
+ */
11580
+ const TileAlignment = {
11581
+ TOP_LEFT: "tl",
11582
+ TOP: "t",
11583
+ TOP_RIGHT: "tr",
11584
+ LEFT: "l",
11585
+ CENTER: "ctr",
11586
+ RIGHT: "r",
11587
+ BOTTOM_LEFT: "bl",
11588
+ BOTTOM: "b",
11589
+ BOTTOM_RIGHT: "br"
11590
+ };
11591
+ /**
11592
+ * Creates a tile fill mode element for blip fills.
11593
+ *
11594
+ * When a blip fill uses tile mode, the image is repeated (tiled) to fill
11595
+ * the shape instead of being stretched. This element controls the tiling
11596
+ * parameters such as offset, scale, flip, and alignment.
11597
+ *
11598
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
11599
+ *
11600
+ * ## XSD Schema
11601
+ * ```xml
11602
+ * <xsd:complexType name="CT_TileInfoProperties">
11603
+ * <xsd:attribute name="tx" type="ST_Coordinate" use="optional"/>
11604
+ * <xsd:attribute name="ty" type="ST_Coordinate" use="optional"/>
11605
+ * <xsd:attribute name="sx" type="ST_Percentage" use="optional"/>
11606
+ * <xsd:attribute name="sy" type="ST_Percentage" use="optional"/>
11607
+ * <xsd:attribute name="flip" type="ST_TileFlipMode" default="none"/>
11608
+ * <xsd:attribute name="algn" type="ST_RectAlignment" use="optional"/>
11609
+ * </xsd:complexType>
11610
+ * ```
11611
+ *
11612
+ * @example
11613
+ * ```typescript
11614
+ * // Tile with 50% scale
11615
+ * createTileInfo({ sx: 50, sy: 50 });
11616
+ * // Tile with flip and alignment
11617
+ * createTileInfo({ flip: "XY", align: "CENTER" });
11618
+ * ```
11619
+ */
11620
+ const createTileInfo = (options) => {
11621
+ if (!options) return new BuilderElement({ name: "a:tile" });
11622
+ const attributes = {};
11623
+ if (options.tx !== void 0) attributes.tx = {
11624
+ key: "tx",
11625
+ value: options.tx
11626
+ };
11627
+ if (options.ty !== void 0) attributes.ty = {
11628
+ key: "ty",
11629
+ value: options.ty
11630
+ };
11631
+ if (options.sx !== void 0) attributes.sx = {
11632
+ key: "sx",
11633
+ value: options.sx
11634
+ };
11635
+ if (options.sy !== void 0) attributes.sy = {
11636
+ key: "sy",
11637
+ value: options.sy
11638
+ };
11639
+ if (options.flip !== void 0) attributes.flip = {
11640
+ key: "flip",
11641
+ value: TileFlipMode[options.flip]
11642
+ };
11643
+ if (options.align !== void 0) attributes.algn = {
11644
+ key: "algn",
11645
+ value: TileAlignment[options.align]
11646
+ };
11647
+ return new BuilderElement({
11648
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
11649
+ name: "a:tile"
11650
+ });
11651
+ };
11652
+ //#endregion
11354
11653
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts
11355
11654
  /**
11356
11655
  * Represents a blip fill for pictures in DrawingML.
@@ -11379,12 +11678,48 @@ var Stretch = class extends XmlComponent {
11379
11678
  * // If mediaData.srcRect is set, cropping is applied
11380
11679
  * ```
11381
11680
  */
11382
- var BlipFill = class extends XmlComponent {
11383
- constructor(mediaData) {
11384
- super("pic:blipFill");
11385
- this.root.push(createBlip(mediaData));
11386
- this.root.push(createSourceRectangle(mediaData.srcRect));
11387
- this.root.push(new Stretch());
11681
+ const createBlipFill = (mediaData, options) => {
11682
+ const children = [];
11683
+ children.push(createBlip(mediaData, options === null || options === void 0 ? void 0 : options.blipEffects));
11684
+ children.push(createSourceRectangle(mediaData.srcRect));
11685
+ if (options === null || options === void 0 ? void 0 : options.tile) children.push(createTileInfo(options.tile));
11686
+ else children.push(new Stretch());
11687
+ const attributes = {};
11688
+ if ((options === null || options === void 0 ? void 0 : options.dpi) !== void 0) attributes.dpi = {
11689
+ key: "dpi",
11690
+ value: options.dpi
11691
+ };
11692
+ if ((options === null || options === void 0 ? void 0 : options.rotWithShape) !== void 0) attributes.rotWithShape = {
11693
+ key: "rotWithShape",
11694
+ value: options.rotWithShape ? 1 : 0
11695
+ };
11696
+ return new BuilderElement({
11697
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
11698
+ children,
11699
+ name: "pic:blipFill"
11700
+ });
11701
+ };
11702
+ //#endregion
11703
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/child-non-visual-pic-properties-attributes.ts
11704
+ /**
11705
+ * Attributes for non-visual picture properties.
11706
+ *
11707
+ * @module
11708
+ */
11709
+ /**
11710
+ * Attributes for CT_NonVisualPictureProperties.
11711
+ *
11712
+ * ## XSD Schema
11713
+ * ```xml
11714
+ * <xsd:attribute name="preferRelativeResize" type="xsd:boolean" use="optional" default="true"/>
11715
+ * ```
11716
+ *
11717
+ * @internal
11718
+ */
11719
+ var ChildNonVisualPropertiesAttributes = class extends XmlAttributeComponent {
11720
+ constructor(..._args) {
11721
+ super(..._args);
11722
+ _defineProperty(this, "xmlKeys", { preferRelativeResize: "preferRelativeResize" });
11388
11723
  }
11389
11724
  };
11390
11725
  //#endregion
@@ -11509,6 +11844,7 @@ var PicLocks = class extends XmlComponent {
11509
11844
  var ChildNonVisualProperties = class extends XmlComponent {
11510
11845
  constructor() {
11511
11846
  super("pic:cNvPicPr");
11847
+ this.root.push(new ChildNonVisualPropertiesAttributes({ preferRelativeResize: true }));
11512
11848
  this.root.push(new PicLocks());
11513
11849
  }
11514
11850
  };
@@ -11557,6 +11893,85 @@ const createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
11557
11893
  },
11558
11894
  name: "a:hlinkClick"
11559
11895
  });
11896
+ /**
11897
+ * Creates a hover hyperlink element for a drawing.
11898
+ *
11899
+ * This element defines what happens when a user hovers over a drawing element.
11900
+ *
11901
+ * ## XSD Schema
11902
+ * ```xml
11903
+ * <xsd:complexType name="CT_Hyperlink">
11904
+ * <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
11905
+ * <xsd:attribute name="tgtFrame" type="s:ST_String"/>
11906
+ * <xsd:attribute name="tooltip" type="s:ST_String"/>
11907
+ * <xsd:attribute name="docLocation" type="s:ST_String"/>
11908
+ * <xsd:attribute name="history" type="s:ST_OnOff"/>
11909
+ * <xsd:attribute name="anchor" type="s:ST_String"/>
11910
+ * <xsd:attribute ref="r:id"/>
11911
+ * </xsd:complexType>
11912
+ * ```
11913
+ *
11914
+ * @param linkId - The relationship ID for the hyperlink target
11915
+ * @param hasXmlNs - Whether to include the XML namespace declaration
11916
+ * @returns An XML component representing the hover hyperlink
11917
+ */
11918
+ const createHyperlinkHover = (linkId, hasXmlNs) => new BuilderElement({
11919
+ attributes: {
11920
+ ...hasXmlNs ? { xmlns: {
11921
+ key: "xmlns:a",
11922
+ value: "http://schemas.openxmlformats.org/drawingml/2006/main"
11923
+ } } : {},
11924
+ id: {
11925
+ key: "r:id",
11926
+ value: `rId${linkId}`
11927
+ }
11928
+ },
11929
+ name: "a:hlinkHover"
11930
+ });
11931
+ //#endregion
11932
+ //#region src/file/relationships/relationship/relationship.ts
11933
+ /**
11934
+ * Target mode types for relationships.
11935
+ *
11936
+ * Indicates whether a relationship target is external to the package.
11937
+ */
11938
+ const TargetModeType = { EXTERNAL: "External" };
11939
+ /**
11940
+ * Creates a single relationship between parts in an OPC package.
11941
+ *
11942
+ * A relationship defines a typed connection from a source part to a target part,
11943
+ * identified by a unique ID within the relationships collection.
11944
+ *
11945
+ * @example
11946
+ * ```typescript
11947
+ * // Internal relationship to an image
11948
+ * createRelationship("rId1", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "media/image1.png");
11949
+ *
11950
+ * // External relationship to a hyperlink
11951
+ * createRelationship("rId2", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", "https://example.com", TargetModeType.EXTERNAL);
11952
+ * ```
11953
+ */
11954
+ const createRelationship = (id, type, target, targetMode) => new BuilderElement({
11955
+ attributes: {
11956
+ id: {
11957
+ key: "Id",
11958
+ value: id
11959
+ },
11960
+ target: {
11961
+ key: "Target",
11962
+ value: target
11963
+ },
11964
+ targetMode: {
11965
+ key: "TargetMode",
11966
+ value: targetMode
11967
+ },
11968
+ type: {
11969
+ key: "Type",
11970
+ value: type
11971
+ }
11972
+ },
11973
+ name: "Relationship"
11974
+ });
11560
11975
  //#endregion
11561
11976
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts
11562
11977
  /**
@@ -11586,16 +12001,7 @@ var NonVisualPropertiesAttributes = class extends XmlAttributeComponent {
11586
12001
  };
11587
12002
  //#endregion
11588
12003
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts
11589
- /**
11590
- * Non-visual drawing properties module.
11591
- *
11592
- * This module provides basic metadata for drawing elements including
11593
- * ID, name, description, and hyperlink support.
11594
- *
11595
- * Reference: http://officeopenxml.com/drwPic.php
11596
- *
11597
- * @module
11598
- */
12004
+ const HYPERLINK_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
11599
12005
  /**
11600
12006
  * Represents non-visual drawing properties for pictures.
11601
12007
  *
@@ -11626,8 +12032,10 @@ var NonVisualPropertiesAttributes = class extends XmlAttributeComponent {
11626
12032
  * ```
11627
12033
  */
11628
12034
  var NonVisualProperties = class extends XmlComponent {
11629
- constructor() {
12035
+ constructor(hyperlink) {
11630
12036
  super("pic:cNvPr");
12037
+ _defineProperty(this, "hyperlink", void 0);
12038
+ this.hyperlink = hyperlink;
11631
12039
  this.root.push(new NonVisualPropertiesAttributes({
11632
12040
  descr: "",
11633
12041
  id: 0,
@@ -11635,28 +12043,32 @@ var NonVisualProperties = class extends XmlComponent {
11635
12043
  }));
11636
12044
  }
11637
12045
  prepForXml(context) {
12046
+ let hasStackClick = false;
11638
12047
  for (let i = context.stack.length - 1; i >= 0; i--) {
11639
12048
  const element = context.stack[i];
11640
12049
  if (!(element instanceof ConcreteHyperlink)) continue;
11641
12050
  this.root.push(createHyperlinkClick(element.linkId, false));
12051
+ hasStackClick = true;
11642
12052
  break;
11643
12053
  }
12054
+ if (this.hyperlink) {
12055
+ if (this.hyperlink.click && !hasStackClick) {
12056
+ const linkId = uniqueId();
12057
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE$1, this.hyperlink.click, TargetModeType.EXTERNAL);
12058
+ this.root.push(createHyperlinkClick(linkId, false));
12059
+ }
12060
+ if (this.hyperlink.hover) {
12061
+ const linkId = uniqueId();
12062
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE$1, this.hyperlink.hover, TargetModeType.EXTERNAL);
12063
+ this.root.push(createHyperlinkHover(linkId, false));
12064
+ }
12065
+ }
11644
12066
  return super.prepForXml(context);
11645
12067
  }
11646
12068
  };
11647
12069
  //#endregion
11648
12070
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts
11649
12071
  /**
11650
- * Non-visual picture properties module.
11651
- *
11652
- * This module provides metadata and locking settings for pictures
11653
- * that don't affect their visual appearance.
11654
- *
11655
- * Reference: http://officeopenxml.com/drwPic.php
11656
- *
11657
- * @module
11658
- */
11659
- /**
11660
12072
  * Represents non-visual picture properties.
11661
12073
  *
11662
12074
  * This element specifies non-visual properties for a picture. These properties
@@ -11681,9 +12093,9 @@ var NonVisualProperties = class extends XmlComponent {
11681
12093
  * ```
11682
12094
  */
11683
12095
  var NonVisualPicProperties = class extends XmlComponent {
11684
- constructor() {
12096
+ constructor(hyperlink) {
11685
12097
  super("pic:nvPicPr");
11686
- this.root.push(new NonVisualProperties());
12098
+ this.root.push(new NonVisualProperties(hyperlink));
11687
12099
  this.root.push(new ChildNonVisualProperties());
11688
12100
  }
11689
12101
  };
@@ -11740,14 +12152,19 @@ var PicAttributes = class extends XmlAttributeComponent {
11740
12152
  * ```
11741
12153
  */
11742
12154
  var Pic = class extends XmlComponent {
11743
- constructor({ mediaData, transform, outline }) {
12155
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11744
12156
  super("pic:pic");
11745
12157
  this.root.push(new PicAttributes({ xmlns: "http://schemas.openxmlformats.org/drawingml/2006/picture" }));
11746
- this.root.push(new NonVisualPicProperties());
11747
- this.root.push(new BlipFill(mediaData));
12158
+ this.root.push(new NonVisualPicProperties(hyperlink));
12159
+ this.root.push(createBlipFill(mediaData, {
12160
+ blipEffects,
12161
+ tile
12162
+ }));
11748
12163
  this.root.push(new ShapeProperties({
11749
12164
  element: "pic",
12165
+ effects,
11750
12166
  outline,
12167
+ solidFill,
11751
12168
  transform
11752
12169
  }));
11753
12170
  }
@@ -11873,7 +12290,7 @@ const createWpgGroup = (options) => new BuilderElement({
11873
12290
  * ```
11874
12291
  */
11875
12292
  var GraphicData = class extends XmlComponent {
11876
- constructor({ mediaData, transform, outline, solidFill }) {
12293
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11877
12294
  super("a:graphicData");
11878
12295
  if (mediaData.type === "wps") {
11879
12296
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
@@ -11911,8 +12328,13 @@ var GraphicData = class extends XmlComponent {
11911
12328
  } else {
11912
12329
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.openxmlformats.org/drawingml/2006/picture" }));
11913
12330
  const pic = new Pic({
12331
+ blipEffects,
12332
+ effects,
12333
+ hyperlink,
11914
12334
  mediaData,
11915
12335
  outline,
12336
+ solidFill,
12337
+ tile,
11916
12338
  transform
11917
12339
  });
11918
12340
  this.root.push(pic);
@@ -11958,14 +12380,18 @@ var GraphicAttributes = class extends XmlAttributeComponent {
11958
12380
  * ```
11959
12381
  */
11960
12382
  var Graphic = class extends XmlComponent {
11961
- constructor({ mediaData, transform, outline, solidFill }) {
12383
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11962
12384
  super("a:graphic");
11963
12385
  _defineProperty(this, "data", void 0);
11964
12386
  this.root.push(new GraphicAttributes({ a: "http://schemas.openxmlformats.org/drawingml/2006/main" }));
11965
12387
  this.data = new GraphicData({
12388
+ blipEffects,
12389
+ effects,
12390
+ hyperlink,
11966
12391
  mediaData,
11967
12392
  outline,
11968
12393
  solidFill,
12394
+ tile,
11969
12395
  transform
11970
12396
  });
11971
12397
  this.root.push(this.data);
@@ -12187,12 +12613,13 @@ const createWrapTopAndBottom = (margins = {
12187
12613
  * Document Properties module for DrawingML elements.
12188
12614
  *
12189
12615
  * This module provides non-visual properties for drawing elements,
12190
- * including name, description, and accessibility information.
12616
+ * including name, description, accessibility information, and hyperlinks.
12191
12617
  *
12192
12618
  * Reference: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docPr_topic_ID0ES32OB.html
12193
12619
  *
12194
12620
  * @module
12195
12621
  */
12622
+ const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
12196
12623
  /**
12197
12624
  * Represents non-visual drawing properties in a WordprocessingML document.
12198
12625
  *
@@ -12217,13 +12644,15 @@ const createWrapTopAndBottom = (margins = {
12217
12644
  * ```
12218
12645
  */
12219
12646
  var DocProperties = class extends XmlComponent {
12220
- constructor({ name, description, title, id } = {
12647
+ constructor({ name, description, title, id, hyperlink } = {
12221
12648
  description: "",
12222
12649
  name: "",
12223
12650
  title: ""
12224
12651
  }) {
12225
12652
  super("wp:docPr");
12226
12653
  _defineProperty(this, "docPropertiesUniqueNumericId", docPropertiesUniqueNumericIdGen());
12654
+ _defineProperty(this, "hyperlink", void 0);
12655
+ this.hyperlink = hyperlink;
12227
12656
  const attributes = {
12228
12657
  id: {
12229
12658
  key: "id",
@@ -12245,12 +12674,26 @@ var DocProperties = class extends XmlComponent {
12245
12674
  this.root.push(new NextAttributeComponent(attributes));
12246
12675
  }
12247
12676
  prepForXml(context) {
12677
+ let hasStackClick = false;
12248
12678
  for (let i = context.stack.length - 1; i >= 0; i--) {
12249
12679
  const element = context.stack[i];
12250
12680
  if (!(element instanceof ConcreteHyperlink)) continue;
12251
12681
  this.root.push(createHyperlinkClick(element.linkId, true));
12682
+ hasStackClick = true;
12252
12683
  break;
12253
12684
  }
12685
+ if (this.hyperlink) {
12686
+ if (this.hyperlink.click && !hasStackClick) {
12687
+ const linkId = uniqueId();
12688
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE, this.hyperlink.click, TargetModeType.EXTERNAL);
12689
+ this.root.push(createHyperlinkClick(linkId, true));
12690
+ }
12691
+ if (this.hyperlink.hover) {
12692
+ const linkId = uniqueId();
12693
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE, this.hyperlink.hover, TargetModeType.EXTERNAL);
12694
+ this.root.push(createHyperlinkHover(linkId, true));
12695
+ }
12696
+ }
12254
12697
  return super.prepForXml(context);
12255
12698
  }
12256
12699
  };
@@ -12526,6 +12969,7 @@ var AnchorAttributes = class extends XmlAttributeComponent {
12526
12969
  */
12527
12970
  var Anchor = class extends XmlComponent {
12528
12971
  constructor({ mediaData, transform, drawingOptions }) {
12972
+ var _drawingOptions$docPr;
12529
12973
  super("wp:anchor");
12530
12974
  const floating = {
12531
12975
  allowOverlap: true,
@@ -12578,16 +13022,20 @@ var Anchor = class extends XmlComponent {
12578
13022
  this.root.push(new DocProperties(drawingOptions.docProperties));
12579
13023
  this.root.push(createGraphicFrameProperties());
12580
13024
  this.root.push(new Graphic({
13025
+ blipEffects: drawingOptions.blipEffects,
13026
+ effects: drawingOptions.effects,
13027
+ hyperlink: (_drawingOptions$docPr = drawingOptions.docProperties) === null || _drawingOptions$docPr === void 0 ? void 0 : _drawingOptions$docPr.hyperlink,
12581
13028
  mediaData,
12582
13029
  outline: drawingOptions.outline,
12583
13030
  solidFill: drawingOptions.solidFill,
13031
+ tile: drawingOptions.tile,
12584
13032
  transform
12585
13033
  }));
12586
13034
  }
12587
13035
  };
12588
13036
  //#endregion
12589
13037
  //#region src/file/drawing/inline/inline.ts
12590
- const createInline = ({ mediaData, transform, docProperties, outline, solidFill }) => {
13038
+ const createInline = ({ mediaData, transform, docProperties, outline, solidFill, effects, blipEffects, tile }) => {
12591
13039
  var _outline$width, _outline$width2, _outline$width3, _outline$width4;
12592
13040
  return new BuilderElement({
12593
13041
  attributes: {
@@ -12627,9 +13075,13 @@ const createInline = ({ mediaData, transform, docProperties, outline, solidFill
12627
13075
  new DocProperties(docProperties),
12628
13076
  createGraphicFrameProperties(),
12629
13077
  new Graphic({
13078
+ blipEffects,
13079
+ effects,
13080
+ hyperlink: docProperties === null || docProperties === void 0 ? void 0 : docProperties.hyperlink,
12630
13081
  mediaData,
12631
13082
  outline,
12632
13083
  solidFill,
13084
+ tile,
12633
13085
  transform
12634
13086
  })
12635
13087
  ],
@@ -12660,10 +13112,13 @@ var Drawing = class extends XmlComponent {
12660
13112
  constructor(imageData, drawingOptions = {}) {
12661
13113
  super("w:drawing");
12662
13114
  if (!drawingOptions.floating) this.root.push(createInline({
13115
+ blipEffects: drawingOptions.blipEffects,
12663
13116
  docProperties: drawingOptions.docProperties,
13117
+ effects: drawingOptions.effects,
12664
13118
  mediaData: imageData,
12665
13119
  outline: drawingOptions.outline,
12666
13120
  solidFill: drawingOptions.solidFill,
13121
+ tile: drawingOptions.tile,
12667
13122
  transform: imageData.transformation
12668
13123
  }));
12669
13124
  else this.root.push(new Anchor({
@@ -12809,9 +13264,13 @@ var ImageRun = class extends Run {
12809
13264
  ...createImageData(rawData, options.transformation, key, options.srcRect)
12810
13265
  };
12811
13266
  const drawing = new Drawing(this.imageData, {
13267
+ blipEffects: options.blipEffects,
12812
13268
  docProperties: options.altText,
12813
13269
  floating: options.floating,
12814
- outline: options.outline
13270
+ outline: options.outline,
13271
+ solidFill: options.solidFill,
13272
+ effects: options.effects,
13273
+ tile: options.tile
12815
13274
  });
12816
13275
  this.root.push(drawing);
12817
13276
  }
@@ -13065,50 +13524,6 @@ var RelationshipsAttributes = class extends XmlAttributeComponent {
13065
13524
  }
13066
13525
  };
13067
13526
  //#endregion
13068
- //#region src/file/relationships/relationship/relationship.ts
13069
- /**
13070
- * Target mode types for relationships.
13071
- *
13072
- * Indicates whether a relationship target is external to the package.
13073
- */
13074
- const TargetModeType = { EXTERNAL: "External" };
13075
- /**
13076
- * Creates a single relationship between parts in an OPC package.
13077
- *
13078
- * A relationship defines a typed connection from a source part to a target part,
13079
- * identified by a unique ID within the relationships collection.
13080
- *
13081
- * @example
13082
- * ```typescript
13083
- * // Internal relationship to an image
13084
- * createRelationship("rId1", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "media/image1.png");
13085
- *
13086
- * // External relationship to a hyperlink
13087
- * createRelationship("rId2", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", "https://example.com", TargetModeType.EXTERNAL);
13088
- * ```
13089
- */
13090
- const createRelationship = (id, type, target, targetMode) => new BuilderElement({
13091
- attributes: {
13092
- id: {
13093
- key: "Id",
13094
- value: id
13095
- },
13096
- target: {
13097
- key: "Target",
13098
- value: target
13099
- },
13100
- targetMode: {
13101
- key: "TargetMode",
13102
- value: targetMode
13103
- },
13104
- type: {
13105
- key: "Type",
13106
- value: type
13107
- }
13108
- },
13109
- name: "Relationship"
13110
- });
13111
- //#endregion
13112
13527
  //#region src/file/relationships/relationships.ts
13113
13528
  /**
13114
13529
  * Relationships module for Open Packaging Conventions.
@@ -14209,8 +14624,7 @@ var NumberProperties = class extends XmlComponent {
14209
14624
  var IndentLevel = class extends XmlComponent {
14210
14625
  constructor(level) {
14211
14626
  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 }));
14627
+ this.root.push(new Attributes({ val: Math.min(level, 9) }));
14214
14628
  }
14215
14629
  };
14216
14630
  /**
@@ -22379,9 +22793,8 @@ var LevelBase = class extends XmlComponent {
22379
22793
  this.runProperties = new RunProperties(style && style.run);
22380
22794
  this.root.push(this.paragraphProperties);
22381
22795
  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
22796
  this.root.push(new LevelAttributes({
22384
- ilvl: decimalNumber(level),
22797
+ ilvl: decimalNumber(Math.min(level, 9)),
22385
22798
  tentative: 1
22386
22799
  }));
22387
22800
  }
@@ -24136,7 +24549,10 @@ var ExternalStylesFactory = class {
24136
24549
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24137
24550
  let stylesXmlElement;
24138
24551
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24139
- if (stylesXmlElement === void 0) throw new Error("can not find styles element");
24552
+ if (stylesXmlElement === void 0) return {
24553
+ importedStyles: [],
24554
+ initialStyles: new ImportedRootElementAttributes({})
24555
+ };
24140
24556
  return {
24141
24557
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24142
24558
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)