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.umd.js CHANGED
@@ -8926,8 +8926,8 @@
8926
8926
  } },
8927
8927
  children: [(() => {
8928
8928
  if (align) return createAlign(align);
8929
- else if (offset !== void 0) return createPositionOffset(offset);
8930
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8929
+ if (offset !== void 0) return createPositionOffset(offset);
8930
+ return createAlign(HorizontalPositionAlign.LEFT);
8931
8931
  })()],
8932
8932
  name: "wp:positionH"
8933
8933
  });
@@ -8987,8 +8987,8 @@
8987
8987
  } },
8988
8988
  children: [(() => {
8989
8989
  if (align) return createAlign(align);
8990
- else if (offset !== void 0) return createPositionOffset(offset);
8991
- else throw new Error("There is no configuration provided for floating position (Align or offset)");
8990
+ if (offset !== void 0) return createPositionOffset(offset);
8991
+ return createAlign(VerticalPositionAlign.TOP);
8992
8992
  })()],
8993
8993
  name: "wp:positionV"
8994
8994
  });
@@ -9702,6 +9702,44 @@
9702
9702
  name: "a:solidFill"
9703
9703
  });
9704
9704
  //#endregion
9705
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/fill-overlay.ts
9706
+ /**
9707
+ * Fill overlay effect for DrawingML shapes.
9708
+ *
9709
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_FillOverlayEffect
9710
+ *
9711
+ * @module
9712
+ */
9713
+ /**
9714
+ * Creates a fill overlay effect element.
9715
+ *
9716
+ * ## XSD Schema
9717
+ * ```xml
9718
+ * <xsd:complexType name="CT_FillOverlayEffect">
9719
+ * <xsd:sequence>
9720
+ * <xsd:group ref="EG_FillProperties" minOccurs="1" maxOccurs="1"/>
9721
+ * </xsd:sequence>
9722
+ * <xsd:attribute name="blend" type="ST_BlendMode" use="required"/>
9723
+ * </xsd:complexType>
9724
+ * ```
9725
+ *
9726
+ * @example
9727
+ * ```typescript
9728
+ * const fillOverlay = createFillOverlayEffect({
9729
+ * blend: BlendMode.MULTIPLY,
9730
+ * color: { value: "FF0000" },
9731
+ * });
9732
+ * ```
9733
+ */
9734
+ const createFillOverlayEffect = (options) => new BuilderElement({
9735
+ attributes: { blend: {
9736
+ key: "blend",
9737
+ value: options.blend
9738
+ } },
9739
+ children: [createSolidFill(options.color)],
9740
+ name: "a:fillOverlay"
9741
+ });
9742
+ //#endregion
9705
9743
  //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/glow.ts
9706
9744
  /**
9707
9745
  * Glow effect for DrawingML shapes.
@@ -9738,7 +9776,7 @@
9738
9776
  });
9739
9777
  };
9740
9778
  //#endregion
9741
- //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/inner-shdw.ts
9779
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/inner-shadow.ts
9742
9780
  /**
9743
9781
  * Inner shadow effect for DrawingML shapes.
9744
9782
  *
@@ -9786,7 +9824,7 @@
9786
9824
  });
9787
9825
  };
9788
9826
  //#endregion
9789
- //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/outer-shdw.ts
9827
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/outer-shadow.ts
9790
9828
  /**
9791
9829
  * Outer shadow effect for DrawingML shapes.
9792
9830
  *
@@ -9874,7 +9912,7 @@
9874
9912
  });
9875
9913
  };
9876
9914
  //#endregion
9877
- //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/prst-shdw.ts
9915
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/effects/preset-shadow.ts
9878
9916
  /**
9879
9917
  * Preset shadow effect for DrawingML shapes.
9880
9918
  *
@@ -10128,10 +10166,11 @@
10128
10166
  const createEffectList = (options) => {
10129
10167
  const children = [];
10130
10168
  if (options.blur) children.push(createBlurEffect(options.blur));
10169
+ if (options.fillOverlay) children.push(createFillOverlayEffect(options.fillOverlay));
10131
10170
  if (options.glow) children.push(createGlowEffect(options.glow));
10132
- if (options.innerShdw) children.push(createInnerShadowEffect(options.innerShdw));
10133
- if (options.outerShdw) children.push(createOuterShadowEffect(options.outerShdw));
10134
- if (options.prstShdw) children.push(createPresetShadowEffect(options.prstShdw));
10171
+ if (options.innerShadow) children.push(createInnerShadowEffect(options.innerShadow));
10172
+ if (options.outerShadow) children.push(createOuterShadowEffect(options.outerShadow));
10173
+ if (options.presetShadow) children.push(createPresetShadowEffect(options.presetShadow));
10135
10174
  if (options.reflection) children.push(createReflectionEffect(options.reflection === true ? void 0 : options.reflection));
10136
10175
  if (options.softEdge !== void 0) children.push(createSoftEdgeEffect(options.softEdge));
10137
10176
  return new BuilderElement({
@@ -10567,10 +10606,13 @@
10567
10606
  };
10568
10607
  /**
10569
10608
  * Creates the fill child element for an outline.
10609
+ *
10610
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
10570
10611
  */
