docx 9.9.0 → 9.10.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.d.ts CHANGED
@@ -1307,7 +1307,26 @@ declare const CompoundLine: {
1307
1307
  */
1308
1308
  export declare class ConcreteHyperlink extends XmlComponent {
1309
1309
  readonly linkId: string;
1310
- constructor(children: readonly ParagraphChild[], relationshipId: string, anchor?: string);
1310
+ private readonly drawingLink?;
1311
+ /**
1312
+ * @param children - Inline content of the hyperlink
1313
+ * @param relationshipId - Id of the external relationship, without the rId prefix
1314
+ * @param anchor - Bookmark name or external URL fragment
1315
+ * @param externalLink - The full address of an external hyperlink, so the relationship id is kept alongside its anchor
1316
+ */
1317
+ constructor(children: readonly ParagraphChild[], relationshipId: string, anchor?: string, externalLink?: string);
1318
+ /**
1319
+ * Creates the `a:hlinkClick` of a picture in the hyperlink, which links to the same address.
1320
+ *
1321
+ * The hyperlink decides which relationship its pictures use, rather than the pictures reading `linkId`, because only it
1322
+ * knows whether that relationship has lost the fragment to `w:anchor`. The picture's relationship is added as the
1323
+ * picture is written, through the context's relationships, so it lands in the part the picture is in, both when
1324
+ * packing and when patching.
1325
+ *
1326
+ * @param context - The context the picture is written in, whose relationships get the picture's link if it has its own
1327
+ * @param declareNamespace - Declares the DrawingML namespace, for elements outside `a:graphic` such as `wp:docPr`
1328
+ */
1329
+ createDrawingClick(context: IContext, declareNamespace: boolean): XmlComponent;
1311
1330
  }
1312
1331
 
1313
1332
  /**
@@ -3465,6 +3484,23 @@ export declare type EffectExtentAttributes = {
3465
3484
  */
3466
3485
  export declare const eighthPointMeasureValue: (val: number) => number;
3467
3486
 
3487
+ /**
3488
+ * A font file the document embeds: one face of one of its fonts, with the unique key it is obfuscated with.
3489
+ *
3490
+ * @property name - Font family name
3491
+ * @property data - Font file data of the face
3492
+ * @property bold - Whether the face is bold
3493
+ * @property italic - Whether the face is italic
3494
+ * @property fontKey - Unique key (GUID) the file is obfuscated with
3495
+ */
3496
+ declare type EmbeddedFontFile = {
3497
+ readonly name: string;
3498
+ readonly data: Buffer;
3499
+ readonly bold: boolean;
3500
+ readonly italic: boolean;
3501
+ readonly fontKey: string;
3502
+ };
3503
+
3468
3504
  /**
3469
3505
  * A file of a package that is embedded in the document, such as a sheet of an embedded workbook.
3470
3506
  */
@@ -3657,6 +3693,11 @@ export declare type EstimatedPageNumbers = {
3657
3693
  * External hyperlinks create a relationship to an external resource (URL).
3658
3694
  * The relationship is created during document preparation and the hyperlink
3659
3695
  * is converted to a ConcreteHyperlink with the relationship ID.
3696
+ * URL fragments of at most 255 UTF-16 units are written as anchors, preserving any additional # characters.
3697
+ * Longer fragments stay in the original relationship URI to avoid exceeding Word's anchor limit;
3698
+ * those links retain the existing limitations for fragments with multiple # characters.
3699
+ * Word appends the anchor to the relationship target as described in MS-OI29500 §17.16.22:
3700
+ * https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/df06e423-11a6-4a36-bfb3-82139e531781
3660
3701
  *
3661
3702
  * Reference: http://officeopenxml.com/WPhyperlink.php
3662
3703
  *
@@ -3670,6 +3711,7 @@ export declare type EstimatedPageNumbers = {
3670
3711
  * <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
3671
3712
  * <xsd:attribute ref="r:id"/>
3672
3713
  * <xsd:attribute name="history" type="s:ST_OnOff" use="optional"/>
3714
+ * <xsd:attribute name="anchor" type="s:ST_String" use="optional"/>
3673
3715
  * </xsd:complexType>
3674
3716
  * ```
3675
3717
  *
@@ -3908,14 +3950,20 @@ export declare const fillSequenceNumbers: (body: IXmlableObject, context: IConte
3908
3950
  declare type FontOptions = {
3909
3951
  /** Font family name */
3910
3952
  readonly name: string;
3911
- /** Font file data (TTF, OTF, etc.) */
3953
+ /** Font file data (TTF, OTF, etc.) of the regular face */
3912
3954
  readonly data: Buffer;
3955
+ /** Font file data of the bold face, embedded as `w:embedBold` */
3956
+ readonly bold?: Buffer;
3957
+ /** Font file data of the italic face, embedded as `w:embedItalic` */
3958
+ readonly italic?: Buffer;
3959
+ /** Font file data of the bold italic face, embedded as `w:embedBoldItalic` */
3960
+ readonly boldItalic?: Buffer;
3913
3961
  /** Character set/encoding for the font */
3914
3962
  readonly characterSet?: (typeof CharacterSet)[keyof typeof CharacterSet];
3915
3963
  };
3916
3964
 
3917
3965
  /**
3918
- * Font options extended with a unique font key.
3966
+ * Font options extended with the unique key of the regular face's file.
3919
3967
  */
3920
3968
  declare type FontOptionsWithKey = FontOptions & {
3921
3969
  readonly fontKey: string;
@@ -3925,12 +3973,13 @@ declare type FontOptionsWithKey = FontOptions & {
3925
3973
  * Wrapper class for managing the font table and its relationships.
3926
3974
  *
3927
3975
  * Creates a font table with embedded font files and manages the relationships
3928
- * required for font embedding. Each font is assigned a unique key for obfuscation.
3976
+ * required for font embedding. Each face of a font is embedded as a file of its own,
3977
+ * with a unique key for obfuscation.
3929
3978
  *
3930
3979
  * @example
3931
3980
  * ```typescript
3932
3981
  * const fontWrapper = new FontWrapper([
3933
- * { name: "CustomFont", data: fontBuffer }
3982
+ * { name: "CustomFont", data: fontBuffer, bold: boldFontBuffer }
3934
3983
  * ]);
3935
3984
  * ```
3936
3985
  */
@@ -3938,7 +3987,10 @@ declare class FontWrapper implements IViewWrapper {
3938
3987
  readonly options: readonly FontOptions[];
3939
3988
  private readonly fontTable;
3940
3989
  private readonly relationships;
3990
+ /** @deprecated Use `files`, which has the file and key of each face a font embeds, not only the regular face's key */
3941
3991
  readonly fontOptionsWithKey: readonly FontOptionsWithKey[];
3992
+ /** The files of the faces the fonts embed, in order: the Nth is `fonts/font<N>.odttf`, with the relationship `rId<N>` */
3993
+ readonly files: readonly EmbeddedFontFile[];
3942
3994
  constructor(options: readonly FontOptions[]);
3943
3995
  get View(): XmlComponent;
3944
3996
  get Relationships(): Relationships;
@@ -7756,7 +7808,12 @@ export declare type ITableRowPropertiesOptions = ITableRowPropertiesOptionsBase
7756
7808
  export declare type ITableRowPropertiesOptionsBase = {
7757
7809
  /** Whether the row can be split across pages (cantSplit) */
7758
7810
  readonly cantSplit?: boolean;
7759
- /** Whether the row should be repeated as a header row on each page (tblHeader) */
7811
+ /**
7812
+ * Whether the row should be repeated as a header row on each page (tblHeader).
7813
+ *
7814
+ * Only the table's first row and the rows straight after it that also set this repeat. Word ignores it on
7815
+ * any row further down, so to repeat a different header for each part of a table, make each part a table of its own.
7816
+ */
7760
7817
  readonly tableHeader?: boolean;
7761
7818
  /** Row height configuration (trHeight) */
7762
7819
  readonly height?: {
@@ -12787,7 +12787,7 @@ DOT: "dot" };
12787
12787
  hash.sha512 = hash.sha.sha512;
12788
12788
  hash.ripemd160 = hash.ripemd.ripemd160;
12789
12789
  })))(), 1);
12790
- var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
12790
+ var urlAlphabet = "57X6y3wQZNzYjJB2L_10pxbackgroundhimselfUTF-8DEMOGRAPHICSVqvt4KW9";
12791
12791
  //#endregion
12792
12792
  //#region node_modules/nanoid/non-secure/index.js
12793
12793
  var customAlphabet = (alphabet, defaultSize = 21) => {
@@ -14584,48 +14584,6 @@ DOT: "dot" };
14584
14584
  }
14585
14585
  };
14586
14586
  //#endregion
14587
- //#region src/file/drawing/doc-properties/doc-properties-children.ts
14588
- /**
14589
- * Child elements for document properties.
14590
- *
14591
- * This module provides hyperlink elements that can be attached to
14592
- * drawing elements for interactive behavior.
14593
- *
14594
- * @module
14595
- */
14596
- /**
14597
- * Creates a click hyperlink element for a drawing.
14598
- *
14599
- * This element defines what happens when a user clicks on a drawing element.
14600
- *
14601
- * ## XSD Schema
14602
- * ```xml
14603
- * <xsd:complexType name="CT_Hyperlink">
14604
- * <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
14605
- * <xsd:attribute name="tgtFrame" type="s:ST_String"/>
14606
- * <xsd:attribute name="tooltip" type="s:ST_String"/>
14607
- * <xsd:attribute name="docLocation" type="s:ST_String"/>
14608
- * <xsd:attribute name="history" type="s:ST_OnOff"/>
14609
- * <xsd:attribute name="anchor" type="s:ST_String"/>
14610
- * <xsd:attribute ref="r:id"/>
14611
- * </xsd:complexType>
14612
- * ```
14613
- *
14614
- * @param linkId - The relationship ID for the hyperlink target
14615
- * @param hasXmlNs - Whether to include the XML namespace declaration
14616
- * @returns An XML component representing the click hyperlink
14617
- */
14618
- var createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
14619
- name: "a:hlinkClick",
14620
- attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
14621
- key: "xmlns:a",
14622
- value: "http://schemas.openxmlformats.org/drawingml/2006/main"
14623
- } } : {}), {}, { id: {
14624
- key: "r:id",
14625
- value: `rId${linkId}`
14626
- } })
14627
- });
14628
- //#endregion
14629
14587
  //#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts
14630
14588
  /**
14631
14589
  * Non-visual properties attributes module.
@@ -14706,7 +14664,7 @@ DOT: "dot" };
14706
14664
  for (let i = context.stack.length - 1; i >= 0; i--) {
14707
14665
  const element = context.stack[i];
14708
14666
  if (!(element instanceof ConcreteHyperlink)) continue;
14709
- this.root.push(createHyperlinkClick(element.linkId, false));
14667
+ this.root.push(element.createDrawingClick(context, false));
14710
14668
  break;
14711
14669
  }
14712
14670
  const result = super.prepForXml(context);
@@ -15376,6 +15334,48 @@ EXTERNAL: "External" };
15376
15334
  }
15377
15335
  });
15378
15336
  //#endregion
15337
+ //#region src/file/drawing/doc-properties/doc-properties-children.ts
15338
+ /**
15339
+ * Child elements for document properties.
15340
+ *
15341
+ * This module provides hyperlink elements that can be attached to
15342
+ * drawing elements for interactive behavior.
15343
+ *
15344
+ * @module
15345
+ */
15346
+ /**
15347
+ * Creates a click hyperlink element for a drawing.
15348
+ *
15349
+ * This element defines what happens when a user clicks on a drawing element.
15350
+ *
15351
+ * ## XSD Schema
15352
+ * ```xml
15353
+ * <xsd:complexType name="CT_Hyperlink">
15354
+ * <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
15355
+ * <xsd:attribute name="tgtFrame" type="s:ST_String"/>
15356
+ * <xsd:attribute name="tooltip" type="s:ST_String"/>
15357
+ * <xsd:attribute name="docLocation" type="s:ST_String"/>
15358
+ * <xsd:attribute name="history" type="s:ST_OnOff"/>
15359
+ * <xsd:attribute name="anchor" type="s:ST_String"/>
15360
+ * <xsd:attribute ref="r:id"/>
15361
+ * </xsd:complexType>
15362
+ * ```
15363
+ *
15364
+ * @param linkId - The relationship ID for the hyperlink target
15365
+ * @param hasXmlNs - Whether to include the XML namespace declaration
15366
+ * @returns An XML component representing the click hyperlink
15367
+ */
15368
+ var createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
15369
+ name: "a:hlinkClick",
15370
+ attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
15371
+ key: "xmlns:a",
15372
+ value: "http://schemas.openxmlformats.org/drawingml/2006/main"
15373
+ } } : {}), {}, { id: {
15374
+ key: "r:id",
15375
+ value: `rId${linkId}`
15376
+ } })
15377
+ });
15378
+ //#endregion
15379
15379
  //#region src/file/drawing/doc-properties/non-visual-drawing-properties.ts
15380
15380
  /**
15381
15381
  * Non-visual drawing properties (`CT_NonVisualDrawingProps`) of the shapes, pictures and groups inside a drawing:
@@ -15570,7 +15570,7 @@ EXTERNAL: "External" };
15570
15570
  } else for (let i = context.stack.length - 1; i >= 0; i--) {
15571
15571
  const element = context.stack[i];
15572
15572
  if (!(element instanceof ConcreteHyperlink)) continue;
15573
- this.root.push(createHyperlinkClick(element.linkId, true));
15573
+ this.root.push(element.createDrawingClick(context, true));
15574
15574
  break;
15575
15575
  }
15576
15576
  if (this.decorative) this.root.push(createDecorativeExtensionList(true));
@@ -18958,20 +18958,44 @@ MAX: 9026 };
18958
18958
  * ```
18959
18959
  */
18960
18960
  var ConcreteHyperlink = class extends XmlComponent {
18961
- constructor(children, relationshipId, anchor) {
18961
+ /**
18962
+ * @param children - Inline content of the hyperlink
18963
+ * @param relationshipId - Id of the external relationship, without the rId prefix
18964
+ * @param anchor - Bookmark name or external URL fragment
18965
+ * @param externalLink - The full address of an external hyperlink, so the relationship id is kept alongside its anchor
18966
+ */
18967
+ constructor(children, relationshipId, anchor, externalLink) {
18962
18968
  super("w:hyperlink");
18963
18969
  _defineProperty(this, "linkId", void 0);
18970
+ _defineProperty(this, "drawingLink", void 0);
18964
18971
  this.linkId = relationshipId;
18972
+ this.drawingLink = anchor && externalLink !== void 0 ? new DrawingLink(externalLink) : void 0;
18965
18973
  const attributes = new HyperlinkAttributes({
18966
18974
  history: 1,
18967
18975
  anchor: anchor ? anchor : void 0,
18968
- id: !anchor ? `rId${this.linkId}` : void 0
18976
+ id: !anchor || externalLink !== void 0 ? `rId${this.linkId}` : void 0
18969
18977
  });
18970
18978
  this.root.push(attributes);
18971
18979
  children.forEach((child) => {
18972
18980
  this.root.push(child);
18973
18981
  });
18974
18982
  }
18983
+ /**
18984
+ * Creates the `a:hlinkClick` of a picture in the hyperlink, which links to the same address.
18985
+ *
18986
+ * The hyperlink decides which relationship its pictures use, rather than the pictures reading `linkId`, because only it
18987
+ * knows whether that relationship has lost the fragment to `w:anchor`. The picture's relationship is added as the
18988
+ * picture is written, through the context's relationships, so it lands in the part the picture is in, both when
18989
+ * packing and when patching.
18990
+ *
18991
+ * @param context - The context the picture is written in, whose relationships get the picture's link if it has its own
18992
+ * @param declareNamespace - Declares the DrawingML namespace, for elements outside `a:graphic` such as `wp:docPr`
18993
+ */
18994
+ createDrawingClick(context, declareNamespace) {
18995
+ if (!this.drawingLink) return createHyperlinkClick(this.linkId, declareNamespace);
18996
+ this.drawingLink.addRelationship(context);
18997
+ return this.drawingLink.createClick(declareNamespace);
18998
+ }
18975
18999
  };
18976
19000
  /**
18977
19001
  * Represents an internal hyperlink to a bookmark within the document.
@@ -19020,6 +19044,11 @@ MAX: 9026 };
19020
19044
  * External hyperlinks create a relationship to an external resource (URL).
19021
19045
  * The relationship is created during document preparation and the hyperlink
19022
19046
  * is converted to a ConcreteHyperlink with the relationship ID.
19047
+ * URL fragments of at most 255 UTF-16 units are written as anchors, preserving any additional # characters.
19048
+ * Longer fragments stay in the original relationship URI to avoid exceeding Word's anchor limit;
19049
+ * those links retain the existing limitations for fragments with multiple # characters.
19050
+ * Word appends the anchor to the relationship target as described in MS-OI29500 §17.16.22:
19051
+ * https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/df06e423-11a6-4a36-bfb3-82139e531781
19023
19052
  *
19024
19053
  * Reference: http://officeopenxml.com/WPhyperlink.php
19025
19054
  *
@@ -19033,6 +19062,7 @@ MAX: 9026 };
19033
19062
  * <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
19034
19063
  * <xsd:attribute ref="r:id"/>
19035
19064
  * <xsd:attribute name="history" type="s:ST_OnOff" use="optional"/>
19065
+ * <xsd:attribute name="anchor" type="s:ST_String" use="optional"/>
19036
19066
  * </xsd:complexType>
19037
19067
  * ```
19038
19068
  *
@@ -19481,6 +19511,29 @@ MAX: 9026 };
19481
19511
  }
19482
19512
  };
19483
19513
  //#endregion
19514
+ //#region src/file/paragraph/links/external-hyperlink-target.ts
19515
+ /**
19516
+ * External hyperlink targets and fragments for WordprocessingML.
19517
+ *
19518
+ * Word appends the anchor to the relationship target, separated by a # character.
19519
+ * Reference: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/df06e423-11a6-4a36-bfb3-82139e531781
19520
+ *
19521
+ * @module
19522
+ */
19523
+ var MAX_ANCHOR_LENGTH = 255;
19524
+ /**
19525
+ * Splits a nonempty fragment that fits Word's anchor limit without decoding or normalizing either part.
19526
+ * Longer fragments stay in the original relationship URI, retaining its existing multi-hash limitations.
19527
+ */
19528
+ var externalHyperlinkTarget = (link) => {
19529
+ const index = link.indexOf("#");
19530
+ const fragmentLength = link.length - index - 1;
19531
+ return index > 0 && fragmentLength > 0 && fragmentLength <= MAX_ANCHOR_LENGTH ? {
19532
+ target: link.slice(0, index),
19533
+ anchor: link.slice(index + 1)
19534
+ } : { target: link };
19535
+ };
19536
+ //#endregion
19484
19537
  //#region src/file/fonts/font.ts
19485
19538
  /**
19486
19539
  * Font module for WordprocessingML documents.
@@ -19619,32 +19672,26 @@ MAX: 9026 };
19619
19672
  ]
19620
19673
  });
19621
19674
  //#endregion
19622
- //#region src/file/fonts/create-regular-font.ts
19675
+ //#region src/file/fonts/create-embedded-font.ts
19623
19676
  /**
19624
- * Creates a regular embedded font with default settings.
19677
+ * Creates an embedded font with default settings.
19625
19678
  *
19626
19679
  * This helper function creates a font definition with standard font signature
19627
19680
  * values that work for most common fonts. The signature specifies Unicode
19628
19681
  * and code page ranges supported by the font.
19629
19682
  *
19630
- * @param options - Font creation options
19631
- * @param options.name - Font name
19632
- * @param options.index - Font relationship index
19633
- * @param options.fontKey - Unique font key (GUID) for obfuscation
19634
- * @param options.characterSet - Optional character set identifier
19635
- *
19636
19683
  * @returns XmlComponent representing the font definition
19637
19684
  *
19638
19685
  * @example
19639
19686
  * ```typescript
19640
- * const font = createRegularFont({
19687
+ * const font = createEmbeddedFont({
19641
19688
  * name: "Arial",
19642
- * index: 1,
19643
- * fontKey: "12345678-1234-1234-1234-123456789012"
19689
+ * embedRegular: { id: "rId1", fontKey: "12345678-1234-1234-1234-123456789012" },
19690
+ * embedBold: { id: "rId2", fontKey: "12345678-1234-1234-1234-123456789013" },
19644
19691
  * });
19645
19692
  * ```
19646
19693
  */
19647
- var createRegularFont = ({ name, index, fontKey, characterSet }) => createFont({
19694
+ var createEmbeddedFont = ({ name, characterSet, embedRegular, embedBold, embedItalic, embedBoldItalic }) => createFont({
19648
19695
  name,
19649
19696
  sig: {
19650
19697
  usb0: "E0002AFF",
@@ -19657,10 +19704,10 @@ MAX: 9026 };
19657
19704
  charset: characterSet,
19658
19705
  family: "auto",
19659
19706
  pitch: "variable",
19660
- embedRegular: {
19661
- fontKey,
19662
- id: `rId${index}`
19663
- }
19707
+ embedRegular,
19708
+ embedBold,
19709
+ embedItalic,
19710
+ embedBoldItalic
19664
19711
  });
19665
19712
  //#endregion
19666
19713
  //#region src/file/fonts/font-table.ts
@@ -19738,25 +19785,47 @@ MAX: 9026 };
19738
19785
  value: "w14 w15 w16se w16cid w16 w16cex w16sdtdh"
19739
19786
  }
19740
19787
  },
19741
- children: fonts.map((font, i) => createRegularFont({
19742
- name: font.name,
19743
- index: i + 1,
19744
- fontKey: font.fontKey,
19745
- characterSet: font.characterSet
19746
- }))
19788
+ children: fonts.map(createEmbeddedFont)
19747
19789
  });
19748
19790
  //#endregion
19749
19791
  //#region src/file/fonts/font-wrapper.ts
19792
+ var FACES = [
19793
+ {
19794
+ option: "data",
19795
+ element: "embedRegular",
19796
+ bold: false,
19797
+ italic: false
19798
+ },
19799
+ {
19800
+ option: "bold",
19801
+ element: "embedBold",
19802
+ bold: true,
19803
+ italic: false
19804
+ },
19805
+ {
19806
+ option: "italic",
19807
+ element: "embedItalic",
19808
+ bold: false,
19809
+ italic: true
19810
+ },
19811
+ {
19812
+ option: "boldItalic",
19813
+ element: "embedBoldItalic",
19814
+ bold: true,
19815
+ italic: true
19816
+ }
19817
+ ];
19750
19818
  /**
19751
19819
  * Wrapper class for managing the font table and its relationships.
19752
19820
  *
19753
19821
  * Creates a font table with embedded font files and manages the relationships
19754
- * required for font embedding. Each font is assigned a unique key for obfuscation.
19822
+ * required for font embedding. Each face of a font is embedded as a file of its own,
19823
+ * with a unique key for obfuscation.
19755
19824
  *
19756
19825
  * @example
19757
19826
  * ```typescript
19758
19827
  * const fontWrapper = new FontWrapper([
19759
- * { name: "CustomFont", data: fontBuffer }
19828
+ * { name: "CustomFont", data: fontBuffer, bold: boldFontBuffer }
19760
19829
  * ]);
19761
19830
  * ```
19762
19831
  */
@@ -19765,12 +19834,43 @@ MAX: 9026 };
19765
19834
  _defineProperty(this, "options", void 0);
