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