docx-plus 0.0.14 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -8920,7 +8920,7 @@ const createHorizontalPosition = ({ relative, align, offset }) => new BuilderEle
8920
8920
  children: [(() => {
8921
8921
  if (align) return createAlign(align);
8922
8922
  if (offset !== void 0) return createPositionOffset(offset);
8923
- return createAlign("LEFT");
8923
+ return createAlign(HorizontalPositionAlign.LEFT);
8924
8924
  })()],
8925
8925
  name: "wp:positionH"
8926
8926
  });
@@ -8981,7 +8981,7 @@ const createVerticalPosition = ({ relative, align, offset }) => new BuilderEleme
8981
8981
  children: [(() => {
8982
8982
  if (align) return createAlign(align);
8983
8983
  if (offset !== void 0) return createPositionOffset(offset);
8984
- return createAlign("TOP");
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({
@@ -10915,12 +10954,12 @@ const createShape3D = (options) => {
10915
10954
  const children = [];
10916
10955
  if (options.bevelT) children.push(createBevel(options.bevelT));
10917
10956
  if (options.bevelB) children.push(createBottomBevel(options.bevelB));
10918
- if (options.extrusionClr) children.push(new BuilderElement({
10919
- children: [createColorElement(options.extrusionClr)],
10957
+ if (options.extrusionColor) children.push(new BuilderElement({
10958
+ children: [createColorElement(options.extrusionColor)],
10920
10959
  name: "a:extrusionClr"
10921
10960
  }));
10922
- if (options.contourClr) children.push(new BuilderElement({
10923
- children: [createColorElement(options.contourClr)],
10961
+ if (options.contourColor) children.push(new BuilderElement({
10962
+ children: [createColorElement(options.contourColor)],
10924
10963
  name: "a:contourClr"
10925
10964
  }));
10926
10965
  return new BuilderElement({
@@ -11106,6 +11145,158 @@ var GraphicDataAttributes = class extends XmlAttributeComponent {
11106
11145
  }
11107
11146
  };
11108
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
11109
11300
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts
11110
11301
  /**
11111
11302
  * Creates an SVG blip element for embedding SVG images.
@@ -11215,20 +11406,25 @@ const createExtentionList = (mediaData) => new BuilderElement({
11215
11406
  * @param mediaData - The media data containing the image information
11216
11407
  * @returns An XML component representing the blip element
11217
11408
  */
11218
- const createBlip = (mediaData) => new BuilderElement({
11219
- attributes: {
11220
- cstate: {
11221
- key: "cstate",
11222
- 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
+ }
11223
11423
  },
11224
- embed: {
11225
- key: "r:embed",
11226
- value: `rId{${mediaData.type === "svg" ? mediaData.fallback.fileName : mediaData.fileName}}`
11227
- }
11228
- },
11229
- children: mediaData.type === "svg" ? [createExtentionList(mediaData)] : [],
11230
- name: "a:blip"
11231
- });
11424
+ children,
11425
+ name: "a:blip"
11426
+ });
11427
+ };
11232
11428
  //#endregion
11233
11429
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts
11234
11430
  /**
@@ -11352,6 +11548,106 @@ var Stretch = class extends XmlComponent {
11352
11548
  }
11353
11549
  };
11354
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
11355
11651
  //#region src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts
11356
11652
  /**
11357
11653
  * Represents a blip fill for pictures in DrawingML.
@@ -11380,12 +11676,48 @@ var Stretch = class extends XmlComponent {
11380
11676
  * // If mediaData.srcRect is set, cropping is applied
11381
11677
  * ```
11382
11678
  */
11383
- var BlipFill = class extends XmlComponent {
11384
- constructor(mediaData) {
11385
- super("pic:blipFill");
11386
- this.root.push(createBlip(mediaData));
11387
- this.root.push(createSourceRectangle(mediaData.srcRect));
11388
- 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" });
11389
11721
  }
11390
11722
  };
11391
11723
  //#endregion
@@ -11510,6 +11842,7 @@ var PicLocks = class extends XmlComponent {
11510
11842
  var ChildNonVisualProperties = class extends XmlComponent {
11511
11843
  constructor() {
11512
11844
  super("pic:cNvPicPr");
11845
+ this.root.push(new ChildNonVisualPropertiesAttributes({ preferRelativeResize: true }));
11513
11846
  this.root.push(new PicLocks());
11514
11847
  }
11515
11848
  };
@@ -11558,6 +11891,85 @@ const createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
11558
11891
  },
11559
11892
  name: "a:hlinkClick"
11560
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
+ });
11561
11973
  //#endregion
11562
11974
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts
11563
11975
  /**
@@ -11587,16 +11999,7 @@ var NonVisualPropertiesAttributes = class extends XmlAttributeComponent {
11587
11999
  };
11588
12000
  //#endregion
11589
12001
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts
11590
- /**
11591
- * Non-visual drawing properties module.
11592
- *
11593
- * This module provides basic metadata for drawing elements including
11594
- * ID, name, description, and hyperlink support.
11595
- *
11596
- * Reference: http://officeopenxml.com/drwPic.php
11597
- *
11598
- * @module
11599
- */
12002
+ const HYPERLINK_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
11600
12003
  /**
11601
12004
  * Represents non-visual drawing properties for pictures.
11602
12005
  *
@@ -11627,8 +12030,10 @@ var NonVisualPropertiesAttributes = class extends XmlAttributeComponent {
11627
12030
  * ```
11628
12031
  */
11629
12032
  var NonVisualProperties = class extends XmlComponent {
11630
- constructor() {
12033
+ constructor(hyperlink) {
11631
12034
  super("pic:cNvPr");
12035
+ _defineProperty(this, "hyperlink", void 0);
12036
+ this.hyperlink = hyperlink;
11632
12037
  this.root.push(new NonVisualPropertiesAttributes({
11633
12038
  descr: "",
11634
12039
  id: 0,
@@ -11636,28 +12041,32 @@ var NonVisualProperties = class extends XmlComponent {
11636
12041
  }));
11637
12042
  }
11638
12043
  prepForXml(context) {
12044
+ let hasStackClick = false;
11639
12045
  for (let i = context.stack.length - 1; i >= 0; i--) {
11640
12046
  const element = context.stack[i];
11641
12047
  if (!(element instanceof ConcreteHyperlink)) continue;
11642
12048
  this.root.push(createHyperlinkClick(element.linkId, false));
12049
+ hasStackClick = true;
11643
12050
  break;
11644
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
+ }
11645
12064
  return super.prepForXml(context);
11646
12065
  }
11647
12066
  };
11648
12067
  //#endregion
11649
12068
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts
11650
12069
  /**
11651
- * Non-visual picture properties module.
11652
- *
11653
- * This module provides metadata and locking settings for pictures
11654
- * that don't affect their visual appearance.
11655
- *
11656
- * Reference: http://officeopenxml.com/drwPic.php
11657
- *
11658
- * @module
11659
- */
11660
- /**
11661
12070
  * Represents non-visual picture properties.
11662
12071
  *
11663
12072
  * This element specifies non-visual properties for a picture. These properties
@@ -11682,9 +12091,9 @@ var NonVisualProperties = class extends XmlComponent {
11682
12091
  * ```
11683
12092
  */
11684
12093
  var NonVisualPicProperties = class extends XmlComponent {
11685
- constructor() {
12094
+ constructor(hyperlink) {
11686
12095
  super("pic:nvPicPr");
11687
- this.root.push(new NonVisualProperties());
12096
+ this.root.push(new NonVisualProperties(hyperlink));
11688
12097
  this.root.push(new ChildNonVisualProperties());
11689
12098
  }
11690
12099
  };
@@ -11741,14 +12150,19 @@ var PicAttributes = class extends XmlAttributeComponent {
11741
12150
  * ```
11742
12151
  */
11743
12152
  var Pic = class extends XmlComponent {
11744
- constructor({ mediaData, transform, outline }) {
12153
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11745
12154
  super("pic:pic");
11746
12155
  this.root.push(new PicAttributes({ xmlns: "http://schemas.openxmlformats.org/drawingml/2006/picture" }));
11747
- this.root.push(new NonVisualPicProperties());
11748
- this.root.push(new BlipFill(mediaData));
12156
+ this.root.push(new NonVisualPicProperties(hyperlink));
12157
+ this.root.push(createBlipFill(mediaData, {
12158
+ blipEffects,
12159
+ tile
12160
+ }));
11749
12161
  this.root.push(new ShapeProperties({
11750
12162
  element: "pic",
12163
+ effects,
11751
12164
  outline,
12165
+ solidFill,
11752
12166
  transform
11753
12167
  }));
11754
12168
  }
@@ -11874,7 +12288,7 @@ const createWpgGroup = (options) => new BuilderElement({
11874
12288
  * ```
11875
12289
  */
11876
12290
  var GraphicData = class extends XmlComponent {
11877
- constructor({ mediaData, transform, outline, solidFill }) {
12291
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11878
12292
  super("a:graphicData");
11879
12293
  if (mediaData.type === "wps") {
11880
12294
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
@@ -11912,8 +12326,13 @@ var GraphicData = class extends XmlComponent {
11912
12326
  } else {
11913
12327
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.openxmlformats.org/drawingml/2006/picture" }));
11914
12328
  const pic = new Pic({
12329
+ blipEffects,
12330
+ effects,
12331
+ hyperlink,
11915
12332
  mediaData,
11916
12333
  outline,
12334
+ solidFill,
12335
+ tile,
11917
12336
  transform
11918
12337
  });
11919
12338
  this.root.push(pic);
@@ -11959,14 +12378,18 @@ var GraphicAttributes = class extends XmlAttributeComponent {
11959
12378
  * ```
11960
12379
  */
11961
12380
  var Graphic = class extends XmlComponent {
11962
- constructor({ mediaData, transform, outline, solidFill }) {
12381
+ constructor({ mediaData, transform, outline, solidFill, effects, blipEffects, tile, hyperlink }) {
11963
12382
  super("a:graphic");
11964
12383
  _defineProperty(this, "data", void 0);
11965
12384
  this.root.push(new GraphicAttributes({ a: "http://schemas.openxmlformats.org/drawingml/2006/main" }));
11966
12385
  this.data = new GraphicData({
12386
+ blipEffects,
12387
+ effects,
12388
+ hyperlink,
11967
12389
  mediaData,
11968
12390
  outline,
11969
12391
  solidFill,
12392
+ tile,
11970
12393
  transform
11971
12394
  });
11972
12395
  this.root.push(this.data);
@@ -12188,12 +12611,13 @@ const createWrapTopAndBottom = (margins = {
12188
12611
  * Document Properties module for DrawingML elements.
12189
12612
  *
12190
12613
  * This module provides non-visual properties for drawing elements,
12191
- * including name, description, and accessibility information.
12614
+ * including name, description, accessibility information, and hyperlinks.
12192
12615
  *
12193
12616
  * Reference: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docPr_topic_ID0ES32OB.html
12194
12617
  *
12195
12618
  * @module
12196
12619
  */
12620
+ const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
12197
12621
  /**
12198
12622
  * Represents non-visual drawing properties in a WordprocessingML document.
12199
12623
  *
@@ -12218,13 +12642,15 @@ const createWrapTopAndBottom = (margins = {
12218
12642
  * ```
12219
12643
  */
12220
12644
  var DocProperties = class extends XmlComponent {
12221
- constructor({ name, description, title, id } = {
12645
+ constructor({ name, description, title, id, hyperlink } = {
12222
12646
  description: "",
12223
12647
  name: "",
12224
12648
  title: ""
12225
12649
  }) {
12226
12650
  super("wp:docPr");
12227
12651
  _defineProperty(this, "docPropertiesUniqueNumericId", docPropertiesUniqueNumericIdGen());
12652
+ _defineProperty(this, "hyperlink", void 0);
12653
+ this.hyperlink = hyperlink;
12228
12654
  const attributes = {
12229
12655
  id: {
12230
12656
  key: "id",
@@ -12246,12 +12672,26 @@ var DocProperties = class extends XmlComponent {
12246
12672
  this.root.push(new NextAttributeComponent(attributes));
12247
12673
  }
12248
12674
  prepForXml(context) {
12675
+ let hasStackClick = false;
12249
12676
  for (let i = context.stack.length - 1; i >= 0; i--) {
12250
12677
  const element = context.stack[i];
12251
12678
  if (!(element instanceof ConcreteHyperlink)) continue;
12252
12679
  this.root.push(createHyperlinkClick(element.linkId, true));
12680
+ hasStackClick = true;
12253
12681
  break;
12254
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
+ }
12255
12695
  return super.prepForXml(context);
12256
12696
  }
12257
12697
  };
@@ -12527,6 +12967,7 @@ var AnchorAttributes = class extends XmlAttributeComponent {
12527
12967
  */
12528
12968
  var Anchor = class extends XmlComponent {
12529
12969
  constructor({ mediaData, transform, drawingOptions }) {
12970
+ var _drawingOptions$docPr;
12530
12971
  super("wp:anchor");
12531
12972
  const floating = {
12532
12973
  allowOverlap: true,
@@ -12579,16 +13020,20 @@ var Anchor = class extends XmlComponent {
12579
13020
  this.root.push(new DocProperties(drawingOptions.docProperties));
12580
13021
  this.root.push(createGraphicFrameProperties());
12581
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,
12582
13026
  mediaData,
12583
13027
  outline: drawingOptions.outline,
12584
13028
  solidFill: drawingOptions.solidFill,
13029
+ tile: drawingOptions.tile,
12585
13030
  transform
12586
13031
  }));
12587
13032
  }
12588
13033
  };
12589
13034
  //#endregion
12590
13035
  //#region src/file/drawing/inline/inline.ts
12591
- const createInline = ({ mediaData, transform, docProperties, outline, solidFill }) => {
13036
+ const createInline = ({ mediaData, transform, docProperties, outline, solidFill, effects, blipEffects, tile }) => {
12592
13037
  var _outline$width, _outline$width2, _outline$width3, _outline$width4;
12593
13038
  return new BuilderElement({
12594
13039
  attributes: {
@@ -12628,9 +13073,13 @@ const createInline = ({ mediaData, transform, docProperties, outline, solidFill
12628
13073
  new DocProperties(docProperties),
12629
13074
  createGraphicFrameProperties(),
12630
13075
  new Graphic({
13076
+ blipEffects,
13077
+ effects,
13078
+ hyperlink: docProperties === null || docProperties === void 0 ? void 0 : docProperties.hyperlink,
12631
13079
  mediaData,
12632
13080
  outline,
12633
13081
  solidFill,
13082
+ tile,
12634
13083
  transform
12635
13084
  })
12636
13085
  ],
@@ -12661,10 +13110,13 @@ var Drawing = class extends XmlComponent {
12661
13110
  constructor(imageData, drawingOptions = {}) {
12662
13111
  super("w:drawing");
12663
13112
  if (!drawingOptions.floating) this.root.push(createInline({
13113
+ blipEffects: drawingOptions.blipEffects,
12664
13114
  docProperties: drawingOptions.docProperties,
13115
+ effects: drawingOptions.effects,
12665
13116
  mediaData: imageData,
12666
13117
  outline: drawingOptions.outline,
12667
13118
  solidFill: drawingOptions.solidFill,
13119
+ tile: drawingOptions.tile,
12668
13120
  transform: imageData.transformation
12669
13121
  }));
12670
13122
  else this.root.push(new Anchor({
@@ -12810,9 +13262,13 @@ var ImageRun = class extends Run {
12810
13262
  ...createImageData(rawData, options.transformation, key, options.srcRect)
12811
13263
  };
12812
13264
  const drawing = new Drawing(this.imageData, {
13265
+ blipEffects: options.blipEffects,
12813
13266
  docProperties: options.altText,
12814
13267
  floating: options.floating,
12815
- outline: options.outline
13268
+ outline: options.outline,
13269
+ solidFill: options.solidFill,
13270
+ effects: options.effects,
13271
+ tile: options.tile
12816
13272
  });
12817
13273
  this.root.push(drawing);
12818
13274
  }
@@ -13066,50 +13522,6 @@ var RelationshipsAttributes = class extends XmlAttributeComponent {
13066
13522
  }
13067
13523
  };
13068
13524
  //#endregion
13069
- //#region src/file/relationships/relationship/relationship.ts
13070
- /**
13071
- * Target mode types for relationships.
13072
- *
13073
- * Indicates whether a relationship target is external to the package.
13074
- */
13075
- const TargetModeType = { EXTERNAL: "External" };
13076
- /**
13077
- * Creates a single relationship between parts in an OPC package.
13078
- *
13079
- * A relationship defines a typed connection from a source part to a target part,
13080
- * identified by a unique ID within the relationships collection.
13081
- *
13082
- * @example
13083
- * ```typescript
13084
- * // Internal relationship to an image
13085
- * createRelationship("rId1", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "media/image1.png");
13086
- *
13087
- * // External relationship to a hyperlink
13088
- * createRelationship("rId2", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", "https://example.com", TargetModeType.EXTERNAL);
13089
- * ```
13090
- */
13091
- const createRelationship = (id, type, target, targetMode) => new BuilderElement({
13092
- attributes: {
13093
- id: {
13094
- key: "Id",
13095
- value: id
13096
- },
13097
- target: {
13098
- key: "Target",
13099
- value: target
13100
- },
13101
- targetMode: {
13102
- key: "TargetMode",
13103
- value: targetMode
13104
- },
13105
- type: {
13106
- key: "Type",
13107
- value: type
13108
- }
13109
- },
13110
- name: "Relationship"
13111
- });
13112
- //#endregion
13113
13525
  //#region src/file/relationships/relationships.ts
13114
13526
  /**
13115
13527
  * Relationships module for Open Packaging Conventions.
@@ -19413,6 +19825,11 @@ var ContentTypes = class extends XmlComponent {
19413
19825
  this.root.push(createDefault("image/jpeg", "jpg"));
19414
19826
  this.root.push(createDefault("image/bmp", "bmp"));
19415
19827
  this.root.push(createDefault("image/gif", "gif"));
19828
+ this.root.push(createDefault("image/tiff", "tif"));
19829
+ this.root.push(createDefault("image/tiff", "tiff"));
19830
+ this.root.push(createDefault("image/x-emf", "emf"));
19831
+ this.root.push(createDefault("image/x-wmf", "wmf"));
19832
+ this.root.push(createDefault("image/x-icon", "ico"));
19416
19833
  this.root.push(createDefault("image/svg+xml", "svg"));
19417
19834
  this.root.push(createDefault("application/vnd.openxmlformats-package.relationships+xml", "rels"));
19418
19835
  this.root.push(createDefault("application/xml", "xml"));