19766
19835
  _defineProperty(this, "fontTable", void 0);
19767
19836
  _defineProperty(this, "relationships", void 0);
19768
- _defineProperty(this, "fontOptionsWithKey", []);
19837
+ _defineProperty(
19838
+ this,
19839
+ /** @deprecated Use `files`, which has the file and key of each face a font embeds, not only the regular face's key */
19840
+ "fontOptionsWithKey",
19841
+ []
19842
+ );
19843
+ _defineProperty(
19844
+ this,
19845
+ /** The files of the faces the fonts embed, in order: the Nth is `fonts/font<N>.odttf`, with the relationship `rId<N>` */
19846
+ "files",
19847
+ []
19848
+ );
19769
19849
  this.options = options;
19770
- this.fontOptionsWithKey = options.map((o) => _objectSpread2(_objectSpread2({}, o), {}, { fontKey: uniqueUuid() }));
19771
- this.fontTable = createFontTable(this.fontOptionsWithKey);
19850
+ const faces = options.map((font) => FACES.flatMap(({ option, element, bold, italic }) => {
19851
+ const data = font[option];
19852
+ return data ? [{
19853
+ element,
19854
+ file: {
19855
+ name: font.name,
19856
+ data,
19857
+ bold,
19858
+ italic,
19859
+ fontKey: uniqueUuid()
19860
+ }
19861
+ }] : [];
19862
+ }));
19863
+ this.files = faces.flatMap((ofFont) => ofFont.map(({ file }) => file));
19864
+ this.fontOptionsWithKey = options.map((font, index) => _objectSpread2(_objectSpread2({}, font), {}, { fontKey: faces[index][0].file.fontKey }));
19865
+ this.fontTable = createFontTable(options.map((font, index) => _objectSpread2({
19866
+ name: font.name,
19867
+ characterSet: font.characterSet
19868
+ }, Object.fromEntries(faces[index].map(({ element, file }) => [element, {
19869
+ id: `rId${this.files.indexOf(file) + 1}`,
19870
+ fontKey: file.fontKey
19871
+ }])))));
19772
19872
  this.relationships = new Relationships();