10571
10612
  const createOutlineFill = (options) => {
10572
10613
  if (options.type === "noFill") return createNoFill();
10573
- return createSolidFill(options.color);
10614
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
10615
+ return null;
10574
10616
  };
10575
10617
  /**
10576
10618
  * Creates an outline element for DrawingML shapes.
@@ -10606,7 +10648,8 @@
10606
10648
  */
10607
10649
  const createOutline = (options) => {
10608
10650
  const children = [];
10609
- children.push(createOutlineFill(options));
10651
+ const fill = createOutlineFill(options);
10652
+ if (fill) children.push(fill);
10610
10653
  if (options.dash !== void 0) children.push(new BuilderElement({
10611
10654
  attributes: { val: {
10612
10655
  key: "val",
@@ -10918,12 +10961,12 @@
10918
10961
  const children = [];
10919
10962
  if (options.bevelT) children.push(createBevel(options.bevelT));
10920
10963
  if (options.bevelB) children.push(createBottomBevel(options.bevelB));
10921
- if (options.extrusionClr) children.push(new BuilderElement({
10922
- children: [createColorElement(options.extrusionClr)],
10964
+ if (options.extrusionColor) children.push(new BuilderElement({
10965
+ children: [createColorElement(options.extrusionColor)],
10923
10966
  name: "a:extrusionClr"
10924
10967
  }));
10925
- if (options.contourClr) children.push(new BuilderElement({
10926
- children: [createColorElement(options.contourClr)],
10968
+ if (options.contourColor) children.push(new BuilderElement({
10969
+ children: [createColorElement(options.contourColor)],
10927
10970
  name: "a:contourClr"
10928
10971
  }));
10929
10972
  return new BuilderElement({
@@ -10997,7 +11040,6 @@
10997
11040
  if (noFill) this.root.push(createNoFill());
10998
11041
  else if (solidFill) this.root.push(createSolidFill(solidFill));
10999
11042
  else if (gradientFill) this.root.push(createGradientFill(gradientFill));
11000
- else if (outline) this.root.push(createNoFill());
11001
11043
  if (outline) this.root.push(createOutline(outline));
11002
11044
  if (effects) this.root.push(createEffectList(effects));
11003
11045
  if (shape3d) this.root.push(createShape3D(shape3d));
@@ -11110,6 +11152,158 @@
11110
11152
  }
11111
11153
  };
11112
11154
  //#endregion
11155
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-effects.ts
11156
+ /**
11157
+ * Blip image adjustment effects for DrawingML.
11158
+ *
11159
+ * These effects are applied directly to the image data within the `<a:blip>` element,
11160
+ * corresponding to Word's "Picture Format > Adjust" features (brightness, contrast,
11161
+ * grayscale, tint, duotone, etc.).
11162
+ *
11163
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Blip children
11164
+ *
11165
+ * @module
11166
+ */
11167
+ /**
11168
+ * Creates blip effect elements from BlipEffectsOptions.
11169
+ *
11170
+ * @returns Array of XML components representing blip effects
11171
+ */
11172
+ const createBlipEffects = (options) => {
11173
+ const children = [];
11174
+ if (options.grayscale) children.push(new BuilderElement({ name: "a:grayscl" }));
11175
+ if (options.luminance) {
11176
+ const attrs = {};
11177
+ if (options.luminance.bright !== void 0) attrs.bright = {
11178
+ key: "bright",
11179
+ value: `${options.luminance.bright}%`
11180
+ };
11181
+ if (options.luminance.contrast !== void 0) attrs.contrast = {
11182
+ key: "contrast",
11183
+ value: `${options.luminance.contrast}%`
11184
+ };
11185
+ children.push(new BuilderElement({
11186
+ attributes: attrs,
11187
+ name: "a:lum"
11188
+ }));
11189
+ }
11190
+ if (options.hsl) {
11191
+ const attrs = {};
11192
+ if (options.hsl.hue !== void 0) attrs.hue = {
11193
+ key: "hue",
11194
+ value: String(options.hsl.hue)
11195
+ };
11196
+ if (options.hsl.sat !== void 0) attrs.sat = {
11197
+ key: "sat",
11198
+ value: `${options.hsl.sat}%`
11199
+ };
11200
+ if (options.hsl.lum !== void 0) attrs.lum = {
11201
+ key: "lum",
11202
+ value: `${options.hsl.lum}%`
11203
+ };
11204
+ children.push(new BuilderElement({
11205
+ attributes: attrs,
11206
+ name: "a:hsl"
11207
+ }));
11208
+ }
11209
+ if (options.tint) {
11210
+ const attrs = {};
11211
+ if (options.tint.hue !== void 0) attrs.hue = {
11212
+ key: "hue",
11213
+ value: String(options.tint.hue)
11214
+ };
11215
+ if (options.tint.amt !== void 0) attrs.amt = {
11216
+ key: "amt",
11217
+ value: `${options.tint.amt}%`
11218
+ };
11219
+ children.push(new BuilderElement({
11220
+ attributes: attrs,
11221
+ name: "a:tint"
11222
+ }));
11223
+ }
11224
+ if (options.duotone) children.push(new BuilderElement({
11225
+ children: [createColorElement(options.duotone.color1), createColorElement(options.duotone.color2)],
11226
+ name: "a:duotone"
11227
+ }));
11228
+ if (options.biLevel) children.push(new BuilderElement({
11229
+ attributes: { thresh: {
11230
+ key: "thresh",
11231
+ value: `${options.biLevel.thresh}%`
11232
+ } },
11233
+ name: "a:biLevel"
11234
+ }));
11235
+ if (options.alphaCeiling) children.push(new BuilderElement({ name: "a:alphaCeiling" }));
11236
+ if (options.alphaFloor) children.push(new BuilderElement({ name: "a:alphaFloor" }));
11237
+ if (options.alphaInverse !== void 0) if (typeof options.alphaInverse === "boolean") children.push(new BuilderElement({ name: "a:alphaInv" }));
11238
+ else children.push(new BuilderElement({
11239
+ children: [createColorElement(options.alphaInverse)],
11240
+ name: "a:alphaInv"
11241
+ }));
11242
+ if (options.alphaModFix) {
11243
+ var _options$alphaModFix$;
11244
+ const amt = (_options$alphaModFix$ = options.alphaModFix.amount) !== null && _options$alphaModFix$ !== void 0 ? _options$alphaModFix$ : 100;
11245
+ children.push(new BuilderElement({
11246
+ attributes: { amt: {
11247
+ key: "amt",
11248
+ value: `${amt}%`
11249
+ } },
11250
+ name: "a:alphaModFix"
11251
+ }));
11252
+ }
11253
+ if (options.alphaRepl) children.push(new BuilderElement({
11254
+ attributes: { a: {
11255
+ key: "a",
11256
+ value: `${options.alphaRepl.amount}%`
11257
+ } },
11258
+ name: "a:alphaRepl"
11259
+ }));
11260
+ if (options.alphaBiLevel) children.push(new BuilderElement({
11261
+ attributes: { thresh: {
11262
+ key: "thresh",
11263
+ value: `${options.alphaBiLevel.thresh}%`
11264
+ } },
11265
+ name: "a:alphaBiLevel"
11266
+ }));
11267
+ if (options.colorChange) {
11268
+ const attrs = {};
11269
+ if (options.colorChange.useAlpha === false) attrs.useA = {
11270
+ key: "useA",
11271
+ value: "0"
11272
+ };
11273
+ children.push(new BuilderElement({
11274
+ attributes: attrs,
11275
+ children: [new BuilderElement({
11276
+ children: [createColorElement(options.colorChange.from)],
11277
+ name: "a:clrFrom"
11278
+ }), new BuilderElement({
11279
+ children: [createColorElement(options.colorChange.to)],
11280
+ name: "a:clrTo"
11281
+ })],
11282
+ name: "a:clrChange"
11283
+ }));
11284
+ }
11285
+ if (options.colorRepl) children.push(new BuilderElement({
11286
+ children: [createColorElement(options.colorRepl.color)],
11287
+ name: "a:clrRepl"
11288
+ }));
11289
+ if (options.blur) {
11290
+ const attrs = {};
11291
+ if (options.blur.rad !== void 0) attrs.rad = {
11292
+ key: "rad",
11293
+ value: options.blur.rad
11294
+ };
11295
+ if (options.blur.grow === false) attrs.grow = {
11296
+ key: "grow",
11297
+ value: 0
11298
+ };
11299
+ children.push(new BuilderElement({
11300
+ attributes: attrs,
11301
+ name: "a:blur"
11302
+ }));
11303
+ }
11304
+ return children;
11305
+ };
11306
+ //#endregion
11113
11307
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts
11114
11308
  /**
11115
11309
  * Creates an SVG blip element for embedding SVG images.
@@ -11219,20 +11413,25 @@
11219
11413
  * @param mediaData - The media data containing the image information
11220
11414
  * @returns An XML component representing the blip element
11221
11415
  */
11222
- const createBlip = (mediaData) => new BuilderElement({
11223
- attributes: {
11224
- cstate: {
11225
- key: "cstate",
11226
- value: "none"
11416
+ const createBlip = (mediaData, blipEffects) => {
11417
+ const children = [];
11418
+ if (blipEffects) children.push(...createBlipEffects(blipEffects));
11419
+ if (mediaData.type === "svg") children.push(createExtentionList(mediaData));
11420
+ return new BuilderElement({
11421
+ attributes: {
11422
+ cstate: {
11423
+ key: "cstate",
11424
+ value: "none"
11425
+ },
11426
+ embed: {
11427
+ key: "r:embed",
11428
+ value: `rId{${mediaData.type === "svg" ? mediaData.fallback.fileName : mediaData.fileName}}`
11429
+ }
11227
11430
  },
11228
- embed: {
11229
- key: "r:embed",
11230
- value: `rId{${mediaData.type === "svg" ? mediaData.fallback.fileName : mediaData.fileName}}`
11231
- }
11232
- },
11233
- children: mediaData.type === "svg" ? [createExtentionList(mediaData)] : [],
11234
- name: "a:blip"
11235
- });
11431
+ children,
11432
+ name: "a:blip"
11433
+ });
11434
+ };
11236
11435
  //#endregion
11237
11436
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts
11238
11437
  /**
@@ -11356,6 +11555,106 @@
11356
11555
  }
11357
11556
  };
11358
11557
  //#endregion
11558
+ //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/tile.ts
11559
+ /**
11560
+ * Tile fill module for blip fills.
11561
+ *
11562
+ * This module defines how images are tiled (repeated) to fill shapes.
11563
+ *
11564
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
11565
+ *
11566
+ * @module
11567
+ */
11568
+ /**
11569
+ * Tile flip mode for tiling images.
11570
+ *
11571
+ * Specifies whether the image is flipped along the x-axis, y-axis,
11572
+ * both axes, or not at all when tiling.
11573
+ */
11574
+ const TileFlipMode = {
11575
+ NONE: "none",
11576
+ X: "x",
11577
+ Y: "y",
11578
+ XY: "xy"
11579
+ };
11580
+ /**
11581
+ * Tile alignment within the shape.
11582
+ *
11583
+ * Specifies the anchor position of the first tile relative to the shape.
11584
+ */
11585
+ const TileAlignment = {
11586
+ TOP_LEFT: "tl",
11587
+ TOP: "t",
11588
+ TOP_RIGHT: "tr",
11589
+ LEFT: "l",
11590
+ CENTER: "ctr",
11591
+ RIGHT: "r",
11592
+ BOTTOM_LEFT: "bl",
11593
+ BOTTOM: "b",
11594
+ BOTTOM_RIGHT: "br"
11595
+ };
11596
+ /**
11597
+ * Creates a tile fill mode element for blip fills.
11598
+ *
11599
+ * When a blip fill uses tile mode, the image is repeated (tiled) to fill
11600
+ * the shape instead of being stretched. This element controls the tiling
11601
+ * parameters such as offset, scale, flip, and alignment.
11602
+ *
11603
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
11604
+ *
11605
+ * ## XSD Schema
11606
+ * ```xml
11607
+ * <xsd:complexType name="CT_TileInfoProperties">
11608
+ * <xsd:attribute name="tx" type="ST_Coordinate" use="optional"/>
11609
+ * <xsd:attribute name="ty" type="ST_Coordinate" use="optional"/>
11610
+ * <xsd:attribute name="sx" type="ST_Percentage" use="optional"/>
11611
+ * <xsd:attribute name="sy" type="ST_Percentage" use="optional"/>
11612
+ * <xsd:attribute name="flip" type="ST_TileFlipMode" default="none"/>
11613
+ * <xsd:attribute name="algn" type="ST_RectAlignment" use="optional"/>
11614
+ * </xsd:complexType>
11615
+ * ```
11616
+ *
11617
+ * @example
11618
+ * ```typescript
11619
+ * // Tile with 50% scale
11620
+ * createTileInfo({ sx: 50, sy: 50 });
11621
+ * // Tile with flip and alignment
11622
+ * createTileInfo({ flip: "XY", align: "CENTER" });
11623
+ * ```
11624
+ */
11625
+ const createTileInfo = (options) => {
11626
+ if (!options) return new BuilderElement({ name: "a:tile" });
11627
+ const attributes = {};
11628
+ if (options.tx !== void 0) attributes.tx = {
11629
+ key: "tx",
11630
+ value: options.tx
11631
+ };
11632
+ if (options.ty !== void 0) attributes.ty = {
11633
+ key: "ty",
11634
+ value: options.ty
11635
+ };
11636
+ if (options.sx !== void 0) attributes.sx = {
11637
+ key: "sx",
11638
+ value: options.sx
11639
+ };
11640
+ if (options.sy !== void 0) attributes.sy = {
11641
+ key: "sy",
11642
+ value: options.sy
11643
+ };
11644
+ if (options.flip !== void 0) attributes.flip = {
11645
+ key: "flip",
11646
+ value: TileFlipMode[options.flip]
11647
+ };
11648
+ if (options.align !== void 0) attributes.algn = {
11649
+ key: "algn",
11650
+ value: TileAlignment[options.align]
11651
+ };
11652
+ return new BuilderElement({
11653
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
11654
+ name: "a:tile"
11655
+ });
11656
+ };
11657
+ //#endregion
11359
11658
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts
11360
11659
  /**
11361
11660
  * Represents a blip fill for pictures in DrawingML.
@@ -11384,12 +11683,48 @@
11384
11683
  * // If mediaData.srcRect is set, cropping is applied
11385
11684
  * ```
11386
11685
  */
11387
- var BlipFill = class extends XmlComponent {
11388
- constructor(mediaData) {
11389
- super("pic:blipFill");
11390
- this.root.push(createBlip(mediaData));
11391
- this.root.push(createSourceRectangle(mediaData.srcRect));
11392
- this.root.push(new Stretch());
11686
+ const createBlipFill = (mediaData, options) => {
11687
+ const children = [];
11688
+ children.push(createBlip(mediaData, options === null || options === void 0 ? void 0 : options.blipEffects));
11689
+ children.push(createSourceRectangle(mediaData.srcRect));
11690
+ if (options === null || options === void 0 ? void 0 : options.tile) children.push(createTileInfo(options.tile));
11691
+ else children.push(new Stretch());
11692
+ const attributes = {};
11693
+ if ((options === null || options === void 0 ? void 0 : options.dpi) !== void 0) attributes.dpi = {
11694
+ key: "dpi",
11695
+ value: options.dpi
11696
+ };
11697
+ if ((options === null || options === void 0 ? void 0 : options.rotWithShape) !== void 0) attributes.rotWithShape = {
11698
+ key: "rotWithShape",
11699
+ value: options.rotWithShape ? 1 : 0
11700
+ };
11701
+ return new BuilderElement({
11702
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
11703
+ children,
11704
+ name: "pic:blipFill"
11705
+ });
11706
+ };
11707
+ //#endregion
11708
+ //#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
11709
+ /**
11710
+ * Attributes for non-visual picture properties.
11711
+ *
11712
+ * @module
11713
+ */
11714
+ /**
11715
+ * Attributes for CT_NonVisualPictureProperties.
11716
+ *
11717
+ * ## XSD Schema
11718
+ * ```xml
11719
+ * <xsd:attribute name="preferRelativeResize" type="xsd:boolean" use="optional" default="true"/>
11720
+ * ```
11721
+ *
11722
+ * @internal
11723
+ */
11724
+ var ChildNonVisualPropertiesAttributes = class extends XmlAttributeComponent {
11725
+ constructor(..._args) {
11726
+ super(..._args);
11727
+ _defineProperty(this, "xmlKeys", { preferRelativeResize: "preferRelativeResize" });
11393
11728
  }
11394
11729
  };
11395
11730
  //#endregion
@@ -11514,6 +11849,7 @@
11514
11849
  var ChildNonVisualProperties = class extends XmlComponent {
11515
11850
  constructor() {
11516
11851
  super("pic:cNvPicPr");
11852
+ this.root.push(new ChildNonVisualPropertiesAttributes({ preferRelativeResize: true }));
11517
11853
  this.root.push(new PicLocks());
11518
11854
  }
11519
11855
  };
@@ -11562,6 +11898,85 @@
11562
11898
  },
11563
11899
  name: "a:hlinkClick"
11564
11900
  });
11901
+ /**
11902
+ * Creates a hover hyperlink element for a drawing.
11903
+ *
11904
+ * This element defines what happens when a user hovers over a drawing element.
11905
+ *
11906
+ * ## XSD Schema
11907
+ * ```xml
11908
+ * <xsd:complexType name="CT_Hyperlink">
11909
+ * <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
11910
+ * <xsd:attribute name="tgtFrame" type="s:ST_String"/>
11911
+ * <xsd:attribute name="tooltip" type="s:ST_String"/>
11912
+ * <xsd:attribute name="docLocation" type="s:ST_String"/>
11913
+ * <xsd:attribute name="history" type="s:ST_OnOff"/>
11914
+ * <xsd:attribute name="anchor" type="s:ST_String"/>
11915
+ * <xsd:attribute ref="r:id"/>
11916
+ * </xsd:complexType>
11917
+ * ```
11918
+ *
11919
+ * @param linkId - The relationship ID for the hyperlink target
11920
+ * @param hasXmlNs - Whether to include the XML namespace declaration
11921
+ * @returns An XML component representing the hover hyperlink
11922
+ */
11923
+ const createHyperlinkHover = (linkId, hasXmlNs) => new BuilderElement({
11924
+ attributes: {
11925
+ ...hasXmlNs ? { xmlns: {
11926
+ key: "xmlns:a",
11927
+ value: "http://schemas.openxmlformats.org/drawingml/2006/main"
11928
+ } } : {},
11929
+ id: {
11930
+ key: "r:id",
11931
+ value: `rId${linkId}`
11932
+ }
11933
+ },
11934
+ name: "a:hlinkHover"
11935
+ });
11936
+ //#endregion
11937
+ //#region src/file/relationships/relationship/relationship.ts
11938
+ /**
11939
+ * Target mode types for relationships.
11940
+ *
11941
+ * Indicates whether a relationship target is external to the package.
11942
+ */
11943
+ const TargetModeType = { EXTERNAL: "External" };
11944
+ /**
11945
+ * Creates a single relationship between parts in an OPC package.
11946
+ *
11947
+ * A relationship defines a typed connection from a source part to a target part,
11948
+ * identified by a unique ID within the relationships collection.
11949
+ *
11950
+ * @example
11951
+ * ```typescript
11952
+ * // Internal relationship to an image
11953
+ * createRelationship("rId1", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "media/image1.png");
11954
+ *
11955
+ * // External relationship to a hyperlink
11956
+ * createRelationship("rId2", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", "https://example.com", TargetModeType.EXTERNAL);
11957
+ * ```
11958
+ */
11959
+ const createRelationship = (id, type, target, targetMode) => new BuilderElement({
11960
+ attributes: {
11961
+ id: {
11962
+ key: "Id",
11963
+ value: id
11964
+ },
11965
+ target: {
11966
+ key: "Target",
11967
+ value: target
11968
+ },
11969
+ targetMode: {
11970
+ key: "TargetMode",
11971
+ value: targetMode
11972
+ },
11973
+ type: {
11974
+ key: "Type",
11975
+ value: type
11976
+ }
11977
+ },
11978
+ name: "Relationship"
11979
+ });
11565
11980
  //#endregion
11566
11981
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts
11567
11982
  /**
@@ -11591,16 +12006,7 @@
11591
12006
  };
11592
12007
  //#endregion
11593
12008
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts
11594
- /**
11595
- * Non-visual drawing properties module.
11596
- *
11597
- * This module provides basic metadata for drawing elements including
11598
- * ID, name, description, and hyperlink support.
11599
- *
11600
- * Reference: http://officeopenxml.com/drwPic.php
11601
- *
11602
- * @module
11603
- */
12009
+ const HYPERLINK_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
11604
12010
  /**
11605
12011
  * Represents non-visual drawing properties for pictures.
11606
12012
  *
@@ -11631,8 +12037,10 @@
11631
12037
  * ```
11632
12038
  */
11633
12039
  var NonVisualProperties = class extends XmlComponent {
11634
- constructor() {
12040
+ constructor(hyperlink) {
11635
12041
  super("pic:cNvPr");
12042
+ _defineProperty(this, "hyperlink", void 0);
12043
+ this.hyperlink = hyperlink;
11636
12044
  this.root.push(new NonVisualPropertiesAttributes({
11637
12045
  descr: "",
11638
12046
  id: 0,
@@ -11640,28 +12048,32 @@
11640
12048
  }));
11641
12049
  }
11642
12050
  prepForXml(context) {
12051
+ let hasStackClick = false;
11643
12052
  for (let i = context.stack.length - 1; i >= 0; i--) {
11644
12053
  const element = context.stack[i];
11645
12054
  if (!(element instanceof ConcreteHyperlink)) continue;
11646
12055
  this.root.push(createHyperlinkClick(element.linkId, false));
12056
+ hasStackClick = true;
11647
12057
  break;
11648
12058
  }
12059
+ if (this.hyperlink) {
12060
+ if (this.hyperlink.click && !hasStackClick) {
12061
+ const linkId = uniqueId();
12062
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE$1, this.hyperlink.click, TargetModeType.EXTERNAL);
12063
+ this.root.push(createHyperlinkClick(linkId, false));
12064
+ }
12065
+ if (this.hyperlink.hover) {
12066
+ const linkId = uniqueId();
12067
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE$1, this.hyperlink.hover, TargetModeType.EXTERNAL);
12068
+ this.root.push(createHyperlinkHover(linkId, false));
12069
+ }
12070
+ }
11649
12071
  return super.prepForXml(context);
11650
12072
  }
11651
12073
  };
11652
12074
  //#endregion
11653
12075
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts
11654
12076
  /**
11655
- * Non-visual picture properties module.
11656
- *
11657
- * This module provides metadata and locking settings for pictures
11658
- * that don't affect their visual appearance.
11659
- *
11660
- * Reference: http://officeopenxml.com/drwPic.php
11661
- *
11662
- * @module
11663
- */
11664
- /**
11665
12077
  * Represents non-visual picture properties.
11666
12078
  *
11667
12079
  * This element specifies non-visual properties for a picture. These properties
@@ -11686,9 +12098,9 @@
11686
12098
  * ```
11687
12099
  */
11688
12100
  var NonVisualPicProperties = class extends XmlComponent {
11689
- constructor() {
12101
+ constructor(hyperlink) {
11690
12102
  super("pic:nvPicPr");
11691
- this.root.push(new NonVisualProperties());
12103
+ this.root.push(new NonVisualProperties(hyperlink));
11692
12104
  this.root.push(new ChildNonVisualProperties());
11693
12105
  }
11694
12106
  };
@@ -11745,14 +12157,19 @@
11745
12157
  * ```
11746
12158
  */
11747
12159
  var Pic = class extends XmlComponent {
11748
- constructor({ mediaData, transform, outline }) {
12160
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11749
12161
  super("pic:pic");
11750
12162
  this.root.push(new PicAttributes({ xmlns: "http://schemas.openxmlformats.org/drawingml/2006/picture" }));
11751
- this.root.push(new NonVisualPicProperties());
11752
- this.root.push(new BlipFill(mediaData));
12163
+ this.root.push(new NonVisualPicProperties(hyperlink));
12164
+ this.root.push(createBlipFill(mediaData, {
12165
+ blipEffects,
12166
+ tile
12167
+ }));
11753
12168
  this.root.push(new ShapeProperties({
11754
12169
  element: "pic",
12170
+ effects,
11755
12171
  outline,
12172
+ solidFill,
11756
12173
  transform
11757
12174
  }));
11758
12175
  }
@@ -11878,7 +12295,7 @@
11878
12295
  * ```
11879
12296
  */
11880
12297
  var GraphicData = class extends XmlComponent {
11881
- constructor({ mediaData, transform, outline, solidFill }) {
12298
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11882
12299
  super("a:graphicData");
11883
12300
  if (mediaData.type === "wps") {
11884
12301
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
@@ -11916,8 +12333,13 @@
11916
12333
  } else {
11917
12334
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.openxmlformats.org/drawingml/2006/picture" }));
11918
12335
  const pic = new Pic({
12336
+ blipEffects,
12337
+ effects,
12338
+ hyperlink,
11919
12339
  mediaData,
11920
12340
  outline,
12341
+ solidFill,
12342
+ tile,
11921
12343
  transform
11922
12344
  });
11923
12345
  this.root.push(pic);
@@ -11963,14 +12385,18 @@
11963
12385
  * ```
11964
12386
  */
11965
12387
  var Graphic = class extends XmlComponent {
11966
- constructor({ mediaData, transform, outline, solidFill }) {
12388
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11967
12389
  super("a:graphic");
11968
12390
  _defineProperty(this, "data", void 0);
11969
12391
  this.root.push(new GraphicAttributes({ a: "http://schemas.openxmlformats.org/drawingml/2006/main" }));
11970
12392
  this.data = new GraphicData({
12393
+ blipEffects,
12394
+ effects,
12395
+ hyperlink,
11971
12396
  mediaData,
11972
12397
  outline,
11973
12398
  solidFill,
12399
+ tile,
11974
12400
  transform
11975
12401
  });
11976
12402
  this.root.push(this.data);
@@ -12192,12 +12618,13 @@
12192
12618
  * Document Properties module for DrawingML elements.
12193
12619
  *
12194
12620
  * This module provides non-visual properties for drawing elements,
12195
- * including name, description, and accessibility information.
12621
+ * including name, description, accessibility information, and hyperlinks.
12196
12622
  *
12197
12623
  * Reference: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docPr_topic_ID0ES32OB.html
12198
12624
  *
12199
12625
  * @module
12200
12626
  */
12627
+ const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
12201
12628
  /**
12202
12629
  * Represents non-visual drawing properties in a WordprocessingML document.
12203
12630
  *
@@ -12222,13 +12649,15 @@
12222
12649
  * ```
12223
12650
  */
12224
12651
  var DocProperties = class extends XmlComponent {
12225
- constructor({ name, description, title, id } = {
12652
+ constructor({ name, description, title, id, hyperlink } = {
12226
12653
  description: "",
12227
12654
  name: "",
12228
12655
  title: ""
12229
12656
  }) {
12230
12657
  super("wp:docPr");
12231
12658
  _defineProperty(this, "docPropertiesUniqueNumericId", docPropertiesUniqueNumericIdGen());
12659
+ _defineProperty(this, "hyperlink", void 0);
12660
+ this.hyperlink = hyperlink;
12232
12661
  const attributes = {
12233
12662
  id: {
12234
12663
  key: "id",
@@ -12250,12 +12679,26 @@
12250
12679
  this.root.push(new NextAttributeComponent(attributes));
12251
12680
  }
12252
12681
  prepForXml(context) {
12682
+ let hasStackClick = false;
12253
12683
  for (let i = context.stack.length - 1; i >= 0; i--) {
12254
12684
  const element = context.stack[i];
12255
12685
  if (!(element instanceof ConcreteHyperlink)) continue;
12256
12686
  this.root.push(createHyperlinkClick(element.linkId, true));
12687
+ hasStackClick = true;
12257
12688
  break;
12258
12689
  }
12690
+ if (this.hyperlink) {
12691
+ if (this.hyperlink.click && !hasStackClick) {
12692
+ const linkId = uniqueId();
12693
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE, this.hyperlink.click, TargetModeType.EXTERNAL);
12694
+ this.root.push(createHyperlinkClick(linkId, true));
12695
+ }
12696
+ if (this.hyperlink.hover) {
12697
+ const linkId = uniqueId();
12698
+ context.viewWrapper.Relationships.addRelationship(linkId, HYPERLINK_RELATIONSHIP_TYPE, this.hyperlink.hover, TargetModeType.EXTERNAL);
12699
+ this.root.push(createHyperlinkHover(linkId, true));
12700
+ }
12701
+ }
12259
12702
  return super.prepForXml(context);
12260
12703
  }
12261
12704
  };
@@ -12531,6 +12974,7 @@
12531
12974
  */
12532
12975
  var Anchor = class extends XmlComponent {
12533
12976
  constructor({ mediaData, transform, drawingOptions }) {
12977
+ var _drawingOptions$docPr;
12534
12978
  super("wp:anchor");
12535
12979
  const floating = {
12536
12980
  allowOverlap: true,
@@ -12583,16 +13027,20 @@
12583
13027
  this.root.push(new DocProperties(drawingOptions.docProperties));
12584
13028
  this.root.push(createGraphicFrameProperties());
12585
13029
  this.root.push(new Graphic({
13030
+ blipEffects: drawingOptions.blipEffects,
13031
+ effects: drawingOptions.effects,
13032
+ hyperlink: (_drawingOptions$docPr = drawingOptions.docProperties) === null || _drawingOptions$docPr === void 0 ? void 0 : _drawingOptions$docPr.hyperlink,
12586
13033
  mediaData,
12587
13034
  outline: drawingOptions.outline,
12588
13035
  solidFill: drawingOptions.solidFill,
13036
+ tile: drawingOptions.tile,
12589
13037
  transform
12590
13038
  }));
12591
13039
  }
12592
13040
  };
12593
13041
  //#endregion
12594
13042
  //#region src/file/drawing/inline/inline.ts
12595
- const createInline = ({ mediaData, transform, docProperties, outline, solidFill }) => {
13043
+ const createInline = ({ mediaData, transform, docProperties, outline, solidFill, effects, blipEffects, tile }) => {
12596
13044
  var _outline$width, _outline$width2, _outline$width3, _outline$width4;
12597
13045
  return new BuilderElement({
12598
13046
  attributes: {
@@ -12632,9 +13080,13 @@
12632
13080
  new DocProperties(docProperties),
12633
13081
  createGraphicFrameProperties(),
12634
13082
  new Graphic({
13083
+ blipEffects,
13084
+ effects,
13085
+ hyperlink: docProperties === null || docProperties === void 0 ? void 0 : docProperties.hyperlink,
12635
13086
  mediaData,
12636
13087
  outline,
12637
13088
  solidFill,
13089
+ tile,
12638
13090
  transform
12639
13091
  })
12640
13092
  ],
@@ -12665,10 +13117,13 @@
12665
13117
  constructor(imageData, drawingOptions = {}) {
12666
13118
  super("w:drawing");
12667
13119
  if (!drawingOptions.floating) this.root.push(createInline({
13120
+ blipEffects: drawingOptions.blipEffects,
12668
13121
  docProperties: drawingOptions.docProperties,
13122
+ effects: drawingOptions.effects,
12669
13123
  mediaData: imageData,
12670
13124
  outline: drawingOptions.outline,
12671
13125
  solidFill: drawingOptions.solidFill,
13126
+ tile: drawingOptions.tile,
12672
13127
  transform: imageData.transformation
12673
13128
  }));
12674
13129
  else this.root.push(new Anchor({
@@ -12814,9 +13269,13 @@
12814
13269
  ...createImageData(rawData, options.transformation, key, options.srcRect)
12815
13270
  };
12816
13271
  const drawing = new Drawing(this.imageData, {
13272
+ blipEffects: options.blipEffects,
12817
13273
  docProperties: options.altText,
12818
13274
  floating: options.floating,
12819
- outline: options.outline
13275
+ outline: options.outline,
13276
+ solidFill: options.solidFill,
13277
+ effects: options.effects,
13278
+ tile: options.tile
12820
13279
  });
12821
13280
  this.root.push(drawing);
12822
13281
  }
@@ -13070,50 +13529,6 @@
13070
13529
  }
13071
13530
  };
13072
13531
  //#endregion
13073
- //#region src/file/relationships/relationship/relationship.ts
13074
- /**
13075
- * Target mode types for relationships.
13076
- *
13077
- * Indicates whether a relationship target is external to the package.
13078
- */
13079
- const TargetModeType = { EXTERNAL: "External" };
13080
- /**
13081
- * Creates a single relationship between parts in an OPC package.
13082
- *
13083
- * A relationship defines a typed connection from a source part to a target part,
13084
- * identified by a unique ID within the relationships collection.
13085
- *
13086
- * @example
13087
- * ```typescript
13088
- * // Internal relationship to an image
13089
- * createRelationship("rId1", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "media/image1.png");
13090
- *
13091
- * // External relationship to a hyperlink
13092
- * createRelationship("rId2", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", "https://example.com", TargetModeType.EXTERNAL);
13093
- * ```
13094
- */
13095
- const createRelationship = (id, type, target, targetMode) => new BuilderElement({
13096
- attributes: {
13097
- id: {
13098
- key: "Id",
13099
- value: id
13100
- },
13101
- target: {
13102
- key: "Target",
13103
- value: target
13104
- },
13105
- targetMode: {
13106
- key: "TargetMode",
13107
- value: targetMode
13108
- },
13109
- type: {
13110
- key: "Type",
13111
- value: type
13112
- }
13113
- },
13114
- name: "Relationship"
13115
- });
13116
- //#endregion
13117
13532
  //#region src/file/relationships/relationships.ts
13118
13533
  /**
13119
13534
  * Relationships module for Open Packaging Conventions.
@@ -14214,8 +14629,7 @@
14214
14629
  var IndentLevel = class extends XmlComponent {
14215
14630
  constructor(level) {
14216
14631
  super("w:ilvl");
14217
- 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");
14218
- this.root.push(new Attributes({ val: level }));
14632
+ this.root.push(new Attributes({ val: Math.min(level, 9) }));
14219
14633
  }
14220
14634
  };
14221
14635
  /**
@@ -22384,9 +22798,8 @@
22384
22798
  this.runProperties = new RunProperties(style && style.run);
22385
22799
  this.root.push(this.paragraphProperties);
22386
22800
  this.root.push(this.runProperties);
22387
- 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");
22388
22801
  this.root.push(new LevelAttributes({
22389
- ilvl: decimalNumber(level),
22802
+ ilvl: decimalNumber(Math.min(level, 9)),
22390
22803
  tentative: 1
22391
22804
  }));
22392
22805
  }
@@ -24141,7 +24554,10 @@
24141
24554
  const xmlObj = (0, import_lib.xml2js)(xmlData, { compact: false });
24142
24555
  let stylesXmlElement;
24143
24556
  for (const xmlElm of xmlObj.elements || []) if (xmlElm.name === "w:styles") stylesXmlElement = xmlElm;
24144
- if (stylesXmlElement === void 0) throw new Error("can not find styles element");
24557
+ if (stylesXmlElement === void 0) return {
24558
+ importedStyles: [],
24559
+ initialStyles: new ImportedRootElementAttributes({})
24560
+ };
24145
24561
  return {
24146
24562
  importedStyles: (stylesXmlElement.elements || []).map((childElm) => convertToXmlComponent(childElm)),
24147
24563
  initialStyles: new ImportedRootElementAttributes(stylesXmlElement.attributes)