@office-open/docx 0.14.1 → 0.14.3
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.mts +3 -18
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1187 -1320
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DOCX_NS, DOCX_PARTS, EmbeddingCollection, IMAGE_MEDIA_CONTENT_TYPES, Media, OoxmlMimeType, ParsedArchive, Relationships, TargetModeType,
|
|
1
|
+
import { DOCX_NS, DOCX_PARTS, EmbeddingCollection, IMAGE_MEDIA_CONTENT_TYPES, Media, OoxmlMimeType, ParsedArchive, RELATIONSHIP_TYPES, Relationships, TargetModeType, addModelBinaries, addSmartArtRelationships, appPropertiesDesc, appendContentType, appendOverride, appendRelationship, applyCorePropertiesOverride, assertEncryptedExclusive, blipDesc, buildCorePropertiesXmlString, buildRootRelationships, collectPassthroughParts, compileMapping, contentTypesDesc, convertEmuToPixels, convertInchesToTwip, convertToEmu, convertToPt, convertToTwip, createPacker, createReplacer, createThemeXml, createTraverser, customGeometryDesc, customPropertiesDesc, decimalNumber, derivePasswordHash, dropDanglingPassthroughRels, effectListDesc, eighthPointMeasureValue, encodeBase64, encryptedContainerOutput, encryptedContainerStream, fillDesc, finalizeContentTypes, findAndReplaceImagePlaceholders, formatId, getNextRelationshipIndex, getReferencedMedia, hasPlaceholders, hexColorValue, hpsMeasureValue, imageTypeFromPath, isEncryptedContainer, mapOptional, nextNumericId, nextVmlShapeId, optionalRelsPart, outlineDesc, parseAngle, parseArchive, parseColorChoice, parseCorePropsElement, parseNonVisualDrawingProperties, parseOnOff, parseVmlImageData, parseVmlShapeChild, parseVmlShapeDefaults, parseVmlShapeLayout, parseVmlShapeStyle, parseVmlShapetype, parseVmlStyle, partPathToRelsPath, pictureLockingDesc, pointMeasureValue, presetGeometryDesc, replaceAllPlaceholders, replaceImagePlaceholders, replaceNumberingPlaceholders, resolveRelationshipTarget, resolverFromRegistry, shapePropertiesDesc, strFromU8, stringifyVmlBackground, stringifyVmlShape, stringifyVmlShapeChild, stringifyVmlShapeDefaults, stringifyVmlShapeLayout, stringifyVmlShapetype, toJson, toUint8Array, toUint8ArrayAsync, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, unzipSync, xsdJcAlignment, xsdMathStyle, xsdShadingPattern, xsdTableWidthType, xsdVerticalMergeRev, zipAndConvert } from "@office-open/core";
|
|
2
2
|
import { bodyPropertiesDesc, calculateEffectExtent, connectorLockingDesc, createBodyProperties as createBodyProperties$1, createColorElement, groupShapePropertiesDesc, parseBodyProperties, parseNonVisualContentPartProperties, pictureLockingDesc as pictureLockingDesc$1, scene3DDesc, shape3DDesc, shapeLockingDesc, shapePropertiesDesc as shapePropertiesDesc$1, stringifyBlipEffects, stringifyNonVisualContentPartProperties, stringifyNonVisualDrawingProperties } from "@office-open/core/drawing";
|
|
3
3
|
import { OOXML_XML_DECLARATION, attr, attrBool, attrMeasure, attrNum, attrsRaw, children, colorAttr, element, escapeXml, findChild, findDeep, findFirst, parse, stringify, stringifyElement, textOf } from "@office-open/xml";
|
|
4
4
|
import { ChartCollection, buildUserShapesData, chartSpaceDesc, userShapesDesc } from "@office-open/core/chart";
|
|
@@ -2513,6 +2513,15 @@ function spacingStr(opts) {
|
|
|
2513
2513
|
})}/>`;
|
|
2514
2514
|
}
|
|
2515
2515
|
function indentStr(opts) {
|
|
2516
|
+
let { hanging, firstLine } = opts;
|
|
2517
|
+
if (typeof firstLine === "number" && firstLine < 0) {
|
|
2518
|
+
hanging ??= -firstLine;
|
|
2519
|
+
firstLine = void 0;
|
|
2520
|
+
}
|
|
2521
|
+
if (typeof hanging === "number" && hanging < 0) {
|
|
2522
|
+
firstLine ??= -hanging;
|
|
2523
|
+
hanging = void 0;
|
|
2524
|
+
}
|
|
2516
2525
|
return `<w:ind${attrsRaw({
|
|
2517
2526
|
"w:start": opts.start !== void 0 ? convertToTwip(opts.start) : void 0,
|
|
2518
2527
|
"w:startChars": opts.startChars !== void 0 ? decimalNumber(opts.startChars) : void 0,
|
|
@@ -2522,9 +2531,9 @@ function indentStr(opts) {
|
|
|
2522
2531
|
"w:leftChars": opts.leftChars !== void 0 ? decimalNumber(opts.leftChars) : void 0,
|
|
2523
2532
|
"w:right": opts.right !== void 0 ? convertToTwip(opts.right) : void 0,
|
|
2524
2533
|
"w:rightChars": opts.rightChars !== void 0 ? decimalNumber(opts.rightChars) : void 0,
|
|
2525
|
-
"w:hanging":
|
|
2534
|
+
"w:hanging": hanging !== void 0 ? convertToTwip(hanging) : void 0,
|
|
2526
2535
|
"w:hangingChars": opts.hangingChars !== void 0 ? decimalNumber(opts.hangingChars) : void 0,
|
|
2527
|
-
"w:firstLine":
|
|
2536
|
+
"w:firstLine": firstLine !== void 0 ? convertToTwip(firstLine) : void 0,
|
|
2528
2537
|
"w:firstLineChars": opts.firstLineChars !== void 0 ? decimalNumber(opts.firstLineChars) : void 0
|
|
2529
2538
|
})}/>`;
|
|
2530
2539
|
}
|
|
@@ -2704,18 +2713,20 @@ function stringifyParagraphProperties(options) {
|
|
|
2704
2713
|
if (bParts.length) s += `<w:pBdr>${bParts.join("")}</w:pBdr>`;
|
|
2705
2714
|
}
|
|
2706
2715
|
if (options.shading) s += shadingStr(options.shading);
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2716
|
+
if (options.rightTabStop !== void 0 || options.leftTabStop !== void 0 || options.tabStops !== void 0) {
|
|
2717
|
+
const tabDefs = [
|
|
2718
|
+
...options.rightTabStop !== void 0 ? [{
|
|
2719
|
+
position: options.rightTabStop,
|
|
2720
|
+
type: "right"
|
|
2721
|
+
}] : [],
|
|
2722
|
+
...options.tabStops ? options.tabStops : [],
|
|
2723
|
+
...options.leftTabStop !== void 0 ? [{
|
|
2724
|
+
position: options.leftTabStop,
|
|
2725
|
+
type: "left"
|
|
2726
|
+
}] : []
|
|
2727
|
+
];
|
|
2728
|
+
if (tabDefs.length > 0) s += tabStopsStr(tabDefs);
|
|
2729
|
+
}
|
|
2719
2730
|
if (options.suppressAutoHyphens !== void 0) s += onOff$2("w:suppressAutoHyphens", options.suppressAutoHyphens);
|
|
2720
2731
|
if (options.kinsoku !== void 0) s += onOff$2("w:kinsoku", options.kinsoku);
|
|
2721
2732
|
if (options.wordWrap !== void 0) s += onOff$2("w:wordWrap", options.wordWrap);
|
|
@@ -3028,7 +3039,7 @@ function parseSdtBlock(el, ctx, parseChildren) {
|
|
|
3028
3039
|
*
|
|
3029
3040
|
* @module
|
|
3030
3041
|
*/
|
|
3031
|
-
const ALTCHUNK_REL_TYPE =
|
|
3042
|
+
const ALTCHUNK_REL_TYPE = RELATIONSHIP_TYPES.aFChunk;
|
|
3032
3043
|
function wrapHtmlDocument(fragment) {
|
|
3033
3044
|
if (/<(!DOCTYPE|html|HTML)/i.test(fragment)) return fragment;
|
|
3034
3045
|
return `<!DOCTYPE html>\n<html><head><meta charset="utf-8"></head>\n<body>${fragment}</body></html>`;
|
|
@@ -3084,7 +3095,7 @@ const altChunkDesc = {
|
|
|
3084
3095
|
return opts;
|
|
3085
3096
|
}
|
|
3086
3097
|
};
|
|
3087
|
-
const SUBDOC_REL_TYPE =
|
|
3098
|
+
const SUBDOC_REL_TYPE = RELATIONSHIP_TYPES.subDocument;
|
|
3088
3099
|
const subDocDesc = {
|
|
3089
3100
|
kind: "custom",
|
|
3090
3101
|
stringify(opts, ctx) {
|
|
@@ -3391,138 +3402,6 @@ const TextWrappingSide = {
|
|
|
3391
3402
|
LARGEST: "largest"
|
|
3392
3403
|
};
|
|
3393
3404
|
//#endregion
|
|
3394
|
-
//#region src/parts/drawing/text-wrap/wrap-tight.ts
|
|
3395
|
-
/**
|
|
3396
|
-
* Wrap Tight module for DrawingML text wrapping.
|
|
3397
|
-
*
|
|
3398
|
-
* This module provides tight text wrapping for floating drawings
|
|
3399
|
-
* where text wraps closely around the image shape.
|
|
3400
|
-
*
|
|
3401
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3402
|
-
*
|
|
3403
|
-
* @module
|
|
3404
|
-
*/
|
|
3405
|
-
/**
|
|
3406
|
-
* Creates a default rectangular wrap polygon matching the image extent.
|
|
3407
|
-
*
|
|
3408
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3409
|
-
*
|
|
3410
|
-
* ## XSD Schema
|
|
3411
|
-
* ```xml
|
|
3412
|
-
* <xsd:complexType name="CT_WrapPath">
|
|
3413
|
-
* <xsd:sequence>
|
|
3414
|
-
* <xsd:element name="start" type="a:CT_Point2D" minOccurs="1" maxOccurs="1"/>
|
|
3415
|
-
* <xsd:element name="lineTo" type="a:CT_Point2D" minOccurs="2" maxOccurs="unbounded"/>
|
|
3416
|
-
* </xsd:sequence>
|
|
3417
|
-
* <xsd:attribute name="edited" type="xsd:boolean" use="optional"/>
|
|
3418
|
-
* </xsd:complexType>
|
|
3419
|
-
* ```
|
|
3420
|
-
*/
|
|
3421
|
-
const createWrapPolygon$1 = (cx, cy) => element("wp:wrapPolygon", { edited: "0" }, [
|
|
3422
|
-
`<wp:start x="0" y="0"/>`,
|
|
3423
|
-
`<wp:lineTo x="0" y="${-cy}"/>`,
|
|
3424
|
-
`<wp:lineTo x="${cx}" y="${-cy}"/>`,
|
|
3425
|
-
`<wp:lineTo x="${cx}" y="0"/>`,
|
|
3426
|
-
`<wp:lineTo x="0" y="0"/>`
|
|
3427
|
-
]);
|
|
3428
|
-
/**
|
|
3429
|
-
* Creates tight text wrapping for a floating drawing.
|
|
3430
|
-
*
|
|
3431
|
-
* WrapTight causes text to wrap closely around the contours
|
|
3432
|
-
* of the drawing rather than its rectangular bounding box.
|
|
3433
|
-
* A default rectangular wrap polygon matching the image extent is generated.
|
|
3434
|
-
*
|
|
3435
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3436
|
-
*
|
|
3437
|
-
* ## XSD Schema
|
|
3438
|
-
* ```xml
|
|
3439
|
-
* <xsd:complexType name="CT_WrapTight">
|
|
3440
|
-
* <xsd:sequence>
|
|
3441
|
-
* <xsd:element name="wrapPolygon" type="CT_WrapPath" minOccurs="1" maxOccurs="1"/>
|
|
3442
|
-
* </xsd:sequence>
|
|
3443
|
-
* <xsd:attribute name="wrapText" type="ST_WrapText" use="required"/>
|
|
3444
|
-
* <xsd:attribute name="distL" type="ST_WrapDistance"/>
|
|
3445
|
-
* <xsd:attribute name="distR" type="ST_WrapDistance"/>
|
|
3446
|
-
* </xsd:complexType>
|
|
3447
|
-
* ```
|
|
3448
|
-
*/
|
|
3449
|
-
const createWrapTight = (textWrapping, margins = {
|
|
3450
|
-
bottom: 0,
|
|
3451
|
-
left: 0,
|
|
3452
|
-
right: 0,
|
|
3453
|
-
top: 0
|
|
3454
|
-
}, extent) => element("wp:wrapTight", {
|
|
3455
|
-
distL: margins.left,
|
|
3456
|
-
distR: margins.right,
|
|
3457
|
-
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES
|
|
3458
|
-
}, [createWrapPolygon$1(extent.x, extent.y)]);
|
|
3459
|
-
//#endregion
|
|
3460
|
-
//#region src/parts/drawing/text-wrap/wrap-through.ts
|
|
3461
|
-
/**
|
|
3462
|
-
* Wrap Through module for DrawingML text wrapping.
|
|
3463
|
-
*
|
|
3464
|
-
* This module provides "through" text wrapping for floating drawings
|
|
3465
|
-
* where text wraps through the image contours, filling any concave areas.
|
|
3466
|
-
*
|
|
3467
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3468
|
-
*
|
|
3469
|
-
* @module
|
|
3470
|
-
*/
|
|
3471
|
-
/**
|
|
3472
|
-
* Creates a default rectangular wrap polygon matching the image extent.
|
|
3473
|
-
*
|
|
3474
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3475
|
-
*
|
|
3476
|
-
* ## XSD Schema
|
|
3477
|
-
* ```xml
|
|
3478
|
-
* <xsd:complexType name="CT_WrapPath">
|
|
3479
|
-
* <xsd:sequence>
|
|
3480
|
-
* <xsd:element name="start" type="a:CT_Point2D" minOccurs="1" maxOccurs="1"/>
|
|
3481
|
-
* <xsd:element name="lineTo" type="a:CT_Point2D" minOccurs="2" maxOccurs="unbounded"/>
|
|
3482
|
-
* </xsd:sequence>
|
|
3483
|
-
* <xsd:attribute name="edited" type="xsd:boolean" use="optional"/>
|
|
3484
|
-
* </xsd:complexType>
|
|
3485
|
-
* ```
|
|
3486
|
-
*/
|
|
3487
|
-
const createWrapPolygon = (cx, cy) => element("wp:wrapPolygon", { edited: "0" }, [
|
|
3488
|
-
`<wp:start x="0" y="0"/>`,
|
|
3489
|
-
`<wp:lineTo x="0" y="${-cy}"/>`,
|
|
3490
|
-
`<wp:lineTo x="${cx}" y="${-cy}"/>`,
|
|
3491
|
-
`<wp:lineTo x="${cx}" y="0"/>`,
|
|
3492
|
-
`<wp:lineTo x="0" y="0"/>`
|
|
3493
|
-
]);
|
|
3494
|
-
/**
|
|
3495
|
-
* Creates "through" text wrapping for a floating drawing.
|
|
3496
|
-
*
|
|
3497
|
-
* WrapThrough is similar to WrapTight but allows text to wrap through
|
|
3498
|
-
* the concave portions of the drawing shape (e.g., the inside of the letter "O").
|
|
3499
|
-
* A default rectangular wrap polygon matching the image extent is generated.
|
|
3500
|
-
*
|
|
3501
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3502
|
-
*
|
|
3503
|
-
* ## XSD Schema
|
|
3504
|
-
* ```xml
|
|
3505
|
-
* <xsd:complexType name="CT_WrapThrough">
|
|
3506
|
-
* <xsd:sequence>
|
|
3507
|
-
* <xsd:element name="wrapPolygon" type="CT_WrapPath" minOccurs="1" maxOccurs="1"/>
|
|
3508
|
-
* </xsd:sequence>
|
|
3509
|
-
* <xsd:attribute name="wrapText" type="ST_WrapText" use="required"/>
|
|
3510
|
-
* <xsd:attribute name="distL" type="ST_WrapDistance"/>
|
|
3511
|
-
* <xsd:attribute name="distR" type="ST_WrapDistance"/>
|
|
3512
|
-
* </xsd:complexType>
|
|
3513
|
-
* ```
|
|
3514
|
-
*/
|
|
3515
|
-
const createWrapThrough = (textWrapping, margins = {
|
|
3516
|
-
bottom: 0,
|
|
3517
|
-
left: 0,
|
|
3518
|
-
right: 0,
|
|
3519
|
-
top: 0
|
|
3520
|
-
}, extent) => element("wp:wrapThrough", {
|
|
3521
|
-
distL: margins.left,
|
|
3522
|
-
distR: margins.right,
|
|
3523
|
-
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES
|
|
3524
|
-
}, [createWrapPolygon(extent.x, extent.y)]);
|
|
3525
|
-
//#endregion
|
|
3526
3405
|
//#region src/shared/constants.ts
|
|
3527
3406
|
/**
|
|
3528
3407
|
* Shared constants for WordprocessingML documents.
|
|
@@ -3631,15 +3510,6 @@ const NumberFormat = {
|
|
|
3631
3510
|
UPPER_ROMAN: "upperRoman",
|
|
3632
3511
|
VIETNAMESE_COUNTING: "vietnameseCounting"
|
|
3633
3512
|
};
|
|
3634
|
-
/**
|
|
3635
|
-
* XML space handling modes.
|
|
3636
|
-
*
|
|
3637
|
-
* @publicApi
|
|
3638
|
-
*/
|
|
3639
|
-
const SpaceType = {
|
|
3640
|
-
DEFAULT: "default",
|
|
3641
|
-
PRESERVE: "preserve"
|
|
3642
|
-
};
|
|
3643
3513
|
//#endregion
|
|
3644
3514
|
//#region src/parts/drawing/floating/floating-position.ts
|
|
3645
3515
|
/**
|
|
@@ -4550,7 +4420,7 @@ var FontWrapper = class {
|
|
|
4550
4420
|
relIdx++;
|
|
4551
4421
|
font.embedRid = `rId${relIdx}`;
|
|
4552
4422
|
const target = font.odttfPath ? font.odttfPath.startsWith("word/") ? font.odttfPath.slice(5) : font.odttfPath : `fonts/${font.name}.odttf`;
|
|
4553
|
-
this.relationships.addRelationship(relIdx,
|
|
4423
|
+
this.relationships.addRelationship(relIdx, RELATIONSHIP_TYPES.font, target);
|
|
4554
4424
|
}
|
|
4555
4425
|
}
|
|
4556
4426
|
};
|
|
@@ -5679,13 +5549,15 @@ function parseParagraphProperties(el, ctx) {
|
|
|
5679
5549
|
const endChars = attrNum(ind, "w:endChars");
|
|
5680
5550
|
if (endChars !== void 0) indentObj.endChars = endChars;
|
|
5681
5551
|
const hanging = attrMeasure(ind, "w:hanging");
|
|
5682
|
-
if (hanging !== void 0) indentObj.hanging = hanging;
|
|
5683
5552
|
const hangingChars = attrNum(ind, "w:hangingChars");
|
|
5684
5553
|
if (hangingChars !== void 0) indentObj.hangingChars = hangingChars;
|
|
5685
5554
|
const firstLine = attrMeasure(ind, "w:firstLine");
|
|
5686
|
-
if (firstLine !== void 0) indentObj.firstLine = firstLine;
|
|
5687
5555
|
const firstLineChars = attrNum(ind, "w:firstLineChars");
|
|
5688
5556
|
if (firstLineChars !== void 0) indentObj.firstLineChars = firstLineChars;
|
|
5557
|
+
if (typeof hanging === "number" && hanging < 0) indentObj.firstLine ??= -hanging;
|
|
5558
|
+
else if (hanging !== void 0) indentObj.hanging = hanging;
|
|
5559
|
+
if (typeof firstLine === "number" && firstLine < 0) indentObj.hanging ??= -firstLine;
|
|
5560
|
+
else if (firstLine !== void 0) indentObj.firstLine = firstLine;
|
|
5689
5561
|
if (Object.keys(indentObj).length > 0) opts.indent = indentObj;
|
|
5690
5562
|
}
|
|
5691
5563
|
const numPr = findChild(el, "w:numPr");
|
|
@@ -7912,9 +7784,9 @@ const CHART_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
|
7912
7784
|
const DGM_URI = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
|
|
7913
7785
|
const WPS_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
7914
7786
|
const WPG_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
|
|
7915
|
-
const HYPERLINK_REL =
|
|
7916
|
-
const IMAGE_REL =
|
|
7917
|
-
const TEXT_BOX_REL =
|
|
7787
|
+
const HYPERLINK_REL = RELATIONSHIP_TYPES.hyperlink;
|
|
7788
|
+
const IMAGE_REL = RELATIONSHIP_TYPES.image;
|
|
7789
|
+
const TEXT_BOX_REL = RELATIONSHIP_TYPES.txbxMs;
|
|
7918
7790
|
const SVG_BLIP_EXT_URI = "{96DAC541-7B7A-43D3-8B79-37D633B846F1}";
|
|
7919
7791
|
const USE_LOCAL_DPI_EXT_URI = "{28A0092B-C50C-407E-A947-70E740481C1C}";
|
|
7920
7792
|
const A14_NS = "http://schemas.microsoft.com/office/drawing/2010/main";
|
|
@@ -8433,345 +8305,635 @@ const drawingDesc = {
|
|
|
8433
8305
|
}
|
|
8434
8306
|
};
|
|
8435
8307
|
//#endregion
|
|
8436
|
-
//#region src/parts/
|
|
8437
|
-
|
|
8438
|
-
* Field module for WordprocessingML documents.
|
|
8439
|
-
*
|
|
8440
|
-
* This module provides support for complex fields, which are regions of text
|
|
8441
|
-
* that can contain dynamic content such as page numbers, dates, or mail merge fields.
|
|
8442
|
-
* Fields are delimited by field character elements (begin, separate, end).
|
|
8443
|
-
*
|
|
8444
|
-
* Reference: http://officeopenxml.com/WPrun.php
|
|
8445
|
-
*
|
|
8446
|
-
* @module
|
|
8447
|
-
*/
|
|
8448
|
-
/**
|
|
8449
|
-
* Field character types that delimit field regions.
|
|
8450
|
-
*
|
|
8451
|
-
* @internal
|
|
8452
|
-
*/
|
|
8453
|
-
const FieldCharacterType = {
|
|
8454
|
-
BEGIN: "begin",
|
|
8455
|
-
END: "end",
|
|
8456
|
-
SEPARATE: "separate"
|
|
8457
|
-
};
|
|
8458
|
-
/**
|
|
8459
|
-
* Creates a field character element.
|
|
8460
|
-
*
|
|
8461
|
-
* ## XSD Schema
|
|
8462
|
-
* ```xml
|
|
8463
|
-
* <xsd:complexType name="CT_FldChar">
|
|
8464
|
-
* <xsd:sequence>
|
|
8465
|
-
* <xsd:element name="fldData" type="CT_Text" minOccurs="0"/>
|
|
8466
|
-
* <xsd:element name="ffData" type="CT_FFData" minOccurs="0"/>
|
|
8467
|
-
* <xsd:element name="numberingChange" type="CT_TrackChangeNumbering" minOccurs="0"/>
|
|
8468
|
-
* </xsd:sequence>
|
|
8469
|
-
* <xsd:attribute name="fldCharType" type="ST_FldCharType" use="required"/>
|
|
8470
|
-
* <xsd:attribute name="fldLock" type="s:ST_OnOff"/>
|
|
8471
|
-
* <xsd:attribute name="dirty" type="s:ST_OnOff"/>
|
|
8472
|
-
* </xsd:complexType>
|
|
8473
|
-
* ```
|
|
8474
|
-
* @internal
|
|
8475
|
-
*/
|
|
8476
|
-
const createFieldChar = (type, dirty, ffData, fldData, fieldLock) => {
|
|
8477
|
-
const children = [];
|
|
8478
|
-
if (fldData !== void 0) children.push(element("w:fldData", { "xml:space": "preserve" }, [fldData]));
|
|
8479
|
-
if (ffData) children.push(ffData);
|
|
8480
|
-
return element("w:fldChar", {
|
|
8481
|
-
"w:dirty": dirty,
|
|
8482
|
-
"w:fldLock": fieldLock,
|
|
8483
|
-
"w:fldCharType": type
|
|
8484
|
-
}, children.length > 0 ? children : void 0);
|
|
8485
|
-
};
|
|
8308
|
+
//#region src/parts/inline-drawings.ts
|
|
8309
|
+
let nextChartId = 1;
|
|
8486
8310
|
/**
|
|
8487
|
-
*
|
|
8488
|
-
*
|
|
8489
|
-
*
|
|
8490
|
-
* field instructions, an optional separate character, field result, and an end character.
|
|
8491
|
-
*
|
|
8492
|
-
* For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.
|
|
8493
|
-
*
|
|
8494
|
-
* @param dirty - Whether the field should be recalculated
|
|
8495
|
-
* @param formField - Optional form field data to embed in the begin character
|
|
8496
|
-
*
|
|
8497
|
-
* @example
|
|
8498
|
-
* ```typescript
|
|
8499
|
-
* // Simple field begin
|
|
8500
|
-
* createBegin();
|
|
8501
|
-
*
|
|
8502
|
-
* // Form field (checkbox)
|
|
8503
|
-
* createBegin(false, {
|
|
8504
|
-
* name: "Check1",
|
|
8505
|
-
* checkBox: { checked: true, sizeAuto: true },
|
|
8506
|
-
* });
|
|
8507
|
-
* ```
|
|
8311
|
+
* Wrap a `<w:drawing>` run, rebuilding an mc:AlternateContent wrapper when a
|
|
8312
|
+
* VML fallback was carried from parse (Choice stays structured/editable,
|
|
8313
|
+
* Fallback round-trips as raw XML for fidelity).
|
|
8508
8314
|
*/
|
|
8509
|
-
|
|
8315
|
+
function wrapDrawingRun(drawingXml, opts) {
|
|
8316
|
+
const xml = drawingXml ?? "";
|
|
8317
|
+
const rPr = stringifyRunProperties(opts.runProperties) ?? "";
|
|
8318
|
+
const lrpb = opts.lastRenderedPageBreak ? "<w:lastRenderedPageBreak/>" : "";
|
|
8319
|
+
if (opts.vmlFallback) return `<w:r>${rPr}${lrpb}<mc:AlternateContent><mc:Choice Requires="${opts.mcChoiceRequires ?? "wps"}">${xml}</mc:Choice>${opts.vmlFallback}</mc:AlternateContent></w:r>`;
|
|
8320
|
+
return `<w:r>${rPr}${lrpb}${xml}</w:r>`;
|
|
8321
|
+
}
|
|
8510
8322
|
/**
|
|
8511
|
-
*
|
|
8323
|
+
* Register media carried by a VML fallback (mc:AlternateContent Fallback) so the
|
|
8324
|
+
* compiler resolves the fallback's `{fileName}` placeholders into rIds.
|
|
8512
8325
|
*
|
|
8513
|
-
*
|
|
8514
|
-
*
|
|
8326
|
+
* A VML fallback image mirrors its Choice blip (same source bytes). When the
|
|
8327
|
+
* blip is already registered, reuse it and remap the fallback's `{fileName}`
|
|
8328
|
+
* placeholder to the shared media — matching Office, which emits one
|
|
8329
|
+
* relationship/file per image rather than a duplicate for the VML branch.
|
|
8515
8330
|
*/
|
|
8516
|
-
|
|
8331
|
+
function registerVmlFallbackMedia(opts, ctx) {
|
|
8332
|
+
if (!opts.vmlFallbackMedia) return;
|
|
8333
|
+
for (const m of opts.vmlFallbackMedia) {
|
|
8334
|
+
const data = toUint8Array(m.data);
|
|
8335
|
+
const entry = ctx.file.media.addMedia(data, m.type, (fileName) => ({
|
|
8336
|
+
type: m.type,
|
|
8337
|
+
data,
|
|
8338
|
+
fileName,
|
|
8339
|
+
transformation: {
|
|
8340
|
+
emus: {
|
|
8341
|
+
x: 0,
|
|
8342
|
+
y: 0
|
|
8343
|
+
},
|
|
8344
|
+
pixels: {
|
|
8345
|
+
x: 0,
|
|
8346
|
+
y: 0
|
|
8347
|
+
}
|
|
8348
|
+
}
|
|
8349
|
+
}), m.fileName);
|
|
8350
|
+
if (entry.fileName !== m.fileName && opts.vmlFallback) opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
8351
|
+
}
|
|
8352
|
+
}
|
|
8353
|
+
/** Rewrite ../media targets inside verbatim data rels after the media
|
|
8354
|
+
* collection re-allocated pinned names. All renames apply in one pass over
|
|
8355
|
+
* the original text, each match bounded by its closing quote, so a name
|
|
8356
|
+
* that prefixes another cannot collide and chained renames cannot re-hit
|
|
8357
|
+
* an already-rewritten target. Preserves the input form (string stays
|
|
8358
|
+
* string, bytes stay bytes). */
|
|
8359
|
+
function remapDataRelsTargets(rels, renames) {
|
|
8360
|
+
const isText = typeof rels === "string";
|
|
8361
|
+
const text = isText ? rels : new TextDecoder().decode(toUint8Array(rels));
|
|
8362
|
+
let out = "";
|
|
8363
|
+
let last = 0;
|
|
8364
|
+
for (const m of text.matchAll(/\.\.\/media\/([^"']*)["']/g)) {
|
|
8365
|
+
const name = m[1] ?? "";
|
|
8366
|
+
const to = renames.get(name);
|
|
8367
|
+
if (to === void 0) continue;
|
|
8368
|
+
const start = (m.index ?? 0) + 9;
|
|
8369
|
+
out += text.slice(last, start) + to;
|
|
8370
|
+
last = start + name.length;
|
|
8371
|
+
}
|
|
8372
|
+
out += text.slice(last);
|
|
8373
|
+
return isText ? out : new TextEncoder().encode(out);
|
|
8374
|
+
}
|
|
8375
|
+
/** Content fingerprint of the raw source parts: every field participates so
|
|
8376
|
+
* two instances that differ in any raw part (or in their companion rels or
|
|
8377
|
+
* media names) never merge into one diagram part set. */
|
|
8378
|
+
function rawSmartArtFingerprint(raw) {
|
|
8379
|
+
if (!raw) return void 0;
|
|
8380
|
+
const b64 = (v) => v === void 0 ? void 0 : encodeBase64(toUint8Array(v));
|
|
8381
|
+
return JSON.stringify({
|
|
8382
|
+
data: b64(raw.data),
|
|
8383
|
+
layout: b64(raw.layout),
|
|
8384
|
+
style: b64(raw.style),
|
|
8385
|
+
color: b64(raw.color),
|
|
8386
|
+
dataRels: b64(raw.dataRels),
|
|
8387
|
+
media: raw.media?.map((m) => m.fileName)
|
|
8388
|
+
});
|
|
8389
|
+
}
|
|
8390
|
+
/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */
|
|
8391
|
+
function hashSmartArtData(options) {
|
|
8392
|
+
const data = JSON.stringify({
|
|
8393
|
+
nodes: options.nodes,
|
|
8394
|
+
layout: options.layout,
|
|
8395
|
+
style: options.style,
|
|
8396
|
+
color: options.color,
|
|
8397
|
+
raw: rawSmartArtFingerprint(options.raw)
|
|
8398
|
+
});
|
|
8399
|
+
let hash = 0;
|
|
8400
|
+
for (let i = 0; i < data.length; i++) {
|
|
8401
|
+
const char = data.charCodeAt(i);
|
|
8402
|
+
hash = (hash << 5) - hash + char | 0;
|
|
8403
|
+
}
|
|
8404
|
+
return Math.abs(hash);
|
|
8405
|
+
}
|
|
8517
8406
|
/**
|
|
8518
|
-
*
|
|
8407
|
+
* Stringify the drawing-family children of the JSON dispatch: picture, chart,
|
|
8408
|
+
* SmartArt, WPS shape, content part, and WPG group. Each registers its media
|
|
8409
|
+
* or part side effects, then emits the `<w:drawing>` run.
|
|
8519
8410
|
*
|
|
8520
|
-
*
|
|
8521
|
-
* element must be terminated with an End element.
|
|
8411
|
+
* Returns `undefined` when the child is not a drawing-family wrapper.
|
|
8522
8412
|
*/
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
}
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
}
|
|
8573
|
-
function stringifyRuby(opts, ctx) {
|
|
8574
|
-
const properties = opts.properties;
|
|
8575
|
-
const dirty = properties.dirty !== void 0 ? onOff$2("w:dirty", properties.dirty) : "";
|
|
8576
|
-
return `<w:ruby><w:rubyPr><w:rubyAlign w:val="${properties.alignment}"/><w:hps w:val="${hpsMeasureValue(properties.fontSize * 2)}"/><w:hpsRaise w:val="${hpsMeasureValue(properties.raise * 2)}"/><w:hpsBaseText w:val="${hpsMeasureValue(properties.baseFontSize * 2)}"/><w:lid w:val="${escapeXml(properties.languageId)}"/>${dirty}</w:rubyPr><w:rt>${stringifyRubyContent(opts.text, ctx)}</w:rt><w:rubyBase>${stringifyRubyContent(opts.base, ctx)}</w:rubyBase></w:ruby>`;
|
|
8577
|
-
}
|
|
8578
|
-
function stringifyRunInline(opts, ctx) {
|
|
8579
|
-
let body = "";
|
|
8580
|
-
let commentRefStyle = false;
|
|
8581
|
-
if (opts.children) {
|
|
8582
|
-
for (const child of opts.children) if (typeof child === "object" && child !== null && "commentReference" in child) {
|
|
8583
|
-
commentRefStyle = true;
|
|
8584
|
-
break;
|
|
8413
|
+
function stringifyDrawingChild(child, ctx) {
|
|
8414
|
+
if ("picture" in child) {
|
|
8415
|
+
const opts = child.picture;
|
|
8416
|
+
if (opts.type !== "svg" && opts.data === void 0 && opts.sourceUrl !== void 0) return wrapDrawingRun(drawingDesc.stringify({
|
|
8417
|
+
mediaData: {
|
|
8418
|
+
type: opts.type,
|
|
8419
|
+
sourceUrl: opts.sourceUrl,
|
|
8420
|
+
transformation: createTransformation(opts.transformation),
|
|
8421
|
+
sourceRectangle: opts.sourceRectangle,
|
|
8422
|
+
nonVisualProperties: opts.nonVisualProperties,
|
|
8423
|
+
useLocalDpi: opts.useLocalDpi,
|
|
8424
|
+
compression: opts.compression
|
|
8425
|
+
},
|
|
8426
|
+
docProperties: opts.altText,
|
|
8427
|
+
floating: opts.floating,
|
|
8428
|
+
outline: opts.outline,
|
|
8429
|
+
fill: opts.fill,
|
|
8430
|
+
effects: opts.effects,
|
|
8431
|
+
scene3d: opts.scene3d,
|
|
8432
|
+
shape3d: opts.shape3d,
|
|
8433
|
+
blipEffects: opts.blipEffects,
|
|
8434
|
+
tile: opts.tile,
|
|
8435
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8436
|
+
}, ctx), opts);
|
|
8437
|
+
const rawData = toUint8Array(opts.data, { encoding: "base64" });
|
|
8438
|
+
let mediaData;
|
|
8439
|
+
if (opts.type === "svg") {
|
|
8440
|
+
const fallbackData = toUint8Array(opts.fallback.data, { encoding: "base64" });
|
|
8441
|
+
const fallbackType = opts.fallback.type;
|
|
8442
|
+
const fallback = ctx.file.media.addMedia(fallbackData, fallbackType, (fileName) => ({
|
|
8443
|
+
type: fallbackType,
|
|
8444
|
+
...createPictureData(fallbackData, opts.transformation, fileName)
|
|
8445
|
+
}), opts.fallback.fileName);
|
|
8446
|
+
mediaData = ctx.file.media.addMedia(rawData, "svg", (fileName) => ({
|
|
8447
|
+
type: "svg",
|
|
8448
|
+
...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
8449
|
+
useLocalDpi: opts.useLocalDpi,
|
|
8450
|
+
compression: opts.compression,
|
|
8451
|
+
fallback
|
|
8452
|
+
}), opts.fileName);
|
|
8453
|
+
} else {
|
|
8454
|
+
const type = opts.type;
|
|
8455
|
+
mediaData = ctx.file.media.addMedia(rawData, type, (fileName) => ({
|
|
8456
|
+
type,
|
|
8457
|
+
...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
8458
|
+
useLocalDpi: opts.useLocalDpi,
|
|
8459
|
+
compression: opts.compression,
|
|
8460
|
+
sourceUrl: opts.sourceUrl
|
|
8461
|
+
}), opts.fileName);
|
|
8585
8462
|
}
|
|
8463
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8464
|
+
mediaData,
|
|
8465
|
+
docProperties: opts.altText,
|
|
8466
|
+
floating: opts.floating,
|
|
8467
|
+
outline: opts.outline,
|
|
8468
|
+
fill: opts.fill,
|
|
8469
|
+
effects: opts.effects,
|
|
8470
|
+
scene3d: opts.scene3d,
|
|
8471
|
+
shape3d: opts.shape3d,
|
|
8472
|
+
blipEffects: opts.blipEffects,
|
|
8473
|
+
tile: opts.tile,
|
|
8474
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8475
|
+
}, ctx), opts);
|
|
8586
8476
|
}
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
const
|
|
8597
|
-
const
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8477
|
+
if ("chart" in child) {
|
|
8478
|
+
const opts = child.chart;
|
|
8479
|
+
const chartKey = `chart_${nextChartId++}`;
|
|
8480
|
+
const mediaData = {
|
|
8481
|
+
chartKey,
|
|
8482
|
+
transformation: createTransformation(opts.transformation),
|
|
8483
|
+
type: "chart"
|
|
8484
|
+
};
|
|
8485
|
+
const { transformation: _t, floating: _f, altText: _a, graphicFrameLocks: _g, runProperties: _r, lastRenderedPageBreak: _l, ...chartSpace } = opts;
|
|
8486
|
+
const chartXml = chartSpaceDesc.stringify(chartSpace, ctx.file);
|
|
8487
|
+
const externalData = chartSpace.externalData;
|
|
8488
|
+
ctx.file.charts.addChart(chartKey, {
|
|
8489
|
+
key: chartKey,
|
|
8490
|
+
chartSpaceXml: chartXml ?? "",
|
|
8491
|
+
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
8492
|
+
relationshipId: externalData.relationshipId,
|
|
8493
|
+
fileName: externalData.fileName,
|
|
8494
|
+
data: externalData.data
|
|
8495
|
+
} } : {},
|
|
8496
|
+
...chartSpace.userShapes ? { userShapes: buildUserShapesData(chartSpace.userShapes) } : {}
|
|
8497
|
+
});
|
|
8498
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8499
|
+
mediaData,
|
|
8500
|
+
docProperties: opts.altText,
|
|
8501
|
+
floating: opts.floating,
|
|
8502
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8503
|
+
}, ctx), opts);
|
|
8603
8504
|
}
|
|
8604
|
-
if (
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
}
|
|
8639
|
-
const bareEnRef = child.endnoteReference;
|
|
8640
|
-
if (bareEnRef !== void 0) {
|
|
8641
|
-
const id = typeof bareEnRef === "number" ? bareEnRef : bareEnRef.id;
|
|
8642
|
-
const cmf = typeof bareEnRef === "object" && bareEnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8643
|
-
body += `<w:endnoteReference w:id="${id}"${cmf}/>`;
|
|
8644
|
-
continue;
|
|
8645
|
-
}
|
|
8646
|
-
let firstKey;
|
|
8647
|
-
for (const key in child) {
|
|
8648
|
-
firstKey = key;
|
|
8649
|
-
break;
|
|
8650
|
-
}
|
|
8651
|
-
const emptyXml = firstKey !== void 0 ? EMPTY_RUN_ELEMENTS[firstKey] : void 0;
|
|
8652
|
-
if (emptyXml) {
|
|
8653
|
-
body += emptyXml;
|
|
8654
|
-
continue;
|
|
8655
|
-
}
|
|
8656
|
-
if ("ruby" in child) {
|
|
8657
|
-
body += stringifyRuby(child.ruby, ctx);
|
|
8658
|
-
continue;
|
|
8659
|
-
}
|
|
8660
|
-
if ("object" in child) {
|
|
8661
|
-
body += objectDesc.stringify(child.object, ctx) ?? "";
|
|
8662
|
-
continue;
|
|
8663
|
-
}
|
|
8664
|
-
if ("pict" in child) {
|
|
8665
|
-
body += stringifyPict(child.pict, ctx);
|
|
8666
|
-
continue;
|
|
8505
|
+
if ("smartArt" in child) {
|
|
8506
|
+
const opts = child.smartArt;
|
|
8507
|
+
const smartArtKey = `smartart_${hashSmartArtData(opts)}`;
|
|
8508
|
+
const mediaData = {
|
|
8509
|
+
smartArtKey,
|
|
8510
|
+
transformation: createTransformation(opts.transformation),
|
|
8511
|
+
type: "smartart"
|
|
8512
|
+
};
|
|
8513
|
+
const layoutId = typeof opts.layout === "object" ? definitionId(opts.layout) : opts.layout ?? "default";
|
|
8514
|
+
const styleId = typeof opts.style === "object" ? definitionId(opts.style) : opts.style ?? "simple1";
|
|
8515
|
+
const colorId = typeof opts.color === "object" ? definitionId(opts.color) : opts.color ?? "accent1_2";
|
|
8516
|
+
const dataModelXml = createDataModel(opts.nodes, layoutId, styleId, colorId);
|
|
8517
|
+
let remappedDataRels = opts.raw?.dataRels;
|
|
8518
|
+
if (opts.raw?.media) {
|
|
8519
|
+
const renames = /* @__PURE__ */ new Map();
|
|
8520
|
+
for (const m of opts.raw.media) {
|
|
8521
|
+
const data = toUint8Array(m.data);
|
|
8522
|
+
const type = imageTypeFromPath(m.fileName);
|
|
8523
|
+
const entry = ctx.file.media.addMedia(data, type, (fileName) => ({
|
|
8524
|
+
type,
|
|
8525
|
+
data,
|
|
8526
|
+
fileName,
|
|
8527
|
+
transformation: {
|
|
8528
|
+
emus: {
|
|
8529
|
+
x: 0,
|
|
8530
|
+
y: 0
|
|
8531
|
+
},
|
|
8532
|
+
pixels: {
|
|
8533
|
+
x: 0,
|
|
8534
|
+
y: 0
|
|
8535
|
+
}
|
|
8536
|
+
}
|
|
8537
|
+
}), m.fileName);
|
|
8538
|
+
if (entry.fileName !== m.fileName) renames.set(m.fileName, entry.fileName);
|
|
8667
8539
|
}
|
|
8668
|
-
|
|
8669
|
-
if (jsonResult !== void 0) body += Array.isArray(jsonResult) ? jsonResult.join("") : jsonResult;
|
|
8670
|
-
else if ("text" in child || "children" in child || "break" in child) body += stringifyRunInline(child, ctx);
|
|
8540
|
+
if (renames.size > 0 && remappedDataRels !== void 0) remappedDataRels = remapDataRelsTargets(remappedDataRels, renames);
|
|
8671
8541
|
}
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8542
|
+
ctx.file.smartArts.addSmartArt(smartArtKey, {
|
|
8543
|
+
dataModelXml,
|
|
8544
|
+
key: smartArtKey,
|
|
8545
|
+
layout: opts.layout ?? "default",
|
|
8546
|
+
style: opts.style ?? "simple1",
|
|
8547
|
+
color: opts.color ?? "accent1_2",
|
|
8548
|
+
...opts.raw || remappedDataRels !== void 0 ? { raw: {
|
|
8549
|
+
...opts.raw,
|
|
8550
|
+
dataRels: remappedDataRels
|
|
8551
|
+
} } : {}
|
|
8552
|
+
});
|
|
8553
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8554
|
+
mediaData,
|
|
8555
|
+
docProperties: opts.altText,
|
|
8556
|
+
floating: opts.floating,
|
|
8557
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8558
|
+
}, ctx), {
|
|
8559
|
+
runProperties: opts.runProperties,
|
|
8560
|
+
lastRenderedPageBreak: opts.lastRenderedPageBreak
|
|
8561
|
+
});
|
|
8562
|
+
}
|
|
8563
|
+
if ("wpsShape" in child) {
|
|
8564
|
+
const opts = child.wpsShape;
|
|
8565
|
+
const mediaData = {
|
|
8566
|
+
data: opts,
|
|
8567
|
+
transformation: createTransformation(opts.transformation),
|
|
8568
|
+
type: "wps"
|
|
8569
|
+
};
|
|
8570
|
+
const drawingXml = drawingDesc.stringify({
|
|
8571
|
+
mediaData,
|
|
8572
|
+
docProperties: opts.altText,
|
|
8573
|
+
floating: opts.floating,
|
|
8574
|
+
outline: opts.outline,
|
|
8575
|
+
fill: opts.fill,
|
|
8576
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8577
|
+
}, ctx);
|
|
8578
|
+
registerVmlFallbackMedia(opts, ctx);
|
|
8579
|
+
return wrapDrawingRun(drawingXml, opts);
|
|
8580
|
+
}
|
|
8581
|
+
if ("contentPart" in child) return `<w:r><w:contentPart r:id="${child.contentPart.referenceId}"/></w:r>`;
|
|
8582
|
+
if ("wpgGroup" in child) {
|
|
8583
|
+
const opts = child.wpgGroup;
|
|
8584
|
+
const mediaData = {
|
|
8585
|
+
children: opts.children,
|
|
8586
|
+
transformation: createTransformation(opts.transformation),
|
|
8587
|
+
childOffsetX: opts.childOffsetX,
|
|
8588
|
+
childOffsetY: opts.childOffsetY,
|
|
8589
|
+
childExtentWidth: opts.childExtentWidth,
|
|
8590
|
+
childExtentHeight: opts.childExtentHeight,
|
|
8591
|
+
fill: opts.fill,
|
|
8592
|
+
effects: opts.effects,
|
|
8593
|
+
groupShapeLocks: opts.groupShapeLocks,
|
|
8594
|
+
type: "wpg"
|
|
8595
|
+
};
|
|
8596
|
+
const registerMedia = (children) => {
|
|
8597
|
+
for (const c of children) {
|
|
8598
|
+
if (c.type === "wps") continue;
|
|
8599
|
+
if (c.type === "wpg") {
|
|
8600
|
+
registerMedia(c.children);
|
|
8601
|
+
continue;
|
|
8602
|
+
}
|
|
8603
|
+
if (c.type === "chart") {
|
|
8604
|
+
if (c.chartOptions && !c.chartKey) {
|
|
8605
|
+
c.chartKey = `chart_${nextChartId++}`;
|
|
8606
|
+
const externalData = c.chartOptions.externalData;
|
|
8607
|
+
ctx.file.charts.addChart(c.chartKey, {
|
|
8608
|
+
key: c.chartKey,
|
|
8609
|
+
chartSpaceXml: chartSpaceDesc.stringify(c.chartOptions, ctx.file) ?? "",
|
|
8610
|
+
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
8611
|
+
relationshipId: externalData.relationshipId,
|
|
8612
|
+
fileName: externalData.fileName,
|
|
8613
|
+
data: externalData.data
|
|
8614
|
+
} } : {},
|
|
8615
|
+
...c.chartOptions.userShapes ? { userShapes: buildUserShapesData(c.chartOptions.userShapes) } : {}
|
|
8616
|
+
});
|
|
8617
|
+
}
|
|
8618
|
+
continue;
|
|
8619
|
+
}
|
|
8620
|
+
if (c.type === "contentPart") continue;
|
|
8621
|
+
if (c.type === "svg") {
|
|
8622
|
+
const fb = c.fallback;
|
|
8623
|
+
fb.fileName = ctx.file.media.addMedia(fb.data, fb.type, () => fb, fb.fileName).fileName;
|
|
8624
|
+
c.fileName = ctx.file.media.addMedia(c.data, "svg", () => c, c.fileName).fileName;
|
|
8625
|
+
continue;
|
|
8626
|
+
}
|
|
8627
|
+
c.fileName = ctx.file.media.addMedia(c.data, c.type, () => c, c.fileName).fileName;
|
|
8628
|
+
}
|
|
8629
|
+
};
|
|
8630
|
+
registerMedia(opts.children);
|
|
8631
|
+
const drawingXml = drawingDesc.stringify({
|
|
8632
|
+
mediaData,
|
|
8633
|
+
docProperties: opts.altText,
|
|
8634
|
+
floating: opts.floating,
|
|
8635
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8636
|
+
}, ctx);
|
|
8637
|
+
registerVmlFallbackMedia(opts, ctx);
|
|
8638
|
+
return wrapDrawingRun(drawingXml, opts);
|
|
8639
|
+
}
|
|
8678
8640
|
}
|
|
8679
|
-
|
|
8641
|
+
//#endregion
|
|
8642
|
+
//#region src/parts/paragraph/run/field.ts
|
|
8680
8643
|
/**
|
|
8681
|
-
*
|
|
8644
|
+
* Field module for WordprocessingML documents.
|
|
8682
8645
|
*
|
|
8683
|
-
*
|
|
8684
|
-
*
|
|
8646
|
+
* This module provides support for complex fields, which are regions of text
|
|
8647
|
+
* that can contain dynamic content such as page numbers, dates, or mail merge fields.
|
|
8648
|
+
* Fields are delimited by field character elements (begin, separate, end).
|
|
8685
8649
|
*
|
|
8686
|
-
*
|
|
8650
|
+
* Reference: http://officeopenxml.com/WPrun.php
|
|
8651
|
+
*
|
|
8652
|
+
* @module
|
|
8687
8653
|
*/
|
|
8688
8654
|
/**
|
|
8689
|
-
*
|
|
8690
|
-
*
|
|
8691
|
-
*
|
|
8655
|
+
* Field character types that delimit field regions.
|
|
8656
|
+
*
|
|
8657
|
+
* @internal
|
|
8692
8658
|
*/
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
return `<w:r>${rPr}${lrpb}${xml}</w:r>`;
|
|
8699
|
-
}
|
|
8659
|
+
const FieldCharacterType = {
|
|
8660
|
+
BEGIN: "begin",
|
|
8661
|
+
END: "end",
|
|
8662
|
+
SEPARATE: "separate"
|
|
8663
|
+
};
|
|
8700
8664
|
/**
|
|
8701
|
-
*
|
|
8702
|
-
* compiler resolves the fallback's `{fileName}` placeholders into rIds.
|
|
8665
|
+
* Creates a field character element.
|
|
8703
8666
|
*
|
|
8704
|
-
*
|
|
8705
|
-
*
|
|
8706
|
-
*
|
|
8707
|
-
*
|
|
8667
|
+
* ## XSD Schema
|
|
8668
|
+
* ```xml
|
|
8669
|
+
* <xsd:complexType name="CT_FldChar">
|
|
8670
|
+
* <xsd:sequence>
|
|
8671
|
+
* <xsd:element name="fldData" type="CT_Text" minOccurs="0"/>
|
|
8672
|
+
* <xsd:element name="ffData" type="CT_FFData" minOccurs="0"/>
|
|
8673
|
+
* <xsd:element name="numberingChange" type="CT_TrackChangeNumbering" minOccurs="0"/>
|
|
8674
|
+
* </xsd:sequence>
|
|
8675
|
+
* <xsd:attribute name="fldCharType" type="ST_FldCharType" use="required"/>
|
|
8676
|
+
* <xsd:attribute name="fldLock" type="s:ST_OnOff"/>
|
|
8677
|
+
* <xsd:attribute name="dirty" type="s:ST_OnOff"/>
|
|
8678
|
+
* </xsd:complexType>
|
|
8679
|
+
* ```
|
|
8680
|
+
* @internal
|
|
8708
8681
|
*/
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
x: 0,
|
|
8720
|
-
y: 0
|
|
8721
|
-
},
|
|
8722
|
-
pixels: {
|
|
8723
|
-
x: 0,
|
|
8724
|
-
y: 0
|
|
8725
|
-
}
|
|
8726
|
-
}
|
|
8727
|
-
}), m.fileName);
|
|
8728
|
-
if (entry.fileName !== m.fileName && opts.vmlFallback) opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
8729
|
-
}
|
|
8730
|
-
}
|
|
8682
|
+
const createFieldChar = (type, dirty, ffData, fldData, fieldLock) => {
|
|
8683
|
+
const children = [];
|
|
8684
|
+
if (fldData !== void 0) children.push(element("w:fldData", { "xml:space": "preserve" }, [fldData]));
|
|
8685
|
+
if (ffData) children.push(ffData);
|
|
8686
|
+
return element("w:fldChar", {
|
|
8687
|
+
"w:dirty": dirty,
|
|
8688
|
+
"w:fldLock": fieldLock,
|
|
8689
|
+
"w:fldCharType": type
|
|
8690
|
+
}, children.length > 0 ? children : void 0);
|
|
8691
|
+
};
|
|
8731
8692
|
/**
|
|
8732
|
-
*
|
|
8693
|
+
* Creates the beginning of a complex field.
|
|
8694
|
+
*
|
|
8695
|
+
* The Begin element marks the start of a field. A field consists of a begin character,
|
|
8696
|
+
* field instructions, an optional separate character, field result, and an end character.
|
|
8697
|
+
*
|
|
8698
|
+
* For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.
|
|
8699
|
+
*
|
|
8700
|
+
* @param dirty - Whether the field should be recalculated
|
|
8701
|
+
* @param formField - Optional form field data to embed in the begin character
|
|
8702
|
+
*
|
|
8703
|
+
* @example
|
|
8704
|
+
* ```typescript
|
|
8705
|
+
* // Simple field begin
|
|
8706
|
+
* createBegin();
|
|
8707
|
+
*
|
|
8708
|
+
* // Form field (checkbox)
|
|
8709
|
+
* createBegin(false, {
|
|
8710
|
+
* name: "Check1",
|
|
8711
|
+
* checkBox: { checked: true, sizeAuto: true },
|
|
8712
|
+
* });
|
|
8713
|
+
* ```
|
|
8733
8714
|
*/
|
|
8734
|
-
|
|
8735
|
-
function buildMarkupRangeAttrs(m) {
|
|
8736
|
-
const a = [`w:id="${m.id}"`];
|
|
8737
|
-
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
8738
|
-
return a.join(" ");
|
|
8739
|
-
}
|
|
8740
|
-
/** Shared attribute string for w:bookmarkStart (CT_Bookmark). */
|
|
8741
|
-
function buildBookmarkStartAttrs(bs) {
|
|
8742
|
-
const a = [`w:id="${bs.id}"`, `w:name="${escapeXml(bs.name)}"`];
|
|
8743
|
-
if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml="${bs.displacedByCustomXml}"`);
|
|
8744
|
-
if (bs.colFirst !== void 0) a.push(`w:colFirst="${bs.colFirst}"`);
|
|
8745
|
-
if (bs.colLast !== void 0) a.push(`w:colLast="${bs.colLast}"`);
|
|
8746
|
-
return a.join(" ");
|
|
8747
|
-
}
|
|
8748
|
-
/** Shared attribute string for w:moveFromRangeStart / w:moveToRangeStart (CT_MoveBookmark). */
|
|
8749
|
-
function buildMoveRangeStartAttrs(m) {
|
|
8750
|
-
const a = [`w:id="${m.id}"`];
|
|
8751
|
-
if (m.name) a.push(`w:name="${escapeXml(m.name)}"`);
|
|
8752
|
-
if (m.author) a.push(`w:author="${escapeXml(m.author)}"`);
|
|
8753
|
-
if (m.date) a.push(`w:date="${m.date}"`);
|
|
8754
|
-
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
8755
|
-
if (m.colFirst !== void 0) a.push(`w:colFirst="${m.colFirst}"`);
|
|
8756
|
-
if (m.colLast !== void 0) a.push(`w:colLast="${m.colLast}"`);
|
|
8757
|
-
return a.join(" ");
|
|
8758
|
-
}
|
|
8759
|
-
/** Stringify inline run/text content — the `wrap` shared by every sugar child. */
|
|
8760
|
-
function stringifyInlineWrap(wrap, ctx) {
|
|
8761
|
-
const parts = [];
|
|
8762
|
-
for (const item of wrap ?? []) parts.push(typeof item === "string" ? stringifyRunInline({ text: item }, ctx) : stringifyRunInline(item, ctx));
|
|
8763
|
-
return parts.join("");
|
|
8764
|
-
}
|
|
8715
|
+
const createBegin = (dirty, formField, fieldLock) => createFieldChar(FieldCharacterType.BEGIN, dirty, formField ? createFormFieldData(formField) : void 0, void 0, fieldLock);
|
|
8765
8716
|
/**
|
|
8766
|
-
*
|
|
8767
|
-
*
|
|
8768
|
-
* the
|
|
8717
|
+
* Creates the separator between field code and field result in a complex field.
|
|
8718
|
+
*
|
|
8719
|
+
* The Separate element divides the field code (instructions) from the field result
|
|
8720
|
+
* (the computed value).
|
|
8769
8721
|
*/
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8722
|
+
const createSeparate = (dirty) => createFieldChar(FieldCharacterType.SEPARATE, dirty);
|
|
8723
|
+
/**
|
|
8724
|
+
* Creates the end of a complex field.
|
|
8725
|
+
*
|
|
8726
|
+
* The End element marks the end of a field. Every field that begins with a Begin
|
|
8727
|
+
* element must be terminated with an End element.
|
|
8728
|
+
*/
|
|
8729
|
+
const createEnd = (dirty) => createFieldChar(FieldCharacterType.END, dirty);
|
|
8730
|
+
//#endregion
|
|
8731
|
+
//#region src/parts/inline.ts
|
|
8732
|
+
/**
|
|
8733
|
+
* Shared inline run/paragraph stringification for DOCX descriptors.
|
|
8734
|
+
*
|
|
8735
|
+
* Used by table.ts, comments.ts, body.ts, and other descriptors that need to
|
|
8736
|
+
* serialize paragraph/run content. Includes JSON child dispatch for all
|
|
8737
|
+
* ParagraphChild variants (picture, chart, hyperlink, etc.).
|
|
8738
|
+
*
|
|
8739
|
+
* Pure string concatenation — no intermediate object tree.
|
|
8740
|
+
*
|
|
8741
|
+
* @module
|
|
8742
|
+
*/
|
|
8743
|
+
function stringifySymbolRunInner(opts) {
|
|
8744
|
+
return `<${opts.kind === "office2016" ? "w16se:sym" : "w:sym"} w:char="${escapeXml(opts.char)}" w:font="${escapeXml(opts.symbolFont ?? "Wingdings")}"/>`;
|
|
8745
|
+
}
|
|
8746
|
+
/** Serialize a complex field's run chain. Inside a w:del wrapper the
|
|
8747
|
+
* instruction is spelled w:delInstrText and the cached result w:delText. */
|
|
8748
|
+
function stringifyComplexFieldRuns(cf, isDelete = false) {
|
|
8749
|
+
const instrTag = isDelete ? "w:delInstrText" : "w:instrText";
|
|
8750
|
+
const textTag = isDelete ? "w:delText" : "w:t";
|
|
8751
|
+
const ctrl = cf.rPrXml ?? "";
|
|
8752
|
+
const res = cf.resultRPrXml ?? ctrl;
|
|
8753
|
+
const instrXml = cf.instrRunsXml ?? (cf.instruction !== "" ? `<w:r>${ctrl}<${instrTag} xml:space="preserve">${escapeXml(cf.instruction)}</${instrTag}></w:r>` : "");
|
|
8754
|
+
const resultXml = cf.resultRunsXml !== void 0 ? `<w:r>${ctrl}<w:fldChar w:fldCharType="separate"/></w:r>` + cf.resultRunsXml : cf.result !== void 0 ? `<w:r>${ctrl}<w:fldChar w:fldCharType="separate"/></w:r><w:r>${res}<${textTag} xml:space="preserve">${escapeXml(cf.result)}</${textTag}></w:r>` : "";
|
|
8755
|
+
return `<w:r>${ctrl}${cf.lastRenderedPageBreak ? "<w:lastRenderedPageBreak/>" : ""}<w:fldChar w:fldCharType="begin"/></w:r>` + instrXml + resultXml + `<w:r>${cf.endRPrXml ?? ctrl}<w:fldChar w:fldCharType="end"/></w:r>`;
|
|
8756
|
+
}
|
|
8757
|
+
/** Serialize a deleted run: rPr + delText (or field delInstrText). */
|
|
8758
|
+
function stringifyDeletedRun(c) {
|
|
8759
|
+
const opts = typeof c === "string" ? { text: c } : c;
|
|
8760
|
+
const parts = [];
|
|
8761
|
+
const rPr = stringifyRunProperties(opts);
|
|
8762
|
+
if (rPr) parts.push(rPr);
|
|
8763
|
+
if (opts.break) parts.push(breakXml(opts.break));
|
|
8764
|
+
let attr = "";
|
|
8765
|
+
if (opts.additionRsid) attr += ` w:rsidR="${opts.additionRsid}"`;
|
|
8766
|
+
if (opts.runPropertiesRsid) attr += ` w:rsidRPr="${opts.runPropertiesRsid}"`;
|
|
8767
|
+
if (opts.deletionRsid) attr += ` w:rsidDel="${opts.deletionRsid}"`;
|
|
8768
|
+
const openTag = attr ? `<w:r${attr}>` : "<w:r>";
|
|
8769
|
+
if (opts.children) {
|
|
8770
|
+
for (const cc of opts.children) if (typeof cc === "string") parts.push(`<w:delText xml:space="preserve">${escapeXml(cc)}</w:delText>`);
|
|
8771
|
+
else if (typeof cc === "object" && cc !== null && "commentReference" in cc) parts.push(`<w:commentReference w:id="${Number(cc.commentReference)}"/>`);
|
|
8772
|
+
else if (typeof cc === "object" && cc !== null && "break" in cc) parts.push(breakXml(cc.break));
|
|
8773
|
+
} else if (opts.text) parts.push(`<w:delText xml:space="preserve">${escapeXml(String(opts.text))}</w:delText>`);
|
|
8774
|
+
return `${openTag}${parts.join("")}</w:r>`;
|
|
8775
|
+
}
|
|
8776
|
+
function stringifyRubyContent(opts, ctx) {
|
|
8777
|
+
return opts.children?.map((child) => stringifyRunInline(typeof child === "string" ? { text: child } : child, ctx)).join("") ?? "";
|
|
8778
|
+
}
|
|
8779
|
+
function stringifyRuby(opts, ctx) {
|
|
8780
|
+
const properties = opts.properties;
|
|
8781
|
+
const dirty = properties.dirty !== void 0 ? onOff$2("w:dirty", properties.dirty) : "";
|
|
8782
|
+
return `<w:ruby><w:rubyPr><w:rubyAlign w:val="${properties.alignment}"/><w:hps w:val="${hpsMeasureValue(properties.fontSize * 2)}"/><w:hpsRaise w:val="${hpsMeasureValue(properties.raise * 2)}"/><w:hpsBaseText w:val="${hpsMeasureValue(properties.baseFontSize * 2)}"/><w:lid w:val="${escapeXml(properties.languageId)}"/>${dirty}</w:rubyPr><w:rt>${stringifyRubyContent(opts.text, ctx)}</w:rt><w:rubyBase>${stringifyRubyContent(opts.base, ctx)}</w:rubyBase></w:ruby>`;
|
|
8783
|
+
}
|
|
8784
|
+
function stringifyRunInline(opts, ctx) {
|
|
8785
|
+
let body = "";
|
|
8786
|
+
let commentRefStyle = false;
|
|
8787
|
+
if (opts.children && !opts.style) {
|
|
8788
|
+
for (const child of opts.children) if (typeof child === "object" && child !== null && "commentReference" in child) {
|
|
8789
|
+
commentRefStyle = true;
|
|
8790
|
+
break;
|
|
8791
|
+
}
|
|
8792
|
+
}
|
|
8793
|
+
const rPr = stringifyRunProperties(commentRefStyle && !opts.style ? {
|
|
8794
|
+
...opts,
|
|
8795
|
+
style: "CommentReference"
|
|
8796
|
+
} : opts);
|
|
8797
|
+
if (rPr) body += rPr;
|
|
8798
|
+
if (opts.break) body += breakXml(opts.break);
|
|
8799
|
+
const fnRef = opts.footnoteReference;
|
|
8800
|
+
const enRef = opts.endnoteReference;
|
|
8801
|
+
if (fnRef !== void 0) {
|
|
8802
|
+
const id = typeof fnRef === "number" ? fnRef : fnRef.id;
|
|
8803
|
+
const cmf = typeof fnRef === "object" && fnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8804
|
+
body += `<w:footnoteReference w:id="${id}"${cmf}/>`;
|
|
8805
|
+
} else if (enRef !== void 0) {
|
|
8806
|
+
const id = typeof enRef === "number" ? enRef : enRef.id;
|
|
8807
|
+
const cmf = typeof enRef === "object" && enRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8808
|
+
body += `<w:endnoteReference w:id="${id}"${cmf}/>`;
|
|
8809
|
+
}
|
|
8810
|
+
if (opts.children) {
|
|
8811
|
+
for (const child of opts.children) if (typeof child === "string") body += `<w:t xml:space="preserve">${escapeXml(child)}</w:t>`;
|
|
8812
|
+
else if (typeof child === "object" && child !== null) {
|
|
8813
|
+
if ("tab" in child) {
|
|
8814
|
+
body += "<w:tab/>";
|
|
8815
|
+
continue;
|
|
8816
|
+
}
|
|
8817
|
+
if ("pageBreak" in child) {
|
|
8818
|
+
body += "<w:br w:type=\"page\"/>";
|
|
8819
|
+
continue;
|
|
8820
|
+
}
|
|
8821
|
+
if ("columnBreak" in child) {
|
|
8822
|
+
body += "<w:br w:type=\"column\"/>";
|
|
8823
|
+
continue;
|
|
8824
|
+
}
|
|
8825
|
+
if ("break" in child) {
|
|
8826
|
+
body += breakXml(child.break);
|
|
8827
|
+
continue;
|
|
8828
|
+
}
|
|
8829
|
+
if ("commentReference" in child) {
|
|
8830
|
+
body += `<w:commentReference w:id="${Number(child.commentReference)}"/>`;
|
|
8831
|
+
continue;
|
|
8832
|
+
}
|
|
8833
|
+
if ("symbolRun" in child) {
|
|
8834
|
+
const sym = child.symbolRun;
|
|
8835
|
+
body += `${stringifyRunProperties(sym) ?? ""}${stringifySymbolRunInner(sym)}`;
|
|
8836
|
+
continue;
|
|
8837
|
+
}
|
|
8838
|
+
const bareFnRef = child.footnoteReference;
|
|
8839
|
+
if (bareFnRef !== void 0) {
|
|
8840
|
+
const id = typeof bareFnRef === "number" ? bareFnRef : bareFnRef.id;
|
|
8841
|
+
const cmf = typeof bareFnRef === "object" && bareFnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8842
|
+
body += `<w:footnoteReference w:id="${id}"${cmf}/>`;
|
|
8843
|
+
continue;
|
|
8844
|
+
}
|
|
8845
|
+
const bareEnRef = child.endnoteReference;
|
|
8846
|
+
if (bareEnRef !== void 0) {
|
|
8847
|
+
const id = typeof bareEnRef === "number" ? bareEnRef : bareEnRef.id;
|
|
8848
|
+
const cmf = typeof bareEnRef === "object" && bareEnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8849
|
+
body += `<w:endnoteReference w:id="${id}"${cmf}/>`;
|
|
8850
|
+
continue;
|
|
8851
|
+
}
|
|
8852
|
+
let firstKey;
|
|
8853
|
+
for (const key in child) {
|
|
8854
|
+
firstKey = key;
|
|
8855
|
+
break;
|
|
8856
|
+
}
|
|
8857
|
+
const emptyXml = firstKey !== void 0 ? EMPTY_RUN_ELEMENTS[firstKey] : void 0;
|
|
8858
|
+
if (emptyXml) {
|
|
8859
|
+
body += emptyXml;
|
|
8860
|
+
continue;
|
|
8861
|
+
}
|
|
8862
|
+
if ("ruby" in child) {
|
|
8863
|
+
body += stringifyRuby(child.ruby, ctx);
|
|
8864
|
+
continue;
|
|
8865
|
+
}
|
|
8866
|
+
if ("object" in child) {
|
|
8867
|
+
body += objectDesc.stringify(child.object, ctx) ?? "";
|
|
8868
|
+
continue;
|
|
8869
|
+
}
|
|
8870
|
+
if ("pict" in child) {
|
|
8871
|
+
body += stringifyPict(child.pict, ctx);
|
|
8872
|
+
continue;
|
|
8873
|
+
}
|
|
8874
|
+
const jsonResult = stringifyChildDispatch(child, ctx);
|
|
8875
|
+
if (jsonResult !== void 0) body += Array.isArray(jsonResult) ? jsonResult.join("") : jsonResult;
|
|
8876
|
+
else if ("text" in child || "children" in child || "break" in child) body += stringifyRunInline(child, ctx);
|
|
8877
|
+
}
|
|
8878
|
+
} else if (opts.text !== void 0) body += `<w:t xml:space="preserve">${escapeXml(String(opts.text))}</w:t>`;
|
|
8879
|
+
let attr = "";
|
|
8880
|
+
if (opts.additionRsid) attr += ` w:rsidR="${opts.additionRsid}"`;
|
|
8881
|
+
if (opts.runPropertiesRsid) attr += ` w:rsidRPr="${opts.runPropertiesRsid}"`;
|
|
8882
|
+
if (opts.deletionRsid) attr += ` w:rsidDel="${opts.deletionRsid}"`;
|
|
8883
|
+
return body.length === 0 ? attr ? `<w:r${attr}/>` : "<w:r/>" : `<w:r${attr}>${body}</w:r>`;
|
|
8884
|
+
}
|
|
8885
|
+
/**
|
|
8886
|
+
* Stringify a ParagraphChild into one or more XML strings.
|
|
8887
|
+
*
|
|
8888
|
+
* Handles side effects (media, chart, smartArt, relationship registration)
|
|
8889
|
+
* directly without creating temporary class instances.
|
|
8890
|
+
*
|
|
8891
|
+
* Returns `undefined` if the child is not a recognized JSON wrapper.
|
|
8892
|
+
*/
|
|
8893
|
+
/**
|
|
8894
|
+
* Build the rPr XML for a break/tab run from its structured run properties.
|
|
8895
|
+
*/
|
|
8896
|
+
/** Shared attribute string for CT_MarkupRange end markers (commentRange, move range end). */
|
|
8897
|
+
function buildMarkupRangeAttrs(m) {
|
|
8898
|
+
const a = [`w:id="${m.id}"`];
|
|
8899
|
+
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
8900
|
+
return a.join(" ");
|
|
8901
|
+
}
|
|
8902
|
+
/** Shared attribute string for w:bookmarkStart (CT_Bookmark). */
|
|
8903
|
+
function buildBookmarkStartAttrs(bs) {
|
|
8904
|
+
const a = [`w:id="${bs.id}"`, `w:name="${escapeXml(bs.name)}"`];
|
|
8905
|
+
if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml="${bs.displacedByCustomXml}"`);
|
|
8906
|
+
if (bs.colFirst !== void 0) a.push(`w:colFirst="${bs.colFirst}"`);
|
|
8907
|
+
if (bs.colLast !== void 0) a.push(`w:colLast="${bs.colLast}"`);
|
|
8908
|
+
return a.join(" ");
|
|
8909
|
+
}
|
|
8910
|
+
/** Shared attribute string for w:moveFromRangeStart / w:moveToRangeStart (CT_MoveBookmark). */
|
|
8911
|
+
function buildMoveRangeStartAttrs(m) {
|
|
8912
|
+
const a = [`w:id="${m.id}"`];
|
|
8913
|
+
if (m.name) a.push(`w:name="${escapeXml(m.name)}"`);
|
|
8914
|
+
if (m.author) a.push(`w:author="${escapeXml(m.author)}"`);
|
|
8915
|
+
if (m.date) a.push(`w:date="${m.date}"`);
|
|
8916
|
+
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
8917
|
+
if (m.colFirst !== void 0) a.push(`w:colFirst="${m.colFirst}"`);
|
|
8918
|
+
if (m.colLast !== void 0) a.push(`w:colLast="${m.colLast}"`);
|
|
8919
|
+
return a.join(" ");
|
|
8920
|
+
}
|
|
8921
|
+
/** Stringify inline run/text content — the `wrap` shared by every sugar child. */
|
|
8922
|
+
function stringifyInlineWrap(wrap, ctx) {
|
|
8923
|
+
const parts = [];
|
|
8924
|
+
for (const item of wrap ?? []) parts.push(typeof item === "string" ? stringifyRunInline({ text: item }, ctx) : stringifyRunInline(item, ctx));
|
|
8925
|
+
return parts.join("");
|
|
8926
|
+
}
|
|
8927
|
+
/**
|
|
8928
|
+
* Serialize a break run inside a track-change wrapper. A parsed break run
|
|
8929
|
+
* keeps its run properties and rsid attributes — the same flat-props shape
|
|
8930
|
+
* the paragraph-level break variants carry.
|
|
8931
|
+
*/
|
|
8932
|
+
function stringifyTrackChangeBreak(opts, type) {
|
|
8933
|
+
const rPr = stringifyRunProperties(opts) ?? "";
|
|
8934
|
+
let attr = "";
|
|
8935
|
+
if (opts.additionRsid) attr += ` w:rsidR="${opts.additionRsid}"`;
|
|
8936
|
+
if (opts.runPropertiesRsid) attr += ` w:rsidRPr="${opts.runPropertiesRsid}"`;
|
|
8775
8937
|
if (opts.deletionRsid) attr += ` w:rsidDel="${opts.deletionRsid}"`;
|
|
8776
8938
|
return `<w:r${attr}>${rPr}<w:br w:type="${type}"/></w:r>`;
|
|
8777
8939
|
}
|
|
@@ -8871,301 +9033,77 @@ function stringifyMoveRangeChild(kind, opts, ctx) {
|
|
|
8871
9033
|
displacedByCustomXml: opts.displacedByCustomXml
|
|
8872
9034
|
});
|
|
8873
9035
|
return `<${startTag} ${rangeStartAttrs}/><${runTag} w:id="${runId}" w:author="${escapeXml(opts.author)}" w:date="${opts.date}">${stringifyInlineWrap(opts.wrap, ctx)}</${runTag}><${endTag} ${endAttrs}/>`;
|
|
8874
|
-
}
|
|
8875
|
-
function runPropertiesXml(child) {
|
|
8876
|
-
return stringifyRunProperties(child) ?? "";
|
|
8877
|
-
}
|
|
8878
|
-
/**
|
|
8879
|
-
* The plain-run shape the dispatch text fast path claims: text set, with none
|
|
8880
|
-
* of the variants that legally coexist with text and have their own dispatch
|
|
8881
|
-
* branch (references, the { text, hyperlink } shorthand). Callers that need
|
|
8882
|
-
* context-specific text spelling (w:delText inside a deletion wrapper) use
|
|
8883
|
-
* this to claim the shape before dispatch does.
|
|
8884
|
-
*/
|
|
8885
|
-
function isPlainTextRun(child) {
|
|
8886
|
-
const run = child;
|
|
8887
|
-
return "text" in child && run.text !== void 0 && run.footnoteReference === void 0 && run.endnoteReference === void 0 && !("commentReference" in child) && !("hyperlink" in child);
|
|
8888
|
-
}
|
|
8889
|
-
function stringifyChildDispatch(child, ctx) {
|
|
8890
|
-
if ("rawXml" in child) return child.rawXml;
|
|
8891
|
-
if (isPlainTextRun(child)) return stringifyRunInline(child, ctx);
|
|
8892
|
-
if ("pageBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="page"/></w:r>`;
|
|
8893
|
-
if ("columnBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="column"/></w:r>`;
|
|
8894
|
-
if ("tab" in child) return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;
|
|
8895
|
-
if ("subDoc" in child) return subDocDesc.stringify(child.subDoc, ctx) ?? "";
|
|
8896
|
-
const fnRefChild = child.footnoteReference;
|
|
8897
|
-
if (fnRefChild !== void 0) {
|
|
8898
|
-
const id = typeof fnRefChild === "number" ? fnRefChild : fnRefChild.id;
|
|
8899
|
-
const cmf = typeof fnRefChild === "object" && fnRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8900
|
-
const props = "properties" in child ? child.properties : void 0;
|
|
8901
|
-
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr>"}<w:footnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
8902
|
-
}
|
|
8903
|
-
const enRefChild = child.endnoteReference;
|
|
8904
|
-
if (enRefChild !== void 0) {
|
|
8905
|
-
const id = typeof enRefChild === "number" ? enRefChild : enRefChild.id;
|
|
8906
|
-
const cmf = typeof enRefChild === "object" && enRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8907
|
-
const props = "properties" in child ? child.properties : void 0;
|
|
8908
|
-
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr>"}<w:endnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
8909
|
-
}
|
|
8910
|
-
if ("comment" in child) return stringifyCommentChild(child.comment, ctx);
|
|
8911
|
-
if ("commentRangeStart" in child) return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;
|
|
8912
|
-
if ("commentRangeEnd" in child) return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;
|
|
8913
|
-
if ("commentReference" in child) return `<w:r>${child.properties ? stringifyRunProperties(child.properties) ?? "" : ""}<w:commentReference w:id="${child.commentReference}"/></w:r>`;
|
|
8914
|
-
if ("bookmarkStart" in child) return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;
|
|
8915
|
-
if ("bookmarkEnd" in child) return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;
|
|
8916
|
-
if ("bookmark" in child) return stringifyBookmarkChild(child.bookmark, ctx);
|
|
8917
|
-
if ("symbolRun" in child) {
|
|
8918
|
-
const opts = child.symbolRun;
|
|
8919
|
-
return `<w:r>${stringifyRunProperties(opts) ?? ""}${stringifySymbolRunInner(opts)}</w:r>`;
|
|
8920
|
-
}
|
|
8921
|
-
if ("object" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${objectDesc.stringify(child.object, ctx)}</w:r>`;
|
|
8922
|
-
if ("pict" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${stringifyPict(child.pict, ctx)}</w:r>`;
|
|
8923
|
-
if ("formField" in child) {
|
|
8924
|
-
const ff = child.formField;
|
|
8925
|
-
let result = "";
|
|
8926
|
-
let instrCode = "";
|
|
8927
|
-
let symbolFont = false;
|
|
8928
|
-
if (ff.checkBox) {
|
|
8929
|
-
result = ff.checkBox.checked ? "☒" : "☐";
|
|
8930
|
-
instrCode = "FORMCHECKBOX";
|
|
8931
|
-
symbolFont = true;
|
|
8932
|
-
} else if (ff.dropDownList) {
|
|
8933
|
-
const idx = ff.dropDownList.result ?? ff.dropDownList.default;
|
|
8934
|
-
result = idx !== void 0 ? ff.dropDownList.entries[idx] ?? "" : "";
|
|
8935
|
-
instrCode = "FORMDROPDOWN";
|
|
8936
|
-
} else if (ff.textInput) {
|
|
8937
|
-
result = ff.textInput.value ?? ff.textInput.default ?? "";
|
|
8938
|
-
instrCode = "FORMTEXT";
|
|
8939
|
-
}
|
|
8940
|
-
const rPr = symbolFont ? "<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>" : "";
|
|
8941
|
-
return `<w:r>${createBegin(false, ff)}</w:r><w:r><w:instrText xml:space="preserve"> ${instrCode} </w:instrText></w:r><w:r>${createSeparate()}</w:r><w:r>${rPr}<w:t xml:space="preserve">${escapeXml(result)}</w:t></w:r><w:r>${createEnd()}</w:r>`;
|
|
8942
|
-
}
|
|
8943
|
-
if ("picture" in child) {
|
|
8944
|
-
const opts = child.picture;
|
|
8945
|
-
if (opts.type !== "svg" && opts.data === void 0 && opts.sourceUrl !== void 0) return wrapDrawingRun(drawingDesc.stringify({
|
|
8946
|
-
mediaData: {
|
|
8947
|
-
type: opts.type,
|
|
8948
|
-
sourceUrl: opts.sourceUrl,
|
|
8949
|
-
transformation: createTransformation(opts.transformation),
|
|
8950
|
-
sourceRectangle: opts.sourceRectangle,
|
|
8951
|
-
nonVisualProperties: opts.nonVisualProperties,
|
|
8952
|
-
useLocalDpi: opts.useLocalDpi,
|
|
8953
|
-
compression: opts.compression
|
|
8954
|
-
},
|
|
8955
|
-
docProperties: opts.altText,
|
|
8956
|
-
floating: opts.floating,
|
|
8957
|
-
outline: opts.outline,
|
|
8958
|
-
fill: opts.fill,
|
|
8959
|
-
effects: opts.effects,
|
|
8960
|
-
scene3d: opts.scene3d,
|
|
8961
|
-
shape3d: opts.shape3d,
|
|
8962
|
-
blipEffects: opts.blipEffects,
|
|
8963
|
-
tile: opts.tile,
|
|
8964
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
8965
|
-
}, ctx), opts);
|
|
8966
|
-
const rawData = toUint8Array(opts.data, { encoding: "base64" });
|
|
8967
|
-
let mediaData;
|
|
8968
|
-
if (opts.type === "svg") {
|
|
8969
|
-
const fallbackData = toUint8Array(opts.fallback.data, { encoding: "base64" });
|
|
8970
|
-
const fallbackType = opts.fallback.type;
|
|
8971
|
-
const fallback = ctx.file.media.addMedia(fallbackData, fallbackType, (fileName) => ({
|
|
8972
|
-
type: fallbackType,
|
|
8973
|
-
...createPictureData(fallbackData, opts.transformation, fileName)
|
|
8974
|
-
}), opts.fallback.fileName);
|
|
8975
|
-
mediaData = ctx.file.media.addMedia(rawData, "svg", (fileName) => ({
|
|
8976
|
-
type: "svg",
|
|
8977
|
-
...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
8978
|
-
useLocalDpi: opts.useLocalDpi,
|
|
8979
|
-
compression: opts.compression,
|
|
8980
|
-
fallback
|
|
8981
|
-
}), opts.fileName);
|
|
8982
|
-
} else {
|
|
8983
|
-
const type = opts.type;
|
|
8984
|
-
mediaData = ctx.file.media.addMedia(rawData, type, (fileName) => ({
|
|
8985
|
-
type,
|
|
8986
|
-
...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
8987
|
-
useLocalDpi: opts.useLocalDpi,
|
|
8988
|
-
compression: opts.compression,
|
|
8989
|
-
sourceUrl: opts.sourceUrl
|
|
8990
|
-
}), opts.fileName);
|
|
8991
|
-
}
|
|
8992
|
-
return wrapDrawingRun(drawingDesc.stringify({
|
|
8993
|
-
mediaData,
|
|
8994
|
-
docProperties: opts.altText,
|
|
8995
|
-
floating: opts.floating,
|
|
8996
|
-
outline: opts.outline,
|
|
8997
|
-
fill: opts.fill,
|
|
8998
|
-
effects: opts.effects,
|
|
8999
|
-
scene3d: opts.scene3d,
|
|
9000
|
-
shape3d: opts.shape3d,
|
|
9001
|
-
blipEffects: opts.blipEffects,
|
|
9002
|
-
tile: opts.tile,
|
|
9003
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9004
|
-
}, ctx), opts);
|
|
9005
|
-
}
|
|
9006
|
-
if ("chart" in child) {
|
|
9007
|
-
const opts = child.chart;
|
|
9008
|
-
const chartKey = `chart_${nextChartId++}`;
|
|
9009
|
-
const mediaData = {
|
|
9010
|
-
chartKey,
|
|
9011
|
-
transformation: createTransformation(opts.transformation),
|
|
9012
|
-
type: "chart"
|
|
9013
|
-
};
|
|
9014
|
-
const { transformation: _t, floating: _f, altText: _a, graphicFrameLocks: _g, runProperties: _r, lastRenderedPageBreak: _l, ...chartSpace } = opts;
|
|
9015
|
-
const chartXml = chartSpaceDesc.stringify(chartSpace, ctx.file);
|
|
9016
|
-
const externalData = chartSpace.externalData;
|
|
9017
|
-
ctx.file.charts.addChart(chartKey, {
|
|
9018
|
-
key: chartKey,
|
|
9019
|
-
chartSpaceXml: chartXml ?? "",
|
|
9020
|
-
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
9021
|
-
relationshipId: externalData.relationshipId,
|
|
9022
|
-
fileName: externalData.fileName,
|
|
9023
|
-
data: externalData.data
|
|
9024
|
-
} } : {},
|
|
9025
|
-
...chartSpace.userShapes ? { userShapes: buildUserShapesData(chartSpace.userShapes) } : {}
|
|
9026
|
-
});
|
|
9027
|
-
return wrapDrawingRun(drawingDesc.stringify({
|
|
9028
|
-
mediaData,
|
|
9029
|
-
docProperties: opts.altText,
|
|
9030
|
-
floating: opts.floating,
|
|
9031
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9032
|
-
}, ctx), opts);
|
|
9033
|
-
}
|
|
9034
|
-
if ("smartArt" in child) {
|
|
9035
|
-
const opts = child.smartArt;
|
|
9036
|
-
const smartArtKey = `smartart_${hashSmartArtData(opts)}`;
|
|
9037
|
-
const mediaData = {
|
|
9038
|
-
smartArtKey,
|
|
9039
|
-
transformation: createTransformation(opts.transformation),
|
|
9040
|
-
type: "smartart"
|
|
9041
|
-
};
|
|
9042
|
-
const layoutId = typeof opts.layout === "object" ? definitionId(opts.layout) : opts.layout ?? "default";
|
|
9043
|
-
const styleId = typeof opts.style === "object" ? definitionId(opts.style) : opts.style ?? "simple1";
|
|
9044
|
-
const colorId = typeof opts.color === "object" ? definitionId(opts.color) : opts.color ?? "accent1_2";
|
|
9045
|
-
const dataModelXml = createDataModel(opts.nodes, layoutId, styleId, colorId);
|
|
9046
|
-
let remappedDataRels = opts.raw?.dataRels;
|
|
9047
|
-
if (opts.raw?.media) {
|
|
9048
|
-
const renames = /* @__PURE__ */ new Map();
|
|
9049
|
-
for (const m of opts.raw.media) {
|
|
9050
|
-
const data = toUint8Array(m.data);
|
|
9051
|
-
const type = imageTypeFromPath(m.fileName);
|
|
9052
|
-
const entry = ctx.file.media.addMedia(data, type, (fileName) => ({
|
|
9053
|
-
type,
|
|
9054
|
-
data,
|
|
9055
|
-
fileName,
|
|
9056
|
-
transformation: {
|
|
9057
|
-
emus: {
|
|
9058
|
-
x: 0,
|
|
9059
|
-
y: 0
|
|
9060
|
-
},
|
|
9061
|
-
pixels: {
|
|
9062
|
-
x: 0,
|
|
9063
|
-
y: 0
|
|
9064
|
-
}
|
|
9065
|
-
}
|
|
9066
|
-
}), m.fileName);
|
|
9067
|
-
if (entry.fileName !== m.fileName) renames.set(m.fileName, entry.fileName);
|
|
9068
|
-
}
|
|
9069
|
-
if (renames.size > 0 && remappedDataRels !== void 0) remappedDataRels = remapDataRelsTargets(remappedDataRels, renames);
|
|
9070
|
-
}
|
|
9071
|
-
ctx.file.smartArts.addSmartArt(smartArtKey, {
|
|
9072
|
-
dataModelXml,
|
|
9073
|
-
key: smartArtKey,
|
|
9074
|
-
layout: opts.layout ?? "default",
|
|
9075
|
-
style: opts.style ?? "simple1",
|
|
9076
|
-
color: opts.color ?? "accent1_2",
|
|
9077
|
-
...opts.raw || remappedDataRels !== void 0 ? { raw: {
|
|
9078
|
-
...opts.raw,
|
|
9079
|
-
dataRels: remappedDataRels
|
|
9080
|
-
} } : {}
|
|
9081
|
-
});
|
|
9082
|
-
return wrapDrawingRun(drawingDesc.stringify({
|
|
9083
|
-
mediaData,
|
|
9084
|
-
docProperties: opts.altText,
|
|
9085
|
-
floating: opts.floating,
|
|
9086
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9087
|
-
}, ctx), {
|
|
9088
|
-
runProperties: opts.runProperties,
|
|
9089
|
-
lastRenderedPageBreak: opts.lastRenderedPageBreak
|
|
9090
|
-
});
|
|
9091
|
-
}
|
|
9092
|
-
if ("wpsShape" in child) {
|
|
9093
|
-
const opts = child.wpsShape;
|
|
9094
|
-
const mediaData = {
|
|
9095
|
-
data: opts,
|
|
9096
|
-
transformation: createTransformation(opts.transformation),
|
|
9097
|
-
type: "wps"
|
|
9098
|
-
};
|
|
9099
|
-
const drawingXml = drawingDesc.stringify({
|
|
9100
|
-
mediaData,
|
|
9101
|
-
docProperties: opts.altText,
|
|
9102
|
-
floating: opts.floating,
|
|
9103
|
-
outline: opts.outline,
|
|
9104
|
-
fill: opts.fill,
|
|
9105
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9106
|
-
}, ctx);
|
|
9107
|
-
registerVmlFallbackMedia(opts, ctx);
|
|
9108
|
-
return wrapDrawingRun(drawingXml, opts);
|
|
9109
|
-
}
|
|
9110
|
-
if ("contentPart" in child) return `<w:r><w:contentPart r:id="${child.contentPart.referenceId}"/></w:r>`;
|
|
9111
|
-
if ("wpgGroup" in child) {
|
|
9112
|
-
const opts = child.wpgGroup;
|
|
9113
|
-
const mediaData = {
|
|
9114
|
-
children: opts.children,
|
|
9115
|
-
transformation: createTransformation(opts.transformation),
|
|
9116
|
-
childOffsetX: opts.childOffsetX,
|
|
9117
|
-
childOffsetY: opts.childOffsetY,
|
|
9118
|
-
childExtentWidth: opts.childExtentWidth,
|
|
9119
|
-
childExtentHeight: opts.childExtentHeight,
|
|
9120
|
-
fill: opts.fill,
|
|
9121
|
-
effects: opts.effects,
|
|
9122
|
-
groupShapeLocks: opts.groupShapeLocks,
|
|
9123
|
-
type: "wpg"
|
|
9124
|
-
};
|
|
9125
|
-
const registerMedia = (children) => {
|
|
9126
|
-
for (const c of children) {
|
|
9127
|
-
if (c.type === "wps") continue;
|
|
9128
|
-
if (c.type === "wpg") {
|
|
9129
|
-
registerMedia(c.children);
|
|
9130
|
-
continue;
|
|
9131
|
-
}
|
|
9132
|
-
if (c.type === "chart") {
|
|
9133
|
-
if (c.chartOptions && !c.chartKey) {
|
|
9134
|
-
c.chartKey = `chart_${nextChartId++}`;
|
|
9135
|
-
const externalData = c.chartOptions.externalData;
|
|
9136
|
-
ctx.file.charts.addChart(c.chartKey, {
|
|
9137
|
-
key: c.chartKey,
|
|
9138
|
-
chartSpaceXml: chartSpaceDesc.stringify(c.chartOptions, ctx.file) ?? "",
|
|
9139
|
-
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
9140
|
-
relationshipId: externalData.relationshipId,
|
|
9141
|
-
fileName: externalData.fileName,
|
|
9142
|
-
data: externalData.data
|
|
9143
|
-
} } : {},
|
|
9144
|
-
...c.chartOptions.userShapes ? { userShapes: buildUserShapesData(c.chartOptions.userShapes) } : {}
|
|
9145
|
-
});
|
|
9146
|
-
}
|
|
9147
|
-
continue;
|
|
9148
|
-
}
|
|
9149
|
-
if (c.type === "contentPart") continue;
|
|
9150
|
-
if (c.type === "svg") {
|
|
9151
|
-
const fb = c.fallback;
|
|
9152
|
-
fb.fileName = ctx.file.media.addMedia(fb.data, fb.type, () => fb, fb.fileName).fileName;
|
|
9153
|
-
c.fileName = ctx.file.media.addMedia(c.data, "svg", () => c, c.fileName).fileName;
|
|
9154
|
-
continue;
|
|
9155
|
-
}
|
|
9156
|
-
c.fileName = ctx.file.media.addMedia(c.data, c.type, () => c, c.fileName).fileName;
|
|
9157
|
-
}
|
|
9158
|
-
};
|
|
9159
|
-
registerMedia(opts.children);
|
|
9160
|
-
const drawingXml = drawingDesc.stringify({
|
|
9161
|
-
mediaData,
|
|
9162
|
-
docProperties: opts.altText,
|
|
9163
|
-
floating: opts.floating,
|
|
9164
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9165
|
-
}, ctx);
|
|
9166
|
-
registerVmlFallbackMedia(opts, ctx);
|
|
9167
|
-
return wrapDrawingRun(drawingXml, opts);
|
|
9036
|
+
}
|
|
9037
|
+
function runPropertiesXml(child) {
|
|
9038
|
+
return stringifyRunProperties(child) ?? "";
|
|
9039
|
+
}
|
|
9040
|
+
/**
|
|
9041
|
+
* The plain-run shape the dispatch text fast path claims: text set, with none
|
|
9042
|
+
* of the variants that legally coexist with text and have their own dispatch
|
|
9043
|
+
* branch (references, the { text, hyperlink } shorthand). Callers that need
|
|
9044
|
+
* context-specific text spelling (w:delText inside a deletion wrapper) use
|
|
9045
|
+
* this to claim the shape before dispatch does.
|
|
9046
|
+
*/
|
|
9047
|
+
function isPlainTextRun(child) {
|
|
9048
|
+
const run = child;
|
|
9049
|
+
return "text" in child && run.text !== void 0 && run.footnoteReference === void 0 && run.endnoteReference === void 0 && !("commentReference" in child) && !("hyperlink" in child);
|
|
9050
|
+
}
|
|
9051
|
+
function stringifyChildDispatch(child, ctx) {
|
|
9052
|
+
if ("rawXml" in child) return child.rawXml;
|
|
9053
|
+
if (isPlainTextRun(child)) return stringifyRunInline(child, ctx);
|
|
9054
|
+
if ("pageBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="page"/></w:r>`;
|
|
9055
|
+
if ("columnBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="column"/></w:r>`;
|
|
9056
|
+
if ("tab" in child) return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;
|
|
9057
|
+
if ("subDoc" in child) return subDocDesc.stringify(child.subDoc, ctx) ?? "";
|
|
9058
|
+
const fnRefChild = child.footnoteReference;
|
|
9059
|
+
if (fnRefChild !== void 0) {
|
|
9060
|
+
const id = typeof fnRefChild === "number" ? fnRefChild : fnRefChild.id;
|
|
9061
|
+
const cmf = typeof fnRefChild === "object" && fnRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
9062
|
+
const props = "properties" in child ? child.properties : void 0;
|
|
9063
|
+
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr>"}<w:footnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
9064
|
+
}
|
|
9065
|
+
const enRefChild = child.endnoteReference;
|
|
9066
|
+
if (enRefChild !== void 0) {
|
|
9067
|
+
const id = typeof enRefChild === "number" ? enRefChild : enRefChild.id;
|
|
9068
|
+
const cmf = typeof enRefChild === "object" && enRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
9069
|
+
const props = "properties" in child ? child.properties : void 0;
|
|
9070
|
+
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr>"}<w:endnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
9071
|
+
}
|
|
9072
|
+
if ("comment" in child) return stringifyCommentChild(child.comment, ctx);
|
|
9073
|
+
if ("commentRangeStart" in child) return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;
|
|
9074
|
+
if ("commentRangeEnd" in child) return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;
|
|
9075
|
+
if ("commentReference" in child) return `<w:r>${child.properties ? stringifyRunProperties(child.properties) ?? "" : ""}<w:commentReference w:id="${child.commentReference}"/></w:r>`;
|
|
9076
|
+
if ("bookmarkStart" in child) return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;
|
|
9077
|
+
if ("bookmarkEnd" in child) return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;
|
|
9078
|
+
if ("bookmark" in child) return stringifyBookmarkChild(child.bookmark, ctx);
|
|
9079
|
+
if ("symbolRun" in child) {
|
|
9080
|
+
const opts = child.symbolRun;
|
|
9081
|
+
return `<w:r>${stringifyRunProperties(opts) ?? ""}${stringifySymbolRunInner(opts)}</w:r>`;
|
|
9082
|
+
}
|
|
9083
|
+
if ("object" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${objectDesc.stringify(child.object, ctx)}</w:r>`;
|
|
9084
|
+
if ("pict" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${stringifyPict(child.pict, ctx)}</w:r>`;
|
|
9085
|
+
if ("formField" in child) {
|
|
9086
|
+
const ff = child.formField;
|
|
9087
|
+
let result = "";
|
|
9088
|
+
let instrCode = "";
|
|
9089
|
+
let symbolFont = false;
|
|
9090
|
+
if (ff.checkBox) {
|
|
9091
|
+
result = ff.checkBox.checked ? "☒" : "☐";
|
|
9092
|
+
instrCode = "FORMCHECKBOX";
|
|
9093
|
+
symbolFont = true;
|
|
9094
|
+
} else if (ff.dropDownList) {
|
|
9095
|
+
const idx = ff.dropDownList.result ?? ff.dropDownList.default;
|
|
9096
|
+
result = idx !== void 0 ? ff.dropDownList.entries[idx] ?? "" : "";
|
|
9097
|
+
instrCode = "FORMDROPDOWN";
|
|
9098
|
+
} else if (ff.textInput) {
|
|
9099
|
+
result = ff.textInput.value ?? ff.textInput.default ?? "";
|
|
9100
|
+
instrCode = "FORMTEXT";
|
|
9101
|
+
}
|
|
9102
|
+
const rPr = symbolFont ? "<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>" : "";
|
|
9103
|
+
return `<w:r>${createBegin(false, ff)}</w:r><w:r><w:instrText xml:space="preserve"> ${instrCode} </w:instrText></w:r><w:r>${createSeparate()}</w:r><w:r>${rPr}<w:t xml:space="preserve">${escapeXml(result)}</w:t></w:r><w:r>${createEnd()}</w:r>`;
|
|
9168
9104
|
}
|
|
9105
|
+
const drawingXml = stringifyDrawingChild(child, ctx);
|
|
9106
|
+
if (drawingXml !== void 0) return drawingXml;
|
|
9169
9107
|
if ("math" in child && typeof child.math === "object" && child.math !== null) {
|
|
9170
9108
|
const mathOpts = child.math;
|
|
9171
9109
|
const children = mathOpts.children ?? [];
|
|
@@ -9199,7 +9137,8 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
9199
9137
|
if (hl.docLocation) attrs.push(`w:docLocation="${escapeXml(hl.docLocation)}"`);
|
|
9200
9138
|
};
|
|
9201
9139
|
if (hl.url) {
|
|
9202
|
-
const
|
|
9140
|
+
const relType = RELATIONSHIP_TYPES.hyperlink;
|
|
9141
|
+
const attrs = [`r:id="${`rId${ctx.viewWrapper.relationships.add(relType, hl.url, TargetModeType.EXTERNAL)}`}"`];
|
|
9203
9142
|
pushHlAttrs(attrs);
|
|
9204
9143
|
return `<w:hyperlink ${attrs.join(" ")}>${body}</w:hyperlink>`;
|
|
9205
9144
|
}
|
|
@@ -9351,59 +9290,6 @@ function serializeDispatchChildren(children, ctx) {
|
|
|
9351
9290
|
}
|
|
9352
9291
|
return body;
|
|
9353
9292
|
}
|
|
9354
|
-
/** Rewrite ../media targets inside verbatim data rels after the media
|
|
9355
|
-
* collection re-allocated pinned names. All renames apply in one pass over
|
|
9356
|
-
* the original text, each match bounded by its closing quote, so a name
|
|
9357
|
-
* that prefixes another cannot collide and chained renames cannot re-hit
|
|
9358
|
-
* an already-rewritten target. Preserves the input form (string stays
|
|
9359
|
-
* string, bytes stay bytes). */
|
|
9360
|
-
function remapDataRelsTargets(rels, renames) {
|
|
9361
|
-
const isText = typeof rels === "string";
|
|
9362
|
-
const text = isText ? rels : new TextDecoder().decode(toUint8Array(rels));
|
|
9363
|
-
let out = "";
|
|
9364
|
-
let last = 0;
|
|
9365
|
-
for (const m of text.matchAll(/\.\.\/media\/([^"']*)["']/g)) {
|
|
9366
|
-
const name = m[1] ?? "";
|
|
9367
|
-
const to = renames.get(name);
|
|
9368
|
-
if (to === void 0) continue;
|
|
9369
|
-
const start = (m.index ?? 0) + 9;
|
|
9370
|
-
out += text.slice(last, start) + to;
|
|
9371
|
-
last = start + name.length;
|
|
9372
|
-
}
|
|
9373
|
-
out += text.slice(last);
|
|
9374
|
-
return isText ? out : new TextEncoder().encode(out);
|
|
9375
|
-
}
|
|
9376
|
-
/** Content fingerprint of the raw source parts: every field participates so
|
|
9377
|
-
* two instances that differ in any raw part (or in their companion rels or
|
|
9378
|
-
* media names) never merge into one diagram part set. */
|
|
9379
|
-
function rawSmartArtFingerprint(raw) {
|
|
9380
|
-
if (!raw) return void 0;
|
|
9381
|
-
const b64 = (v) => v === void 0 ? void 0 : encodeBase64(toUint8Array(v));
|
|
9382
|
-
return JSON.stringify({
|
|
9383
|
-
data: b64(raw.data),
|
|
9384
|
-
layout: b64(raw.layout),
|
|
9385
|
-
style: b64(raw.style),
|
|
9386
|
-
color: b64(raw.color),
|
|
9387
|
-
dataRels: b64(raw.dataRels),
|
|
9388
|
-
media: raw.media?.map((m) => m.fileName)
|
|
9389
|
-
});
|
|
9390
|
-
}
|
|
9391
|
-
/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */
|
|
9392
|
-
function hashSmartArtData(options) {
|
|
9393
|
-
const data = JSON.stringify({
|
|
9394
|
-
nodes: options.nodes,
|
|
9395
|
-
layout: options.layout,
|
|
9396
|
-
style: options.style,
|
|
9397
|
-
color: options.color,
|
|
9398
|
-
raw: rawSmartArtFingerprint(options.raw)
|
|
9399
|
-
});
|
|
9400
|
-
let hash = 0;
|
|
9401
|
-
for (let i = 0; i < data.length; i++) {
|
|
9402
|
-
const char = data.charCodeAt(i);
|
|
9403
|
-
hash = (hash << 5) - hash + char | 0;
|
|
9404
|
-
}
|
|
9405
|
-
return Math.abs(hash);
|
|
9406
|
-
}
|
|
9407
9293
|
function stringifyParagraphInline(opts, ctx) {
|
|
9408
9294
|
const resolved = typeof opts === "string" ? { text: opts } : opts;
|
|
9409
9295
|
let body = "";
|
|
@@ -11598,11 +11484,14 @@ function headingOverride(options, level) {
|
|
|
11598
11484
|
}
|
|
11599
11485
|
/** Word's default `<w:rPrDefault>` — theme fonts, kern, 11pt, ligatures. Injected
|
|
11600
11486
|
* for fresh documents (no structured docDefaults provided) to mirror Word's
|
|
11601
|
-
* Normal.dotx
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11487
|
+
* Normal.dotx; `language` stands in for Word's editing language (default: an
|
|
11488
|
+
* en-US install writes `<w:lang w:val="en-US"/>`). On round-trip the structured
|
|
11489
|
+
* form is used instead. */
|
|
11490
|
+
const wordDefaultRprDefault = (language) => "<w:rPrDefault><w:rPr><w:rFonts w:asciiTheme=\"minorHAnsi\" w:eastAsiaTheme=\"minorEastAsia\" w:hAnsiTheme=\"minorHAnsi\" w:cstheme=\"minorBidi\"/><w:kern w:val=\"2\"/><w:sz w:val=\"22\"/><w:szCs w:val=\"24\"/>" + languageStr(language ?? { value: "en-US" }) + "<w14:ligatures w14:val=\"standardContextual\"/></w:rPr></w:rPrDefault>";
|
|
11491
|
+
/** Word's default `<w:pPrDefault>` — 8pt after / 1.16 line. widowControl is not
|
|
11492
|
+
* written: ECMA-376 defaults it to on, matching Word's template bytes. Injected
|
|
11493
|
+
* for fresh documents only. */
|
|
11494
|
+
const WORD_DEFAULT_PPR_DEFAULT = "<w:pPrDefault><w:pPr><w:spacing w:after=\"160\" w:line=\"278\" w:lineRule=\"auto\"/></w:pPr></w:pPrDefault>";
|
|
11606
11495
|
/**
|
|
11607
11496
|
* Build `<w:docDefaults>` XML from a structured {@link DocumentDefaultsOptions}.
|
|
11608
11497
|
*
|
|
@@ -11616,13 +11505,13 @@ const WORD_DEFAULT_PPR_DEFAULT = "<w:pPrDefault><w:pPr><w:widowControl/><w:spaci
|
|
|
11616
11505
|
* mirror Word's Normal.dotx; on round-trip we omit the element
|
|
11617
11506
|
* to preserve the source's "this default category is absent".
|
|
11618
11507
|
*/
|
|
11619
|
-
function stringifyDocDefaults(opts, injectDefaults = true) {
|
|
11508
|
+
function stringifyDocDefaults(opts, injectDefaults = true, language) {
|
|
11620
11509
|
const children = [];
|
|
11621
11510
|
if (opts.run) {
|
|
11622
11511
|
const rPr = stringifyRunProperties(opts.run);
|
|
11623
11512
|
children.push(rPr ? `<w:rPrDefault>${rPr}</w:rPrDefault>` : `<w:rPrDefault/>`);
|
|
11624
11513
|
} else if (opts.run === null) children.push(`<w:rPrDefault/>`);
|
|
11625
|
-
else if (injectDefaults) children.push(
|
|
11514
|
+
else if (injectDefaults) children.push(wordDefaultRprDefault(language));
|
|
11626
11515
|
if (opts.paragraph) {
|
|
11627
11516
|
const pPr = stringifyParagraphProperties(opts.paragraph).xml;
|
|
11628
11517
|
children.push(pPr ? `<w:pPrDefault>${pPr}</w:pPrDefault>` : `<w:pPrDefault/>`);
|
|
@@ -11661,7 +11550,7 @@ var DefaultStylesFactory = class {
|
|
|
11661
11550
|
]),
|
|
11662
11551
|
"mc:Ignorable": "w14 w15"
|
|
11663
11552
|
};
|
|
11664
|
-
importedStyles.push(stringifyDocDefaults(options.document ?? {}));
|
|
11553
|
+
importedStyles.push(stringifyDocDefaults(options.document ?? {}, true, options.language));
|
|
11665
11554
|
importedStyles.push("<w:latentStyles w:defLockedState=\"0\" w:defUIPriority=\"99\" w:defSemiHidden=\"0\" w:defUnhideWhenUsed=\"0\" w:defQFormat=\"0\" w:count=\"376\"><w:lsdException w:name=\"Normal\" w:uiPriority=\"0\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 1\" w:uiPriority=\"9\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 2\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 3\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 4\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 5\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 6\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 7\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 8\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"heading 9\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"Default Paragraph Font\" w:semiHidden=\"1\" w:uiPriority=\"1\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"Normal Table\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"No List\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"Subtitle\" w:uiPriority=\"11\" w:qFormat=\"1\"/><w:lsdException w:name=\"Strong\" w:uiPriority=\"22\" w:qFormat=\"1\"/><w:lsdException w:name=\"Emphasis\" w:uiPriority=\"20\" w:qFormat=\"1\"/><w:lsdException w:name=\"Hyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"FollowedHyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/><w:lsdException w:name=\"No Spacing\" w:uiPriority=\"1\" w:qFormat=\"1\"/><w:lsdException w:name=\"Revision\" w:semiHidden=\"1\"/></w:latentStyles>");
|
|
11666
11555
|
paragraphStyles.push({
|
|
11667
11556
|
id: "Normal",
|
|
@@ -11674,7 +11563,7 @@ var DefaultStylesFactory = class {
|
|
|
11674
11563
|
id: "Heading1",
|
|
11675
11564
|
name: "heading 1",
|
|
11676
11565
|
link: "Heading1Char",
|
|
11677
|
-
sz:
|
|
11566
|
+
sz: 24,
|
|
11678
11567
|
before: 480,
|
|
11679
11568
|
after: 80,
|
|
11680
11569
|
outlineLvl: 0
|
|
@@ -11683,7 +11572,7 @@ var DefaultStylesFactory = class {
|
|
|
11683
11572
|
id: "Heading2",
|
|
11684
11573
|
name: "heading 2",
|
|
11685
11574
|
link: "Heading2Char",
|
|
11686
|
-
sz:
|
|
11575
|
+
sz: 20,
|
|
11687
11576
|
before: 160,
|
|
11688
11577
|
after: 80,
|
|
11689
11578
|
outlineLvl: 1
|
|
@@ -11692,7 +11581,7 @@ var DefaultStylesFactory = class {
|
|
|
11692
11581
|
id: "Heading3",
|
|
11693
11582
|
name: "heading 3",
|
|
11694
11583
|
link: "Heading3Char",
|
|
11695
|
-
sz:
|
|
11584
|
+
sz: 16,
|
|
11696
11585
|
before: 160,
|
|
11697
11586
|
after: 80,
|
|
11698
11587
|
outlineLvl: 2
|
|
@@ -11701,7 +11590,7 @@ var DefaultStylesFactory = class {
|
|
|
11701
11590
|
id: "Heading4",
|
|
11702
11591
|
name: "heading 4",
|
|
11703
11592
|
link: "Heading4Char",
|
|
11704
|
-
sz:
|
|
11593
|
+
sz: 14,
|
|
11705
11594
|
before: 80,
|
|
11706
11595
|
after: 40,
|
|
11707
11596
|
outlineLvl: 3
|
|
@@ -11710,7 +11599,7 @@ var DefaultStylesFactory = class {
|
|
|
11710
11599
|
id: "Heading5",
|
|
11711
11600
|
name: "heading 5",
|
|
11712
11601
|
link: "Heading5Char",
|
|
11713
|
-
sz:
|
|
11602
|
+
sz: 12,
|
|
11714
11603
|
before: 80,
|
|
11715
11604
|
after: 40,
|
|
11716
11605
|
outlineLvl: 4
|
|
@@ -11802,9 +11691,8 @@ var DefaultStylesFactory = class {
|
|
|
11802
11691
|
}
|
|
11803
11692
|
};
|
|
11804
11693
|
if (h.sz) {
|
|
11805
|
-
|
|
11806
|
-
runProps.
|
|
11807
|
-
runProps.sizeComplexScript = sizePt;
|
|
11694
|
+
runProps.size = h.sz;
|
|
11695
|
+
runProps.sizeComplexScript = h.sz;
|
|
11808
11696
|
}
|
|
11809
11697
|
if (outlineLvl >= 5) {
|
|
11810
11698
|
runProps.bold = true;
|
|
@@ -12191,7 +12079,7 @@ var DefaultStylesFactory = class {
|
|
|
12191
12079
|
line: 240,
|
|
12192
12080
|
lineRule: "auto"
|
|
12193
12081
|
} },
|
|
12194
|
-
run: { size:
|
|
12082
|
+
run: { size: 10 },
|
|
12195
12083
|
...options.footnoteText
|
|
12196
12084
|
});
|
|
12197
12085
|
characterStyles.push({
|
|
@@ -12200,7 +12088,7 @@ var DefaultStylesFactory = class {
|
|
|
12200
12088
|
basedOn: "DefaultParagraphFont",
|
|
12201
12089
|
link: "FootnoteText",
|
|
12202
12090
|
semiHidden: true,
|
|
12203
|
-
run: { size:
|
|
12091
|
+
run: { size: 10 },
|
|
12204
12092
|
...options.footnoteTextChar
|
|
12205
12093
|
});
|
|
12206
12094
|
characterStyles.push({
|
|
@@ -12225,7 +12113,7 @@ var DefaultStylesFactory = class {
|
|
|
12225
12113
|
line: 240,
|
|
12226
12114
|
lineRule: "auto"
|
|
12227
12115
|
} },
|
|
12228
|
-
run: { size:
|
|
12116
|
+
run: { size: 10 },
|
|
12229
12117
|
...options.endnoteText
|
|
12230
12118
|
});
|
|
12231
12119
|
characterStyles.push({
|
|
@@ -12234,7 +12122,7 @@ var DefaultStylesFactory = class {
|
|
|
12234
12122
|
basedOn: "DefaultParagraphFont",
|
|
12235
12123
|
link: "EndnoteText",
|
|
12236
12124
|
semiHidden: true,
|
|
12237
|
-
run: { size:
|
|
12125
|
+
run: { size: 10 },
|
|
12238
12126
|
...options.endnoteTextChar
|
|
12239
12127
|
});
|
|
12240
12128
|
characterStyles.push({
|
|
@@ -13227,71 +13115,7 @@ const FRESH_COMPATIBILITY = {
|
|
|
13227
13115
|
};
|
|
13228
13116
|
function stringifyCompatibility(opts) {
|
|
13229
13117
|
const p = [];
|
|
13230
|
-
if (opts
|
|
13231
|
-
if (opts.wordPerfectJustification) p.push(onOff("w:wpJustification", true));
|
|
13232
|
-
if (opts.noTabStopForHangingIndent) p.push(onOff("w:noTabHangInd", true));
|
|
13233
|
-
if (opts.noLeading) p.push(onOff("w:noLeading", true));
|
|
13234
|
-
if (opts.spaceForUnderline) p.push(onOff("w:spaceForUL", true));
|
|
13235
|
-
if (opts.noColumnBalance) p.push(onOff("w:noColumnBalance", true));
|
|
13236
|
-
if (opts.balanceSingleByteDoubleByteWidth) p.push(onOff("w:balanceSingleByteDoubleByteWidth", true));
|
|
13237
|
-
if (opts.noExtraLineSpacing) p.push(onOff("w:noExtraLineSpacing", true));
|
|
13238
|
-
if (opts.doNotLeaveBackslashAlone) p.push(onOff("w:doNotLeaveBackslashAlone", true));
|
|
13239
|
-
if (opts.underlineTrailingSpaces) p.push(onOff("w:ulTrailSpace", true));
|
|
13240
|
-
if (opts.doNotExpandShiftReturn) p.push(onOff("w:doNotExpandShiftReturn", true));
|
|
13241
|
-
if (opts.spacingInWholePoints) p.push(onOff("w:spacingInWholePoints", true));
|
|
13242
|
-
if (opts.lineWrapLikeWord6) p.push(onOff("w:lineWrapLikeWord6", true));
|
|
13243
|
-
if (opts.printBodyTextBeforeHeader) p.push(onOff("w:printBodyTextBeforeHeader", true));
|
|
13244
|
-
if (opts.printColorsBlack) p.push(onOff("w:printColBlack", true));
|
|
13245
|
-
if (opts.spaceWidth) p.push(onOff("w:wpSpaceWidth", true));
|
|
13246
|
-
if (opts.showBreaksInFrames) p.push(onOff("w:showBreaksInFrames", true));
|
|
13247
|
-
if (opts.subFontBySize) p.push(onOff("w:subFontBySize", true));
|
|
13248
|
-
if (opts.suppressBottomSpacing) p.push(onOff("w:suppressBottomSpacing", true));
|
|
13249
|
-
if (opts.suppressTopSpacing) p.push(onOff("w:suppressTopSpacing", true));
|
|
13250
|
-
if (opts.suppressSpacingAtTopOfPage) p.push(onOff("w:suppressSpacingAtTopOfPage", true));
|
|
13251
|
-
if (opts.suppressTopSpacingWP) p.push(onOff("w:suppressTopSpacingWP", true));
|
|
13252
|
-
if (opts.suppressSpBfAfterPgBrk) p.push(onOff("w:suppressSpBfAfterPgBrk", true));
|
|
13253
|
-
if (opts.swapBordersFacingPages) p.push(onOff("w:swapBordersFacingPages", true));
|
|
13254
|
-
if (opts.convertMailMergeEsc) p.push(onOff("w:convMailMergeEsc", true));
|
|
13255
|
-
if (opts.truncateFontHeightsLikeWP6) p.push(onOff("w:truncateFontHeightsLikeWP6", true));
|
|
13256
|
-
if (opts.macWordSmallCaps) p.push(onOff("w:mwSmallCaps", true));
|
|
13257
|
-
if (opts.usePrinterMetrics) p.push(onOff("w:usePrinterMetrics", true));
|
|
13258
|
-
if (opts.doNotSuppressParagraphBorders) p.push(onOff("w:doNotSuppressParagraphBorders", true));
|
|
13259
|
-
if (opts.wrapTrailSpaces) p.push(onOff("w:wrapTrailSpaces", true));
|
|
13260
|
-
if (opts.footnoteLayoutLikeWW8) p.push(onOff("w:footnoteLayoutLikeWW8", true));
|
|
13261
|
-
if (opts.shapeLayoutLikeWW8) p.push(onOff("w:shapeLayoutLikeWW8", true));
|
|
13262
|
-
if (opts.alignTablesRowByRow) p.push(onOff("w:alignTablesRowByRow", true));
|
|
13263
|
-
if (opts.forgetLastTabAlignment) p.push(onOff("w:forgetLastTabAlignment", true));
|
|
13264
|
-
if (opts.adjustLineHeightInTable) p.push(onOff("w:adjustLineHeightInTable", true));
|
|
13265
|
-
if (opts.autoSpaceLikeWord95) p.push(onOff("w:autoSpaceLikeWord95", true));
|
|
13266
|
-
if (opts.noSpaceRaiseLower) p.push(onOff("w:noSpaceRaiseLower", true));
|
|
13267
|
-
if (opts.doNotUseHTMLParagraphAutoSpacing) p.push(onOff("w:doNotUseHTMLParagraphAutoSpacing", true));
|
|
13268
|
-
if (opts.layoutRawTableWidth) p.push(onOff("w:layoutRawTableWidth", true));
|
|
13269
|
-
if (opts.layoutTableRowsApart) p.push(onOff("w:layoutTableRowsApart", true));
|
|
13270
|
-
if (opts.useWord97LineBreakRules) p.push(onOff("w:useWord97LineBreakRules", true));
|
|
13271
|
-
if (opts.doNotBreakWrappedTables) p.push(onOff("w:doNotBreakWrappedTables", true));
|
|
13272
|
-
if (opts.doNotSnapToGridInCell) p.push(onOff("w:doNotSnapToGridInCell", true));
|
|
13273
|
-
if (opts.selectFieldWithFirstOrLastCharacter) p.push(onOff("w:selectFldWithFirstOrLastChar", true));
|
|
13274
|
-
if (opts.applyBreakingRules) p.push(onOff("w:applyBreakingRules", true));
|
|
13275
|
-
if (opts.doNotWrapTextWithPunctuation) p.push(onOff("w:doNotWrapTextWithPunct", true));
|
|
13276
|
-
if (opts.doNotUseEastAsianBreakRules) p.push(onOff("w:doNotUseEastAsianBreakRules", true));
|
|
13277
|
-
if (opts.useWord2002TableStyleRules) p.push(onOff("w:useWord2002TableStyleRules", true));
|
|
13278
|
-
if (opts.growAutofit) p.push(onOff("w:growAutofit", true));
|
|
13279
|
-
if (opts.useFELayout) p.push(onOff("w:useFELayout", true));
|
|
13280
|
-
if (opts.useNormalStyleForList) p.push(onOff("w:useNormalStyleForList", true));
|
|
13281
|
-
if (opts.doNotUseIndentAsNumberingTabStop) p.push(onOff("w:doNotUseIndentAsNumberingTabStop", true));
|
|
13282
|
-
if (opts.useAlternateEastAsianLineBreakRules) p.push(onOff("w:useAltKinsokuLineBreakRules", true));
|
|
13283
|
-
if (opts.allowSpaceOfSameStyleInTable) p.push(onOff("w:allowSpaceOfSameStyleInTable", true));
|
|
13284
|
-
if (opts.doNotSuppressIndentation) p.push(onOff("w:doNotSuppressIndentation", true));
|
|
13285
|
-
if (opts.doNotAutofitConstrainedTables) p.push(onOff("w:doNotAutofitConstrainedTables", true));
|
|
13286
|
-
if (opts.autofitToFirstFixedWidthCell) p.push(onOff("w:autofitToFirstFixedWidthCell", true));
|
|
13287
|
-
if (opts.underlineTabInNumberingList) p.push(onOff("w:underlineTabInNumList", true));
|
|
13288
|
-
if (opts.displayHangulFixedWidth) p.push(onOff("w:displayHangulFixedWidth", true));
|
|
13289
|
-
if (opts.splitPgBreakAndParaMark) p.push(onOff("w:splitPgBreakAndParaMark", true));
|
|
13290
|
-
if (opts.doNotVerticallyAlignCellWithSp) p.push(onOff("w:doNotVertAlignCellWithSp", true));
|
|
13291
|
-
if (opts.doNotBreakConstrainedForcedTable) p.push(onOff("w:doNotBreakConstrainedForcedTable", true));
|
|
13292
|
-
if (opts.ignoreVerticalAlignmentInTextboxes) p.push(onOff("w:doNotVertAlignInTxbx", true));
|
|
13293
|
-
if (opts.useAnsiKerningPairs) p.push(onOff("w:useAnsiKerningPairs", true));
|
|
13294
|
-
if (opts.cachedColumnBalance) p.push(onOff("w:cachedColBalance", true));
|
|
13118
|
+
for (const [key, tag] of COMPAT_FLAG_MAP) if (opts[key]) p.push(onOff(tag, true));
|
|
13295
13119
|
if (opts.enableOpenTypeKerning) p.push("<w14:enableOpenTypeKerning/>");
|
|
13296
13120
|
if (opts.version) p.push(compatSetting("compatibilityMode", opts.version));
|
|
13297
13121
|
if (opts.overrideTableStyleFontSizeAndJustification) p.push(compatSetting("overrideTableStyleFontSizeAndJustification", 1));
|
|
@@ -14325,8 +14149,8 @@ var DocxWriteContext = class {
|
|
|
14325
14149
|
this.fontTable = new FontWrapper(options.fonts ?? []);
|
|
14326
14150
|
this.glossaryOptions = options.glossary;
|
|
14327
14151
|
this.webSettings = options.webSettings ?? void 0;
|
|
14328
|
-
if (options.glossary) this.registerDocumentRel(
|
|
14329
|
-
if (this.webSettings) this.registerDocumentRel(
|
|
14152
|
+
if (options.glossary) this.registerDocumentRel(RELATIONSHIP_TYPES.glossaryDocument, "glossary/document.xml");
|
|
14153
|
+
if (this.webSettings) this.registerDocumentRel(RELATIONSHIP_TYPES.webSettings, "webSettings.xml");
|
|
14330
14154
|
}
|
|
14331
14155
|
get headers() {
|
|
14332
14156
|
return this._headers;
|
|
@@ -14378,12 +14202,12 @@ var DocxWriteContext = class {
|
|
|
14378
14202
|
addHeaderToDocument(header, partName) {
|
|
14379
14203
|
this._headers.push(header);
|
|
14380
14204
|
header.partName = this.nextPartName(this._headers, partName, "header");
|
|
14381
|
-
this.document.relationships.addRelationship(header.referenceId,
|
|
14205
|
+
this.document.relationships.addRelationship(header.referenceId, RELATIONSHIP_TYPES.header, header.partName);
|
|
14382
14206
|
}
|
|
14383
14207
|
addFooterToDocument(footer, partName) {
|
|
14384
14208
|
this._footers.push(footer);
|
|
14385
14209
|
footer.partName = this.nextPartName(this._footers, partName, "footer");
|
|
14386
|
-
this.document.relationships.addRelationship(footer.referenceId,
|
|
14210
|
+
this.document.relationships.addRelationship(footer.referenceId, RELATIONSHIP_TYPES.footer, footer.partName);
|
|
14387
14211
|
}
|
|
14388
14212
|
/** Resolve the part file name: the round-tripped source name when given,
|
|
14389
14213
|
* else the next free <kind>N.xml slot (pinned names never collide). */
|
|
@@ -14399,17 +14223,17 @@ var DocxWriteContext = class {
|
|
|
14399
14223
|
return name;
|
|
14400
14224
|
}
|
|
14401
14225
|
addDefaultRelationships() {
|
|
14402
|
-
this.registerDocumentRel(
|
|
14403
|
-
if (this._hasNumbering) this.registerDocumentRel(
|
|
14404
|
-
if (this._hasFootnotes) this.registerDocumentRel(
|
|
14405
|
-
if (this._hasEndnotes) this.registerDocumentRel(
|
|
14406
|
-
this.registerDocumentRel(
|
|
14407
|
-
if (this._options.comments?.length || this._hasCommentSugar) this.registerDocumentRel(
|
|
14408
|
-
if (this._options.people?.length) this.registerDocumentRel(
|
|
14409
|
-
if (this._options.commentsExtended?.length) this.registerDocumentRel(
|
|
14410
|
-
if (this._options.bibliography) this.registerDocumentRel(
|
|
14226
|
+
this.registerDocumentRel(RELATIONSHIP_TYPES.styles, "styles.xml");
|
|
14227
|
+
if (this._hasNumbering) this.registerDocumentRel(RELATIONSHIP_TYPES.numbering, "numbering.xml");
|
|
14228
|
+
if (this._hasFootnotes) this.registerDocumentRel(RELATIONSHIP_TYPES.footnotes, "footnotes.xml");
|
|
14229
|
+
if (this._hasEndnotes) this.registerDocumentRel(RELATIONSHIP_TYPES.endnotes, "endnotes.xml");
|
|
14230
|
+
this.registerDocumentRel(RELATIONSHIP_TYPES.settings, "settings.xml");
|
|
14231
|
+
if (this._options.comments?.length || this._hasCommentSugar) this.registerDocumentRel(RELATIONSHIP_TYPES.comments, "comments.xml");
|
|
14232
|
+
if (this._options.people?.length) this.registerDocumentRel(RELATIONSHIP_TYPES.peopleMs, "people.xml");
|
|
14233
|
+
if (this._options.commentsExtended?.length) this.registerDocumentRel(RELATIONSHIP_TYPES.commentsExtendedMs, "commentsExtended.xml");
|
|
14234
|
+
if (this._options.bibliography) this.registerDocumentRel(RELATIONSHIP_TYPES.bibliography, "bibliography.xml");
|
|
14411
14235
|
const themeRel = (this._options.passthroughRelationships ?? []).find((r) => r.source === "word/document.xml" && r.relationshipType.endsWith("/theme"));
|
|
14412
|
-
this.registerDocumentRel(
|
|
14236
|
+
this.registerDocumentRel(RELATIONSHIP_TYPES.theme, themeRel ? themeRel.target : "theme/theme1.xml");
|
|
14413
14237
|
}
|
|
14414
14238
|
/**
|
|
14415
14239
|
* Register a default document relationship. On round-trip, reuse the source
|
|
@@ -16492,9 +16316,9 @@ const VerticalAlignSection = {
|
|
|
16492
16316
|
//#region src/patch/from-docx.ts
|
|
16493
16317
|
/** Reusable TextEncoder (stateless, safe to share). */
|
|
16494
16318
|
const encoder$1 = new TextEncoder();
|
|
16495
|
-
const COMMENTS_REL_TYPE =
|
|
16319
|
+
const COMMENTS_REL_TYPE = RELATIONSHIP_TYPES.comments;
|
|
16496
16320
|
const COMMENTS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml";
|
|
16497
|
-
const HYPERLINK_REL_TYPE =
|
|
16321
|
+
const HYPERLINK_REL_TYPE = RELATIONSHIP_TYPES.hyperlink;
|
|
16498
16322
|
/**
|
|
16499
16323
|
* Rendered hyperlink ids start here so they can never collide with the real
|
|
16500
16324
|
* rIdN ids of the part's relationships — including the media entries the
|
|
@@ -16829,7 +16653,7 @@ const patchDocument = async ({ outputType, data, placeholders, findReplace, core
|
|
|
16829
16653
|
map.set(key, JSON.parse(newJson));
|
|
16830
16654
|
for (const [i, media] of mediaDatas.entries()) {
|
|
16831
16655
|
const { fileName } = media;
|
|
16832
|
-
appendRelationship(relationshipsJson, index + i,
|
|
16656
|
+
appendRelationship(relationshipsJson, index + i, RELATIONSHIP_TYPES.image, `media/${fileName}`);
|
|
16833
16657
|
}
|
|
16834
16658
|
}
|
|
16835
16659
|
const hyperlinksByPart = /* @__PURE__ */ new Map();
|
|
@@ -18727,20 +18551,273 @@ const guidSize = 32;
|
|
|
18727
18551
|
* const obfuscatedData = obfuscate(fontData, fontKey);
|
|
18728
18552
|
* ```
|
|
18729
18553
|
*
|
|
18730
|
-
* @internal
|
|
18554
|
+
* @internal
|
|
18555
|
+
*/
|
|
18556
|
+
const obfuscate = (buf, fontKey) => {
|
|
18557
|
+
const guid = fontKey.replace(/-/g, "");
|
|
18558
|
+
if (guid.length !== guidSize) throw new Error(`Error: Cannot extract GUID from font filename: ${fontKey}`);
|
|
18559
|
+
const hexNumbers = guid.replace(/(..)/g, "$1 ").trim().split(" ").map((hexString) => parseInt(hexString, 16));
|
|
18560
|
+
hexNumbers.reverse();
|
|
18561
|
+
const obfuscatedBytes = buf.slice(obfuscatedStartOffset, obfuscatedEndOffset).map((byte, i) => byte ^ hexNumbers[i % hexNumbers.length]);
|
|
18562
|
+
const out = new Uint8Array(obfuscatedStartOffset + obfuscatedBytes.length + Math.max(0, buf.length - obfuscatedEndOffset));
|
|
18563
|
+
out.set(buf.slice(0, obfuscatedStartOffset));
|
|
18564
|
+
out.set(obfuscatedBytes, obfuscatedStartOffset);
|
|
18565
|
+
out.set(buf.slice(obfuscatedEndOffset), obfuscatedStartOffset + obfuscatedBytes.length);
|
|
18566
|
+
return out;
|
|
18567
|
+
};
|
|
18568
|
+
//#endregion
|
|
18569
|
+
//#region src/compile/shared.ts
|
|
18570
|
+
/**
|
|
18571
|
+
* Relationship wiring shared by the docx compile phases: the XML declaration,
|
|
18572
|
+
* the OLE/PACKAGE embedding relationship resolution, and the per-part media +
|
|
18573
|
+
* embedding placeholder bridge.
|
|
18574
|
+
*
|
|
18575
|
+
* @module
|
|
18576
|
+
*/
|
|
18577
|
+
/** XML declaration prepended to every OOXML part. */
|
|
18578
|
+
const XML_DECL = OOXML_XML_DECLARATION;
|
|
18579
|
+
/** Relationship type for OLE embedding parts (word|ppt/embeddings/*). */
|
|
18580
|
+
const OLE_OBJECT_RELATIONSHIP = RELATIONSHIP_TYPES.oleObject;
|
|
18581
|
+
/** Relationship type for native-format embedding parts (embedded xlsx/docx). */
|
|
18582
|
+
const PACKAGE_RELATIONSHIP = RELATIONSHIP_TYPES.package;
|
|
18583
|
+
/** Re-emit the relationship type the source used for an embedding part — a
|
|
18584
|
+
* native OPC package (xlsx/docx) stays a package rel, an OLE compound binary
|
|
18585
|
+
* stays an oleObject rel. */
|
|
18586
|
+
const embeddingRelationship = (embeddings, fileName) => embeddings.array.find((e) => e.fileName === fileName)?.relationshipType === "package" ? PACKAGE_RELATIONSHIP : OLE_OBJECT_RELATIONSHIP;
|
|
18587
|
+
/**
|
|
18588
|
+
* Resolve a part's {fileName} media placeholders against the package media
|
|
18589
|
+
* store, then its embedding placeholders chained past the media
|
|
18590
|
+
* relationships (same ordering as the document part — headers/footers and
|
|
18591
|
+
* notes can carry w:object runs of their own).
|
|
18592
|
+
*/
|
|
18593
|
+
function resolvePartMedia(xml, ctx, relCount) {
|
|
18594
|
+
const media = findAndReplaceImagePlaceholders(xml, ctx.media.array, relCount);
|
|
18595
|
+
const embeddingOffset = relCount + media.referenced.length;
|
|
18596
|
+
const embeddings = findAndReplaceImagePlaceholders(media.xml, ctx.embeddings.array, embeddingOffset);
|
|
18597
|
+
return {
|
|
18598
|
+
xml: embeddings.xml,
|
|
18599
|
+
relCount,
|
|
18600
|
+
embeddingOffset,
|
|
18601
|
+
mediaRefs: media.referenced,
|
|
18602
|
+
embeddingRefs: embeddings.referenced
|
|
18603
|
+
};
|
|
18604
|
+
}
|
|
18605
|
+
/** Register the resolved media + embedding relationships on the part's rels. */
|
|
18606
|
+
function registerPartMedia(rels, ctx, resolved) {
|
|
18607
|
+
for (const [i, ref] of resolved.mediaRefs.entries()) rels.addRelationship(resolved.relCount + i, RELATIONSHIP_TYPES.image, `media/${ref.fileName}`);
|
|
18608
|
+
for (const [i, ref] of resolved.embeddingRefs.entries()) rels.addRelationship(resolved.embeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
18609
|
+
}
|
|
18610
|
+
//#endregion
|
|
18611
|
+
//#region src/compile/document.ts
|
|
18612
|
+
/**
|
|
18613
|
+
* Document part compile phase: word/document.xml (chart/SmartArt/numbering
|
|
18614
|
+
* placeholder resolution over the stringified body) and
|
|
18615
|
+
* word/_rels/document.xml.rels.
|
|
18616
|
+
*
|
|
18617
|
+
* The document part is the only one whose media/embedding relationships
|
|
18618
|
+
* re-emit the source rIds on round-trip: the body XML references them
|
|
18619
|
+
* verbatim, so registration goes through sourceRidFor before falling back to
|
|
18620
|
+
* the offset-derived id.
|
|
18621
|
+
*
|
|
18622
|
+
* @module
|
|
18623
|
+
*/
|
|
18624
|
+
/**
|
|
18625
|
+
* Look up the source rId for a document relationship by kind+target. Returns
|
|
18626
|
+
* the numeric id when the source carried the same rel, undefined otherwise.
|
|
18627
|
+
* The body XML's `r:id` references the source rId verbatim on round-trip, so
|
|
18628
|
+
* the structured compiler must emit the rel at that exact id — otherwise
|
|
18629
|
+
* `r:id="rId4"` would point at a different rel and Word refuses to open.
|
|
18630
|
+
*/
|
|
18631
|
+
function sourceRidFor(passthroughRelationships, ownerSource, relationshipType, target) {
|
|
18632
|
+
if (!passthroughRelationships) return void 0;
|
|
18633
|
+
for (const rel of passthroughRelationships) if (rel.source === ownerSource && rel.relationshipType === relationshipType && rel.target === target) {
|
|
18634
|
+
const m = /^rId(\d+)$/.exec(rel.rId);
|
|
18635
|
+
if (m) return Number(m[1]);
|
|
18636
|
+
}
|
|
18637
|
+
}
|
|
18638
|
+
/**
|
|
18639
|
+
* Build a {fileName → rId} map for source rels targeting `media/` or
|
|
18640
|
+
* `embeddings/`. findAndReplaceImagePlaceholders consults this map to
|
|
18641
|
+
* substitute the source rId in body XML (so `<a:blip r:embed="rId5"/>` points
|
|
18642
|
+
* at the rel registered at rId5 — not the rel registered at an
|
|
18643
|
+
* offset-derived id, which dangles against any source body that referenced
|
|
18644
|
+
* the source rId). Placeholder keys use the media-collection fileName; a
|
|
18645
|
+
* dedup-renamed file misses the map and falls through to the offset id on
|
|
18646
|
+
* BOTH the body and the .rels side, keeping them consistent.
|
|
18647
|
+
*/
|
|
18648
|
+
function documentSourceRids(ctx, dir) {
|
|
18649
|
+
const map = /* @__PURE__ */ new Map();
|
|
18650
|
+
const prefix = `${dir}/`;
|
|
18651
|
+
for (const rel of ctx._options.passthroughRelationships ?? []) {
|
|
18652
|
+
if (rel.source !== "word/document.xml") continue;
|
|
18653
|
+
if (!rel.target.startsWith(prefix)) continue;
|
|
18654
|
+
map.set(rel.target.slice(prefix.length), rel.rId);
|
|
18655
|
+
}
|
|
18656
|
+
return map;
|
|
18657
|
+
}
|
|
18658
|
+
/** Resolve the document body's media/embedding placeholders, then emit the
|
|
18659
|
+
* document part and its rels. The rels entry registers media, embeddings,
|
|
18660
|
+
* charts, SmartArt, the font table, and the claimed passthrough rels — in
|
|
18661
|
+
* that order, so the source rId ordering is preserved. */
|
|
18662
|
+
function compileDocumentEntries(ctx, documentXmlData, documentRelationshipCount) {
|
|
18663
|
+
const documentMedia = findAndReplaceImagePlaceholders(documentXmlData, ctx.media.array, documentRelationshipCount, "rId", documentSourceRids(ctx, "media"));
|
|
18664
|
+
const documentEmbeddingOffset = documentRelationshipCount + documentMedia.referenced.length;
|
|
18665
|
+
const documentEmbeddings = findAndReplaceImagePlaceholders(documentMedia.xml, ctx.embeddings.array, documentEmbeddingOffset, "rId", documentSourceRids(ctx, "embeddings"));
|
|
18666
|
+
return {
|
|
18667
|
+
Document: {
|
|
18668
|
+
data: (() => {
|
|
18669
|
+
let xmlData = documentEmbeddings.xml;
|
|
18670
|
+
if (hasPlaceholders(xmlData)) {
|
|
18671
|
+
const mediaCount = documentMedia.referenced.length;
|
|
18672
|
+
const embeddingCount = documentEmbeddings.referenced.length;
|
|
18673
|
+
const chartKeys = ctx.charts.array.map((c) => c.key);
|
|
18674
|
+
const smartArtKeys = ctx.smartArts.array.map((s) => s.key);
|
|
18675
|
+
const chartOffset = documentRelationshipCount + mediaCount + embeddingCount;
|
|
18676
|
+
const smartArtOffset = chartOffset + chartKeys.length;
|
|
18677
|
+
const entries = [];
|
|
18678
|
+
for (const [i, key] of chartKeys.entries()) {
|
|
18679
|
+
const chartTarget = `charts/chart${i + 1}.xml`;
|
|
18680
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.chart, chartTarget);
|
|
18681
|
+
entries.push({
|
|
18682
|
+
prefix: "chart:",
|
|
18683
|
+
key,
|
|
18684
|
+
value: sourceRid !== void 0 ? `rId${sourceRid}` : formatId(chartOffset, i, "rId")
|
|
18685
|
+
});
|
|
18686
|
+
}
|
|
18687
|
+
const saPrefixes = [
|
|
18688
|
+
"smartart:",
|
|
18689
|
+
"smartart-lo:",
|
|
18690
|
+
"smartart-qs:",
|
|
18691
|
+
"smartart-cs:"
|
|
18692
|
+
];
|
|
18693
|
+
for (const [i, key] of smartArtKeys.entries()) for (let p = 0; p < saPrefixes.length; p++) entries.push({
|
|
18694
|
+
prefix: saPrefixes[p],
|
|
18695
|
+
key,
|
|
18696
|
+
value: formatId(smartArtOffset + p * smartArtKeys.length, i, "rId")
|
|
18697
|
+
});
|
|
18698
|
+
for (const { reference, instance, numId } of ctx.numbering.concreteNumbering) entries.push({
|
|
18699
|
+
key: `${reference}-${instance}`,
|
|
18700
|
+
value: numId.toString()
|
|
18701
|
+
});
|
|
18702
|
+
xmlData = replaceAllPlaceholders(xmlData, entries);
|
|
18703
|
+
} else xmlData = replaceNumberingPlaceholders(xmlData, ctx.numbering.concreteNumbering);
|
|
18704
|
+
return xmlData;
|
|
18705
|
+
})(),
|
|
18706
|
+
path: "word/document.xml"
|
|
18707
|
+
},
|
|
18708
|
+
Relationships: {
|
|
18709
|
+
data: (() => {
|
|
18710
|
+
for (const [i, ref] of documentMedia.referenced.entries()) {
|
|
18711
|
+
const target = `media/${ref.fileName}`;
|
|
18712
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.image, target);
|
|
18713
|
+
ctx.document.relationships.addRelationship(sourceRid ?? documentRelationshipCount + i, RELATIONSHIP_TYPES.image, target);
|
|
18714
|
+
}
|
|
18715
|
+
for (const [i, ref] of documentEmbeddings.referenced.entries()) {
|
|
18716
|
+
const target = `embeddings/${ref.fileName}`;
|
|
18717
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
18718
|
+
ctx.document.relationships.addRelationship(sourceRid ?? documentEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
18719
|
+
}
|
|
18720
|
+
const chartOffset = documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length;
|
|
18721
|
+
for (let i = 0; i < ctx.charts.array.length; i++) {
|
|
18722
|
+
const target = `charts/chart${i + 1}.xml`;
|
|
18723
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.chart, target);
|
|
18724
|
+
ctx.document.relationships.addRelationship(sourceRid ?? chartOffset + i, RELATIONSHIP_TYPES.chart, target);
|
|
18725
|
+
}
|
|
18726
|
+
addSmartArtRelationships(ctx.smartArts.array.map((s) => s.key), (id, type, target) => {
|
|
18727
|
+
ctx.document.relationships.addRelationship(id, type, target);
|
|
18728
|
+
}, documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length + ctx.charts.array.length, 0, {
|
|
18729
|
+
pathPrefix: "",
|
|
18730
|
+
styleRelType: RELATIONSHIP_TYPES.diagramQuickStyle,
|
|
18731
|
+
hasDrawing: (key) => ctx.smartArts.array.find((s) => s.key === key)?.raw?.drawing !== void 0
|
|
18732
|
+
});
|
|
18733
|
+
ctx.document.relationships.addRelationship(sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.fontTable, "fontTable.xml") ?? ctx.document.relationships.nextRelationshipId, RELATIONSHIP_TYPES.fontTable, "fontTable.xml");
|
|
18734
|
+
ctx.addPassthroughDocumentRelationships();
|
|
18735
|
+
return XML_DECL + ctx.document.relationships.serialize();
|
|
18736
|
+
})(),
|
|
18737
|
+
path: "word/_rels/document.xml.rels"
|
|
18738
|
+
}
|
|
18739
|
+
};
|
|
18740
|
+
}
|
|
18741
|
+
//#endregion
|
|
18742
|
+
//#region src/compile/drawings.ts
|
|
18743
|
+
/**
|
|
18744
|
+
* Drawing tail compile phase: the chart parts (chartSpace, userShapes, their
|
|
18745
|
+
* rels and embedded workbooks) and the SmartArt diagram part sets
|
|
18746
|
+
* (data/layout/quickStyle/colors plus the Office render-cache drawing), read
|
|
18747
|
+
* off the collections the document body stringification filled.
|
|
18748
|
+
*
|
|
18749
|
+
* @module
|
|
18731
18750
|
*/
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
|
|
18735
|
-
|
|
18736
|
-
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
|
|
18740
|
-
|
|
18741
|
-
|
|
18742
|
-
|
|
18743
|
-
|
|
18751
|
+
/** Chart part → user-shapes part relationship (c:userShapes bridge). */
|
|
18752
|
+
const CHART_USER_SHAPES_REL = RELATIONSHIP_TYPES.chartUserShapes;
|
|
18753
|
+
function compileChartParts(ctx) {
|
|
18754
|
+
if (ctx.charts.array.length === 0) return {};
|
|
18755
|
+
return {
|
|
18756
|
+
Charts: ctx.charts.array.flatMap((chartData, i) => {
|
|
18757
|
+
const parts = [{
|
|
18758
|
+
data: XML_DECL + chartData.chartSpaceXml,
|
|
18759
|
+
path: `word/charts/chart${i + 1}.xml`
|
|
18760
|
+
}];
|
|
18761
|
+
if (chartData.userShapes) parts.push({
|
|
18762
|
+
data: XML_DECL + chartData.userShapes.xml,
|
|
18763
|
+
path: `word/charts/userShapes${i + 1}.xml`
|
|
18764
|
+
});
|
|
18765
|
+
const e = chartData.embedding;
|
|
18766
|
+
const rels = [...e ? [`<Relationship Id="${escapeXml(e.relationshipId)}" Type="${PACKAGE_RELATIONSHIP}" Target="../embeddings/${escapeXml(e.fileName)}"/>`] : [], ...chartData.userShapes ? [`<Relationship Id="${escapeXml(chartData.userShapes.relationshipId)}" Type="${CHART_USER_SHAPES_REL}" Target="userShapes${i + 1}.xml"/>`] : []];
|
|
18767
|
+
if (rels.length > 0) parts.push({
|
|
18768
|
+
data: XML_DECL + `<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${rels.join("")}</Relationships>`,
|
|
18769
|
+
path: `word/charts/_rels/chart${i + 1}.xml.rels`
|
|
18770
|
+
});
|
|
18771
|
+
return parts;
|
|
18772
|
+
}),
|
|
18773
|
+
ChartEmbeddings: (() => {
|
|
18774
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18775
|
+
const parts = [];
|
|
18776
|
+
for (const c of ctx.charts.array) {
|
|
18777
|
+
const e = c.embedding;
|
|
18778
|
+
if (!e || seen.has(e.fileName)) continue;
|
|
18779
|
+
seen.add(e.fileName);
|
|
18780
|
+
parts.push({
|
|
18781
|
+
data: toUint8Array(e.data),
|
|
18782
|
+
path: `word/embeddings/${e.fileName}`
|
|
18783
|
+
});
|
|
18784
|
+
}
|
|
18785
|
+
return parts;
|
|
18786
|
+
})()
|
|
18787
|
+
};
|
|
18788
|
+
}
|
|
18789
|
+
function compileSmartArtParts(ctx) {
|
|
18790
|
+
if (ctx.smartArts.array.length === 0) return {};
|
|
18791
|
+
return {
|
|
18792
|
+
DiagramData: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18793
|
+
data: smartArtData.raw?.data !== void 0 ? toUint8Array(smartArtData.raw.data) : XML_DECL + smartArtData.dataModelXml,
|
|
18794
|
+
path: `word/diagrams/data${i + 1}.xml`
|
|
18795
|
+
})),
|
|
18796
|
+
DiagramLayout: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18797
|
+
data: smartArtData.raw?.layout !== void 0 ? toUint8Array(smartArtData.raw.layout) : typeof smartArtData.layout === "string" ? getLayoutXml(smartArtData.layout) : stringifyLayoutDefinitionPart(smartArtData.layout),
|
|
18798
|
+
path: `word/diagrams/layout${i + 1}.xml`
|
|
18799
|
+
})),
|
|
18800
|
+
DiagramStyle: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18801
|
+
data: smartArtData.raw?.style !== void 0 ? toUint8Array(smartArtData.raw.style) : typeof smartArtData.style === "string" ? getStyleXml(smartArtData.style) : stringifyStyleDefinitionPart(smartArtData.style),
|
|
18802
|
+
path: `word/diagrams/quickStyle${i + 1}.xml`
|
|
18803
|
+
})),
|
|
18804
|
+
DiagramColors: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18805
|
+
data: smartArtData.raw?.color !== void 0 ? toUint8Array(smartArtData.raw.color) : typeof smartArtData.color === "string" ? getColorXml(smartArtData.color) : stringifyColorDefinitionPart(smartArtData.color),
|
|
18806
|
+
path: `word/diagrams/colors${i + 1}.xml`
|
|
18807
|
+
})),
|
|
18808
|
+
DiagramDrawing: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18809
|
+
smartArtData,
|
|
18810
|
+
i
|
|
18811
|
+
})).filter(({ smartArtData }) => smartArtData.raw?.drawing !== void 0).map(({ smartArtData, i }) => ({
|
|
18812
|
+
data: toUint8Array(smartArtData.raw.drawing),
|
|
18813
|
+
path: `word/diagrams/drawing${i + 1}.xml`
|
|
18814
|
+
})),
|
|
18815
|
+
...ctx.smartArts.array.some((s) => s.raw?.dataRels !== void 0) ? { SmartArtDataRels: ctx.smartArts.array.flatMap((smartArtData, i) => smartArtData.raw?.dataRels !== void 0 ? [{
|
|
18816
|
+
data: toUint8Array(smartArtData.raw.dataRels),
|
|
18817
|
+
path: `word/diagrams/_rels/data${i + 1}.xml.rels`
|
|
18818
|
+
}] : []) } : {}
|
|
18819
|
+
};
|
|
18820
|
+
}
|
|
18744
18821
|
//#endregion
|
|
18745
18822
|
//#region src/parts/header-footer.ts
|
|
18746
18823
|
/**
|
|
@@ -18820,6 +18897,146 @@ function stringifyHeaderFooter(tag, namespaces, children, ctx) {
|
|
|
18820
18897
|
return body.length === 0 ? `<${tag} ${attrStr}/>` : `<${tag} ${attrStr}>${body}</${tag}>`;
|
|
18821
18898
|
}
|
|
18822
18899
|
//#endregion
|
|
18900
|
+
//#region src/compile/headerfooter.ts
|
|
18901
|
+
/**
|
|
18902
|
+
* Header/footer compile phase: the four mapping arrays (Headers, Footers,
|
|
18903
|
+
* HeaderRelationships, FooterRelationships).
|
|
18904
|
+
*
|
|
18905
|
+
* Headers and footers are structural twins — same stringify → placeholder
|
|
18906
|
+
* resolution → relationship registration pipeline, differing only in element
|
|
18907
|
+
* name, namespaces, and default part name — so one per-part helper serves
|
|
18908
|
+
* both, and each part's body and rels are produced together (no cross-entry
|
|
18909
|
+
* state needed).
|
|
18910
|
+
*
|
|
18911
|
+
* @module
|
|
18912
|
+
*/
|
|
18913
|
+
/** Stringify one header/footer part and wire its media/embedding
|
|
18914
|
+
* relationships. Images get per-part relationship IDs starting at
|
|
18915
|
+
* nextRelationshipId, mirroring the document part; the placeholder pass uses
|
|
18916
|
+
* referenced-local positions, so body r:embed and .rels stay aligned. */
|
|
18917
|
+
function compileHeaderFooterPart(kind, entry, index, ctx, mkCtx) {
|
|
18918
|
+
const partName = entry.partName ?? `${kind}${index + 1}.xml`;
|
|
18919
|
+
const partCtx = mkCtx({
|
|
18920
|
+
relationships: entry.relationships,
|
|
18921
|
+
partName: `word/${partName}`
|
|
18922
|
+
});
|
|
18923
|
+
const xmlData = XML_DECL + stringifyHeaderFooter(kind === "footer" ? "w:ftr" : "w:hdr", kind === "footer" ? FOOTER_NAMESPACES : HEADER_NAMESPACES, entry.children, partCtx);
|
|
18924
|
+
const relCount = entry.relationships.nextRelationshipId;
|
|
18925
|
+
const resolved = resolvePartMedia(xmlData, ctx, relCount);
|
|
18926
|
+
registerPartMedia(entry.relationships, ctx, resolved);
|
|
18927
|
+
return {
|
|
18928
|
+
part: {
|
|
18929
|
+
data: replaceNumberingPlaceholders(resolved.xml, ctx.numbering.concreteNumbering),
|
|
18930
|
+
path: `word/${partName}`
|
|
18931
|
+
},
|
|
18932
|
+
rels: optionalRelsPart(entry.relationships, XML_DECL, `word/_rels/${partName}.rels`)
|
|
18933
|
+
};
|
|
18934
|
+
}
|
|
18935
|
+
function mapParts(entries, kind, ctx, mkCtx) {
|
|
18936
|
+
const parts = [];
|
|
18937
|
+
const rels = [];
|
|
18938
|
+
entries.forEach((entry, index) => {
|
|
18939
|
+
const compiled = compileHeaderFooterPart(kind, entry, index, ctx, mkCtx);
|
|
18940
|
+
parts.push(compiled.part);
|
|
18941
|
+
if (compiled.rels) rels.push(compiled.rels);
|
|
18942
|
+
});
|
|
18943
|
+
return {
|
|
18944
|
+
parts,
|
|
18945
|
+
rels
|
|
18946
|
+
};
|
|
18947
|
+
}
|
|
18948
|
+
function compileHeaderFooterParts(ctx, mkCtx) {
|
|
18949
|
+
const headers = mapParts(ctx.headers, "header", ctx, mkCtx);
|
|
18950
|
+
const footers = mapParts(ctx.footers, "footer", ctx, mkCtx);
|
|
18951
|
+
return {
|
|
18952
|
+
Headers: headers.parts,
|
|
18953
|
+
HeaderRelationships: headers.rels,
|
|
18954
|
+
Footers: footers.parts,
|
|
18955
|
+
FooterRelationships: footers.rels
|
|
18956
|
+
};
|
|
18957
|
+
}
|
|
18958
|
+
//#endregion
|
|
18959
|
+
//#region src/compile/notes.ts
|
|
18960
|
+
/**
|
|
18961
|
+
* Notes compile phase: comments, footnotes, and endnotes parts.
|
|
18962
|
+
*
|
|
18963
|
+
* All three share the same wiring shape — stringify the part, resolve its
|
|
18964
|
+
* {fileName} media and {oleObjectN.bin} embedding placeholders, register the
|
|
18965
|
+
* matching relationships on the part's own rels, and replace numbering
|
|
18966
|
+
* placeholders. Collected here so the three stay symmetric.
|
|
18967
|
+
*
|
|
18968
|
+
* @module
|
|
18969
|
+
*/
|
|
18970
|
+
/**
|
|
18971
|
+
* Comments carried by the document: those the caller listed explicitly
|
|
18972
|
+
* (`options.comments`) plus entries registered by `{ comment }` sugar children
|
|
18973
|
+
* during body stringification. Drives both word/comments.xml generation and the
|
|
18974
|
+
* [Content_Types] comments Override, which must stay in sync (OPC consistency).
|
|
18975
|
+
*/
|
|
18976
|
+
function mergedCommentChildren(ctx) {
|
|
18977
|
+
return [...ctx._options.comments ?? [], ...ctx.comments.entries];
|
|
18978
|
+
}
|
|
18979
|
+
/** The three notes parts, present only when the document carries content for
|
|
18980
|
+
* them (an empty part with a dangling relationship is the OPC violation Word
|
|
18981
|
+
* rejects on open). */
|
|
18982
|
+
function compileNotesParts(ctx, mkCtx) {
|
|
18983
|
+
const result = {};
|
|
18984
|
+
const comments = mergedCommentChildren(ctx);
|
|
18985
|
+
if (comments.length > 0) {
|
|
18986
|
+
const commentCtx = mkCtx({ relationships: ctx.comments.relationships });
|
|
18987
|
+
const commentXmlData = XML_DECL + (commentsDesc.stringify(comments, commentCtx) ?? "");
|
|
18988
|
+
const commentRelCount = ctx.comments.relationships.nextRelationshipId;
|
|
18989
|
+
const resolved = resolvePartMedia(commentXmlData, ctx, commentRelCount);
|
|
18990
|
+
registerPartMedia(ctx.comments.relationships, ctx, resolved);
|
|
18991
|
+
result.Comments = {
|
|
18992
|
+
data: replaceNumberingPlaceholders(resolved.xml, ctx.numbering.concreteNumbering),
|
|
18993
|
+
path: "word/comments.xml"
|
|
18994
|
+
};
|
|
18995
|
+
result.CommentsRelationships = optionalRelsPart(ctx.comments.relationships, XML_DECL, "word/_rels/comments.xml.rels");
|
|
18996
|
+
}
|
|
18997
|
+
const footnoteCtx = mkCtx({ relationships: ctx.footNotes.relationships });
|
|
18998
|
+
const footnoteXmlData = XML_DECL + (footnotesDesc.stringify({
|
|
18999
|
+
notes: ctx.footNotes.notes,
|
|
19000
|
+
separator: ctx.footNotes.separator,
|
|
19001
|
+
continuationSeparator: ctx.footNotes.continuationSeparator,
|
|
19002
|
+
continuationNotice: ctx.footNotes.continuationNotice
|
|
19003
|
+
}, footnoteCtx) ?? "");
|
|
19004
|
+
const footnoteRelCount = ctx.footNotes.relationships.nextRelationshipId;
|
|
19005
|
+
const footnoteResolved = resolvePartMedia(footnoteXmlData, ctx, footnoteRelCount);
|
|
19006
|
+
registerPartMedia(ctx.footNotes.relationships, ctx, footnoteResolved);
|
|
19007
|
+
if (ctx.hasFootnotes) {
|
|
19008
|
+
result.FootNotes = {
|
|
19009
|
+
data: replaceNumberingPlaceholders(footnoteResolved.xml, ctx.numbering.concreteNumbering),
|
|
19010
|
+
path: "word/footnotes.xml"
|
|
19011
|
+
};
|
|
19012
|
+
if (ctx.footNotes.relationships.relationshipCount > 0) result.FootNotesRelationships = {
|
|
19013
|
+
data: XML_DECL + ctx.footNotes.relationships.serialize(),
|
|
19014
|
+
path: "word/_rels/footnotes.xml.rels"
|
|
19015
|
+
};
|
|
19016
|
+
}
|
|
19017
|
+
if (ctx.hasEndnotes) {
|
|
19018
|
+
const endnoteCtx = mkCtx({ relationships: ctx.endnotes.relationships });
|
|
19019
|
+
const endnoteXmlData = XML_DECL + (endnotesDesc.stringify({
|
|
19020
|
+
notes: ctx.endnotes.notes,
|
|
19021
|
+
separator: ctx.endnotes.separator,
|
|
19022
|
+
continuationSeparator: ctx.endnotes.continuationSeparator,
|
|
19023
|
+
continuationNotice: ctx.endnotes.continuationNotice
|
|
19024
|
+
}, endnoteCtx) ?? "");
|
|
19025
|
+
const endnoteRelCount = ctx.endnotes.relationships.nextRelationshipId;
|
|
19026
|
+
const resolved = resolvePartMedia(endnoteXmlData, ctx, endnoteRelCount);
|
|
19027
|
+
registerPartMedia(ctx.endnotes.relationships, ctx, resolved);
|
|
19028
|
+
result.Endnotes = {
|
|
19029
|
+
data: replaceNumberingPlaceholders(resolved.xml, ctx.numbering.concreteNumbering),
|
|
19030
|
+
path: "word/endnotes.xml"
|
|
19031
|
+
};
|
|
19032
|
+
if (ctx.endnotes.relationships.relationshipCount > 0) result.EndnotesRelationships = {
|
|
19033
|
+
data: XML_DECL + ctx.endnotes.relationships.serialize(),
|
|
19034
|
+
path: "word/_rels/endnotes.xml.rels"
|
|
19035
|
+
};
|
|
19036
|
+
}
|
|
19037
|
+
return result;
|
|
19038
|
+
}
|
|
19039
|
+
//#endregion
|
|
18823
19040
|
//#region src/compiler.ts
|
|
18824
19041
|
/**
|
|
18825
19042
|
* DOCX document compiler — pure function entry point.
|
|
@@ -18829,58 +19046,19 @@ function stringifyHeaderFooter(tag, namespaces, children, ctx) {
|
|
|
18829
19046
|
* All XML parts are produced via descriptors or serialize() —
|
|
18830
19047
|
* no Formatter dependency.
|
|
18831
19048
|
*
|
|
19049
|
+
* The part wiring runs in phases owned by the compile/ folder: the document
|
|
19050
|
+
* body and its rels (compile/document), the notes parts (compile/notes),
|
|
19051
|
+
* headers/footers (compile/headerfooter), and the chart/SmartArt tail
|
|
19052
|
+
* (compile/drawings), with the placeholder bridge and embedding rel
|
|
19053
|
+
* resolution they share in compile/shared. This module keeps the
|
|
19054
|
+
* part-mapping orchestration.
|
|
19055
|
+
*
|
|
18832
19056
|
* @module
|
|
18833
19057
|
*/
|
|
18834
19058
|
/** Reusable TextEncoder (stateless, safe to share). */
|
|
18835
19059
|
const encoder = new TextEncoder();
|
|
18836
|
-
/** Relationship type for OLE embedding parts (word|ppt/embeddings/*). */
|
|
18837
|
-
const OLE_OBJECT_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
18838
|
-
/** Relationship type for native-format embedding parts (embedded xlsx/docx). */
|
|
18839
|
-
const PACKAGE_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
18840
|
-
/** Re-emit the relationship type the source used for an embedding part — a
|
|
18841
|
-
* native OPC package (xlsx/docx) stays a package rel, an OLE compound binary
|
|
18842
|
-
* stays an oleObject rel. */
|
|
18843
|
-
const embeddingRelationship = (embeddings, fileName) => embeddings.array.find((e) => e.fileName === fileName)?.relationshipType === "package" ? PACKAGE_RELATIONSHIP : OLE_OBJECT_RELATIONSHIP;
|
|
18844
|
-
/** XML declaration prepended to every OOXML part. */
|
|
18845
|
-
const XML_DECL = OOXML_XML_DECLARATION;
|
|
18846
|
-
/**
|
|
18847
|
-
* Look up the source rId for a document relationship by kind+target. Returns
|
|
18848
|
-
* the numeric id when the source carried the same rel, undefined otherwise.
|
|
18849
|
-
* The body XML's `r:id` references the source rId verbatim on round-trip, so
|
|
18850
|
-
* the structured compiler must emit the rel at that exact id — otherwise
|
|
18851
|
-
* `r:id="rId4"` would point at a different rel and Word refuses to open.
|
|
18852
|
-
*/
|
|
18853
|
-
function sourceRidFor(passthroughRelationships, ownerSource, relationshipType, target) {
|
|
18854
|
-
if (!passthroughRelationships) return void 0;
|
|
18855
|
-
for (const rel of passthroughRelationships) if (rel.source === ownerSource && rel.relationshipType === relationshipType && rel.target === target) {
|
|
18856
|
-
const m = /^rId(\d+)$/.exec(rel.rId);
|
|
18857
|
-
if (m) return Number(m[1]);
|
|
18858
|
-
}
|
|
18859
|
-
}
|
|
18860
|
-
/**
|
|
18861
|
-
* Build a {fileName → rId} map for source rels targeting `media/` or
|
|
18862
|
-
* `embeddings/`. findAndReplaceImagePlaceholders consults this map to
|
|
18863
|
-
* substitute the source rId in body XML (so `<a:blip r:embed="rId5"/>` points
|
|
18864
|
-
* at the rel registered at rId5 — not the rel registered at an
|
|
18865
|
-
* offset-derived id, which dangles against any source body that referenced
|
|
18866
|
-
* the source rId). Placeholder keys use the media-collection fileName; a
|
|
18867
|
-
* dedup-renamed file misses the map and falls through to the offset id on
|
|
18868
|
-
* BOTH the body and the .rels side, keeping them consistent.
|
|
18869
|
-
*/
|
|
18870
|
-
function documentSourceRids(ctx, dir) {
|
|
18871
|
-
const map = /* @__PURE__ */ new Map();
|
|
18872
|
-
const prefix = `${dir}/`;
|
|
18873
|
-
for (const rel of ctx._options.passthroughRelationships ?? []) {
|
|
18874
|
-
if (rel.source !== "word/document.xml") continue;
|
|
18875
|
-
if (!rel.target.startsWith(prefix)) continue;
|
|
18876
|
-
map.set(rel.target.slice(prefix.length), rel.rId);
|
|
18877
|
-
}
|
|
18878
|
-
return map;
|
|
18879
|
-
}
|
|
18880
19060
|
/** DOCX part path → content type, derived from the part registry. */
|
|
18881
19061
|
const DOCX_CONTENT_TYPE_RESOLVER = resolverFromRegistry(DOCX_PARTS);
|
|
18882
|
-
/** Chart part → user-shapes part relationship (c:userShapes bridge). */
|
|
18883
|
-
const CHART_USER_SHAPES_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
|
|
18884
19062
|
/** Extension → MIME for media/font/embedding Default entries. Declared only
|
|
18885
19063
|
* for extensions actually present in the package. */
|
|
18886
19064
|
const DOCX_MEDIA_CONTENT_TYPES = {
|
|
@@ -18901,87 +19079,28 @@ function compileDocument(options, overrides = [], mediaLevel = 0) {
|
|
|
18901
19079
|
const ctx = new DocxWriteContext(options);
|
|
18902
19080
|
const xmlifiedFileMapping = xmlifyContext(ctx);
|
|
18903
19081
|
const files = compileMapping(xmlifiedFileMapping, overrides);
|
|
18904
|
-
|
|
18905
|
-
for (const mediaData of mediaArray) {
|
|
18906
|
-
addBinaryFile(files, `word/media/${mediaData.fileName}`, mediaData.data, mediaLevel);
|
|
18907
|
-
if (mediaData.type === "svg") addBinaryFile(files, `word/media/${mediaData.fallback.fileName}`, mediaData.fallback.data, mediaLevel);
|
|
18908
|
-
}
|
|
18909
|
-
for (const embedding of ctx.embeddings.array) addBinaryFile(files, `word/embeddings/${embedding.fileName}`, embedding.data, mediaLevel);
|
|
19082
|
+
addModelBinaries(files, "word", ctx.media.array, ctx.embeddings.array, mediaLevel);
|
|
18910
19083
|
for (const font of ctx.fontTable.fontOptionsWithKey) {
|
|
18911
19084
|
if (font.data === void 0) continue;
|
|
18912
19085
|
const [nameWithoutExtension] = font.name.split(".");
|
|
18913
19086
|
const filePath = font.odttfPath ?? `word/fonts/${nameWithoutExtension}.odttf`;
|
|
18914
19087
|
files[filePath] = font.rawOdttf ? font.data : obfuscate(font.data, font.fontKey);
|
|
18915
19088
|
}
|
|
18916
|
-
|
|
18917
|
-
for (const part of ctx._options.rawParts ?? []) {
|
|
18918
|
-
if (files[part.path] !== void 0) {
|
|
18919
|
-
passthroughSkipped.add(part.path);
|
|
18920
|
-
continue;
|
|
18921
|
-
}
|
|
18922
|
-
files[part.path] = toUint8Array(part.data);
|
|
18923
|
-
}
|
|
18924
|
-
files["[Content_Types].xml"] = encoder.encode(buildContentTypesData(ctx, files, passthroughSkipped));
|
|
18925
|
-
dropDanglingPassthroughRels(files, ctx._options.passthroughRelationships);
|
|
18926
|
-
return files;
|
|
18927
|
-
}
|
|
18928
|
-
/**
|
|
18929
|
-
* Comments carried by the document: those the caller listed explicitly
|
|
18930
|
-
* (`options.comments`) plus entries registered by `{ comment }` sugar children
|
|
18931
|
-
* during body stringification. Drives both word/comments.xml generation and the
|
|
18932
|
-
* [Content_Types] comments Override, which must stay in sync (OPC consistency).
|
|
18933
|
-
*/
|
|
18934
|
-
function mergedCommentChildren(ctx) {
|
|
18935
|
-
return [...ctx._options.comments ?? [], ...ctx.comments.entries];
|
|
18936
|
-
}
|
|
18937
|
-
/**
|
|
18938
|
-
* Serialize [Content_Types].xml from the part registry, then backfill media/
|
|
18939
|
-
* font/embedding `<Default>` entries from the parts actually written.
|
|
18940
|
-
*
|
|
18941
|
-
* Must run after every part has been stringified (parts call `ctx.addMedia`
|
|
18942
|
-
* during stringify), so call this once `xmlifyContext` has finished — not from
|
|
18943
|
-
* inside its object literal, where ContentTypes would evaluate before the
|
|
18944
|
-
* later-defined header/footer/font parts have registered their media.
|
|
18945
|
-
*/
|
|
18946
|
-
/**
|
|
18947
|
-
* Derive [Content_Types].xml from the parts actually written to the package.
|
|
18948
|
-
*
|
|
18949
|
-
* The file set is the single source of truth: every part the resolver knows
|
|
18950
|
-
* becomes an Override, every other file falls through to an extension Default,
|
|
18951
|
-
* and altChunk/sub-document parts — whose content type is data-driven, not
|
|
18952
|
-
* path-determinable — are injected as explicit overrides.
|
|
18953
|
-
*
|
|
18954
|
-
* Round-trip no longer passes the source [Content_Types] through: the compiler
|
|
18955
|
-
* regenerates every part path (altChunks get a fresh uniqueId), so deriving
|
|
18956
|
-
* from the written files is what keeps declarations and parts in sync.
|
|
18957
|
-
*/
|
|
18958
|
-
function buildContentTypesData(ctx, files, passthroughSkipped) {
|
|
18959
|
-
const overrides = [...ctx.altChunks.array.map((ac) => ({
|
|
18960
|
-
path: `word/${ac.path}`,
|
|
18961
|
-
contentType: ac.contentType ?? "application/xhtml+xml"
|
|
18962
|
-
})), ...ctx.subDocs.array.map((sd) => ({
|
|
18963
|
-
path: `word/${sd.path}`,
|
|
18964
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
18965
|
-
}))];
|
|
18966
|
-
const input = deriveContentTypes(Object.keys(files), {
|
|
19089
|
+
files["[Content_Types].xml"] = encoder.encode(finalizeContentTypes(files, {
|
|
18967
19090
|
resolve: DOCX_CONTENT_TYPE_RESOLVER,
|
|
18968
19091
|
mediaContentTypes: DOCX_MEDIA_CONTENT_TYPES,
|
|
18969
|
-
overrides,
|
|
18970
19092
|
source: ctx._options.contentTypes,
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
18982
|
-
});
|
|
18983
|
-
}
|
|
18984
|
-
return XML_DECL + (contentTypesDesc.stringify(input, ctx) ?? "");
|
|
19093
|
+
rawParts: ctx._options.rawParts,
|
|
19094
|
+
overrides: [...ctx.altChunks.array.map((ac) => ({
|
|
19095
|
+
path: `word/${ac.path}`,
|
|
19096
|
+
contentType: ac.contentType ?? "application/xhtml+xml"
|
|
19097
|
+
})), ...ctx.subDocs.array.map((sd) => ({
|
|
19098
|
+
path: `word/${sd.path}`,
|
|
19099
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
19100
|
+
}))]
|
|
19101
|
+
}, ctx));
|
|
19102
|
+
dropDanglingPassthroughRels(files, ctx._options.passthroughRelationships);
|
|
19103
|
+
return files;
|
|
18985
19104
|
}
|
|
18986
19105
|
function xmlifyContext(ctx) {
|
|
18987
19106
|
const mkCtx = (viewWrapper = ctx.document) => {
|
|
@@ -18997,59 +19116,18 @@ function xmlifyContext(ctx) {
|
|
|
18997
19116
|
bodyCtx.stringifyChild = (child) => stringifyBodyChild(child, bodyCtx);
|
|
18998
19117
|
return bodyCtx;
|
|
18999
19118
|
};
|
|
19000
|
-
const footerMediaResults = /* @__PURE__ */ new Map();
|
|
19001
|
-
const footerEmbeddingResults = /* @__PURE__ */ new Map();
|
|
19002
|
-
const headerMediaResults = /* @__PURE__ */ new Map();
|
|
19003
|
-
const headerEmbeddingResults = /* @__PURE__ */ new Map();
|
|
19004
19119
|
const docCtx = mkCtx(ctx.document);
|
|
19005
19120
|
const documentXmlData = XML_DECL + stringifyDocumentXml(ctx, docCtx);
|
|
19006
19121
|
const documentRelationshipCount = ctx.document.relationships.nextRelationshipId;
|
|
19007
|
-
const
|
|
19008
|
-
const
|
|
19009
|
-
const
|
|
19010
|
-
const commentXmlData = commentCtx ? XML_DECL + commentsDesc.stringify(mergedCommentChildrenList, commentCtx) : "";
|
|
19011
|
-
const commentRelationshipCount = hasComments ? ctx.comments.relationships.nextRelationshipId : 0;
|
|
19012
|
-
const footnoteCtx = mkCtx({ relationships: ctx.footNotes.relationships });
|
|
19013
|
-
const footnoteXmlData = XML_DECL + (footnotesDesc.stringify({
|
|
19014
|
-
notes: ctx.footNotes.notes,
|
|
19015
|
-
separator: ctx.footNotes.separator,
|
|
19016
|
-
continuationSeparator: ctx.footNotes.continuationSeparator,
|
|
19017
|
-
continuationNotice: ctx.footNotes.continuationNotice
|
|
19018
|
-
}, footnoteCtx) ?? "");
|
|
19019
|
-
const footnoteRelationshipCount = ctx.footNotes.relationships.nextRelationshipId;
|
|
19020
|
-
const documentMedia = findAndReplaceImagePlaceholders(documentXmlData, ctx.media.array, documentRelationshipCount, "rId", documentSourceRids(ctx, "media"));
|
|
19021
|
-
const documentEmbeddingOffset = documentRelationshipCount + documentMedia.referenced.length;
|
|
19022
|
-
const documentEmbeddings = findAndReplaceImagePlaceholders(documentMedia.xml, ctx.embeddings.array, documentEmbeddingOffset, "rId", documentSourceRids(ctx, "embeddings"));
|
|
19023
|
-
const commentMedia = hasComments ? findAndReplaceImagePlaceholders(commentXmlData, ctx.media.array, commentRelationshipCount) : {
|
|
19024
|
-
xml: "",
|
|
19025
|
-
referenced: []
|
|
19026
|
-
};
|
|
19027
|
-
const commentEmbeddingOffset = commentRelationshipCount + commentMedia.referenced.length;
|
|
19028
|
-
const commentEmbeddings = hasComments ? findAndReplaceImagePlaceholders(commentMedia.xml, ctx.embeddings.array, commentEmbeddingOffset) : {
|
|
19029
|
-
xml: "",
|
|
19030
|
-
referenced: []
|
|
19031
|
-
};
|
|
19032
|
-
const footnoteMedia = findAndReplaceImagePlaceholders(footnoteXmlData, ctx.media.array, footnoteRelationshipCount);
|
|
19033
|
-
const footnoteEmbeddingOffset = footnoteRelationshipCount + footnoteMedia.referenced.length;
|
|
19034
|
-
const footnoteEmbeddings = findAndReplaceImagePlaceholders(footnoteMedia.xml, ctx.embeddings.array, footnoteEmbeddingOffset);
|
|
19035
|
-
for (const [i, ref] of footnoteMedia.referenced.entries()) ctx.footNotes.relationships.addRelationship(footnoteRelationshipCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19036
|
-
for (const [i, ref] of footnoteEmbeddings.referenced.entries()) ctx.footNotes.relationships.addRelationship(footnoteEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19122
|
+
const notesParts = compileNotesParts(ctx, mkCtx);
|
|
19123
|
+
const headerFooterParts = compileHeaderFooterParts(ctx, mkCtx);
|
|
19124
|
+
const documentEntries = compileDocumentEntries(ctx, documentXmlData, documentRelationshipCount);
|
|
19037
19125
|
return {
|
|
19038
19126
|
AppProperties: {
|
|
19039
19127
|
data: XML_DECL + (appPropertiesDesc.stringify(ctx._options.appProperties ?? {}, ctx) ?? ""),
|
|
19040
19128
|
path: "docProps/app.xml"
|
|
19041
19129
|
},
|
|
19042
|
-
...
|
|
19043
|
-
Comments: {
|
|
19044
|
-
data: replaceNumberingPlaceholders(commentEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19045
|
-
path: "word/comments.xml"
|
|
19046
|
-
},
|
|
19047
|
-
CommentsRelationships: (() => {
|
|
19048
|
-
for (const [i, ref] of commentMedia.referenced.entries()) ctx.comments.relationships.addRelationship(commentRelationshipCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19049
|
-
for (const [i, ref] of commentEmbeddings.referenced.entries()) ctx.comments.relationships.addRelationship(commentEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19050
|
-
return optionalRelsPart(ctx.comments.relationships, XML_DECL, "word/_rels/comments.xml.rels");
|
|
19051
|
-
})()
|
|
19052
|
-
} : {},
|
|
19130
|
+
...notesParts,
|
|
19053
19131
|
...ctx._options.customProperties !== void 0 ? { CustomProperties: {
|
|
19054
19132
|
data: XML_DECL + (customPropertiesDesc.stringify({ properties: ctx._options.customProperties }, ctx) ?? ""),
|
|
19055
19133
|
path: "docProps/custom.xml"
|
|
@@ -19062,76 +19140,11 @@ function xmlifyContext(ctx) {
|
|
|
19062
19140
|
data: XML_DECL + (commentsExtendedDesc.stringify(ctx._options.commentsExtended, ctx) ?? ""),
|
|
19063
19141
|
path: "word/commentsExtended.xml"
|
|
19064
19142
|
} } : {},
|
|
19065
|
-
|
|
19066
|
-
data: (() => {
|
|
19067
|
-
let xmlData = documentEmbeddings.xml;
|
|
19068
|
-
if (hasPlaceholders(xmlData)) {
|
|
19069
|
-
const mediaCount = documentMedia.referenced.length;
|
|
19070
|
-
const embeddingCount = documentEmbeddings.referenced.length;
|
|
19071
|
-
const chartKeys = ctx.charts.array.map((c) => c.key);
|
|
19072
|
-
const smartArtKeys = ctx.smartArts.array.map((s) => s.key);
|
|
19073
|
-
const chartOffset = documentRelationshipCount + mediaCount + embeddingCount;
|
|
19074
|
-
const smartArtOffset = chartOffset + chartKeys.length;
|
|
19075
|
-
const entries = [];
|
|
19076
|
-
for (const [i, key] of chartKeys.entries()) {
|
|
19077
|
-
const chartTarget = `charts/chart${i + 1}.xml`;
|
|
19078
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", chartTarget);
|
|
19079
|
-
entries.push({
|
|
19080
|
-
prefix: "chart:",
|
|
19081
|
-
key,
|
|
19082
|
-
value: sourceRid !== void 0 ? `rId${sourceRid}` : formatId(chartOffset, i, "rId")
|
|
19083
|
-
});
|
|
19084
|
-
}
|
|
19085
|
-
const saPrefixes = [
|
|
19086
|
-
"smartart:",
|
|
19087
|
-
"smartart-lo:",
|
|
19088
|
-
"smartart-qs:",
|
|
19089
|
-
"smartart-cs:"
|
|
19090
|
-
];
|
|
19091
|
-
for (const [i, key] of smartArtKeys.entries()) for (let p = 0; p < saPrefixes.length; p++) entries.push({
|
|
19092
|
-
prefix: saPrefixes[p],
|
|
19093
|
-
key,
|
|
19094
|
-
value: formatId(smartArtOffset + p * smartArtKeys.length, i, "rId")
|
|
19095
|
-
});
|
|
19096
|
-
for (const { reference, instance, numId } of ctx.numbering.concreteNumbering) entries.push({
|
|
19097
|
-
key: `${reference}-${instance}`,
|
|
19098
|
-
value: numId.toString()
|
|
19099
|
-
});
|
|
19100
|
-
xmlData = replaceAllPlaceholders(xmlData, entries);
|
|
19101
|
-
} else xmlData = replaceNumberingPlaceholders(xmlData, ctx.numbering.concreteNumbering);
|
|
19102
|
-
return xmlData;
|
|
19103
|
-
})(),
|
|
19104
|
-
path: "word/document.xml"
|
|
19105
|
-
},
|
|
19143
|
+
...documentEntries,
|
|
19106
19144
|
...ctx._options.rawParts?.some((part) => part.path.startsWith("word/theme/")) ? {} : { Theme: {
|
|
19107
19145
|
data: XML_DECL + createThemeXml(),
|
|
19108
19146
|
path: "word/theme/theme1.xml"
|
|
19109
19147
|
} },
|
|
19110
|
-
...ctx.hasEndnotes ? {
|
|
19111
|
-
Endnotes: {
|
|
19112
|
-
data: (() => {
|
|
19113
|
-
const endnoteCtx = mkCtx({ relationships: ctx.endnotes.relationships });
|
|
19114
|
-
const xmlData = XML_DECL + (endnotesDesc.stringify({
|
|
19115
|
-
notes: ctx.endnotes.notes,
|
|
19116
|
-
separator: ctx.endnotes.separator,
|
|
19117
|
-
continuationSeparator: ctx.endnotes.continuationSeparator,
|
|
19118
|
-
continuationNotice: ctx.endnotes.continuationNotice
|
|
19119
|
-
}, endnoteCtx) ?? "");
|
|
19120
|
-
const endnoteRelCount = ctx.endnotes.relationships.nextRelationshipId;
|
|
19121
|
-
const endnoteMedia = findAndReplaceImagePlaceholders(xmlData, ctx.media.array, endnoteRelCount);
|
|
19122
|
-
for (const [i, ref] of endnoteMedia.referenced.entries()) ctx.endnotes.relationships.addRelationship(endnoteRelCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19123
|
-
const endnoteEmbeddingOffset = endnoteRelCount + endnoteMedia.referenced.length;
|
|
19124
|
-
const endnoteEmbeddings = findAndReplaceImagePlaceholders(endnoteMedia.xml, ctx.embeddings.array, endnoteEmbeddingOffset);
|
|
19125
|
-
for (const [i, ref] of endnoteEmbeddings.referenced.entries()) ctx.endnotes.relationships.addRelationship(endnoteEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19126
|
-
return replaceNumberingPlaceholders(endnoteEmbeddings.xml, ctx.numbering.concreteNumbering);
|
|
19127
|
-
})(),
|
|
19128
|
-
path: "word/endnotes.xml"
|
|
19129
|
-
},
|
|
19130
|
-
EndnotesRelationships: ctx.endnotes.relationships.relationshipCount > 0 ? {
|
|
19131
|
-
data: XML_DECL + ctx.endnotes.relationships.serialize(),
|
|
19132
|
-
path: "word/_rels/endnotes.xml.rels"
|
|
19133
|
-
} : void 0
|
|
19134
|
-
} : {},
|
|
19135
19148
|
FileRelationships: {
|
|
19136
19149
|
data: XML_DECL + ctx.fileRelationships.serialize(),
|
|
19137
19150
|
path: "_rels/.rels"
|
|
@@ -19141,67 +19154,12 @@ function xmlifyContext(ctx) {
|
|
|
19141
19154
|
path: "word/fontTable.xml"
|
|
19142
19155
|
},
|
|
19143
19156
|
FontTableRelationships: optionalRelsPart(ctx.fontTable.relationships, XML_DECL, "word/_rels/fontTable.xml.rels"),
|
|
19144
|
-
...
|
|
19145
|
-
FootNotes: {
|
|
19146
|
-
data: replaceNumberingPlaceholders(footnoteEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19147
|
-
path: "word/footnotes.xml"
|
|
19148
|
-
},
|
|
19149
|
-
FootNotesRelationships: ctx.footNotes.relationships.relationshipCount > 0 ? {
|
|
19150
|
-
data: XML_DECL + ctx.footNotes.relationships.serialize(),
|
|
19151
|
-
path: "word/_rels/footnotes.xml.rels"
|
|
19152
|
-
} : void 0
|
|
19153
|
-
} : {},
|
|
19154
|
-
FooterRelationships: ctx.footers.map((entry, index) => {
|
|
19155
|
-
const footerCtx = mkCtx({
|
|
19156
|
-
relationships: entry.relationships,
|
|
19157
|
-
partName: `word/${entry.partName ?? `footer${index + 1}.xml`}`
|
|
19158
|
-
});
|
|
19159
|
-
const xmlData = XML_DECL + stringifyHeaderFooter("w:ftr", FOOTER_NAMESPACES, entry.children, footerCtx);
|
|
19160
|
-
const footerRelCount = entry.relationships.nextRelationshipId;
|
|
19161
|
-
const footerMedia = findAndReplaceImagePlaceholders(xmlData, ctx.media.array, footerRelCount);
|
|
19162
|
-
footerMediaResults.set(index, footerMedia);
|
|
19163
|
-
const footerEmbeddingOffset = footerRelCount + footerMedia.referenced.length;
|
|
19164
|
-
const footerEmbeddings = findAndReplaceImagePlaceholders(footerMedia.xml, ctx.embeddings.array, footerEmbeddingOffset);
|
|
19165
|
-
footerEmbeddingResults.set(index, footerEmbeddings);
|
|
19166
|
-
for (const [i, ref] of footerMedia.referenced.entries()) entry.relationships.addRelationship(footerRelCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19167
|
-
for (const [i, ref] of footerEmbeddings.referenced.entries()) entry.relationships.addRelationship(footerEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19168
|
-
return optionalRelsPart(entry.relationships, XML_DECL, `word/_rels/${entry.partName ?? `footer${index + 1}.xml`}.rels`);
|
|
19169
|
-
}).filter((r) => r !== void 0),
|
|
19170
|
-
Footers: ctx.footers.map((entry, index) => {
|
|
19171
|
-
const footerEmbeddings = footerEmbeddingResults.get(index);
|
|
19172
|
-
return {
|
|
19173
|
-
data: replaceNumberingPlaceholders(footerEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19174
|
-
path: `word/${entry.partName ?? `footer${index + 1}.xml`}`
|
|
19175
|
-
};
|
|
19176
|
-
}),
|
|
19177
|
-
HeaderRelationships: ctx.headers.map((entry, index) => {
|
|
19178
|
-
const headerCtx = mkCtx({
|
|
19179
|
-
relationships: entry.relationships,
|
|
19180
|
-
partName: `word/${entry.partName ?? `header${index + 1}.xml`}`
|
|
19181
|
-
});
|
|
19182
|
-
const xmlData = XML_DECL + stringifyHeaderFooter("w:hdr", HEADER_NAMESPACES, entry.children, headerCtx);
|
|
19183
|
-
const headerRelCount = entry.relationships.nextRelationshipId;
|
|
19184
|
-
const headerMedia = findAndReplaceImagePlaceholders(xmlData, ctx.media.array, headerRelCount);
|
|
19185
|
-
headerMediaResults.set(index, headerMedia);
|
|
19186
|
-
const headerEmbeddingOffset = headerRelCount + headerMedia.referenced.length;
|
|
19187
|
-
const headerEmbeddings = findAndReplaceImagePlaceholders(headerMedia.xml, ctx.embeddings.array, headerEmbeddingOffset);
|
|
19188
|
-
headerEmbeddingResults.set(index, headerEmbeddings);
|
|
19189
|
-
for (const [i, ref] of headerMedia.referenced.entries()) entry.relationships.addRelationship(headerRelCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19190
|
-
for (const [i, ref] of headerEmbeddings.referenced.entries()) entry.relationships.addRelationship(headerEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19191
|
-
return optionalRelsPart(entry.relationships, XML_DECL, `word/_rels/${entry.partName ?? `header${index + 1}.xml`}.rels`);
|
|
19192
|
-
}).filter((r) => r !== void 0),
|
|
19193
|
-
Headers: ctx.headers.map((entry, index) => {
|
|
19194
|
-
const headerEmbeddings = headerEmbeddingResults.get(index);
|
|
19195
|
-
return {
|
|
19196
|
-
data: replaceNumberingPlaceholders(headerEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19197
|
-
path: `word/${entry.partName ?? `header${index + 1}.xml`}`
|
|
19198
|
-
};
|
|
19199
|
-
}),
|
|
19157
|
+
...headerFooterParts,
|
|
19200
19158
|
...ctx.hasNumbering ? (() => {
|
|
19201
19159
|
const numberingXml = ctx.numbering.serialize(ctx);
|
|
19202
19160
|
const numberingMedia = findAndReplaceImagePlaceholders(numberingXml, ctx.media.array, 1);
|
|
19203
19161
|
const numberingRels = new Relationships();
|
|
19204
|
-
for (const [i, ref] of numberingMedia.referenced.entries()) numberingRels.addRelationship(1 + i,
|
|
19162
|
+
for (const [i, ref] of numberingMedia.referenced.entries()) numberingRels.addRelationship(1 + i, RELATIONSHIP_TYPES.image, `media/${ref.fileName}`);
|
|
19205
19163
|
return {
|
|
19206
19164
|
Numbering: {
|
|
19207
19165
|
data: numberingMedia.xml,
|
|
@@ -19214,44 +19172,13 @@ function xmlifyContext(ctx) {
|
|
|
19214
19172
|
data: XML_DECL + (corePropertiesDesc.stringify(ctx._options, ctx) ?? ""),
|
|
19215
19173
|
path: "docProps/core.xml"
|
|
19216
19174
|
},
|
|
19217
|
-
Relationships: {
|
|
19218
|
-
data: (() => {
|
|
19219
|
-
for (const [i, ref] of documentMedia.referenced.entries()) {
|
|
19220
|
-
const target = `media/${ref.fileName}`;
|
|
19221
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", target);
|
|
19222
|
-
ctx.document.relationships.addRelationship(sourceRid ?? documentRelationshipCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", target);
|
|
19223
|
-
}
|
|
19224
|
-
for (const [i, ref] of documentEmbeddings.referenced.entries()) {
|
|
19225
|
-
const target = `embeddings/${ref.fileName}`;
|
|
19226
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
19227
|
-
ctx.document.relationships.addRelationship(sourceRid ?? documentEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
19228
|
-
}
|
|
19229
|
-
const chartOffset = documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length;
|
|
19230
|
-
for (let i = 0; i < ctx.charts.array.length; i++) {
|
|
19231
|
-
const target = `charts/chart${i + 1}.xml`;
|
|
19232
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", target);
|
|
19233
|
-
ctx.document.relationships.addRelationship(sourceRid ?? chartOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", target);
|
|
19234
|
-
}
|
|
19235
|
-
addSmartArtRelationships(ctx.smartArts.array.map((s) => s.key), (id, type, target) => {
|
|
19236
|
-
ctx.document.relationships.addRelationship(id, type, target);
|
|
19237
|
-
}, documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length + ctx.charts.array.length, 0, {
|
|
19238
|
-
pathPrefix: "",
|
|
19239
|
-
styleRelType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle",
|
|
19240
|
-
hasDrawing: (key) => ctx.smartArts.array.find((s) => s.key === key)?.raw?.drawing !== void 0
|
|
19241
|
-
});
|
|
19242
|
-
ctx.document.relationships.addRelationship(sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", "fontTable.xml") ?? ctx.document.relationships.nextRelationshipId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", "fontTable.xml");
|
|
19243
|
-
ctx.addPassthroughDocumentRelationships();
|
|
19244
|
-
return XML_DECL + ctx.document.relationships.serialize();
|
|
19245
|
-
})(),
|
|
19246
|
-
path: "word/_rels/document.xml.rels"
|
|
19247
|
-
},
|
|
19248
19175
|
Settings: {
|
|
19249
19176
|
data: XML_DECL + (settingsDesc.stringify(ctx._settingsOptions, ctx) ?? ""),
|
|
19250
19177
|
path: "word/settings.xml"
|
|
19251
19178
|
},
|
|
19252
19179
|
...ctx._settingsOptions.attachedTemplate !== void 0 ? (() => {
|
|
19253
19180
|
const rels = new Relationships();
|
|
19254
|
-
rels.addRelationship(1,
|
|
19181
|
+
rels.addRelationship(1, RELATIONSHIP_TYPES.attachedTemplate, ctx._settingsOptions.attachedTemplate, TargetModeType.EXTERNAL);
|
|
19255
19182
|
return { SettingsRelationships: {
|
|
19256
19183
|
data: XML_DECL + rels.serialize(),
|
|
19257
19184
|
path: "word/_rels/settings.xml.rels"
|
|
@@ -19268,68 +19195,8 @@ function xmlifyContext(ctx) {
|
|
|
19268
19195
|
data: XML_DECL + (bibliographyDesc.stringify(ctx._options.bibliography, ctx) ?? ""),
|
|
19269
19196
|
path: "word/bibliography.xml"
|
|
19270
19197
|
} } : {},
|
|
19271
|
-
...ctx
|
|
19272
|
-
|
|
19273
|
-
const parts = [{
|
|
19274
|
-
data: XML_DECL + chartData.chartSpaceXml,
|
|
19275
|
-
path: `word/charts/chart${i + 1}.xml`
|
|
19276
|
-
}];
|
|
19277
|
-
if (chartData.userShapes) parts.push({
|
|
19278
|
-
data: XML_DECL + chartData.userShapes.xml,
|
|
19279
|
-
path: `word/charts/userShapes${i + 1}.xml`
|
|
19280
|
-
});
|
|
19281
|
-
const e = chartData.embedding;
|
|
19282
|
-
const rels = [...e ? [`<Relationship Id="${escapeXml(e.relationshipId)}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package" Target="../embeddings/${escapeXml(e.fileName)}"/>`] : [], ...chartData.userShapes ? [`<Relationship Id="${escapeXml(chartData.userShapes.relationshipId)}" Type="${CHART_USER_SHAPES_REL}" Target="userShapes${i + 1}.xml"/>`] : []];
|
|
19283
|
-
if (rels.length > 0) parts.push({
|
|
19284
|
-
data: XML_DECL + `<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${rels.join("")}</Relationships>`,
|
|
19285
|
-
path: `word/charts/_rels/chart${i + 1}.xml.rels`
|
|
19286
|
-
});
|
|
19287
|
-
return parts;
|
|
19288
|
-
}),
|
|
19289
|
-
ChartEmbeddings: (() => {
|
|
19290
|
-
const seen = /* @__PURE__ */ new Set();
|
|
19291
|
-
const parts = [];
|
|
19292
|
-
for (const c of ctx.charts.array) {
|
|
19293
|
-
const e = c.embedding;
|
|
19294
|
-
if (!e || seen.has(e.fileName)) continue;
|
|
19295
|
-
seen.add(e.fileName);
|
|
19296
|
-
parts.push({
|
|
19297
|
-
data: toUint8Array(e.data),
|
|
19298
|
-
path: `word/embeddings/${e.fileName}`
|
|
19299
|
-
});
|
|
19300
|
-
}
|
|
19301
|
-
return parts;
|
|
19302
|
-
})()
|
|
19303
|
-
} : {},
|
|
19304
|
-
...ctx.smartArts.array.length > 0 ? {
|
|
19305
|
-
DiagramData: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19306
|
-
data: smartArtData.raw?.data !== void 0 ? toUint8Array(smartArtData.raw.data) : XML_DECL + smartArtData.dataModelXml,
|
|
19307
|
-
path: `word/diagrams/data${i + 1}.xml`
|
|
19308
|
-
})),
|
|
19309
|
-
DiagramLayout: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19310
|
-
data: smartArtData.raw?.layout !== void 0 ? toUint8Array(smartArtData.raw.layout) : typeof smartArtData.layout === "string" ? getLayoutXml(smartArtData.layout) : stringifyLayoutDefinitionPart(smartArtData.layout),
|
|
19311
|
-
path: `word/diagrams/layout${i + 1}.xml`
|
|
19312
|
-
})),
|
|
19313
|
-
DiagramStyle: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19314
|
-
data: smartArtData.raw?.style !== void 0 ? toUint8Array(smartArtData.raw.style) : typeof smartArtData.style === "string" ? getStyleXml(smartArtData.style) : stringifyStyleDefinitionPart(smartArtData.style),
|
|
19315
|
-
path: `word/diagrams/quickStyle${i + 1}.xml`
|
|
19316
|
-
})),
|
|
19317
|
-
DiagramColors: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19318
|
-
data: smartArtData.raw?.color !== void 0 ? toUint8Array(smartArtData.raw.color) : typeof smartArtData.color === "string" ? getColorXml(smartArtData.color) : stringifyColorDefinitionPart(smartArtData.color),
|
|
19319
|
-
path: `word/diagrams/colors${i + 1}.xml`
|
|
19320
|
-
})),
|
|
19321
|
-
DiagramDrawing: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19322
|
-
smartArtData,
|
|
19323
|
-
i
|
|
19324
|
-
})).filter(({ smartArtData }) => smartArtData.raw?.drawing !== void 0).map(({ smartArtData, i }) => ({
|
|
19325
|
-
data: toUint8Array(smartArtData.raw.drawing),
|
|
19326
|
-
path: `word/diagrams/drawing${i + 1}.xml`
|
|
19327
|
-
})),
|
|
19328
|
-
...ctx.smartArts.array.some((s) => s.raw?.dataRels !== void 0) ? { SmartArtDataRels: ctx.smartArts.array.flatMap((smartArtData, i) => smartArtData.raw?.dataRels !== void 0 ? [{
|
|
19329
|
-
data: toUint8Array(smartArtData.raw.dataRels),
|
|
19330
|
-
path: `word/diagrams/_rels/data${i + 1}.xml.rels`
|
|
19331
|
-
}] : []) } : {}
|
|
19332
|
-
} : {},
|
|
19198
|
+
...compileChartParts(ctx),
|
|
19199
|
+
...compileSmartArtParts(ctx),
|
|
19333
19200
|
...ctx.altChunks.array.length > 0 ? { AltChunks: ctx.altChunks.array.map((altChunkData) => ({
|
|
19334
19201
|
data: altChunkData.data,
|
|
19335
19202
|
path: `word/${altChunkData.path}`
|
|
@@ -19420,6 +19287,6 @@ function generateDocumentStream(options, packerOptions) {
|
|
|
19420
19287
|
return Packer.toStream(options, packerOptions);
|
|
19421
19288
|
}
|
|
19422
19289
|
//#endregion
|
|
19423
|
-
export { AlignmentType, AltChunkCollection, BorderStyle, BreakType, COMMENTS_NS, CharacterSet, DefaultStylesFactory, DocPartBehavior, DocPartGallery, DocPartType, DocumentAttributeNamespaces, DocumentGridType, DocxReadContext, DocxWriteContext, DropCapType, EMPTY_RUN_ELEMENTS, EditGroupType, EmphasisMarkType, FormFieldTextType, FrameAnchorType, FrameWrap, HIGHLIGHT_PALETTE_RGB, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HyperlinkType, LeaderType, LevelFormat, LevelSuffix, LineNumberRestartFormat, LineRuleType, Media, NumberFormat, Numbering, OverlapType, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageNumber, PageNumberSeparator, PageOrientation, PageTextDirectionType, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, ProofErrorType, RelativeHorizontalPosition, RelativeVerticalPosition, RubyAlign, SdtDateMappingType, SdtLock, SectionType, ShadingType,
|
|
19290
|
+
export { AlignmentType, AltChunkCollection, BorderStyle, BreakType, COMMENTS_NS, CharacterSet, DefaultStylesFactory, DocPartBehavior, DocPartGallery, DocPartType, DocumentAttributeNamespaces, DocumentGridType, DocxReadContext, DocxWriteContext, DropCapType, EMPTY_RUN_ELEMENTS, EditGroupType, EmphasisMarkType, FormFieldTextType, FrameAnchorType, FrameWrap, HIGHLIGHT_PALETTE_RGB, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HyperlinkType, LeaderType, LevelFormat, LevelSuffix, LineNumberRestartFormat, LineRuleType, Media, NumberFormat, Numbering, OverlapType, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageNumber, PageNumberSeparator, PageOrientation, PageTextDirectionType, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, ProofErrorType, RelativeHorizontalPosition, RelativeVerticalPosition, RubyAlign, SdtDateMappingType, SdtLock, SectionType, ShadingType, StyleLevel, Styles, SubDocCollection, TABLE_BORDERS_NONE, TabStopPosition, TabStopType, TableAnchorType, TableLayoutType, TargetScreenSize, TextAlignmentType, TextDirection, TextEffect, TextWrappingSide, TextWrappingType, TextboxTightWrapType, UnderlineType, VerticalAlignSection, VerticalAlignTable, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WidthType, altChunkDesc, appPropertiesDesc, bibliographyDesc, bodyPropertiesDesc, breakXml, buildBookmarkStartAttrs, buildMarkupRangeAttrs, buildNumIdCache, buildNumberingCache, buildStyleCache, checkboxSymbolRunInner, commentsDesc, commentsExtendedDesc, compileDocument, corePropertiesDesc, createBodyProperties, createDocumentGrid, createFormFieldData, createHorizontalPosition, createLineNumberType, createPageMargin, createPageNumberType, createPictureData, createSectionType, createTransformation, createVerticalPosition, customPropertiesDesc, customXmlBlockDesc, documentNamespaceAttributes, documentNamespaceRecord, drawingDesc, endnotesDesc, extractStyleId, fontTableDesc, footnotesDesc, frameXml, framesetXml, generateDocument, generateDocumentStream, generateDocumentSync, glossaryDesc, keepTocClosingParagraph, objectDesc, parseArchive, parseBodyProperties, parseBorderSide, parseCustomXmlProperties, parseDocument, parseDocumentSync, parseDocx, parseFormFieldData, parseNumberingDefinitions, parsePict, parseRegisteredBodyChild, parseSdtBlock, parseSdtProperties, parseSectionPropertiesEl, parseShading, parseStyleDefinitions, parseTableCellPropertiesEl, parseTablePropertiesEl, parseTableRowPropertiesEl, parseToc, parseTocFieldFromElements, parseTocFieldInstruction, patchDetector, patchDocument, peopleDesc, resetDrawingIdGen, sdtBlockDesc, sectionMarginDefaults, sectionPageSizeDefaults, sectionPropertiesDesc, selectTocEntryElements, setBodyParseChild, setTableParseChild, settingsDesc, stringifyCharacterStyle, stringifyChildDispatch, stringifyConditionalTableStyle, stringifyCustomXmlShell, stringifyDocDefaults, stringifyNumberingStyle, stringifyParagraphInline, stringifyParagraphStyle, stringifyPict, stringifyRunInline, stringifySdtPr, stringifySdtShell, stringifySectionProperties, stringifyTableOfContents, stringifyTableStyle, subDocDesc, tableDesc, webSettingsDesc, widthFiftiethsToPct, widthPctToFiftieths };
|
|
19424
19291
|
|
|
19425
19292
|
//# sourceMappingURL=index.mjs.map
|