19773
- for (let i = 0; i < options.length; i++) this.relationships.addRelationship(i + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font", `fonts/font${i + 1}.odttf`);
19873
+ for (let i = 0; i < this.files.length; i++) this.relationships.addRelationship(i + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font", `fonts/font${i + 1}.odttf`);
19774
19874
  }
19775
19875
  get View() {
19776
19876
  return this.fontTable;
@@ -20293,8 +20393,9 @@ MAX: 9026 };
20293
20393
  prepForXml(context) {
20294
20394
  for (const element of this.root) if (element instanceof ExternalHyperlink) {
20295
20395
  const index = this.root.indexOf(element);
20296
- const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
20297
- context.viewWrapper.Relationships.addRelationship(concreteHyperlink.linkId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", element.options.link, TargetModeType.EXTERNAL);
20396
+ const { target, anchor } = externalHyperlinkTarget(element.options.link);
20397
+ const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId(), anchor, element.options.link);
20398
+ context.viewWrapper.Relationships.addRelationship(concreteHyperlink.linkId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", target, TargetModeType.EXTERNAL);
20298
20399
  this.root[index] = concreteHyperlink;
20299
20400
  }
20300
20401
  return super.prepForXml(context);
@@ -35469,7 +35570,7 @@ while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[+
35469
35570
  zip.file(`word/media/${data.fileName}`, data.data);
35470
35571
  zip.file(`word/media/${data.fallback.fileName}`, data.fallback.data);
35471
35572
  }
35472
- for (const [i, { data: buffer, fontKey }] of file.FontTable.fontOptionsWithKey.entries()) zip.file(`word/fonts/font${i + 1}.odttf`, obfuscate(buffer, fontKey));
35573
+ for (const [i, { data: buffer, fontKey }] of file.FontTable.files.entries()) zip.file(`word/fonts/font${i + 1}.odttf`, obfuscate(buffer, fontKey));
35473
35574
  return zip;
35474
35575
  }
35475
35576
  xmlifyFile(file, prettify) {
@@ -37764,12 +37865,13 @@ while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[+
37764
37865
  json: element,
37765
37866
  patch: _objectSpread2(_objectSpread2({}, patchValue), {}, { children: patchValue.children.flatMap((child) => child instanceof Bookmark ? child.writtenAs : [child]).map((child) => {
37766
37867
  if (child instanceof ExternalHyperlink) {
37767
- const concreteHyperlink = new ConcreteHyperlink(child.options.children, uniqueId());
37868
+ const { target, anchor } = externalHyperlinkTarget(child.options.link);
37869
+ const concreteHyperlink = new ConcreteHyperlink(child.options.children, uniqueId(), anchor, child.options.link);
37768
37870
  hyperlinkRelationships.push({
37769
37871
  key,
37770
37872
  id: concreteHyperlink.linkId,
37771
37873
  type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
37772
- target: child.options.link,
37874
+ target,
37773
37875
  targetMode: TargetModeType.EXTERNAL
37774
37876
  });
37775
37877
  return concreteHyperlink;