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.cjs +182 -80
- package/dist/index.d.cts +63 -6
- package/dist/index.d.ts +63 -6
- package/dist/index.iife.js +182 -80
- package/dist/index.mjs +182 -80
- package/dist/index.umd.cjs +182 -80
- package/dist/layout.cjs +1 -6
- package/dist/layout.iife.js +1 -6
- package/dist/layout.mjs +1 -6
- package/dist/layout.umd.cjs +1 -6
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -12786,7 +12786,7 @@ var import_hash = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
|
|
|
12786
12786
|
hash.sha512 = hash.sha.sha512;
|
|
12787
12787
|
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
12788
12788
|
})))(), 1);
|
|
12789
|
-
var urlAlphabet = "
|
|
12789
|
+
var urlAlphabet = "57X6y3wQZNzYjJB2L_10pxbackgroundhimselfUTF-8DEMOGRAPHICSVqvt4KW9";
|
|
12790
12790
|
//#endregion
|
|
12791
12791
|
//#region node_modules/nanoid/non-secure/index.js
|
|
12792
12792
|
var customAlphabet = (alphabet, defaultSize = 21) => {
|
|
@@ -14583,48 +14583,6 @@ var ChildNonVisualProperties = class extends XmlComponent {
|
|
|
14583
14583
|
}
|
|
14584
14584
|
};
|
|
14585
14585
|
//#endregion
|
|
14586
|
-
//#region src/file/drawing/doc-properties/doc-properties-children.ts
|
|
14587
|
-
/**
|
|
14588
|
-
* Child elements for document properties.
|
|
14589
|
-
*
|
|
14590
|
-
* This module provides hyperlink elements that can be attached to
|
|
14591
|
-
* drawing elements for interactive behavior.
|
|
14592
|
-
*
|
|
14593
|
-
* @module
|
|
14594
|
-
*/
|
|
14595
|
-
/**
|
|
14596
|
-
* Creates a click hyperlink element for a drawing.
|
|
14597
|
-
*
|
|
14598
|
-
* This element defines what happens when a user clicks on a drawing element.
|
|
14599
|
-
*
|
|
14600
|
-
* ## XSD Schema
|
|
14601
|
-
* ```xml
|
|
14602
|
-
* <xsd:complexType name="CT_Hyperlink">
|
|
14603
|
-
* <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
|
|
14604
|
-
* <xsd:attribute name="tgtFrame" type="s:ST_String"/>
|
|
14605
|
-
* <xsd:attribute name="tooltip" type="s:ST_String"/>
|
|
14606
|
-
* <xsd:attribute name="docLocation" type="s:ST_String"/>
|
|
14607
|
-
* <xsd:attribute name="history" type="s:ST_OnOff"/>
|
|
14608
|
-
* <xsd:attribute name="anchor" type="s:ST_String"/>
|
|
14609
|
-
* <xsd:attribute ref="r:id"/>
|
|
14610
|
-
* </xsd:complexType>
|
|
14611
|
-
* ```
|
|
14612
|
-
*
|
|
14613
|
-
* @param linkId - The relationship ID for the hyperlink target
|
|
14614
|
-
* @param hasXmlNs - Whether to include the XML namespace declaration
|
|
14615
|
-
* @returns An XML component representing the click hyperlink
|
|
14616
|
-
*/
|
|
14617
|
-
var createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
|
|
14618
|
-
name: "a:hlinkClick",
|
|
14619
|
-
attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
|
|
14620
|
-
key: "xmlns:a",
|
|
14621
|
-
value: "http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
14622
|
-
} } : {}), {}, { id: {
|
|
14623
|
-
key: "r:id",
|
|
14624
|
-
value: `rId${linkId}`
|
|
14625
|
-
} })
|
|
14626
|
-
});
|
|
14627
|
-
//#endregion
|
|
14628
14586
|
//#region src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties-attributes.ts
|
|
14629
14587
|
/**
|
|
14630
14588
|
* Non-visual properties attributes module.
|
|
@@ -14705,7 +14663,7 @@ var NonVisualProperties = class extends XmlComponent {
|
|
|
14705
14663
|
for (let i = context.stack.length - 1; i >= 0; i--) {
|
|
14706
14664
|
const element = context.stack[i];
|
|
14707
14665
|
if (!(element instanceof ConcreteHyperlink)) continue;
|
|
14708
|
-
this.root.push(
|
|
14666
|
+
this.root.push(element.createDrawingClick(context, false));
|
|
14709
14667
|
break;
|
|
14710
14668
|
}
|
|
14711
14669
|
const result = super.prepForXml(context);
|
|
@@ -15375,6 +15333,48 @@ var createRelationship = (id, type, target, targetMode) => new BuilderElement({
|
|
|
15375
15333
|
}
|
|
15376
15334
|
});
|
|
15377
15335
|
//#endregion
|
|
15336
|
+
//#region src/file/drawing/doc-properties/doc-properties-children.ts
|
|
15337
|
+
/**
|
|
15338
|
+
* Child elements for document properties.
|
|
15339
|
+
*
|
|
15340
|
+
* This module provides hyperlink elements that can be attached to
|
|
15341
|
+
* drawing elements for interactive behavior.
|
|
15342
|
+
*
|
|
15343
|
+
* @module
|
|
15344
|
+
*/
|
|
15345
|
+
/**
|
|
15346
|
+
* Creates a click hyperlink element for a drawing.
|
|
15347
|
+
*
|
|
15348
|
+
* This element defines what happens when a user clicks on a drawing element.
|
|
15349
|
+
*
|
|
15350
|
+
* ## XSD Schema
|
|
15351
|
+
* ```xml
|
|
15352
|
+
* <xsd:complexType name="CT_Hyperlink">
|
|
15353
|
+
* <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
|
|
15354
|
+
* <xsd:attribute name="tgtFrame" type="s:ST_String"/>
|
|
15355
|
+
* <xsd:attribute name="tooltip" type="s:ST_String"/>
|
|
15356
|
+
* <xsd:attribute name="docLocation" type="s:ST_String"/>
|
|
15357
|
+
* <xsd:attribute name="history" type="s:ST_OnOff"/>
|
|
15358
|
+
* <xsd:attribute name="anchor" type="s:ST_String"/>
|
|
15359
|
+
* <xsd:attribute ref="r:id"/>
|
|
15360
|
+
* </xsd:complexType>
|
|
15361
|
+
* ```
|
|
15362
|
+
*
|
|
15363
|
+
* @param linkId - The relationship ID for the hyperlink target
|
|
15364
|
+
* @param hasXmlNs - Whether to include the XML namespace declaration
|
|
15365
|
+
* @returns An XML component representing the click hyperlink
|
|
15366
|
+
*/
|
|
15367
|
+
var createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
|
|
15368
|
+
name: "a:hlinkClick",
|
|
15369
|
+
attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
|
|
15370
|
+
key: "xmlns:a",
|
|
15371
|
+
value: "http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
15372
|
+
} } : {}), {}, { id: {
|
|
15373
|
+
key: "r:id",
|
|
15374
|
+
value: `rId${linkId}`
|
|
15375
|
+
} })
|
|
15376
|
+
});
|
|
15377
|
+
//#endregion
|
|
15378
15378
|
//#region src/file/drawing/doc-properties/non-visual-drawing-properties.ts
|
|
15379
15379
|
/**
|
|
15380
15380
|
* Non-visual drawing properties (`CT_NonVisualDrawingProps`) of the shapes, pictures and groups inside a drawing:
|
|
@@ -15569,7 +15569,7 @@ var DocProperties = class extends XmlComponent {
|
|
|
15569
15569
|
} else for (let i = context.stack.length - 1; i >= 0; i--) {
|
|
15570
15570
|
const element = context.stack[i];
|
|
15571
15571
|
if (!(element instanceof ConcreteHyperlink)) continue;
|
|
15572
|
-
this.root.push(
|
|
15572
|
+
this.root.push(element.createDrawingClick(context, true));
|
|
15573
15573
|
break;
|
|
15574
15574
|
}
|
|
15575
15575
|
if (this.decorative) this.root.push(createDecorativeExtensionList(true));
|
|
@@ -18957,20 +18957,44 @@ var HyperlinkType = {
|
|
|
18957
18957
|
* ```
|
|
18958
18958
|
*/
|
|
18959
18959
|
var ConcreteHyperlink = class extends XmlComponent {
|
|
18960
|
-
|
|
18960
|
+
/**
|
|
18961
|
+
* @param children - Inline content of the hyperlink
|
|
18962
|
+
* @param relationshipId - Id of the external relationship, without the rId prefix
|
|
18963
|
+
* @param anchor - Bookmark name or external URL fragment
|
|
18964
|
+
* @param externalLink - The full address of an external hyperlink, so the relationship id is kept alongside its anchor
|
|
18965
|
+
*/
|
|
18966
|
+
constructor(children, relationshipId, anchor, externalLink) {
|
|
18961
18967
|
super("w:hyperlink");
|
|
18962
18968
|
_defineProperty(this, "linkId", void 0);
|
|
18969
|
+
_defineProperty(this, "drawingLink", void 0);
|
|
18963
18970
|
this.linkId = relationshipId;
|
|
18971
|
+
this.drawingLink = anchor && externalLink !== void 0 ? new DrawingLink(externalLink) : void 0;
|
|
18964
18972
|
const attributes = new HyperlinkAttributes({
|
|
18965
18973
|
history: 1,
|
|
18966
18974
|
anchor: anchor ? anchor : void 0,
|
|
18967
|
-
id: !anchor ? `rId${this.linkId}` : void 0
|
|
18975
|
+
id: !anchor || externalLink !== void 0 ? `rId${this.linkId}` : void 0
|
|
18968
18976
|
});
|
|
18969
18977
|
this.root.push(attributes);
|
|
18970
18978
|
children.forEach((child) => {
|
|
18971
18979
|
this.root.push(child);
|
|
18972
18980
|
});
|
|
18973
18981
|
}
|
|
18982
|
+
/**
|
|
18983
|
+
* Creates the `a:hlinkClick` of a picture in the hyperlink, which links to the same address.
|
|
18984
|
+
*
|
|
18985
|
+
* The hyperlink decides which relationship its pictures use, rather than the pictures reading `linkId`, because only it
|
|
18986
|
+
* knows whether that relationship has lost the fragment to `w:anchor`. The picture's relationship is added as the
|
|
18987
|
+
* picture is written, through the context's relationships, so it lands in the part the picture is in, both when
|
|
18988
|
+
* packing and when patching.
|
|
18989
|
+
*
|
|
18990
|
+
* @param context - The context the picture is written in, whose relationships get the picture's link if it has its own
|
|
18991
|
+
* @param declareNamespace - Declares the DrawingML namespace, for elements outside `a:graphic` such as `wp:docPr`
|
|
18992
|
+
*/
|
|
18993
|
+
createDrawingClick(context, declareNamespace) {
|
|
18994
|
+
if (!this.drawingLink) return createHyperlinkClick(this.linkId, declareNamespace);
|
|
18995
|
+
this.drawingLink.addRelationship(context);
|
|
18996
|
+
return this.drawingLink.createClick(declareNamespace);
|
|
18997
|
+
}
|
|
18974
18998
|
};
|
|
18975
18999
|
/**
|
|
18976
19000
|
* Represents an internal hyperlink to a bookmark within the document.
|
|
@@ -19019,6 +19043,11 @@ var InternalHyperlink = class extends ConcreteHyperlink {
|
|
|
19019
19043
|
* External hyperlinks create a relationship to an external resource (URL).
|
|
19020
19044
|
* The relationship is created during document preparation and the hyperlink
|
|
19021
19045
|
* is converted to a ConcreteHyperlink with the relationship ID.
|
|
19046
|
+
* URL fragments of at most 255 UTF-16 units are written as anchors, preserving any additional # characters.
|
|
19047
|
+
* Longer fragments stay in the original relationship URI to avoid exceeding Word's anchor limit;
|
|
19048
|
+
* those links retain the existing limitations for fragments with multiple # characters.
|
|
19049
|
+
* Word appends the anchor to the relationship target as described in MS-OI29500 §17.16.22:
|
|
19050
|
+
* https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/df06e423-11a6-4a36-bfb3-82139e531781
|
|
19022
19051
|
*
|
|
19023
19052
|
* Reference: http://officeopenxml.com/WPhyperlink.php
|
|
19024
19053
|
*
|
|
@@ -19032,6 +19061,7 @@ var InternalHyperlink = class extends ConcreteHyperlink {
|
|
|
19032
19061
|
* <xsd:group ref="EG_PContent" minOccurs="0" maxOccurs="unbounded"/>
|
|
19033
19062
|
* <xsd:attribute ref="r:id"/>
|
|
19034
19063
|
* <xsd:attribute name="history" type="s:ST_OnOff" use="optional"/>
|
|
19064
|
+
* <xsd:attribute name="anchor" type="s:ST_String" use="optional"/>
|
|
19035
19065
|
* </xsd:complexType>
|
|
19036
19066
|
* ```
|
|
19037
19067
|
*
|
|
@@ -19480,6 +19510,29 @@ var PageReference = class extends Run {
|
|
|
19480
19510
|
}
|
|
19481
19511
|
};
|
|
19482
19512
|
//#endregion
|
|
19513
|
+
//#region src/file/paragraph/links/external-hyperlink-target.ts
|
|
19514
|
+
/**
|
|
19515
|
+
* External hyperlink targets and fragments for WordprocessingML.
|
|
19516
|
+
*
|
|
19517
|
+
* Word appends the anchor to the relationship target, separated by a # character.
|
|
19518
|
+
* Reference: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/df06e423-11a6-4a36-bfb3-82139e531781
|
|
19519
|
+
*
|
|
19520
|
+
* @module
|
|
19521
|
+
*/
|
|
19522
|
+
var MAX_ANCHOR_LENGTH = 255;
|
|
19523
|
+
/**
|
|
19524
|
+
* Splits a nonempty fragment that fits Word's anchor limit without decoding or normalizing either part.
|
|
19525
|
+
* Longer fragments stay in the original relationship URI, retaining its existing multi-hash limitations.
|
|
19526
|
+
*/
|
|
19527
|
+
var externalHyperlinkTarget = (link) => {
|
|
19528
|
+
const index = link.indexOf("#");
|
|
19529
|
+
const fragmentLength = link.length - index - 1;
|
|
19530
|
+
return index > 0 && fragmentLength > 0 && fragmentLength <= MAX_ANCHOR_LENGTH ? {
|
|
19531
|
+
target: link.slice(0, index),
|
|
19532
|
+
anchor: link.slice(index + 1)
|
|
19533
|
+
} : { target: link };
|
|
19534
|
+
};
|
|
19535
|
+
//#endregion
|
|
19483
19536
|
//#region src/file/fonts/font.ts
|
|
19484
19537
|
/**
|
|
19485
19538
|
* Font module for WordprocessingML documents.
|
|
@@ -19618,32 +19671,26 @@ var createFont = ({ name, altName, panose1, charset, family, notTrueType, pitch,
|
|
|
19618
19671
|
]
|
|
19619
19672
|
});
|
|
19620
19673
|
//#endregion
|
|
19621
|
-
//#region src/file/fonts/create-
|
|
19674
|
+
//#region src/file/fonts/create-embedded-font.ts
|
|
19622
19675
|
/**
|
|
19623
|
-
* Creates
|
|
19676
|
+
* Creates an embedded font with default settings.
|
|
19624
19677
|
*
|
|
19625
19678
|
* This helper function creates a font definition with standard font signature
|
|
19626
19679
|
* values that work for most common fonts. The signature specifies Unicode
|
|
19627
19680
|
* and code page ranges supported by the font.
|
|
19628
19681
|
*
|
|
19629
|
-
* @param options - Font creation options
|
|
19630
|
-
* @param options.name - Font name
|
|
19631
|
-
* @param options.index - Font relationship index
|
|
19632
|
-
* @param options.fontKey - Unique font key (GUID) for obfuscation
|
|
19633
|
-
* @param options.characterSet - Optional character set identifier
|
|
19634
|
-
*
|
|
19635
19682
|
* @returns XmlComponent representing the font definition
|
|
19636
19683
|
*
|
|
19637
19684
|
* @example
|
|
19638
19685
|
* ```typescript
|
|
19639
|
-
* const font =
|
|
19686
|
+
* const font = createEmbeddedFont({
|
|
19640
19687
|
* name: "Arial",
|
|
19641
|
-
*
|
|
19642
|
-
* fontKey: "12345678-1234-1234-1234-
|
|
19688
|
+
* embedRegular: { id: "rId1", fontKey: "12345678-1234-1234-1234-123456789012" },
|
|
19689
|
+
* embedBold: { id: "rId2", fontKey: "12345678-1234-1234-1234-123456789013" },
|
|
19643
19690
|
* });
|
|
19644
19691
|
* ```
|
|
19645
19692
|
*/
|
|
19646
|
-
var
|
|
19693
|
+
var createEmbeddedFont = ({ name, characterSet, embedRegular, embedBold, embedItalic, embedBoldItalic }) => createFont({
|
|
19647
19694
|
name,
|
|
19648
19695
|
sig: {
|
|
19649
19696
|
usb0: "E0002AFF",
|
|
@@ -19656,10 +19703,10 @@ var createRegularFont = ({ name, index, fontKey, characterSet }) => createFont({
|
|
|
19656
19703
|
charset: characterSet,
|
|
19657
19704
|
family: "auto",
|
|
19658
19705
|
pitch: "variable",
|
|
19659
|
-
embedRegular
|
|
19660
|
-
|
|
19661
|
-
|
|
19662
|
-
|
|
19706
|
+
embedRegular,
|
|
19707
|
+
embedBold,
|
|
19708
|
+
embedItalic,
|
|
19709
|
+
embedBoldItalic
|
|
19663
19710
|
});
|
|
19664
19711
|
//#endregion
|
|
19665
19712
|
//#region src/file/fonts/font-table.ts
|
|
@@ -19737,25 +19784,47 @@ var createFontTable = (fonts) => new BuilderElement({
|
|
|
19737
19784
|
value: "w14 w15 w16se w16cid w16 w16cex w16sdtdh"
|
|
19738
19785
|
}
|
|
19739
19786
|
},
|
|
19740
|
-
children: fonts.map(
|
|
19741
|
-
name: font.name,
|
|
19742
|
-
index: i + 1,
|
|
19743
|
-
fontKey: font.fontKey,
|
|
19744
|
-
characterSet: font.characterSet
|
|
19745
|
-
}))
|
|
19787
|
+
children: fonts.map(createEmbeddedFont)
|
|
19746
19788
|
});
|
|
19747
19789
|
//#endregion
|
|
19748
19790
|
//#region src/file/fonts/font-wrapper.ts
|
|
19791
|
+
var FACES = [
|
|
19792
|
+
{
|
|
19793
|
+
option: "data",
|
|
19794
|
+
element: "embedRegular",
|
|
19795
|
+
bold: false,
|
|
19796
|
+
italic: false
|
|
19797
|
+
},
|
|
19798
|
+
{
|
|
19799
|
+
option: "bold",
|
|
19800
|
+
element: "embedBold",
|
|
19801
|
+
bold: true,
|
|
19802
|
+
italic: false
|
|
19803
|
+
},
|
|
19804
|
+
{
|
|
19805
|
+
option: "italic",
|
|
19806
|
+
element: "embedItalic",
|
|
19807
|
+
bold: false,
|
|
19808
|
+
italic: true
|
|
19809
|
+
},
|
|
19810
|
+
{
|
|
19811
|
+
option: "boldItalic",
|
|
19812
|
+
element: "embedBoldItalic",
|
|
19813
|
+
bold: true,
|
|
19814
|
+
italic: true
|
|
19815
|
+
}
|
|
19816
|
+
];
|
|
19749
19817
|
/**
|
|
19750
19818
|
* Wrapper class for managing the font table and its relationships.
|
|
19751
19819
|
*
|
|
19752
19820
|
* Creates a font table with embedded font files and manages the relationships
|
|
19753
|
-
* required for font embedding. Each font is
|
|
19821
|
+
* required for font embedding. Each face of a font is embedded as a file of its own,
|
|
19822
|
+
* with a unique key for obfuscation.
|
|
19754
19823
|
*
|
|
19755
19824
|
* @example
|
|
19756
19825
|
* ```typescript
|
|
19757
19826
|
* const fontWrapper = new FontWrapper([
|
|
19758
|
-
* { name: "CustomFont", data: fontBuffer }
|
|
19827
|
+
* { name: "CustomFont", data: fontBuffer, bold: boldFontBuffer }
|
|
19759
19828
|
* ]);
|
|
19760
19829
|
* ```
|
|
19761
19830
|
*/
|
|
@@ -19764,12 +19833,43 @@ var FontWrapper = class {
|
|
|
19764
19833
|
_defineProperty(this, "options", void 0);
|
|
19765
19834
|
_defineProperty(this, "fontTable", void 0);
|
|
19766
19835
|
_defineProperty(this, "relationships", void 0);
|
|
19767
|
-
_defineProperty(
|
|
19836
|
+
_defineProperty(
|
|
19837
|
+
this,
|
|
19838
|
+
/** @deprecated Use `files`, which has the file and key of each face a font embeds, not only the regular face's key */
|
|
19839
|
+
"fontOptionsWithKey",
|
|
19840
|
+
[]
|
|
19841
|
+
);
|
|
19842
|
+
_defineProperty(
|
|
19843
|
+
this,
|
|
19844
|
+
/** The files of the faces the fonts embed, in order: the Nth is `fonts/font<N>.odttf`, with the relationship `rId<N>` */
|
|
19845
|
+
"files",
|
|
19846
|
+
[]
|
|
19847
|
+
);
|
|
19768
19848
|
this.options = options;
|
|
19769
|
-
|
|
19770
|
-
|
|
19849
|
+
const faces = options.map((font) => FACES.flatMap(({ option, element, bold, italic }) => {
|
|
19850
|
+
const data = font[option];
|
|
19851
|
+
return data ? [{
|
|
19852
|
+
element,
|
|
19853
|
+
file: {
|
|
19854
|
+
name: font.name,
|
|
19855
|
+
data,
|
|
19856
|
+
bold,
|
|
19857
|
+
italic,
|
|
19858
|
+
fontKey: uniqueUuid()
|
|
19859
|
+
}
|
|
19860
|
+
}] : [];
|
|
19861
|
+
}));
|
|
19862
|
+
this.files = faces.flatMap((ofFont) => ofFont.map(({ file }) => file));
|
|
19863
|
+
this.fontOptionsWithKey = options.map((font, index) => _objectSpread2(_objectSpread2({}, font), {}, { fontKey: faces[index][0].file.fontKey }));
|
|
19864
|
+
this.fontTable = createFontTable(options.map((font, index) => _objectSpread2({
|
|
19865
|
+
name: font.name,
|
|
19866
|
+
characterSet: font.characterSet
|
|
19867
|
+
}, Object.fromEntries(faces[index].map(({ element, file }) => [element, {
|
|
19868
|
+
id: `rId${this.files.indexOf(file) + 1}`,
|
|
19869
|
+
fontKey: file.fontKey
|
|
19870
|
+
}])))));
|
|
19771
19871
|
this.relationships = new Relationships();
|
|
19772
|
-
for (let i = 0; i <
|
|
19872
|
+
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`);
|
|
19773
19873
|
}
|
|
19774
19874
|
get View() {
|
|
19775
19875
|
return this.fontTable;
|
|
@@ -20292,8 +20392,9 @@ var Paragraph = class extends FileChild {
|
|
|
20292
20392
|
prepForXml(context) {
|
|
20293
20393
|
for (const element of this.root) if (element instanceof ExternalHyperlink) {
|
|
20294
20394
|
const index = this.root.indexOf(element);
|
|
20295
|
-
const
|
|
20296
|
-
|
|
20395
|
+
const { target, anchor } = externalHyperlinkTarget(element.options.link);
|
|
20396
|
+
const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId(), anchor, element.options.link);
|
|
20397
|
+
context.viewWrapper.Relationships.addRelationship(concreteHyperlink.linkId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", target, TargetModeType.EXTERNAL);
|
|
20297
20398
|
this.root[index] = concreteHyperlink;
|
|
20298
20399
|
}
|
|
20299
20400
|
return super.prepForXml(context);
|
|
@@ -35468,7 +35569,7 @@ var Compiler = class {
|
|
|
35468
35569
|
zip.file(`word/media/${data.fileName}`, data.data);
|
|
35469
35570
|
zip.file(`word/media/${data.fallback.fileName}`, data.fallback.data);
|
|
35470
35571
|
}
|
|
35471
|
-
for (const [i, { data: buffer, fontKey }] of file.FontTable.
|
|
35572
|
+
for (const [i, { data: buffer, fontKey }] of file.FontTable.files.entries()) zip.file(`word/fonts/font${i + 1}.odttf`, obfuscate(buffer, fontKey));
|
|
35472
35573
|
return zip;
|
|
35473
35574
|
}
|
|
35474
35575
|
xmlifyFile(file, prettify) {
|
|
@@ -37763,12 +37864,13 @@ var patchDocument = function() {
|
|
|
37763
37864
|
json: element,
|
|
37764
37865
|
patch: _objectSpread2(_objectSpread2({}, patchValue), {}, { children: patchValue.children.flatMap((child) => child instanceof Bookmark ? child.writtenAs : [child]).map((child) => {
|
|
37765
37866
|
if (child instanceof ExternalHyperlink) {
|
|
37766
|
-
const
|
|
37867
|
+
const { target, anchor } = externalHyperlinkTarget(child.options.link);
|
|
37868
|
+
const concreteHyperlink = new ConcreteHyperlink(child.options.children, uniqueId(), anchor, child.options.link);
|
|
37767
37869
|
hyperlinkRelationships.push({
|
|
37768
37870
|
key,
|
|
37769
37871
|
id: concreteHyperlink.linkId,
|
|
37770
37872
|
type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
|
37771
|
-
target
|
|
37873
|
+
target,
|
|
37772
37874
|
targetMode: TargetModeType.EXTERNAL
|
|
37773
37875
|
});
|
|
37774
37876
|
return concreteHyperlink;
|
package/dist/index.d.cts
CHANGED
|
@@ -1307,7 +1307,26 @@ declare const CompoundLine: {
|
|
|
1307
1307
|
*/
|
|
1308
1308
|
export declare class ConcreteHyperlink extends XmlComponent {
|
|
1309
1309
|
readonly linkId: string;
|
|
1310
|
-
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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?: {
|