@office-open/docx 0.14.2 → 0.14.4
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 +1295 -1301
- 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";
|
|
@@ -2713,18 +2713,20 @@ function stringifyParagraphProperties(options) {
|
|
|
2713
2713
|
if (bParts.length) s += `<w:pBdr>${bParts.join("")}</w:pBdr>`;
|
|
2714
2714
|
}
|
|
2715
2715
|
if (options.shading) s += shadingStr(options.shading);
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
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
|
+
}
|
|
2728
2730
|
if (options.suppressAutoHyphens !== void 0) s += onOff$2("w:suppressAutoHyphens", options.suppressAutoHyphens);
|
|
2729
2731
|
if (options.kinsoku !== void 0) s += onOff$2("w:kinsoku", options.kinsoku);
|
|
2730
2732
|
if (options.wordWrap !== void 0) s += onOff$2("w:wordWrap", options.wordWrap);
|
|
@@ -3037,7 +3039,7 @@ function parseSdtBlock(el, ctx, parseChildren) {
|
|
|
3037
3039
|
*
|
|
3038
3040
|
* @module
|
|
3039
3041
|
*/
|
|
3040
|
-
const ALTCHUNK_REL_TYPE =
|
|
3042
|
+
const ALTCHUNK_REL_TYPE = RELATIONSHIP_TYPES.aFChunk;
|
|
3041
3043
|
function wrapHtmlDocument(fragment) {
|
|
3042
3044
|
if (/<(!DOCTYPE|html|HTML)/i.test(fragment)) return fragment;
|
|
3043
3045
|
return `<!DOCTYPE html>\n<html><head><meta charset="utf-8"></head>\n<body>${fragment}</body></html>`;
|
|
@@ -3093,7 +3095,7 @@ const altChunkDesc = {
|
|
|
3093
3095
|
return opts;
|
|
3094
3096
|
}
|
|
3095
3097
|
};
|
|
3096
|
-
const SUBDOC_REL_TYPE =
|
|
3098
|
+
const SUBDOC_REL_TYPE = RELATIONSHIP_TYPES.subDocument;
|
|
3097
3099
|
const subDocDesc = {
|
|
3098
3100
|
kind: "custom",
|
|
3099
3101
|
stringify(opts, ctx) {
|
|
@@ -3400,138 +3402,6 @@ const TextWrappingSide = {
|
|
|
3400
3402
|
LARGEST: "largest"
|
|
3401
3403
|
};
|
|
3402
3404
|
//#endregion
|
|
3403
|
-
//#region src/parts/drawing/text-wrap/wrap-tight.ts
|
|
3404
|
-
/**
|
|
3405
|
-
* Wrap Tight module for DrawingML text wrapping.
|
|
3406
|
-
*
|
|
3407
|
-
* This module provides tight text wrapping for floating drawings
|
|
3408
|
-
* where text wraps closely around the image shape.
|
|
3409
|
-
*
|
|
3410
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3411
|
-
*
|
|
3412
|
-
* @module
|
|
3413
|
-
*/
|
|
3414
|
-
/**
|
|
3415
|
-
* Creates a default rectangular wrap polygon matching the image extent.
|
|
3416
|
-
*
|
|
3417
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3418
|
-
*
|
|
3419
|
-
* ## XSD Schema
|
|
3420
|
-
* ```xml
|
|
3421
|
-
* <xsd:complexType name="CT_WrapPath">
|
|
3422
|
-
* <xsd:sequence>
|
|
3423
|
-
* <xsd:element name="start" type="a:CT_Point2D" minOccurs="1" maxOccurs="1"/>
|
|
3424
|
-
* <xsd:element name="lineTo" type="a:CT_Point2D" minOccurs="2" maxOccurs="unbounded"/>
|
|
3425
|
-
* </xsd:sequence>
|
|
3426
|
-
* <xsd:attribute name="edited" type="xsd:boolean" use="optional"/>
|
|
3427
|
-
* </xsd:complexType>
|
|
3428
|
-
* ```
|
|
3429
|
-
*/
|
|
3430
|
-
const createWrapPolygon$1 = (cx, cy) => element("wp:wrapPolygon", { edited: "0" }, [
|
|
3431
|
-
`<wp:start x="0" y="0"/>`,
|
|
3432
|
-
`<wp:lineTo x="0" y="${-cy}"/>`,
|
|
3433
|
-
`<wp:lineTo x="${cx}" y="${-cy}"/>`,
|
|
3434
|
-
`<wp:lineTo x="${cx}" y="0"/>`,
|
|
3435
|
-
`<wp:lineTo x="0" y="0"/>`
|
|
3436
|
-
]);
|
|
3437
|
-
/**
|
|
3438
|
-
* Creates tight text wrapping for a floating drawing.
|
|
3439
|
-
*
|
|
3440
|
-
* WrapTight causes text to wrap closely around the contours
|
|
3441
|
-
* of the drawing rather than its rectangular bounding box.
|
|
3442
|
-
* A default rectangular wrap polygon matching the image extent is generated.
|
|
3443
|
-
*
|
|
3444
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3445
|
-
*
|
|
3446
|
-
* ## XSD Schema
|
|
3447
|
-
* ```xml
|
|
3448
|
-
* <xsd:complexType name="CT_WrapTight">
|
|
3449
|
-
* <xsd:sequence>
|
|
3450
|
-
* <xsd:element name="wrapPolygon" type="CT_WrapPath" minOccurs="1" maxOccurs="1"/>
|
|
3451
|
-
* </xsd:sequence>
|
|
3452
|
-
* <xsd:attribute name="wrapText" type="ST_WrapText" use="required"/>
|
|
3453
|
-
* <xsd:attribute name="distL" type="ST_WrapDistance"/>
|
|
3454
|
-
* <xsd:attribute name="distR" type="ST_WrapDistance"/>
|
|
3455
|
-
* </xsd:complexType>
|
|
3456
|
-
* ```
|
|
3457
|
-
*/
|
|
3458
|
-
const createWrapTight = (textWrapping, margins = {
|
|
3459
|
-
bottom: 0,
|
|
3460
|
-
left: 0,
|
|
3461
|
-
right: 0,
|
|
3462
|
-
top: 0
|
|
3463
|
-
}, extent) => element("wp:wrapTight", {
|
|
3464
|
-
distL: margins.left,
|
|
3465
|
-
distR: margins.right,
|
|
3466
|
-
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES
|
|
3467
|
-
}, [createWrapPolygon$1(extent.x, extent.y)]);
|
|
3468
|
-
//#endregion
|
|
3469
|
-
//#region src/parts/drawing/text-wrap/wrap-through.ts
|
|
3470
|
-
/**
|
|
3471
|
-
* Wrap Through module for DrawingML text wrapping.
|
|
3472
|
-
*
|
|
3473
|
-
* This module provides "through" text wrapping for floating drawings
|
|
3474
|
-
* where text wraps through the image contours, filling any concave areas.
|
|
3475
|
-
*
|
|
3476
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3477
|
-
*
|
|
3478
|
-
* @module
|
|
3479
|
-
*/
|
|
3480
|
-
/**
|
|
3481
|
-
* Creates a default rectangular wrap polygon matching the image extent.
|
|
3482
|
-
*
|
|
3483
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3484
|
-
*
|
|
3485
|
-
* ## XSD Schema
|
|
3486
|
-
* ```xml
|
|
3487
|
-
* <xsd:complexType name="CT_WrapPath">
|
|
3488
|
-
* <xsd:sequence>
|
|
3489
|
-
* <xsd:element name="start" type="a:CT_Point2D" minOccurs="1" maxOccurs="1"/>
|
|
3490
|
-
* <xsd:element name="lineTo" type="a:CT_Point2D" minOccurs="2" maxOccurs="unbounded"/>
|
|
3491
|
-
* </xsd:sequence>
|
|
3492
|
-
* <xsd:attribute name="edited" type="xsd:boolean" use="optional"/>
|
|
3493
|
-
* </xsd:complexType>
|
|
3494
|
-
* ```
|
|
3495
|
-
*/
|
|
3496
|
-
const createWrapPolygon = (cx, cy) => element("wp:wrapPolygon", { edited: "0" }, [
|
|
3497
|
-
`<wp:start x="0" y="0"/>`,
|
|
3498
|
-
`<wp:lineTo x="0" y="${-cy}"/>`,
|
|
3499
|
-
`<wp:lineTo x="${cx}" y="${-cy}"/>`,
|
|
3500
|
-
`<wp:lineTo x="${cx}" y="0"/>`,
|
|
3501
|
-
`<wp:lineTo x="0" y="0"/>`
|
|
3502
|
-
]);
|
|
3503
|
-
/**
|
|
3504
|
-
* Creates "through" text wrapping for a floating drawing.
|
|
3505
|
-
*
|
|
3506
|
-
* WrapThrough is similar to WrapTight but allows text to wrap through
|
|
3507
|
-
* the concave portions of the drawing shape (e.g., the inside of the letter "O").
|
|
3508
|
-
* A default rectangular wrap polygon matching the image extent is generated.
|
|
3509
|
-
*
|
|
3510
|
-
* Reference: http://officeopenxml.com/drwPicFloating-textWrap.php
|
|
3511
|
-
*
|
|
3512
|
-
* ## XSD Schema
|
|
3513
|
-
* ```xml
|
|
3514
|
-
* <xsd:complexType name="CT_WrapThrough">
|
|
3515
|
-
* <xsd:sequence>
|
|
3516
|
-
* <xsd:element name="wrapPolygon" type="CT_WrapPath" minOccurs="1" maxOccurs="1"/>
|
|
3517
|
-
* </xsd:sequence>
|
|
3518
|
-
* <xsd:attribute name="wrapText" type="ST_WrapText" use="required"/>
|
|
3519
|
-
* <xsd:attribute name="distL" type="ST_WrapDistance"/>
|
|
3520
|
-
* <xsd:attribute name="distR" type="ST_WrapDistance"/>
|
|
3521
|
-
* </xsd:complexType>
|
|
3522
|
-
* ```
|
|
3523
|
-
*/
|
|
3524
|
-
const createWrapThrough = (textWrapping, margins = {
|
|
3525
|
-
bottom: 0,
|
|
3526
|
-
left: 0,
|
|
3527
|
-
right: 0,
|
|
3528
|
-
top: 0
|
|
3529
|
-
}, extent) => element("wp:wrapThrough", {
|
|
3530
|
-
distL: margins.left,
|
|
3531
|
-
distR: margins.right,
|
|
3532
|
-
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES
|
|
3533
|
-
}, [createWrapPolygon(extent.x, extent.y)]);
|
|
3534
|
-
//#endregion
|
|
3535
3405
|
//#region src/shared/constants.ts
|
|
3536
3406
|
/**
|
|
3537
3407
|
* Shared constants for WordprocessingML documents.
|
|
@@ -3640,15 +3510,6 @@ const NumberFormat = {
|
|
|
3640
3510
|
UPPER_ROMAN: "upperRoman",
|
|
3641
3511
|
VIETNAMESE_COUNTING: "vietnameseCounting"
|
|
3642
3512
|
};
|
|
3643
|
-
/**
|
|
3644
|
-
* XML space handling modes.
|
|
3645
|
-
*
|
|
3646
|
-
* @publicApi
|
|
3647
|
-
*/
|
|
3648
|
-
const SpaceType = {
|
|
3649
|
-
DEFAULT: "default",
|
|
3650
|
-
PRESERVE: "preserve"
|
|
3651
|
-
};
|
|
3652
3513
|
//#endregion
|
|
3653
3514
|
//#region src/parts/drawing/floating/floating-position.ts
|
|
3654
3515
|
/**
|
|
@@ -4559,7 +4420,7 @@ var FontWrapper = class {
|
|
|
4559
4420
|
relIdx++;
|
|
4560
4421
|
font.embedRid = `rId${relIdx}`;
|
|
4561
4422
|
const target = font.odttfPath ? font.odttfPath.startsWith("word/") ? font.odttfPath.slice(5) : font.odttfPath : `fonts/${font.name}.odttf`;
|
|
4562
|
-
this.relationships.addRelationship(relIdx,
|
|
4423
|
+
this.relationships.addRelationship(relIdx, RELATIONSHIP_TYPES.font, target);
|
|
4563
4424
|
}
|
|
4564
4425
|
}
|
|
4565
4426
|
};
|
|
@@ -5424,6 +5285,7 @@ function stringifyBodyChild(child, ctx, sectionPropertiesXml) {
|
|
|
5424
5285
|
}
|
|
5425
5286
|
function stringifyDocumentBackground(opts, ctx) {
|
|
5426
5287
|
if (opts.rawXml) {
|
|
5288
|
+
let xml = opts.rawXml;
|
|
5427
5289
|
if (opts.rawMedia) for (const m of opts.rawMedia) {
|
|
5428
5290
|
const data = toUint8Array(m.data);
|
|
5429
5291
|
const entry = ctx.file.media.addMedia(data, m.type, (fileName) => ({
|
|
@@ -5441,9 +5303,9 @@ function stringifyDocumentBackground(opts, ctx) {
|
|
|
5441
5303
|
}
|
|
5442
5304
|
}
|
|
5443
5305
|
}), m.fileName);
|
|
5444
|
-
if (entry.fileName !== m.fileName)
|
|
5306
|
+
if (entry.fileName !== m.fileName) xml = xml.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
5445
5307
|
}
|
|
5446
|
-
return
|
|
5308
|
+
return xml;
|
|
5447
5309
|
}
|
|
5448
5310
|
const attrs = [];
|
|
5449
5311
|
if (opts.color !== void 0) attrs.push(`w:color="${hexColorValue(opts.color)}"`);
|
|
@@ -7923,9 +7785,9 @@ const CHART_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
|
7923
7785
|
const DGM_URI = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
|
|
7924
7786
|
const WPS_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
7925
7787
|
const WPG_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
|
|
7926
|
-
const HYPERLINK_REL =
|
|
7927
|
-
const IMAGE_REL =
|
|
7928
|
-
const TEXT_BOX_REL =
|
|
7788
|
+
const HYPERLINK_REL = RELATIONSHIP_TYPES.hyperlink;
|
|
7789
|
+
const IMAGE_REL = RELATIONSHIP_TYPES.image;
|
|
7790
|
+
const TEXT_BOX_REL = RELATIONSHIP_TYPES.txbxMs;
|
|
7929
7791
|
const SVG_BLIP_EXT_URI = "{96DAC541-7B7A-43D3-8B79-37D633B846F1}";
|
|
7930
7792
|
const USE_LOCAL_DPI_EXT_URI = "{28A0092B-C50C-407E-A947-70E740481C1C}";
|
|
7931
7793
|
const A14_NS = "http://schemas.microsoft.com/office/drawing/2010/main";
|
|
@@ -8444,334 +8306,679 @@ const drawingDesc = {
|
|
|
8444
8306
|
}
|
|
8445
8307
|
};
|
|
8446
8308
|
//#endregion
|
|
8447
|
-
//#region src/parts/
|
|
8448
|
-
|
|
8449
|
-
* Field module for WordprocessingML documents.
|
|
8450
|
-
*
|
|
8451
|
-
* This module provides support for complex fields, which are regions of text
|
|
8452
|
-
* that can contain dynamic content such as page numbers, dates, or mail merge fields.
|
|
8453
|
-
* Fields are delimited by field character elements (begin, separate, end).
|
|
8454
|
-
*
|
|
8455
|
-
* Reference: http://officeopenxml.com/WPrun.php
|
|
8456
|
-
*
|
|
8457
|
-
* @module
|
|
8458
|
-
*/
|
|
8459
|
-
/**
|
|
8460
|
-
* Field character types that delimit field regions.
|
|
8461
|
-
*
|
|
8462
|
-
* @internal
|
|
8463
|
-
*/
|
|
8464
|
-
const FieldCharacterType = {
|
|
8465
|
-
BEGIN: "begin",
|
|
8466
|
-
END: "end",
|
|
8467
|
-
SEPARATE: "separate"
|
|
8468
|
-
};
|
|
8469
|
-
/**
|
|
8470
|
-
* Creates a field character element.
|
|
8471
|
-
*
|
|
8472
|
-
* ## XSD Schema
|
|
8473
|
-
* ```xml
|
|
8474
|
-
* <xsd:complexType name="CT_FldChar">
|
|
8475
|
-
* <xsd:sequence>
|
|
8476
|
-
* <xsd:element name="fldData" type="CT_Text" minOccurs="0"/>
|
|
8477
|
-
* <xsd:element name="ffData" type="CT_FFData" minOccurs="0"/>
|
|
8478
|
-
* <xsd:element name="numberingChange" type="CT_TrackChangeNumbering" minOccurs="0"/>
|
|
8479
|
-
* </xsd:sequence>
|
|
8480
|
-
* <xsd:attribute name="fldCharType" type="ST_FldCharType" use="required"/>
|
|
8481
|
-
* <xsd:attribute name="fldLock" type="s:ST_OnOff"/>
|
|
8482
|
-
* <xsd:attribute name="dirty" type="s:ST_OnOff"/>
|
|
8483
|
-
* </xsd:complexType>
|
|
8484
|
-
* ```
|
|
8485
|
-
* @internal
|
|
8486
|
-
*/
|
|
8487
|
-
const createFieldChar = (type, dirty, ffData, fldData, fieldLock) => {
|
|
8488
|
-
const children = [];
|
|
8489
|
-
if (fldData !== void 0) children.push(element("w:fldData", { "xml:space": "preserve" }, [fldData]));
|
|
8490
|
-
if (ffData) children.push(ffData);
|
|
8491
|
-
return element("w:fldChar", {
|
|
8492
|
-
"w:dirty": dirty,
|
|
8493
|
-
"w:fldLock": fieldLock,
|
|
8494
|
-
"w:fldCharType": type
|
|
8495
|
-
}, children.length > 0 ? children : void 0);
|
|
8496
|
-
};
|
|
8309
|
+
//#region src/parts/inline-drawings.ts
|
|
8310
|
+
let nextChartId = 1;
|
|
8497
8311
|
/**
|
|
8498
|
-
*
|
|
8499
|
-
*
|
|
8500
|
-
*
|
|
8501
|
-
* field instructions, an optional separate character, field result, and an end character.
|
|
8502
|
-
*
|
|
8503
|
-
* For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.
|
|
8504
|
-
*
|
|
8505
|
-
* @param dirty - Whether the field should be recalculated
|
|
8506
|
-
* @param formField - Optional form field data to embed in the begin character
|
|
8507
|
-
*
|
|
8508
|
-
* @example
|
|
8509
|
-
* ```typescript
|
|
8510
|
-
* // Simple field begin
|
|
8511
|
-
* createBegin();
|
|
8512
|
-
*
|
|
8513
|
-
* // Form field (checkbox)
|
|
8514
|
-
* createBegin(false, {
|
|
8515
|
-
* name: "Check1",
|
|
8516
|
-
* checkBox: { checked: true, sizeAuto: true },
|
|
8517
|
-
* });
|
|
8518
|
-
* ```
|
|
8312
|
+
* Wrap a `<w:drawing>` run, rebuilding an mc:AlternateContent wrapper when a
|
|
8313
|
+
* VML fallback was carried from parse (Choice stays structured/editable,
|
|
8314
|
+
* Fallback round-trips as raw XML for fidelity).
|
|
8519
8315
|
*/
|
|
8520
|
-
|
|
8316
|
+
function wrapDrawingRun(drawingXml, opts, vmlFallback = opts.vmlFallback) {
|
|
8317
|
+
const xml = drawingXml ?? "";
|
|
8318
|
+
const rPr = stringifyRunProperties(opts.runProperties) ?? "";
|
|
8319
|
+
const lrpb = opts.lastRenderedPageBreak ? "<w:lastRenderedPageBreak/>" : "";
|
|
8320
|
+
if (vmlFallback) return `<w:r>${rPr}${lrpb}<mc:AlternateContent><mc:Choice Requires="${opts.mcChoiceRequires ?? "wps"}">${xml}</mc:Choice>${vmlFallback}</mc:AlternateContent></w:r>`;
|
|
8321
|
+
return `<w:r>${rPr}${lrpb}${xml}</w:r>`;
|
|
8322
|
+
}
|
|
8521
8323
|
/**
|
|
8522
|
-
*
|
|
8324
|
+
* Register media carried by a VML fallback (mc:AlternateContent Fallback) so the
|
|
8325
|
+
* compiler resolves the fallback's `{fileName}` placeholders into rIds.
|
|
8523
8326
|
*
|
|
8524
|
-
*
|
|
8525
|
-
*
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
/**
|
|
8529
|
-
* Creates the end of a complex field.
|
|
8327
|
+
* A VML fallback image mirrors its Choice blip (same source bytes). When the
|
|
8328
|
+
* blip is already registered, reuse it and remap the fallback's `{fileName}`
|
|
8329
|
+
* placeholder to the shared media — matching Office, which emits one
|
|
8330
|
+
* relationship/file per image rather than a duplicate for the VML branch.
|
|
8530
8331
|
*
|
|
8531
|
-
*
|
|
8532
|
-
*
|
|
8332
|
+
* Returns the fallback XML with the renames applied — a local copy, never the
|
|
8333
|
+
* caller's `opts.vmlFallback` (options objects are shared, serializable data;
|
|
8334
|
+
* mutating them would leak this run's media numbering into the next run's
|
|
8335
|
+
* input).
|
|
8533
8336
|
*/
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8337
|
+
function registerVmlFallbackMedia(opts, ctx) {
|
|
8338
|
+
const vml = opts.vmlFallback;
|
|
8339
|
+
if (!vml || !opts.vmlFallbackMedia) return vml;
|
|
8340
|
+
let out = vml;
|
|
8341
|
+
for (const m of opts.vmlFallbackMedia) {
|
|
8342
|
+
const data = toUint8Array(m.data);
|
|
8343
|
+
const entry = ctx.file.media.addMedia(data, m.type, (fileName) => ({
|
|
8344
|
+
type: m.type,
|
|
8345
|
+
data,
|
|
8346
|
+
fileName,
|
|
8347
|
+
transformation: {
|
|
8348
|
+
emus: {
|
|
8349
|
+
x: 0,
|
|
8350
|
+
y: 0
|
|
8351
|
+
},
|
|
8352
|
+
pixels: {
|
|
8353
|
+
x: 0,
|
|
8354
|
+
y: 0
|
|
8355
|
+
}
|
|
8356
|
+
}
|
|
8357
|
+
}), m.fileName);
|
|
8358
|
+
if (entry.fileName !== m.fileName) out = out.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
8359
|
+
}
|
|
8360
|
+
return out;
|
|
8361
|
+
}
|
|
8362
|
+
/** Rewrite ../media targets inside verbatim data rels after the media
|
|
8363
|
+
* collection re-allocated pinned names. All renames apply in one pass over
|
|
8364
|
+
* the original text, each match bounded by its closing quote, so a name
|
|
8365
|
+
* that prefixes another cannot collide and chained renames cannot re-hit
|
|
8366
|
+
* an already-rewritten target. Preserves the input form (string stays
|
|
8367
|
+
* string, bytes stay bytes). */
|
|
8368
|
+
function remapDataRelsTargets(rels, renames) {
|
|
8369
|
+
const isText = typeof rels === "string";
|
|
8370
|
+
const text = isText ? rels : new TextDecoder().decode(toUint8Array(rels));
|
|
8371
|
+
let out = "";
|
|
8372
|
+
let last = 0;
|
|
8373
|
+
for (const m of text.matchAll(/\.\.\/media\/([^"']*)["']/g)) {
|
|
8374
|
+
const name = m[1] ?? "";
|
|
8375
|
+
const to = renames.get(name);
|
|
8376
|
+
if (to === void 0) continue;
|
|
8377
|
+
const start = (m.index ?? 0) + 9;
|
|
8378
|
+
out += text.slice(last, start) + to;
|
|
8379
|
+
last = start + name.length;
|
|
8380
|
+
}
|
|
8381
|
+
out += text.slice(last);
|
|
8382
|
+
return isText ? out : new TextEncoder().encode(out);
|
|
8383
|
+
}
|
|
8384
|
+
/** Content fingerprint of the raw source parts: every field participates so
|
|
8385
|
+
* two instances that differ in any raw part (or in their companion rels or
|
|
8386
|
+
* media names) never merge into one diagram part set. */
|
|
8387
|
+
function rawSmartArtFingerprint(raw) {
|
|
8388
|
+
if (!raw) return void 0;
|
|
8389
|
+
const b64 = (v) => v === void 0 ? void 0 : encodeBase64(toUint8Array(v));
|
|
8390
|
+
return JSON.stringify({
|
|
8391
|
+
data: b64(raw.data),
|
|
8392
|
+
layout: b64(raw.layout),
|
|
8393
|
+
style: b64(raw.style),
|
|
8394
|
+
color: b64(raw.color),
|
|
8395
|
+
dataRels: b64(raw.dataRels),
|
|
8396
|
+
media: raw.media?.map((m) => m.fileName)
|
|
8397
|
+
});
|
|
8398
|
+
}
|
|
8399
|
+
/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */
|
|
8400
|
+
function hashSmartArtData(options) {
|
|
8401
|
+
const data = JSON.stringify({
|
|
8402
|
+
nodes: options.nodes,
|
|
8403
|
+
layout: options.layout,
|
|
8404
|
+
style: options.style,
|
|
8405
|
+
color: options.color,
|
|
8406
|
+
raw: rawSmartArtFingerprint(options.raw)
|
|
8407
|
+
});
|
|
8408
|
+
let hash = 0;
|
|
8409
|
+
for (let i = 0; i < data.length; i++) {
|
|
8410
|
+
const char = data.charCodeAt(i);
|
|
8411
|
+
hash = (hash << 5) - hash + char | 0;
|
|
8412
|
+
}
|
|
8413
|
+
return Math.abs(hash);
|
|
8414
|
+
}
|
|
8537
8415
|
/**
|
|
8538
|
-
*
|
|
8539
|
-
*
|
|
8540
|
-
*
|
|
8541
|
-
* serialize paragraph/run content. Includes JSON child dispatch for all
|
|
8542
|
-
* ParagraphChild variants (picture, chart, hyperlink, etc.).
|
|
8543
|
-
*
|
|
8544
|
-
* Pure string concatenation — no intermediate object tree.
|
|
8416
|
+
* Stringify the drawing-family children of the JSON dispatch: picture, chart,
|
|
8417
|
+
* SmartArt, WPS shape, content part, and WPG group. Each registers its media
|
|
8418
|
+
* or part side effects, then emits the `<w:drawing>` run.
|
|
8545
8419
|
*
|
|
8546
|
-
*
|
|
8420
|
+
* Returns `undefined` when the child is not a drawing-family wrapper.
|
|
8547
8421
|
*/
|
|
8548
|
-
function
|
|
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
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8422
|
+
function stringifyDrawingChild(child, ctx) {
|
|
8423
|
+
if ("picture" in child) {
|
|
8424
|
+
const opts = child.picture;
|
|
8425
|
+
if (opts.type !== "svg" && opts.data === void 0 && opts.sourceUrl !== void 0) return wrapDrawingRun(drawingDesc.stringify({
|
|
8426
|
+
mediaData: {
|
|
8427
|
+
type: opts.type,
|
|
8428
|
+
sourceUrl: opts.sourceUrl,
|
|
8429
|
+
transformation: createTransformation(opts.transformation),
|
|
8430
|
+
sourceRectangle: opts.sourceRectangle,
|
|
8431
|
+
nonVisualProperties: opts.nonVisualProperties,
|
|
8432
|
+
useLocalDpi: opts.useLocalDpi,
|
|
8433
|
+
compression: opts.compression
|
|
8434
|
+
},
|
|
8435
|
+
docProperties: opts.altText,
|
|
8436
|
+
floating: opts.floating,
|
|
8437
|
+
outline: opts.outline,
|
|
8438
|
+
fill: opts.fill,
|
|
8439
|
+
effects: opts.effects,
|
|
8440
|
+
scene3d: opts.scene3d,
|
|
8441
|
+
shape3d: opts.shape3d,
|
|
8442
|
+
blipEffects: opts.blipEffects,
|
|
8443
|
+
tile: opts.tile,
|
|
8444
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8445
|
+
}, ctx), opts);
|
|
8446
|
+
const rawData = toUint8Array(opts.data, { encoding: "base64" });
|
|
8447
|
+
let mediaData;
|
|
8448
|
+
if (opts.type === "svg") {
|
|
8449
|
+
const fallbackData = toUint8Array(opts.fallback.data, { encoding: "base64" });
|
|
8450
|
+
const fallbackType = opts.fallback.type;
|
|
8451
|
+
const fallback = ctx.file.media.addMedia(fallbackData, fallbackType, (fileName) => ({
|
|
8452
|
+
type: fallbackType,
|
|
8453
|
+
data: fallbackData,
|
|
8454
|
+
fileName,
|
|
8455
|
+
transformation: {
|
|
8456
|
+
emus: {
|
|
8457
|
+
x: 0,
|
|
8458
|
+
y: 0
|
|
8459
|
+
},
|
|
8460
|
+
pixels: {
|
|
8461
|
+
x: 0,
|
|
8462
|
+
y: 0
|
|
8463
|
+
}
|
|
8464
|
+
}
|
|
8465
|
+
}), opts.fallback.fileName);
|
|
8466
|
+
mediaData = {
|
|
8467
|
+
...ctx.file.media.addMedia(rawData, "svg", (fileName) => ({
|
|
8468
|
+
type: "svg",
|
|
8469
|
+
data: rawData,
|
|
8470
|
+
fileName,
|
|
8471
|
+
fallback,
|
|
8472
|
+
transformation: {
|
|
8473
|
+
emus: {
|
|
8474
|
+
x: 0,
|
|
8475
|
+
y: 0
|
|
8476
|
+
},
|
|
8477
|
+
pixels: {
|
|
8478
|
+
x: 0,
|
|
8479
|
+
y: 0
|
|
8480
|
+
}
|
|
8481
|
+
}
|
|
8482
|
+
}), opts.fileName),
|
|
8483
|
+
fallback,
|
|
8484
|
+
transformation: createTransformation(opts.transformation),
|
|
8485
|
+
sourceRectangle: opts.sourceRectangle,
|
|
8486
|
+
nonVisualProperties: opts.nonVisualProperties,
|
|
8487
|
+
useLocalDpi: opts.useLocalDpi,
|
|
8488
|
+
compression: opts.compression
|
|
8489
|
+
};
|
|
8490
|
+
} else {
|
|
8491
|
+
const type = opts.type;
|
|
8492
|
+
mediaData = {
|
|
8493
|
+
...ctx.file.media.addMedia(rawData, type, (fileName) => ({
|
|
8494
|
+
type,
|
|
8495
|
+
data: rawData,
|
|
8496
|
+
fileName,
|
|
8497
|
+
transformation: {
|
|
8498
|
+
emus: {
|
|
8499
|
+
x: 0,
|
|
8500
|
+
y: 0
|
|
8501
|
+
},
|
|
8502
|
+
pixels: {
|
|
8503
|
+
x: 0,
|
|
8504
|
+
y: 0
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
}), opts.fileName),
|
|
8508
|
+
transformation: createTransformation(opts.transformation),
|
|
8509
|
+
sourceRectangle: opts.sourceRectangle,
|
|
8510
|
+
nonVisualProperties: opts.nonVisualProperties,
|
|
8511
|
+
useLocalDpi: opts.useLocalDpi,
|
|
8512
|
+
compression: opts.compression,
|
|
8513
|
+
sourceUrl: opts.sourceUrl
|
|
8514
|
+
};
|
|
8596
8515
|
}
|
|
8516
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8517
|
+
mediaData,
|
|
8518
|
+
docProperties: opts.altText,
|
|
8519
|
+
floating: opts.floating,
|
|
8520
|
+
outline: opts.outline,
|
|
8521
|
+
fill: opts.fill,
|
|
8522
|
+
effects: opts.effects,
|
|
8523
|
+
scene3d: opts.scene3d,
|
|
8524
|
+
shape3d: opts.shape3d,
|
|
8525
|
+
blipEffects: opts.blipEffects,
|
|
8526
|
+
tile: opts.tile,
|
|
8527
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8528
|
+
}, ctx), opts);
|
|
8597
8529
|
}
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
const
|
|
8608
|
-
const
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8530
|
+
if ("chart" in child) {
|
|
8531
|
+
const opts = child.chart;
|
|
8532
|
+
const chartKey = `chart_${nextChartId++}`;
|
|
8533
|
+
const mediaData = {
|
|
8534
|
+
chartKey,
|
|
8535
|
+
transformation: createTransformation(opts.transformation),
|
|
8536
|
+
type: "chart"
|
|
8537
|
+
};
|
|
8538
|
+
const { transformation: _t, floating: _f, altText: _a, graphicFrameLocks: _g, runProperties: _r, lastRenderedPageBreak: _l, ...chartSpace } = opts;
|
|
8539
|
+
const chartXml = chartSpaceDesc.stringify(chartSpace, ctx.file);
|
|
8540
|
+
const externalData = chartSpace.externalData;
|
|
8541
|
+
ctx.file.charts.addChart(chartKey, {
|
|
8542
|
+
key: chartKey,
|
|
8543
|
+
chartSpaceXml: chartXml ?? "",
|
|
8544
|
+
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
8545
|
+
relationshipId: externalData.relationshipId,
|
|
8546
|
+
fileName: externalData.fileName,
|
|
8547
|
+
data: externalData.data
|
|
8548
|
+
} } : {},
|
|
8549
|
+
...chartSpace.userShapes ? { userShapes: buildUserShapesData(chartSpace.userShapes) } : {}
|
|
8550
|
+
});
|
|
8551
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8552
|
+
mediaData,
|
|
8553
|
+
docProperties: opts.altText,
|
|
8554
|
+
floating: opts.floating,
|
|
8555
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8556
|
+
}, ctx), opts);
|
|
8614
8557
|
}
|
|
8615
|
-
if (
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8558
|
+
if ("smartArt" in child) {
|
|
8559
|
+
const opts = child.smartArt;
|
|
8560
|
+
const smartArtKey = `smartart_${hashSmartArtData(opts)}`;
|
|
8561
|
+
const mediaData = {
|
|
8562
|
+
smartArtKey,
|
|
8563
|
+
transformation: createTransformation(opts.transformation),
|
|
8564
|
+
type: "smartart"
|
|
8565
|
+
};
|
|
8566
|
+
const layoutId = typeof opts.layout === "object" ? definitionId(opts.layout) : opts.layout ?? "default";
|
|
8567
|
+
const styleId = typeof opts.style === "object" ? definitionId(opts.style) : opts.style ?? "simple1";
|
|
8568
|
+
const colorId = typeof opts.color === "object" ? definitionId(opts.color) : opts.color ?? "accent1_2";
|
|
8569
|
+
const dataModelXml = createDataModel(opts.nodes, layoutId, styleId, colorId);
|
|
8570
|
+
let remappedDataRels = opts.raw?.dataRels;
|
|
8571
|
+
if (opts.raw?.media) {
|
|
8572
|
+
const renames = /* @__PURE__ */ new Map();
|
|
8573
|
+
for (const m of opts.raw.media) {
|
|
8574
|
+
const data = toUint8Array(m.data);
|
|
8575
|
+
const type = imageTypeFromPath(m.fileName);
|
|
8576
|
+
const entry = ctx.file.media.addMedia(data, type, (fileName) => ({
|
|
8577
|
+
type,
|
|
8578
|
+
data,
|
|
8579
|
+
fileName,
|
|
8580
|
+
transformation: {
|
|
8581
|
+
emus: {
|
|
8582
|
+
x: 0,
|
|
8583
|
+
y: 0
|
|
8584
|
+
},
|
|
8585
|
+
pixels: {
|
|
8586
|
+
x: 0,
|
|
8587
|
+
y: 0
|
|
8588
|
+
}
|
|
8589
|
+
}
|
|
8590
|
+
}), m.fileName);
|
|
8591
|
+
if (entry.fileName !== m.fileName) renames.set(m.fileName, entry.fileName);
|
|
8649
8592
|
}
|
|
8650
|
-
|
|
8651
|
-
if (bareEnRef !== void 0) {
|
|
8652
|
-
const id = typeof bareEnRef === "number" ? bareEnRef : bareEnRef.id;
|
|
8653
|
-
const cmf = typeof bareEnRef === "object" && bareEnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8654
|
-
body += `<w:endnoteReference w:id="${id}"${cmf}/>`;
|
|
8655
|
-
continue;
|
|
8656
|
-
}
|
|
8657
|
-
let firstKey;
|
|
8658
|
-
for (const key in child) {
|
|
8659
|
-
firstKey = key;
|
|
8660
|
-
break;
|
|
8661
|
-
}
|
|
8662
|
-
const emptyXml = firstKey !== void 0 ? EMPTY_RUN_ELEMENTS[firstKey] : void 0;
|
|
8663
|
-
if (emptyXml) {
|
|
8664
|
-
body += emptyXml;
|
|
8665
|
-
continue;
|
|
8666
|
-
}
|
|
8667
|
-
if ("ruby" in child) {
|
|
8668
|
-
body += stringifyRuby(child.ruby, ctx);
|
|
8669
|
-
continue;
|
|
8670
|
-
}
|
|
8671
|
-
if ("object" in child) {
|
|
8672
|
-
body += objectDesc.stringify(child.object, ctx) ?? "";
|
|
8673
|
-
continue;
|
|
8674
|
-
}
|
|
8675
|
-
if ("pict" in child) {
|
|
8676
|
-
body += stringifyPict(child.pict, ctx);
|
|
8677
|
-
continue;
|
|
8678
|
-
}
|
|
8679
|
-
const jsonResult = stringifyChildDispatch(child, ctx);
|
|
8680
|
-
if (jsonResult !== void 0) body += Array.isArray(jsonResult) ? jsonResult.join("") : jsonResult;
|
|
8681
|
-
else if ("text" in child || "children" in child || "break" in child) body += stringifyRunInline(child, ctx);
|
|
8593
|
+
if (renames.size > 0 && remappedDataRels !== void 0) remappedDataRels = remapDataRelsTargets(remappedDataRels, renames);
|
|
8682
8594
|
}
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8595
|
+
ctx.file.smartArts.addSmartArt(smartArtKey, {
|
|
8596
|
+
dataModelXml,
|
|
8597
|
+
key: smartArtKey,
|
|
8598
|
+
layout: opts.layout ?? "default",
|
|
8599
|
+
style: opts.style ?? "simple1",
|
|
8600
|
+
color: opts.color ?? "accent1_2",
|
|
8601
|
+
...opts.raw || remappedDataRels !== void 0 ? { raw: {
|
|
8602
|
+
...opts.raw,
|
|
8603
|
+
dataRels: remappedDataRels
|
|
8604
|
+
} } : {}
|
|
8605
|
+
});
|
|
8606
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8607
|
+
mediaData,
|
|
8608
|
+
docProperties: opts.altText,
|
|
8609
|
+
floating: opts.floating,
|
|
8610
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8611
|
+
}, ctx), {
|
|
8612
|
+
runProperties: opts.runProperties,
|
|
8613
|
+
lastRenderedPageBreak: opts.lastRenderedPageBreak
|
|
8614
|
+
});
|
|
8615
|
+
}
|
|
8616
|
+
if ("wpsShape" in child) {
|
|
8617
|
+
const opts = child.wpsShape;
|
|
8618
|
+
const mediaData = {
|
|
8619
|
+
data: opts,
|
|
8620
|
+
transformation: createTransformation(opts.transformation),
|
|
8621
|
+
type: "wps"
|
|
8622
|
+
};
|
|
8623
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8624
|
+
mediaData,
|
|
8625
|
+
docProperties: opts.altText,
|
|
8626
|
+
floating: opts.floating,
|
|
8627
|
+
outline: opts.outline,
|
|
8628
|
+
fill: opts.fill,
|
|
8629
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8630
|
+
}, ctx), opts, registerVmlFallbackMedia(opts, ctx));
|
|
8631
|
+
}
|
|
8632
|
+
if ("contentPart" in child) return `<w:r><w:contentPart r:id="${child.contentPart.referenceId}"/></w:r>`;
|
|
8633
|
+
if ("wpgGroup" in child) {
|
|
8634
|
+
const opts = child.wpgGroup;
|
|
8635
|
+
const cloneChild = (c) => c.type === "wpg" ? {
|
|
8636
|
+
...c,
|
|
8637
|
+
children: c.children.map(cloneChild)
|
|
8638
|
+
} : c.type === "svg" ? {
|
|
8639
|
+
...c,
|
|
8640
|
+
fallback: { ...c.fallback }
|
|
8641
|
+
} : { ...c };
|
|
8642
|
+
const mediaData = {
|
|
8643
|
+
children: opts.children.map(cloneChild),
|
|
8644
|
+
transformation: createTransformation(opts.transformation),
|
|
8645
|
+
childOffsetX: opts.childOffsetX,
|
|
8646
|
+
childOffsetY: opts.childOffsetY,
|
|
8647
|
+
childExtentWidth: opts.childExtentWidth,
|
|
8648
|
+
childExtentHeight: opts.childExtentHeight,
|
|
8649
|
+
fill: opts.fill,
|
|
8650
|
+
effects: opts.effects,
|
|
8651
|
+
groupShapeLocks: opts.groupShapeLocks,
|
|
8652
|
+
type: "wpg"
|
|
8653
|
+
};
|
|
8654
|
+
const registerMedia = (children) => {
|
|
8655
|
+
for (const c of children) {
|
|
8656
|
+
if (c.type === "wps") continue;
|
|
8657
|
+
if (c.type === "wpg") {
|
|
8658
|
+
registerMedia(c.children);
|
|
8659
|
+
continue;
|
|
8660
|
+
}
|
|
8661
|
+
if (c.type === "chart") {
|
|
8662
|
+
if (c.chartOptions && !c.chartKey) {
|
|
8663
|
+
c.chartKey = `chart_${nextChartId++}`;
|
|
8664
|
+
const externalData = c.chartOptions.externalData;
|
|
8665
|
+
ctx.file.charts.addChart(c.chartKey, {
|
|
8666
|
+
key: c.chartKey,
|
|
8667
|
+
chartSpaceXml: chartSpaceDesc.stringify(c.chartOptions, ctx.file) ?? "",
|
|
8668
|
+
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
8669
|
+
relationshipId: externalData.relationshipId,
|
|
8670
|
+
fileName: externalData.fileName,
|
|
8671
|
+
data: externalData.data
|
|
8672
|
+
} } : {},
|
|
8673
|
+
...c.chartOptions.userShapes ? { userShapes: buildUserShapesData(c.chartOptions.userShapes) } : {}
|
|
8674
|
+
});
|
|
8675
|
+
}
|
|
8676
|
+
continue;
|
|
8677
|
+
}
|
|
8678
|
+
if (c.type === "contentPart") continue;
|
|
8679
|
+
if (c.type === "svg") {
|
|
8680
|
+
const fb = c.fallback;
|
|
8681
|
+
fb.fileName = ctx.file.media.addMedia(fb.data, fb.type, () => fb, fb.fileName).fileName;
|
|
8682
|
+
c.fileName = ctx.file.media.addMedia(c.data, "svg", () => c, c.fileName).fileName;
|
|
8683
|
+
continue;
|
|
8684
|
+
}
|
|
8685
|
+
c.fileName = ctx.file.media.addMedia(c.data, c.type, () => c, c.fileName).fileName;
|
|
8686
|
+
}
|
|
8687
|
+
};
|
|
8688
|
+
registerMedia(mediaData.children);
|
|
8689
|
+
return wrapDrawingRun(drawingDesc.stringify({
|
|
8690
|
+
mediaData,
|
|
8691
|
+
docProperties: opts.altText,
|
|
8692
|
+
floating: opts.floating,
|
|
8693
|
+
graphicFrameLocks: opts.graphicFrameLocks
|
|
8694
|
+
}, ctx), opts, registerVmlFallbackMedia(opts, ctx));
|
|
8695
|
+
}
|
|
8689
8696
|
}
|
|
8690
|
-
|
|
8697
|
+
//#endregion
|
|
8698
|
+
//#region src/parts/paragraph/run/field.ts
|
|
8691
8699
|
/**
|
|
8692
|
-
*
|
|
8700
|
+
* Field module for WordprocessingML documents.
|
|
8693
8701
|
*
|
|
8694
|
-
*
|
|
8695
|
-
*
|
|
8702
|
+
* This module provides support for complex fields, which are regions of text
|
|
8703
|
+
* that can contain dynamic content such as page numbers, dates, or mail merge fields.
|
|
8704
|
+
* Fields are delimited by field character elements (begin, separate, end).
|
|
8696
8705
|
*
|
|
8697
|
-
*
|
|
8706
|
+
* Reference: http://officeopenxml.com/WPrun.php
|
|
8707
|
+
*
|
|
8708
|
+
* @module
|
|
8698
8709
|
*/
|
|
8699
8710
|
/**
|
|
8700
|
-
*
|
|
8701
|
-
*
|
|
8702
|
-
*
|
|
8711
|
+
* Field character types that delimit field regions.
|
|
8712
|
+
*
|
|
8713
|
+
* @internal
|
|
8703
8714
|
*/
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
return `<w:r>${rPr}${lrpb}${xml}</w:r>`;
|
|
8710
|
-
}
|
|
8715
|
+
const FieldCharacterType = {
|
|
8716
|
+
BEGIN: "begin",
|
|
8717
|
+
END: "end",
|
|
8718
|
+
SEPARATE: "separate"
|
|
8719
|
+
};
|
|
8711
8720
|
/**
|
|
8712
|
-
*
|
|
8713
|
-
* compiler resolves the fallback's `{fileName}` placeholders into rIds.
|
|
8721
|
+
* Creates a field character element.
|
|
8714
8722
|
*
|
|
8715
|
-
*
|
|
8716
|
-
*
|
|
8717
|
-
*
|
|
8718
|
-
*
|
|
8723
|
+
* ## XSD Schema
|
|
8724
|
+
* ```xml
|
|
8725
|
+
* <xsd:complexType name="CT_FldChar">
|
|
8726
|
+
* <xsd:sequence>
|
|
8727
|
+
* <xsd:element name="fldData" type="CT_Text" minOccurs="0"/>
|
|
8728
|
+
* <xsd:element name="ffData" type="CT_FFData" minOccurs="0"/>
|
|
8729
|
+
* <xsd:element name="numberingChange" type="CT_TrackChangeNumbering" minOccurs="0"/>
|
|
8730
|
+
* </xsd:sequence>
|
|
8731
|
+
* <xsd:attribute name="fldCharType" type="ST_FldCharType" use="required"/>
|
|
8732
|
+
* <xsd:attribute name="fldLock" type="s:ST_OnOff"/>
|
|
8733
|
+
* <xsd:attribute name="dirty" type="s:ST_OnOff"/>
|
|
8734
|
+
* </xsd:complexType>
|
|
8735
|
+
* ```
|
|
8736
|
+
* @internal
|
|
8719
8737
|
*/
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
x: 0,
|
|
8731
|
-
y: 0
|
|
8732
|
-
},
|
|
8733
|
-
pixels: {
|
|
8734
|
-
x: 0,
|
|
8735
|
-
y: 0
|
|
8736
|
-
}
|
|
8737
|
-
}
|
|
8738
|
-
}), m.fileName);
|
|
8739
|
-
if (entry.fileName !== m.fileName && opts.vmlFallback) opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
8740
|
-
}
|
|
8741
|
-
}
|
|
8738
|
+
const createFieldChar = (type, dirty, ffData, fldData, fieldLock) => {
|
|
8739
|
+
const children = [];
|
|
8740
|
+
if (fldData !== void 0) children.push(element("w:fldData", { "xml:space": "preserve" }, [fldData]));
|
|
8741
|
+
if (ffData) children.push(ffData);
|
|
8742
|
+
return element("w:fldChar", {
|
|
8743
|
+
"w:dirty": dirty,
|
|
8744
|
+
"w:fldLock": fieldLock,
|
|
8745
|
+
"w:fldCharType": type
|
|
8746
|
+
}, children.length > 0 ? children : void 0);
|
|
8747
|
+
};
|
|
8742
8748
|
/**
|
|
8743
|
-
*
|
|
8749
|
+
* Creates the beginning of a complex field.
|
|
8750
|
+
*
|
|
8751
|
+
* The Begin element marks the start of a field. A field consists of a begin character,
|
|
8752
|
+
* field instructions, an optional separate character, field result, and an end character.
|
|
8753
|
+
*
|
|
8754
|
+
* For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.
|
|
8755
|
+
*
|
|
8756
|
+
* @param dirty - Whether the field should be recalculated
|
|
8757
|
+
* @param formField - Optional form field data to embed in the begin character
|
|
8758
|
+
*
|
|
8759
|
+
* @example
|
|
8760
|
+
* ```typescript
|
|
8761
|
+
* // Simple field begin
|
|
8762
|
+
* createBegin();
|
|
8763
|
+
*
|
|
8764
|
+
* // Form field (checkbox)
|
|
8765
|
+
* createBegin(false, {
|
|
8766
|
+
* name: "Check1",
|
|
8767
|
+
* checkBox: { checked: true, sizeAuto: true },
|
|
8768
|
+
* });
|
|
8769
|
+
* ```
|
|
8744
8770
|
*/
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
return
|
|
8771
|
+
const createBegin = (dirty, formField, fieldLock) => createFieldChar(FieldCharacterType.BEGIN, dirty, formField ? createFormFieldData(formField) : void 0, void 0, fieldLock);
|
|
8772
|
+
/**
|
|
8773
|
+
* Creates the separator between field code and field result in a complex field.
|
|
8774
|
+
*
|
|
8775
|
+
* The Separate element divides the field code (instructions) from the field result
|
|
8776
|
+
* (the computed value).
|
|
8777
|
+
*/
|
|
8778
|
+
const createSeparate = (dirty) => createFieldChar(FieldCharacterType.SEPARATE, dirty);
|
|
8779
|
+
/**
|
|
8780
|
+
* Creates the end of a complex field.
|
|
8781
|
+
*
|
|
8782
|
+
* The End element marks the end of a field. Every field that begins with a Begin
|
|
8783
|
+
* element must be terminated with an End element.
|
|
8784
|
+
*/
|
|
8785
|
+
const createEnd = (dirty) => createFieldChar(FieldCharacterType.END, dirty);
|
|
8786
|
+
//#endregion
|
|
8787
|
+
//#region src/parts/inline.ts
|
|
8788
|
+
/**
|
|
8789
|
+
* Shared inline run/paragraph stringification for DOCX descriptors.
|
|
8790
|
+
*
|
|
8791
|
+
* Used by table.ts, comments.ts, body.ts, and other descriptors that need to
|
|
8792
|
+
* serialize paragraph/run content. Includes JSON child dispatch for all
|
|
8793
|
+
* ParagraphChild variants (picture, chart, hyperlink, etc.).
|
|
8794
|
+
*
|
|
8795
|
+
* Pure string concatenation — no intermediate object tree.
|
|
8796
|
+
*
|
|
8797
|
+
* @module
|
|
8798
|
+
*/
|
|
8799
|
+
function stringifySymbolRunInner(opts) {
|
|
8800
|
+
return `<${opts.kind === "office2016" ? "w16se:sym" : "w:sym"} w:char="${escapeXml(opts.char)}" w:font="${escapeXml(opts.symbolFont ?? "Wingdings")}"/>`;
|
|
8801
|
+
}
|
|
8802
|
+
/** Serialize a complex field's run chain. Inside a w:del wrapper the
|
|
8803
|
+
* instruction is spelled w:delInstrText and the cached result w:delText. */
|
|
8804
|
+
function stringifyComplexFieldRuns(cf, isDelete = false) {
|
|
8805
|
+
const instrTag = isDelete ? "w:delInstrText" : "w:instrText";
|
|
8806
|
+
const textTag = isDelete ? "w:delText" : "w:t";
|
|
8807
|
+
const ctrl = cf.rPrXml ?? "";
|
|
8808
|
+
const res = cf.resultRPrXml ?? ctrl;
|
|
8809
|
+
const instrXml = cf.instrRunsXml ?? (cf.instruction !== "" ? `<w:r>${ctrl}<${instrTag} xml:space="preserve">${escapeXml(cf.instruction)}</${instrTag}></w:r>` : "");
|
|
8810
|
+
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>` : "";
|
|
8811
|
+
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>`;
|
|
8812
|
+
}
|
|
8813
|
+
/** Serialize a deleted run: rPr + delText (or field delInstrText). */
|
|
8814
|
+
function stringifyDeletedRun(c) {
|
|
8815
|
+
const opts = typeof c === "string" ? { text: c } : c;
|
|
8816
|
+
const parts = [];
|
|
8817
|
+
const rPr = stringifyRunProperties(opts);
|
|
8818
|
+
if (rPr) parts.push(rPr);
|
|
8819
|
+
if (opts.break) parts.push(breakXml(opts.break));
|
|
8820
|
+
let attr = "";
|
|
8821
|
+
if (opts.additionRsid) attr += ` w:rsidR="${opts.additionRsid}"`;
|
|
8822
|
+
if (opts.runPropertiesRsid) attr += ` w:rsidRPr="${opts.runPropertiesRsid}"`;
|
|
8823
|
+
if (opts.deletionRsid) attr += ` w:rsidDel="${opts.deletionRsid}"`;
|
|
8824
|
+
const openTag = attr ? `<w:r${attr}>` : "<w:r>";
|
|
8825
|
+
if (opts.children) {
|
|
8826
|
+
for (const cc of opts.children) if (typeof cc === "string") parts.push(`<w:delText xml:space="preserve">${escapeXml(cc)}</w:delText>`);
|
|
8827
|
+
else if (typeof cc === "object" && cc !== null && "commentReference" in cc) parts.push(`<w:commentReference w:id="${Number(cc.commentReference)}"/>`);
|
|
8828
|
+
else if (typeof cc === "object" && cc !== null && "break" in cc) parts.push(breakXml(cc.break));
|
|
8829
|
+
} else if (opts.text) parts.push(`<w:delText xml:space="preserve">${escapeXml(String(opts.text))}</w:delText>`);
|
|
8830
|
+
return `${openTag}${parts.join("")}</w:r>`;
|
|
8831
|
+
}
|
|
8832
|
+
function stringifyRubyContent(opts, ctx) {
|
|
8833
|
+
return opts.children?.map((child) => stringifyRunInline(typeof child === "string" ? { text: child } : child, ctx)).join("") ?? "";
|
|
8834
|
+
}
|
|
8835
|
+
function stringifyRuby(opts, ctx) {
|
|
8836
|
+
const properties = opts.properties;
|
|
8837
|
+
const dirty = properties.dirty !== void 0 ? onOff$2("w:dirty", properties.dirty) : "";
|
|
8838
|
+
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>`;
|
|
8839
|
+
}
|
|
8840
|
+
function stringifyRunInline(opts, ctx) {
|
|
8841
|
+
let body = "";
|
|
8842
|
+
let commentRefStyle = false;
|
|
8843
|
+
if (opts.children && !opts.style) {
|
|
8844
|
+
for (const child of opts.children) if (typeof child === "object" && child !== null && "commentReference" in child) {
|
|
8845
|
+
commentRefStyle = true;
|
|
8846
|
+
break;
|
|
8847
|
+
}
|
|
8848
|
+
}
|
|
8849
|
+
const rPr = stringifyRunProperties(commentRefStyle && !opts.style ? {
|
|
8850
|
+
...opts,
|
|
8851
|
+
style: "CommentReference"
|
|
8852
|
+
} : opts);
|
|
8853
|
+
if (rPr) body += rPr;
|
|
8854
|
+
if (opts.break) body += breakXml(opts.break);
|
|
8855
|
+
const fnRef = opts.footnoteReference;
|
|
8856
|
+
const enRef = opts.endnoteReference;
|
|
8857
|
+
if (fnRef !== void 0) {
|
|
8858
|
+
const id = typeof fnRef === "number" ? fnRef : fnRef.id;
|
|
8859
|
+
const cmf = typeof fnRef === "object" && fnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8860
|
+
body += `<w:footnoteReference w:id="${id}"${cmf}/>`;
|
|
8861
|
+
} else if (enRef !== void 0) {
|
|
8862
|
+
const id = typeof enRef === "number" ? enRef : enRef.id;
|
|
8863
|
+
const cmf = typeof enRef === "object" && enRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8864
|
+
body += `<w:endnoteReference w:id="${id}"${cmf}/>`;
|
|
8865
|
+
}
|
|
8866
|
+
if (opts.children) {
|
|
8867
|
+
for (const child of opts.children) if (typeof child === "string") body += `<w:t xml:space="preserve">${escapeXml(child)}</w:t>`;
|
|
8868
|
+
else if (typeof child === "object" && child !== null) {
|
|
8869
|
+
if ("tab" in child) {
|
|
8870
|
+
body += "<w:tab/>";
|
|
8871
|
+
continue;
|
|
8872
|
+
}
|
|
8873
|
+
if ("pageBreak" in child) {
|
|
8874
|
+
body += "<w:br w:type=\"page\"/>";
|
|
8875
|
+
continue;
|
|
8876
|
+
}
|
|
8877
|
+
if ("columnBreak" in child) {
|
|
8878
|
+
body += "<w:br w:type=\"column\"/>";
|
|
8879
|
+
continue;
|
|
8880
|
+
}
|
|
8881
|
+
if ("break" in child) {
|
|
8882
|
+
body += breakXml(child.break);
|
|
8883
|
+
continue;
|
|
8884
|
+
}
|
|
8885
|
+
if ("commentReference" in child) {
|
|
8886
|
+
body += `<w:commentReference w:id="${Number(child.commentReference)}"/>`;
|
|
8887
|
+
continue;
|
|
8888
|
+
}
|
|
8889
|
+
if ("symbolRun" in child) {
|
|
8890
|
+
const sym = child.symbolRun;
|
|
8891
|
+
body += `${stringifyRunProperties(sym) ?? ""}${stringifySymbolRunInner(sym)}`;
|
|
8892
|
+
continue;
|
|
8893
|
+
}
|
|
8894
|
+
const bareFnRef = child.footnoteReference;
|
|
8895
|
+
if (bareFnRef !== void 0) {
|
|
8896
|
+
const id = typeof bareFnRef === "number" ? bareFnRef : bareFnRef.id;
|
|
8897
|
+
const cmf = typeof bareFnRef === "object" && bareFnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8898
|
+
body += `<w:footnoteReference w:id="${id}"${cmf}/>`;
|
|
8899
|
+
continue;
|
|
8900
|
+
}
|
|
8901
|
+
const bareEnRef = child.endnoteReference;
|
|
8902
|
+
if (bareEnRef !== void 0) {
|
|
8903
|
+
const id = typeof bareEnRef === "number" ? bareEnRef : bareEnRef.id;
|
|
8904
|
+
const cmf = typeof bareEnRef === "object" && bareEnRef.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8905
|
+
body += `<w:endnoteReference w:id="${id}"${cmf}/>`;
|
|
8906
|
+
continue;
|
|
8907
|
+
}
|
|
8908
|
+
let firstKey;
|
|
8909
|
+
for (const key in child) {
|
|
8910
|
+
firstKey = key;
|
|
8911
|
+
break;
|
|
8912
|
+
}
|
|
8913
|
+
const emptyXml = firstKey !== void 0 ? EMPTY_RUN_ELEMENTS[firstKey] : void 0;
|
|
8914
|
+
if (emptyXml) {
|
|
8915
|
+
body += emptyXml;
|
|
8916
|
+
continue;
|
|
8917
|
+
}
|
|
8918
|
+
if ("ruby" in child) {
|
|
8919
|
+
body += stringifyRuby(child.ruby, ctx);
|
|
8920
|
+
continue;
|
|
8921
|
+
}
|
|
8922
|
+
if ("object" in child) {
|
|
8923
|
+
body += objectDesc.stringify(child.object, ctx) ?? "";
|
|
8924
|
+
continue;
|
|
8925
|
+
}
|
|
8926
|
+
if ("pict" in child) {
|
|
8927
|
+
body += stringifyPict(child.pict, ctx);
|
|
8928
|
+
continue;
|
|
8929
|
+
}
|
|
8930
|
+
const jsonResult = stringifyChildDispatch(child, ctx);
|
|
8931
|
+
if (jsonResult !== void 0) body += Array.isArray(jsonResult) ? jsonResult.join("") : jsonResult;
|
|
8932
|
+
else if ("text" in child || "children" in child || "break" in child) body += stringifyRunInline(child, ctx);
|
|
8933
|
+
}
|
|
8934
|
+
} else if (opts.text !== void 0) body += `<w:t xml:space="preserve">${escapeXml(String(opts.text))}</w:t>`;
|
|
8935
|
+
let attr = "";
|
|
8936
|
+
if (opts.additionRsid) attr += ` w:rsidR="${opts.additionRsid}"`;
|
|
8937
|
+
if (opts.runPropertiesRsid) attr += ` w:rsidRPr="${opts.runPropertiesRsid}"`;
|
|
8938
|
+
if (opts.deletionRsid) attr += ` w:rsidDel="${opts.deletionRsid}"`;
|
|
8939
|
+
return body.length === 0 ? attr ? `<w:r${attr}/>` : "<w:r/>" : `<w:r${attr}>${body}</w:r>`;
|
|
8940
|
+
}
|
|
8941
|
+
/**
|
|
8942
|
+
* Stringify a ParagraphChild into one or more XML strings.
|
|
8943
|
+
*
|
|
8944
|
+
* Handles side effects (media, chart, smartArt, relationship registration)
|
|
8945
|
+
* directly without creating temporary class instances.
|
|
8946
|
+
*
|
|
8947
|
+
* Returns `undefined` if the child is not a recognized JSON wrapper.
|
|
8948
|
+
*/
|
|
8949
|
+
/**
|
|
8950
|
+
* Build the rPr XML for a break/tab run from its structured run properties.
|
|
8951
|
+
*/
|
|
8952
|
+
/** Shared attribute string for CT_MarkupRange end markers (commentRange, move range end). */
|
|
8953
|
+
function buildMarkupRangeAttrs(m) {
|
|
8954
|
+
const a = [`w:id="${m.id}"`];
|
|
8955
|
+
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
8956
|
+
return a.join(" ");
|
|
8957
|
+
}
|
|
8958
|
+
/** Shared attribute string for w:bookmarkStart (CT_Bookmark). */
|
|
8959
|
+
function buildBookmarkStartAttrs(bs) {
|
|
8960
|
+
const a = [`w:id="${bs.id}"`, `w:name="${escapeXml(bs.name)}"`];
|
|
8961
|
+
if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml="${bs.displacedByCustomXml}"`);
|
|
8962
|
+
if (bs.colFirst !== void 0) a.push(`w:colFirst="${bs.colFirst}"`);
|
|
8963
|
+
if (bs.colLast !== void 0) a.push(`w:colLast="${bs.colLast}"`);
|
|
8964
|
+
return a.join(" ");
|
|
8965
|
+
}
|
|
8966
|
+
/** Shared attribute string for w:moveFromRangeStart / w:moveToRangeStart (CT_MoveBookmark). */
|
|
8967
|
+
function buildMoveRangeStartAttrs(m) {
|
|
8968
|
+
const a = [`w:id="${m.id}"`];
|
|
8969
|
+
if (m.name) a.push(`w:name="${escapeXml(m.name)}"`);
|
|
8970
|
+
if (m.author) a.push(`w:author="${escapeXml(m.author)}"`);
|
|
8971
|
+
if (m.date) a.push(`w:date="${m.date}"`);
|
|
8972
|
+
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
8973
|
+
if (m.colFirst !== void 0) a.push(`w:colFirst="${m.colFirst}"`);
|
|
8974
|
+
if (m.colLast !== void 0) a.push(`w:colLast="${m.colLast}"`);
|
|
8975
|
+
return a.join(" ");
|
|
8976
|
+
}
|
|
8977
|
+
/** Stringify inline run/text content — the `wrap` shared by every sugar child. */
|
|
8978
|
+
function stringifyInlineWrap(wrap, ctx) {
|
|
8979
|
+
const parts = [];
|
|
8980
|
+
for (const item of wrap ?? []) parts.push(typeof item === "string" ? stringifyRunInline({ text: item }, ctx) : stringifyRunInline(item, ctx));
|
|
8981
|
+
return parts.join("");
|
|
8775
8982
|
}
|
|
8776
8983
|
/**
|
|
8777
8984
|
* Serialize a break run inside a track-change wrapper. A parsed break run
|
|
@@ -8889,294 +9096,70 @@ function runPropertiesXml(child) {
|
|
|
8889
9096
|
/**
|
|
8890
9097
|
* The plain-run shape the dispatch text fast path claims: text set, with none
|
|
8891
9098
|
* of the variants that legally coexist with text and have their own dispatch
|
|
8892
|
-
* branch (references, the { text, hyperlink } shorthand). Callers that need
|
|
8893
|
-
* context-specific text spelling (w:delText inside a deletion wrapper) use
|
|
8894
|
-
* this to claim the shape before dispatch does.
|
|
8895
|
-
*/
|
|
8896
|
-
function isPlainTextRun(child) {
|
|
8897
|
-
const run = child;
|
|
8898
|
-
return "text" in child && run.text !== void 0 && run.footnoteReference === void 0 && run.endnoteReference === void 0 && !("commentReference" in child) && !("hyperlink" in child);
|
|
8899
|
-
}
|
|
8900
|
-
function stringifyChildDispatch(child, ctx) {
|
|
8901
|
-
if ("rawXml" in child) return child.rawXml;
|
|
8902
|
-
if (isPlainTextRun(child)) return stringifyRunInline(child, ctx);
|
|
8903
|
-
if ("pageBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="page"/></w:r>`;
|
|
8904
|
-
if ("columnBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="column"/></w:r>`;
|
|
8905
|
-
if ("tab" in child) return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;
|
|
8906
|
-
if ("subDoc" in child) return subDocDesc.stringify(child.subDoc, ctx) ?? "";
|
|
8907
|
-
const fnRefChild = child.footnoteReference;
|
|
8908
|
-
if (fnRefChild !== void 0) {
|
|
8909
|
-
const id = typeof fnRefChild === "number" ? fnRefChild : fnRefChild.id;
|
|
8910
|
-
const cmf = typeof fnRefChild === "object" && fnRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8911
|
-
const props = "properties" in child ? child.properties : void 0;
|
|
8912
|
-
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr>"}<w:footnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
8913
|
-
}
|
|
8914
|
-
const enRefChild = child.endnoteReference;
|
|
8915
|
-
if (enRefChild !== void 0) {
|
|
8916
|
-
const id = typeof enRefChild === "number" ? enRefChild : enRefChild.id;
|
|
8917
|
-
const cmf = typeof enRefChild === "object" && enRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
8918
|
-
const props = "properties" in child ? child.properties : void 0;
|
|
8919
|
-
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr>"}<w:endnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
8920
|
-
}
|
|
8921
|
-
if ("comment" in child) return stringifyCommentChild(child.comment, ctx);
|
|
8922
|
-
if ("commentRangeStart" in child) return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;
|
|
8923
|
-
if ("commentRangeEnd" in child) return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;
|
|
8924
|
-
if ("commentReference" in child) return `<w:r>${child.properties ? stringifyRunProperties(child.properties) ?? "" : ""}<w:commentReference w:id="${child.commentReference}"/></w:r>`;
|
|
8925
|
-
if ("bookmarkStart" in child) return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;
|
|
8926
|
-
if ("bookmarkEnd" in child) return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;
|
|
8927
|
-
if ("bookmark" in child) return stringifyBookmarkChild(child.bookmark, ctx);
|
|
8928
|
-
if ("symbolRun" in child) {
|
|
8929
|
-
const opts = child.symbolRun;
|
|
8930
|
-
return `<w:r>${stringifyRunProperties(opts) ?? ""}${stringifySymbolRunInner(opts)}</w:r>`;
|
|
8931
|
-
}
|
|
8932
|
-
if ("object" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${objectDesc.stringify(child.object, ctx)}</w:r>`;
|
|
8933
|
-
if ("pict" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${stringifyPict(child.pict, ctx)}</w:r>`;
|
|
8934
|
-
if ("formField" in child) {
|
|
8935
|
-
const ff = child.formField;
|
|
8936
|
-
let result = "";
|
|
8937
|
-
let instrCode = "";
|
|
8938
|
-
let symbolFont = false;
|
|
8939
|
-
if (ff.checkBox) {
|
|
8940
|
-
result = ff.checkBox.checked ? "☒" : "☐";
|
|
8941
|
-
instrCode = "FORMCHECKBOX";
|
|
8942
|
-
symbolFont = true;
|
|
8943
|
-
} else if (ff.dropDownList) {
|
|
8944
|
-
const idx = ff.dropDownList.result ?? ff.dropDownList.default;
|
|
8945
|
-
result = idx !== void 0 ? ff.dropDownList.entries[idx] ?? "" : "";
|
|
8946
|
-
instrCode = "FORMDROPDOWN";
|
|
8947
|
-
} else if (ff.textInput) {
|
|
8948
|
-
result = ff.textInput.value ?? ff.textInput.default ?? "";
|
|
8949
|
-
instrCode = "FORMTEXT";
|
|
8950
|
-
}
|
|
8951
|
-
const rPr = symbolFont ? "<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>" : "";
|
|
8952
|
-
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>`;
|
|
8953
|
-
}
|
|
8954
|
-
if ("picture" in child) {
|
|
8955
|
-
const opts = child.picture;
|
|
8956
|
-
if (opts.type !== "svg" && opts.data === void 0 && opts.sourceUrl !== void 0) return wrapDrawingRun(drawingDesc.stringify({
|
|
8957
|
-
mediaData: {
|
|
8958
|
-
type: opts.type,
|
|
8959
|
-
sourceUrl: opts.sourceUrl,
|
|
8960
|
-
transformation: createTransformation(opts.transformation),
|
|
8961
|
-
sourceRectangle: opts.sourceRectangle,
|
|
8962
|
-
nonVisualProperties: opts.nonVisualProperties,
|
|
8963
|
-
useLocalDpi: opts.useLocalDpi,
|
|
8964
|
-
compression: opts.compression
|
|
8965
|
-
},
|
|
8966
|
-
docProperties: opts.altText,
|
|
8967
|
-
floating: opts.floating,
|
|
8968
|
-
outline: opts.outline,
|
|
8969
|
-
fill: opts.fill,
|
|
8970
|
-
effects: opts.effects,
|
|
8971
|
-
scene3d: opts.scene3d,
|
|
8972
|
-
shape3d: opts.shape3d,
|
|
8973
|
-
blipEffects: opts.blipEffects,
|
|
8974
|
-
tile: opts.tile,
|
|
8975
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
8976
|
-
}, ctx), opts);
|
|
8977
|
-
const rawData = toUint8Array(opts.data, { encoding: "base64" });
|
|
8978
|
-
let mediaData;
|
|
8979
|
-
if (opts.type === "svg") {
|
|
8980
|
-
const fallbackData = toUint8Array(opts.fallback.data, { encoding: "base64" });
|
|
8981
|
-
const fallbackType = opts.fallback.type;
|
|
8982
|
-
const fallback = ctx.file.media.addMedia(fallbackData, fallbackType, (fileName) => ({
|
|
8983
|
-
type: fallbackType,
|
|
8984
|
-
...createPictureData(fallbackData, opts.transformation, fileName)
|
|
8985
|
-
}), opts.fallback.fileName);
|
|
8986
|
-
mediaData = ctx.file.media.addMedia(rawData, "svg", (fileName) => ({
|
|
8987
|
-
type: "svg",
|
|
8988
|
-
...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
8989
|
-
useLocalDpi: opts.useLocalDpi,
|
|
8990
|
-
compression: opts.compression,
|
|
8991
|
-
fallback
|
|
8992
|
-
}), opts.fileName);
|
|
8993
|
-
} else {
|
|
8994
|
-
const type = opts.type;
|
|
8995
|
-
mediaData = ctx.file.media.addMedia(rawData, type, (fileName) => ({
|
|
8996
|
-
type,
|
|
8997
|
-
...createPictureData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
8998
|
-
useLocalDpi: opts.useLocalDpi,
|
|
8999
|
-
compression: opts.compression,
|
|
9000
|
-
sourceUrl: opts.sourceUrl
|
|
9001
|
-
}), opts.fileName);
|
|
9002
|
-
}
|
|
9003
|
-
return wrapDrawingRun(drawingDesc.stringify({
|
|
9004
|
-
mediaData,
|
|
9005
|
-
docProperties: opts.altText,
|
|
9006
|
-
floating: opts.floating,
|
|
9007
|
-
outline: opts.outline,
|
|
9008
|
-
fill: opts.fill,
|
|
9009
|
-
effects: opts.effects,
|
|
9010
|
-
scene3d: opts.scene3d,
|
|
9011
|
-
shape3d: opts.shape3d,
|
|
9012
|
-
blipEffects: opts.blipEffects,
|
|
9013
|
-
tile: opts.tile,
|
|
9014
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9015
|
-
}, ctx), opts);
|
|
9016
|
-
}
|
|
9017
|
-
if ("chart" in child) {
|
|
9018
|
-
const opts = child.chart;
|
|
9019
|
-
const chartKey = `chart_${nextChartId++}`;
|
|
9020
|
-
const mediaData = {
|
|
9021
|
-
chartKey,
|
|
9022
|
-
transformation: createTransformation(opts.transformation),
|
|
9023
|
-
type: "chart"
|
|
9024
|
-
};
|
|
9025
|
-
const { transformation: _t, floating: _f, altText: _a, graphicFrameLocks: _g, runProperties: _r, lastRenderedPageBreak: _l, ...chartSpace } = opts;
|
|
9026
|
-
const chartXml = chartSpaceDesc.stringify(chartSpace, ctx.file);
|
|
9027
|
-
const externalData = chartSpace.externalData;
|
|
9028
|
-
ctx.file.charts.addChart(chartKey, {
|
|
9029
|
-
key: chartKey,
|
|
9030
|
-
chartSpaceXml: chartXml ?? "",
|
|
9031
|
-
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
9032
|
-
relationshipId: externalData.relationshipId,
|
|
9033
|
-
fileName: externalData.fileName,
|
|
9034
|
-
data: externalData.data
|
|
9035
|
-
} } : {},
|
|
9036
|
-
...chartSpace.userShapes ? { userShapes: buildUserShapesData(chartSpace.userShapes) } : {}
|
|
9037
|
-
});
|
|
9038
|
-
return wrapDrawingRun(drawingDesc.stringify({
|
|
9039
|
-
mediaData,
|
|
9040
|
-
docProperties: opts.altText,
|
|
9041
|
-
floating: opts.floating,
|
|
9042
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9043
|
-
}, ctx), opts);
|
|
9044
|
-
}
|
|
9045
|
-
if ("smartArt" in child) {
|
|
9046
|
-
const opts = child.smartArt;
|
|
9047
|
-
const smartArtKey = `smartart_${hashSmartArtData(opts)}`;
|
|
9048
|
-
const mediaData = {
|
|
9049
|
-
smartArtKey,
|
|
9050
|
-
transformation: createTransformation(opts.transformation),
|
|
9051
|
-
type: "smartart"
|
|
9052
|
-
};
|
|
9053
|
-
const layoutId = typeof opts.layout === "object" ? definitionId(opts.layout) : opts.layout ?? "default";
|
|
9054
|
-
const styleId = typeof opts.style === "object" ? definitionId(opts.style) : opts.style ?? "simple1";
|
|
9055
|
-
const colorId = typeof opts.color === "object" ? definitionId(opts.color) : opts.color ?? "accent1_2";
|
|
9056
|
-
const dataModelXml = createDataModel(opts.nodes, layoutId, styleId, colorId);
|
|
9057
|
-
let remappedDataRels = opts.raw?.dataRels;
|
|
9058
|
-
if (opts.raw?.media) {
|
|
9059
|
-
const renames = /* @__PURE__ */ new Map();
|
|
9060
|
-
for (const m of opts.raw.media) {
|
|
9061
|
-
const data = toUint8Array(m.data);
|
|
9062
|
-
const type = imageTypeFromPath(m.fileName);
|
|
9063
|
-
const entry = ctx.file.media.addMedia(data, type, (fileName) => ({
|
|
9064
|
-
type,
|
|
9065
|
-
data,
|
|
9066
|
-
fileName,
|
|
9067
|
-
transformation: {
|
|
9068
|
-
emus: {
|
|
9069
|
-
x: 0,
|
|
9070
|
-
y: 0
|
|
9071
|
-
},
|
|
9072
|
-
pixels: {
|
|
9073
|
-
x: 0,
|
|
9074
|
-
y: 0
|
|
9075
|
-
}
|
|
9076
|
-
}
|
|
9077
|
-
}), m.fileName);
|
|
9078
|
-
if (entry.fileName !== m.fileName) renames.set(m.fileName, entry.fileName);
|
|
9079
|
-
}
|
|
9080
|
-
if (renames.size > 0 && remappedDataRels !== void 0) remappedDataRels = remapDataRelsTargets(remappedDataRels, renames);
|
|
9081
|
-
}
|
|
9082
|
-
ctx.file.smartArts.addSmartArt(smartArtKey, {
|
|
9083
|
-
dataModelXml,
|
|
9084
|
-
key: smartArtKey,
|
|
9085
|
-
layout: opts.layout ?? "default",
|
|
9086
|
-
style: opts.style ?? "simple1",
|
|
9087
|
-
color: opts.color ?? "accent1_2",
|
|
9088
|
-
...opts.raw || remappedDataRels !== void 0 ? { raw: {
|
|
9089
|
-
...opts.raw,
|
|
9090
|
-
dataRels: remappedDataRels
|
|
9091
|
-
} } : {}
|
|
9092
|
-
});
|
|
9093
|
-
return wrapDrawingRun(drawingDesc.stringify({
|
|
9094
|
-
mediaData,
|
|
9095
|
-
docProperties: opts.altText,
|
|
9096
|
-
floating: opts.floating,
|
|
9097
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9098
|
-
}, ctx), {
|
|
9099
|
-
runProperties: opts.runProperties,
|
|
9100
|
-
lastRenderedPageBreak: opts.lastRenderedPageBreak
|
|
9101
|
-
});
|
|
9102
|
-
}
|
|
9103
|
-
if ("wpsShape" in child) {
|
|
9104
|
-
const opts = child.wpsShape;
|
|
9105
|
-
const mediaData = {
|
|
9106
|
-
data: opts,
|
|
9107
|
-
transformation: createTransformation(opts.transformation),
|
|
9108
|
-
type: "wps"
|
|
9109
|
-
};
|
|
9110
|
-
const drawingXml = drawingDesc.stringify({
|
|
9111
|
-
mediaData,
|
|
9112
|
-
docProperties: opts.altText,
|
|
9113
|
-
floating: opts.floating,
|
|
9114
|
-
outline: opts.outline,
|
|
9115
|
-
fill: opts.fill,
|
|
9116
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9117
|
-
}, ctx);
|
|
9118
|
-
registerVmlFallbackMedia(opts, ctx);
|
|
9119
|
-
return wrapDrawingRun(drawingXml, opts);
|
|
9120
|
-
}
|
|
9121
|
-
if ("contentPart" in child) return `<w:r><w:contentPart r:id="${child.contentPart.referenceId}"/></w:r>`;
|
|
9122
|
-
if ("wpgGroup" in child) {
|
|
9123
|
-
const opts = child.wpgGroup;
|
|
9124
|
-
const mediaData = {
|
|
9125
|
-
children: opts.children,
|
|
9126
|
-
transformation: createTransformation(opts.transformation),
|
|
9127
|
-
childOffsetX: opts.childOffsetX,
|
|
9128
|
-
childOffsetY: opts.childOffsetY,
|
|
9129
|
-
childExtentWidth: opts.childExtentWidth,
|
|
9130
|
-
childExtentHeight: opts.childExtentHeight,
|
|
9131
|
-
fill: opts.fill,
|
|
9132
|
-
effects: opts.effects,
|
|
9133
|
-
groupShapeLocks: opts.groupShapeLocks,
|
|
9134
|
-
type: "wpg"
|
|
9135
|
-
};
|
|
9136
|
-
const registerMedia = (children) => {
|
|
9137
|
-
for (const c of children) {
|
|
9138
|
-
if (c.type === "wps") continue;
|
|
9139
|
-
if (c.type === "wpg") {
|
|
9140
|
-
registerMedia(c.children);
|
|
9141
|
-
continue;
|
|
9142
|
-
}
|
|
9143
|
-
if (c.type === "chart") {
|
|
9144
|
-
if (c.chartOptions && !c.chartKey) {
|
|
9145
|
-
c.chartKey = `chart_${nextChartId++}`;
|
|
9146
|
-
const externalData = c.chartOptions.externalData;
|
|
9147
|
-
ctx.file.charts.addChart(c.chartKey, {
|
|
9148
|
-
key: c.chartKey,
|
|
9149
|
-
chartSpaceXml: chartSpaceDesc.stringify(c.chartOptions, ctx.file) ?? "",
|
|
9150
|
-
...externalData?.data !== void 0 && externalData.fileName ? { embedding: {
|
|
9151
|
-
relationshipId: externalData.relationshipId,
|
|
9152
|
-
fileName: externalData.fileName,
|
|
9153
|
-
data: externalData.data
|
|
9154
|
-
} } : {},
|
|
9155
|
-
...c.chartOptions.userShapes ? { userShapes: buildUserShapesData(c.chartOptions.userShapes) } : {}
|
|
9156
|
-
});
|
|
9157
|
-
}
|
|
9158
|
-
continue;
|
|
9159
|
-
}
|
|
9160
|
-
if (c.type === "contentPart") continue;
|
|
9161
|
-
if (c.type === "svg") {
|
|
9162
|
-
const fb = c.fallback;
|
|
9163
|
-
fb.fileName = ctx.file.media.addMedia(fb.data, fb.type, () => fb, fb.fileName).fileName;
|
|
9164
|
-
c.fileName = ctx.file.media.addMedia(c.data, "svg", () => c, c.fileName).fileName;
|
|
9165
|
-
continue;
|
|
9166
|
-
}
|
|
9167
|
-
c.fileName = ctx.file.media.addMedia(c.data, c.type, () => c, c.fileName).fileName;
|
|
9168
|
-
}
|
|
9169
|
-
};
|
|
9170
|
-
registerMedia(opts.children);
|
|
9171
|
-
const drawingXml = drawingDesc.stringify({
|
|
9172
|
-
mediaData,
|
|
9173
|
-
docProperties: opts.altText,
|
|
9174
|
-
floating: opts.floating,
|
|
9175
|
-
graphicFrameLocks: opts.graphicFrameLocks
|
|
9176
|
-
}, ctx);
|
|
9177
|
-
registerVmlFallbackMedia(opts, ctx);
|
|
9178
|
-
return wrapDrawingRun(drawingXml, opts);
|
|
9099
|
+
* branch (references, the { text, hyperlink } shorthand). Callers that need
|
|
9100
|
+
* context-specific text spelling (w:delText inside a deletion wrapper) use
|
|
9101
|
+
* this to claim the shape before dispatch does.
|
|
9102
|
+
*/
|
|
9103
|
+
function isPlainTextRun(child) {
|
|
9104
|
+
const run = child;
|
|
9105
|
+
return "text" in child && run.text !== void 0 && run.footnoteReference === void 0 && run.endnoteReference === void 0 && !("commentReference" in child) && !("hyperlink" in child);
|
|
9106
|
+
}
|
|
9107
|
+
function stringifyChildDispatch(child, ctx) {
|
|
9108
|
+
if ("rawXml" in child) return child.rawXml;
|
|
9109
|
+
if (isPlainTextRun(child)) return stringifyRunInline(child, ctx);
|
|
9110
|
+
if ("pageBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="page"/></w:r>`;
|
|
9111
|
+
if ("columnBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="column"/></w:r>`;
|
|
9112
|
+
if ("tab" in child) return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;
|
|
9113
|
+
if ("subDoc" in child) return subDocDesc.stringify(child.subDoc, ctx) ?? "";
|
|
9114
|
+
const fnRefChild = child.footnoteReference;
|
|
9115
|
+
if (fnRefChild !== void 0) {
|
|
9116
|
+
const id = typeof fnRefChild === "number" ? fnRefChild : fnRefChild.id;
|
|
9117
|
+
const cmf = typeof fnRefChild === "object" && fnRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
9118
|
+
const props = "properties" in child ? child.properties : void 0;
|
|
9119
|
+
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr>"}<w:footnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
9120
|
+
}
|
|
9121
|
+
const enRefChild = child.endnoteReference;
|
|
9122
|
+
if (enRefChild !== void 0) {
|
|
9123
|
+
const id = typeof enRefChild === "number" ? enRefChild : enRefChild.id;
|
|
9124
|
+
const cmf = typeof enRefChild === "object" && enRefChild.customMarkFollows ? " w:customMarkFollows=\"1\"" : "";
|
|
9125
|
+
const props = "properties" in child ? child.properties : void 0;
|
|
9126
|
+
return `<w:r>${props ? stringifyRunProperties(props) ?? "" : "<w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr>"}<w:endnoteReference w:id="${id}"${cmf}/></w:r>`;
|
|
9127
|
+
}
|
|
9128
|
+
if ("comment" in child) return stringifyCommentChild(child.comment, ctx);
|
|
9129
|
+
if ("commentRangeStart" in child) return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;
|
|
9130
|
+
if ("commentRangeEnd" in child) return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;
|
|
9131
|
+
if ("commentReference" in child) return `<w:r>${child.properties ? stringifyRunProperties(child.properties) ?? "" : ""}<w:commentReference w:id="${child.commentReference}"/></w:r>`;
|
|
9132
|
+
if ("bookmarkStart" in child) return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;
|
|
9133
|
+
if ("bookmarkEnd" in child) return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;
|
|
9134
|
+
if ("bookmark" in child) return stringifyBookmarkChild(child.bookmark, ctx);
|
|
9135
|
+
if ("symbolRun" in child) {
|
|
9136
|
+
const opts = child.symbolRun;
|
|
9137
|
+
return `<w:r>${stringifyRunProperties(opts) ?? ""}${stringifySymbolRunInner(opts)}</w:r>`;
|
|
9138
|
+
}
|
|
9139
|
+
if ("object" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${objectDesc.stringify(child.object, ctx)}</w:r>`;
|
|
9140
|
+
if ("pict" in child) return `<w:r>${stringifyRunProperties(child) ?? ""}${stringifyPict(child.pict, ctx)}</w:r>`;
|
|
9141
|
+
if ("formField" in child) {
|
|
9142
|
+
const ff = child.formField;
|
|
9143
|
+
let result = "";
|
|
9144
|
+
let instrCode = "";
|
|
9145
|
+
let symbolFont = false;
|
|
9146
|
+
if (ff.checkBox) {
|
|
9147
|
+
result = ff.checkBox.checked ? "☒" : "☐";
|
|
9148
|
+
instrCode = "FORMCHECKBOX";
|
|
9149
|
+
symbolFont = true;
|
|
9150
|
+
} else if (ff.dropDownList) {
|
|
9151
|
+
const idx = ff.dropDownList.result ?? ff.dropDownList.default;
|
|
9152
|
+
result = idx !== void 0 ? ff.dropDownList.entries[idx] ?? "" : "";
|
|
9153
|
+
instrCode = "FORMDROPDOWN";
|
|
9154
|
+
} else if (ff.textInput) {
|
|
9155
|
+
result = ff.textInput.value ?? ff.textInput.default ?? "";
|
|
9156
|
+
instrCode = "FORMTEXT";
|
|
9157
|
+
}
|
|
9158
|
+
const rPr = symbolFont ? "<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>" : "";
|
|
9159
|
+
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>`;
|
|
9179
9160
|
}
|
|
9161
|
+
const drawingXml = stringifyDrawingChild(child, ctx);
|
|
9162
|
+
if (drawingXml !== void 0) return drawingXml;
|
|
9180
9163
|
if ("math" in child && typeof child.math === "object" && child.math !== null) {
|
|
9181
9164
|
const mathOpts = child.math;
|
|
9182
9165
|
const children = mathOpts.children ?? [];
|
|
@@ -9210,7 +9193,8 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
9210
9193
|
if (hl.docLocation) attrs.push(`w:docLocation="${escapeXml(hl.docLocation)}"`);
|
|
9211
9194
|
};
|
|
9212
9195
|
if (hl.url) {
|
|
9213
|
-
const
|
|
9196
|
+
const relType = RELATIONSHIP_TYPES.hyperlink;
|
|
9197
|
+
const attrs = [`r:id="${`rId${ctx.viewWrapper.relationships.add(relType, hl.url, TargetModeType.EXTERNAL)}`}"`];
|
|
9214
9198
|
pushHlAttrs(attrs);
|
|
9215
9199
|
return `<w:hyperlink ${attrs.join(" ")}>${body}</w:hyperlink>`;
|
|
9216
9200
|
}
|
|
@@ -9362,59 +9346,6 @@ function serializeDispatchChildren(children, ctx) {
|
|
|
9362
9346
|
}
|
|
9363
9347
|
return body;
|
|
9364
9348
|
}
|
|
9365
|
-
/** Rewrite ../media targets inside verbatim data rels after the media
|
|
9366
|
-
* collection re-allocated pinned names. All renames apply in one pass over
|
|
9367
|
-
* the original text, each match bounded by its closing quote, so a name
|
|
9368
|
-
* that prefixes another cannot collide and chained renames cannot re-hit
|
|
9369
|
-
* an already-rewritten target. Preserves the input form (string stays
|
|
9370
|
-
* string, bytes stay bytes). */
|
|
9371
|
-
function remapDataRelsTargets(rels, renames) {
|
|
9372
|
-
const isText = typeof rels === "string";
|
|
9373
|
-
const text = isText ? rels : new TextDecoder().decode(toUint8Array(rels));
|
|
9374
|
-
let out = "";
|
|
9375
|
-
let last = 0;
|
|
9376
|
-
for (const m of text.matchAll(/\.\.\/media\/([^"']*)["']/g)) {
|
|
9377
|
-
const name = m[1] ?? "";
|
|
9378
|
-
const to = renames.get(name);
|
|
9379
|
-
if (to === void 0) continue;
|
|
9380
|
-
const start = (m.index ?? 0) + 9;
|
|
9381
|
-
out += text.slice(last, start) + to;
|
|
9382
|
-
last = start + name.length;
|
|
9383
|
-
}
|
|
9384
|
-
out += text.slice(last);
|
|
9385
|
-
return isText ? out : new TextEncoder().encode(out);
|
|
9386
|
-
}
|
|
9387
|
-
/** Content fingerprint of the raw source parts: every field participates so
|
|
9388
|
-
* two instances that differ in any raw part (or in their companion rels or
|
|
9389
|
-
* media names) never merge into one diagram part set. */
|
|
9390
|
-
function rawSmartArtFingerprint(raw) {
|
|
9391
|
-
if (!raw) return void 0;
|
|
9392
|
-
const b64 = (v) => v === void 0 ? void 0 : encodeBase64(toUint8Array(v));
|
|
9393
|
-
return JSON.stringify({
|
|
9394
|
-
data: b64(raw.data),
|
|
9395
|
-
layout: b64(raw.layout),
|
|
9396
|
-
style: b64(raw.style),
|
|
9397
|
-
color: b64(raw.color),
|
|
9398
|
-
dataRels: b64(raw.dataRels),
|
|
9399
|
-
media: raw.media?.map((m) => m.fileName)
|
|
9400
|
-
});
|
|
9401
|
-
}
|
|
9402
|
-
/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */
|
|
9403
|
-
function hashSmartArtData(options) {
|
|
9404
|
-
const data = JSON.stringify({
|
|
9405
|
-
nodes: options.nodes,
|
|
9406
|
-
layout: options.layout,
|
|
9407
|
-
style: options.style,
|
|
9408
|
-
color: options.color,
|
|
9409
|
-
raw: rawSmartArtFingerprint(options.raw)
|
|
9410
|
-
});
|
|
9411
|
-
let hash = 0;
|
|
9412
|
-
for (let i = 0; i < data.length; i++) {
|
|
9413
|
-
const char = data.charCodeAt(i);
|
|
9414
|
-
hash = (hash << 5) - hash + char | 0;
|
|
9415
|
-
}
|
|
9416
|
-
return Math.abs(hash);
|
|
9417
|
-
}
|
|
9418
9349
|
function stringifyParagraphInline(opts, ctx) {
|
|
9419
9350
|
const resolved = typeof opts === "string" ? { text: opts } : opts;
|
|
9420
9351
|
let body = "";
|
|
@@ -11609,11 +11540,14 @@ function headingOverride(options, level) {
|
|
|
11609
11540
|
}
|
|
11610
11541
|
/** Word's default `<w:rPrDefault>` — theme fonts, kern, 11pt, ligatures. Injected
|
|
11611
11542
|
* for fresh documents (no structured docDefaults provided) to mirror Word's
|
|
11612
|
-
* Normal.dotx
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11543
|
+
* Normal.dotx; `language` stands in for Word's editing language (default: an
|
|
11544
|
+
* en-US install writes `<w:lang w:val="en-US"/>`). On round-trip the structured
|
|
11545
|
+
* form is used instead. */
|
|
11546
|
+
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>";
|
|
11547
|
+
/** Word's default `<w:pPrDefault>` — 8pt after / 1.16 line. widowControl is not
|
|
11548
|
+
* written: ECMA-376 defaults it to on, matching Word's template bytes. Injected
|
|
11549
|
+
* for fresh documents only. */
|
|
11550
|
+
const WORD_DEFAULT_PPR_DEFAULT = "<w:pPrDefault><w:pPr><w:spacing w:after=\"160\" w:line=\"278\" w:lineRule=\"auto\"/></w:pPr></w:pPrDefault>";
|
|
11617
11551
|
/**
|
|
11618
11552
|
* Build `<w:docDefaults>` XML from a structured {@link DocumentDefaultsOptions}.
|
|
11619
11553
|
*
|
|
@@ -11627,13 +11561,13 @@ const WORD_DEFAULT_PPR_DEFAULT = "<w:pPrDefault><w:pPr><w:widowControl/><w:spaci
|
|
|
11627
11561
|
* mirror Word's Normal.dotx; on round-trip we omit the element
|
|
11628
11562
|
* to preserve the source's "this default category is absent".
|
|
11629
11563
|
*/
|
|
11630
|
-
function stringifyDocDefaults(opts, injectDefaults = true) {
|
|
11564
|
+
function stringifyDocDefaults(opts, injectDefaults = true, language) {
|
|
11631
11565
|
const children = [];
|
|
11632
11566
|
if (opts.run) {
|
|
11633
11567
|
const rPr = stringifyRunProperties(opts.run);
|
|
11634
11568
|
children.push(rPr ? `<w:rPrDefault>${rPr}</w:rPrDefault>` : `<w:rPrDefault/>`);
|
|
11635
11569
|
} else if (opts.run === null) children.push(`<w:rPrDefault/>`);
|
|
11636
|
-
else if (injectDefaults) children.push(
|
|
11570
|
+
else if (injectDefaults) children.push(wordDefaultRprDefault(language));
|
|
11637
11571
|
if (opts.paragraph) {
|
|
11638
11572
|
const pPr = stringifyParagraphProperties(opts.paragraph).xml;
|
|
11639
11573
|
children.push(pPr ? `<w:pPrDefault>${pPr}</w:pPrDefault>` : `<w:pPrDefault/>`);
|
|
@@ -11672,7 +11606,7 @@ var DefaultStylesFactory = class {
|
|
|
11672
11606
|
]),
|
|
11673
11607
|
"mc:Ignorable": "w14 w15"
|
|
11674
11608
|
};
|
|
11675
|
-
importedStyles.push(stringifyDocDefaults(options.document ?? {}));
|
|
11609
|
+
importedStyles.push(stringifyDocDefaults(options.document ?? {}, true, options.language));
|
|
11676
11610
|
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>");
|
|
11677
11611
|
paragraphStyles.push({
|
|
11678
11612
|
id: "Normal",
|
|
@@ -11685,7 +11619,7 @@ var DefaultStylesFactory = class {
|
|
|
11685
11619
|
id: "Heading1",
|
|
11686
11620
|
name: "heading 1",
|
|
11687
11621
|
link: "Heading1Char",
|
|
11688
|
-
sz:
|
|
11622
|
+
sz: 24,
|
|
11689
11623
|
before: 480,
|
|
11690
11624
|
after: 80,
|
|
11691
11625
|
outlineLvl: 0
|
|
@@ -11694,7 +11628,7 @@ var DefaultStylesFactory = class {
|
|
|
11694
11628
|
id: "Heading2",
|
|
11695
11629
|
name: "heading 2",
|
|
11696
11630
|
link: "Heading2Char",
|
|
11697
|
-
sz:
|
|
11631
|
+
sz: 20,
|
|
11698
11632
|
before: 160,
|
|
11699
11633
|
after: 80,
|
|
11700
11634
|
outlineLvl: 1
|
|
@@ -11703,7 +11637,7 @@ var DefaultStylesFactory = class {
|
|
|
11703
11637
|
id: "Heading3",
|
|
11704
11638
|
name: "heading 3",
|
|
11705
11639
|
link: "Heading3Char",
|
|
11706
|
-
sz:
|
|
11640
|
+
sz: 16,
|
|
11707
11641
|
before: 160,
|
|
11708
11642
|
after: 80,
|
|
11709
11643
|
outlineLvl: 2
|
|
@@ -11712,7 +11646,7 @@ var DefaultStylesFactory = class {
|
|
|
11712
11646
|
id: "Heading4",
|
|
11713
11647
|
name: "heading 4",
|
|
11714
11648
|
link: "Heading4Char",
|
|
11715
|
-
sz:
|
|
11649
|
+
sz: 14,
|
|
11716
11650
|
before: 80,
|
|
11717
11651
|
after: 40,
|
|
11718
11652
|
outlineLvl: 3
|
|
@@ -11721,7 +11655,7 @@ var DefaultStylesFactory = class {
|
|
|
11721
11655
|
id: "Heading5",
|
|
11722
11656
|
name: "heading 5",
|
|
11723
11657
|
link: "Heading5Char",
|
|
11724
|
-
sz:
|
|
11658
|
+
sz: 12,
|
|
11725
11659
|
before: 80,
|
|
11726
11660
|
after: 40,
|
|
11727
11661
|
outlineLvl: 4
|
|
@@ -11813,9 +11747,8 @@ var DefaultStylesFactory = class {
|
|
|
11813
11747
|
}
|
|
11814
11748
|
};
|
|
11815
11749
|
if (h.sz) {
|
|
11816
|
-
|
|
11817
|
-
runProps.
|
|
11818
|
-
runProps.sizeComplexScript = sizePt;
|
|
11750
|
+
runProps.size = h.sz;
|
|
11751
|
+
runProps.sizeComplexScript = h.sz;
|
|
11819
11752
|
}
|
|
11820
11753
|
if (outlineLvl >= 5) {
|
|
11821
11754
|
runProps.bold = true;
|
|
@@ -12202,7 +12135,7 @@ var DefaultStylesFactory = class {
|
|
|
12202
12135
|
line: 240,
|
|
12203
12136
|
lineRule: "auto"
|
|
12204
12137
|
} },
|
|
12205
|
-
run: { size:
|
|
12138
|
+
run: { size: 10 },
|
|
12206
12139
|
...options.footnoteText
|
|
12207
12140
|
});
|
|
12208
12141
|
characterStyles.push({
|
|
@@ -12211,7 +12144,7 @@ var DefaultStylesFactory = class {
|
|
|
12211
12144
|
basedOn: "DefaultParagraphFont",
|
|
12212
12145
|
link: "FootnoteText",
|
|
12213
12146
|
semiHidden: true,
|
|
12214
|
-
run: { size:
|
|
12147
|
+
run: { size: 10 },
|
|
12215
12148
|
...options.footnoteTextChar
|
|
12216
12149
|
});
|
|
12217
12150
|
characterStyles.push({
|
|
@@ -12236,7 +12169,7 @@ var DefaultStylesFactory = class {
|
|
|
12236
12169
|
line: 240,
|
|
12237
12170
|
lineRule: "auto"
|
|
12238
12171
|
} },
|
|
12239
|
-
run: { size:
|
|
12172
|
+
run: { size: 10 },
|
|
12240
12173
|
...options.endnoteText
|
|
12241
12174
|
});
|
|
12242
12175
|
characterStyles.push({
|
|
@@ -12245,7 +12178,7 @@ var DefaultStylesFactory = class {
|
|
|
12245
12178
|
basedOn: "DefaultParagraphFont",
|
|
12246
12179
|
link: "EndnoteText",
|
|
12247
12180
|
semiHidden: true,
|
|
12248
|
-
run: { size:
|
|
12181
|
+
run: { size: 10 },
|
|
12249
12182
|
...options.endnoteTextChar
|
|
12250
12183
|
});
|
|
12251
12184
|
characterStyles.push({
|
|
@@ -13238,71 +13171,7 @@ const FRESH_COMPATIBILITY = {
|
|
|
13238
13171
|
};
|
|
13239
13172
|
function stringifyCompatibility(opts) {
|
|
13240
13173
|
const p = [];
|
|
13241
|
-
if (opts
|
|
13242
|
-
if (opts.wordPerfectJustification) p.push(onOff("w:wpJustification", true));
|
|
13243
|
-
if (opts.noTabStopForHangingIndent) p.push(onOff("w:noTabHangInd", true));
|
|
13244
|
-
if (opts.noLeading) p.push(onOff("w:noLeading", true));
|
|
13245
|
-
if (opts.spaceForUnderline) p.push(onOff("w:spaceForUL", true));
|
|
13246
|
-
if (opts.noColumnBalance) p.push(onOff("w:noColumnBalance", true));
|
|
13247
|
-
if (opts.balanceSingleByteDoubleByteWidth) p.push(onOff("w:balanceSingleByteDoubleByteWidth", true));
|
|
13248
|
-
if (opts.noExtraLineSpacing) p.push(onOff("w:noExtraLineSpacing", true));
|
|
13249
|
-
if (opts.doNotLeaveBackslashAlone) p.push(onOff("w:doNotLeaveBackslashAlone", true));
|
|
13250
|
-
if (opts.underlineTrailingSpaces) p.push(onOff("w:ulTrailSpace", true));
|
|
13251
|
-
if (opts.doNotExpandShiftReturn) p.push(onOff("w:doNotExpandShiftReturn", true));
|
|
13252
|
-
if (opts.spacingInWholePoints) p.push(onOff("w:spacingInWholePoints", true));
|
|
13253
|
-
if (opts.lineWrapLikeWord6) p.push(onOff("w:lineWrapLikeWord6", true));
|
|
13254
|
-
if (opts.printBodyTextBeforeHeader) p.push(onOff("w:printBodyTextBeforeHeader", true));
|
|
13255
|
-
if (opts.printColorsBlack) p.push(onOff("w:printColBlack", true));
|
|
13256
|
-
if (opts.spaceWidth) p.push(onOff("w:wpSpaceWidth", true));
|
|
13257
|
-
if (opts.showBreaksInFrames) p.push(onOff("w:showBreaksInFrames", true));
|
|
13258
|
-
if (opts.subFontBySize) p.push(onOff("w:subFontBySize", true));
|
|
13259
|
-
if (opts.suppressBottomSpacing) p.push(onOff("w:suppressBottomSpacing", true));
|
|
13260
|
-
if (opts.suppressTopSpacing) p.push(onOff("w:suppressTopSpacing", true));
|
|
13261
|
-
if (opts.suppressSpacingAtTopOfPage) p.push(onOff("w:suppressSpacingAtTopOfPage", true));
|
|
13262
|
-
if (opts.suppressTopSpacingWP) p.push(onOff("w:suppressTopSpacingWP", true));
|
|
13263
|
-
if (opts.suppressSpBfAfterPgBrk) p.push(onOff("w:suppressSpBfAfterPgBrk", true));
|
|
13264
|
-
if (opts.swapBordersFacingPages) p.push(onOff("w:swapBordersFacingPages", true));
|
|
13265
|
-
if (opts.convertMailMergeEsc) p.push(onOff("w:convMailMergeEsc", true));
|
|
13266
|
-
if (opts.truncateFontHeightsLikeWP6) p.push(onOff("w:truncateFontHeightsLikeWP6", true));
|
|
13267
|
-
if (opts.macWordSmallCaps) p.push(onOff("w:mwSmallCaps", true));
|
|
13268
|
-
if (opts.usePrinterMetrics) p.push(onOff("w:usePrinterMetrics", true));
|
|
13269
|
-
if (opts.doNotSuppressParagraphBorders) p.push(onOff("w:doNotSuppressParagraphBorders", true));
|
|
13270
|
-
if (opts.wrapTrailSpaces) p.push(onOff("w:wrapTrailSpaces", true));
|
|
13271
|
-
if (opts.footnoteLayoutLikeWW8) p.push(onOff("w:footnoteLayoutLikeWW8", true));
|
|
13272
|
-
if (opts.shapeLayoutLikeWW8) p.push(onOff("w:shapeLayoutLikeWW8", true));
|
|
13273
|
-
if (opts.alignTablesRowByRow) p.push(onOff("w:alignTablesRowByRow", true));
|
|
13274
|
-
if (opts.forgetLastTabAlignment) p.push(onOff("w:forgetLastTabAlignment", true));
|
|
13275
|
-
if (opts.adjustLineHeightInTable) p.push(onOff("w:adjustLineHeightInTable", true));
|
|
13276
|
-
if (opts.autoSpaceLikeWord95) p.push(onOff("w:autoSpaceLikeWord95", true));
|
|
13277
|
-
if (opts.noSpaceRaiseLower) p.push(onOff("w:noSpaceRaiseLower", true));
|
|
13278
|
-
if (opts.doNotUseHTMLParagraphAutoSpacing) p.push(onOff("w:doNotUseHTMLParagraphAutoSpacing", true));
|
|
13279
|
-
if (opts.layoutRawTableWidth) p.push(onOff("w:layoutRawTableWidth", true));
|
|
13280
|
-
if (opts.layoutTableRowsApart) p.push(onOff("w:layoutTableRowsApart", true));
|
|
13281
|
-
if (opts.useWord97LineBreakRules) p.push(onOff("w:useWord97LineBreakRules", true));
|
|
13282
|
-
if (opts.doNotBreakWrappedTables) p.push(onOff("w:doNotBreakWrappedTables", true));
|
|
13283
|
-
if (opts.doNotSnapToGridInCell) p.push(onOff("w:doNotSnapToGridInCell", true));
|
|
13284
|
-
if (opts.selectFieldWithFirstOrLastCharacter) p.push(onOff("w:selectFldWithFirstOrLastChar", true));
|
|
13285
|
-
if (opts.applyBreakingRules) p.push(onOff("w:applyBreakingRules", true));
|
|
13286
|
-
if (opts.doNotWrapTextWithPunctuation) p.push(onOff("w:doNotWrapTextWithPunct", true));
|
|
13287
|
-
if (opts.doNotUseEastAsianBreakRules) p.push(onOff("w:doNotUseEastAsianBreakRules", true));
|
|
13288
|
-
if (opts.useWord2002TableStyleRules) p.push(onOff("w:useWord2002TableStyleRules", true));
|
|
13289
|
-
if (opts.growAutofit) p.push(onOff("w:growAutofit", true));
|
|
13290
|
-
if (opts.useFELayout) p.push(onOff("w:useFELayout", true));
|
|
13291
|
-
if (opts.useNormalStyleForList) p.push(onOff("w:useNormalStyleForList", true));
|
|
13292
|
-
if (opts.doNotUseIndentAsNumberingTabStop) p.push(onOff("w:doNotUseIndentAsNumberingTabStop", true));
|
|
13293
|
-
if (opts.useAlternateEastAsianLineBreakRules) p.push(onOff("w:useAltKinsokuLineBreakRules", true));
|
|
13294
|
-
if (opts.allowSpaceOfSameStyleInTable) p.push(onOff("w:allowSpaceOfSameStyleInTable", true));
|
|
13295
|
-
if (opts.doNotSuppressIndentation) p.push(onOff("w:doNotSuppressIndentation", true));
|
|
13296
|
-
if (opts.doNotAutofitConstrainedTables) p.push(onOff("w:doNotAutofitConstrainedTables", true));
|
|
13297
|
-
if (opts.autofitToFirstFixedWidthCell) p.push(onOff("w:autofitToFirstFixedWidthCell", true));
|
|
13298
|
-
if (opts.underlineTabInNumberingList) p.push(onOff("w:underlineTabInNumList", true));
|
|
13299
|
-
if (opts.displayHangulFixedWidth) p.push(onOff("w:displayHangulFixedWidth", true));
|
|
13300
|
-
if (opts.splitPgBreakAndParaMark) p.push(onOff("w:splitPgBreakAndParaMark", true));
|
|
13301
|
-
if (opts.doNotVerticallyAlignCellWithSp) p.push(onOff("w:doNotVertAlignCellWithSp", true));
|
|
13302
|
-
if (opts.doNotBreakConstrainedForcedTable) p.push(onOff("w:doNotBreakConstrainedForcedTable", true));
|
|
13303
|
-
if (opts.ignoreVerticalAlignmentInTextboxes) p.push(onOff("w:doNotVertAlignInTxbx", true));
|
|
13304
|
-
if (opts.useAnsiKerningPairs) p.push(onOff("w:useAnsiKerningPairs", true));
|
|
13305
|
-
if (opts.cachedColumnBalance) p.push(onOff("w:cachedColBalance", true));
|
|
13174
|
+
for (const [key, tag] of COMPAT_FLAG_MAP) if (opts[key]) p.push(onOff(tag, true));
|
|
13306
13175
|
if (opts.enableOpenTypeKerning) p.push("<w14:enableOpenTypeKerning/>");
|
|
13307
13176
|
if (opts.version) p.push(compatSetting("compatibilityMode", opts.version));
|
|
13308
13177
|
if (opts.overrideTableStyleFontSizeAndJustification) p.push(compatSetting("overrideTableStyleFontSizeAndJustification", 1));
|
|
@@ -14336,8 +14205,8 @@ var DocxWriteContext = class {
|
|
|
14336
14205
|
this.fontTable = new FontWrapper(options.fonts ?? []);
|
|
14337
14206
|
this.glossaryOptions = options.glossary;
|
|
14338
14207
|
this.webSettings = options.webSettings ?? void 0;
|
|
14339
|
-
if (options.glossary) this.registerDocumentRel(
|
|
14340
|
-
if (this.webSettings) this.registerDocumentRel(
|
|
14208
|
+
if (options.glossary) this.registerDocumentRel(RELATIONSHIP_TYPES.glossaryDocument, "glossary/document.xml");
|
|
14209
|
+
if (this.webSettings) this.registerDocumentRel(RELATIONSHIP_TYPES.webSettings, "webSettings.xml");
|
|
14341
14210
|
}
|
|
14342
14211
|
get headers() {
|
|
14343
14212
|
return this._headers;
|
|
@@ -14389,12 +14258,12 @@ var DocxWriteContext = class {
|
|
|
14389
14258
|
addHeaderToDocument(header, partName) {
|
|
14390
14259
|
this._headers.push(header);
|
|
14391
14260
|
header.partName = this.nextPartName(this._headers, partName, "header");
|
|
14392
|
-
this.document.relationships.addRelationship(header.referenceId,
|
|
14261
|
+
this.document.relationships.addRelationship(header.referenceId, RELATIONSHIP_TYPES.header, header.partName);
|
|
14393
14262
|
}
|
|
14394
14263
|
addFooterToDocument(footer, partName) {
|
|
14395
14264
|
this._footers.push(footer);
|
|
14396
14265
|
footer.partName = this.nextPartName(this._footers, partName, "footer");
|
|
14397
|
-
this.document.relationships.addRelationship(footer.referenceId,
|
|
14266
|
+
this.document.relationships.addRelationship(footer.referenceId, RELATIONSHIP_TYPES.footer, footer.partName);
|
|
14398
14267
|
}
|
|
14399
14268
|
/** Resolve the part file name: the round-tripped source name when given,
|
|
14400
14269
|
* else the next free <kind>N.xml slot (pinned names never collide). */
|
|
@@ -14410,17 +14279,17 @@ var DocxWriteContext = class {
|
|
|
14410
14279
|
return name;
|
|
14411
14280
|
}
|
|
14412
14281
|
addDefaultRelationships() {
|
|
14413
|
-
this.registerDocumentRel(
|
|
14414
|
-
if (this._hasNumbering) this.registerDocumentRel(
|
|
14415
|
-
if (this._hasFootnotes) this.registerDocumentRel(
|
|
14416
|
-
if (this._hasEndnotes) this.registerDocumentRel(
|
|
14417
|
-
this.registerDocumentRel(
|
|
14418
|
-
if (this._options.comments?.length || this._hasCommentSugar) this.registerDocumentRel(
|
|
14419
|
-
if (this._options.people?.length) this.registerDocumentRel(
|
|
14420
|
-
if (this._options.commentsExtended?.length) this.registerDocumentRel(
|
|
14421
|
-
if (this._options.bibliography) this.registerDocumentRel(
|
|
14282
|
+
this.registerDocumentRel(RELATIONSHIP_TYPES.styles, "styles.xml");
|
|
14283
|
+
if (this._hasNumbering) this.registerDocumentRel(RELATIONSHIP_TYPES.numbering, "numbering.xml");
|
|
14284
|
+
if (this._hasFootnotes) this.registerDocumentRel(RELATIONSHIP_TYPES.footnotes, "footnotes.xml");
|
|
14285
|
+
if (this._hasEndnotes) this.registerDocumentRel(RELATIONSHIP_TYPES.endnotes, "endnotes.xml");
|
|
14286
|
+
this.registerDocumentRel(RELATIONSHIP_TYPES.settings, "settings.xml");
|
|
14287
|
+
if (this._options.comments?.length || this._hasCommentSugar) this.registerDocumentRel(RELATIONSHIP_TYPES.comments, "comments.xml");
|
|
14288
|
+
if (this._options.people?.length) this.registerDocumentRel(RELATIONSHIP_TYPES.peopleMs, "people.xml");
|
|
14289
|
+
if (this._options.commentsExtended?.length) this.registerDocumentRel(RELATIONSHIP_TYPES.commentsExtendedMs, "commentsExtended.xml");
|
|
14290
|
+
if (this._options.bibliography) this.registerDocumentRel(RELATIONSHIP_TYPES.bibliography, "bibliography.xml");
|
|
14422
14291
|
const themeRel = (this._options.passthroughRelationships ?? []).find((r) => r.source === "word/document.xml" && r.relationshipType.endsWith("/theme"));
|
|
14423
|
-
this.registerDocumentRel(
|
|
14292
|
+
this.registerDocumentRel(RELATIONSHIP_TYPES.theme, themeRel ? themeRel.target : "theme/theme1.xml");
|
|
14424
14293
|
}
|
|
14425
14294
|
/**
|
|
14426
14295
|
* Register a default document relationship. On round-trip, reuse the source
|
|
@@ -16503,9 +16372,9 @@ const VerticalAlignSection = {
|
|
|
16503
16372
|
//#region src/patch/from-docx.ts
|
|
16504
16373
|
/** Reusable TextEncoder (stateless, safe to share). */
|
|
16505
16374
|
const encoder$1 = new TextEncoder();
|
|
16506
|
-
const COMMENTS_REL_TYPE =
|
|
16375
|
+
const COMMENTS_REL_TYPE = RELATIONSHIP_TYPES.comments;
|
|
16507
16376
|
const COMMENTS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml";
|
|
16508
|
-
const HYPERLINK_REL_TYPE =
|
|
16377
|
+
const HYPERLINK_REL_TYPE = RELATIONSHIP_TYPES.hyperlink;
|
|
16509
16378
|
/**
|
|
16510
16379
|
* Rendered hyperlink ids start here so they can never collide with the real
|
|
16511
16380
|
* rIdN ids of the part's relationships — including the media entries the
|
|
@@ -16840,7 +16709,7 @@ const patchDocument = async ({ outputType, data, placeholders, findReplace, core
|
|
|
16840
16709
|
map.set(key, JSON.parse(newJson));
|
|
16841
16710
|
for (const [i, media] of mediaDatas.entries()) {
|
|
16842
16711
|
const { fileName } = media;
|
|
16843
|
-
appendRelationship(relationshipsJson, index + i,
|
|
16712
|
+
appendRelationship(relationshipsJson, index + i, RELATIONSHIP_TYPES.image, `media/${fileName}`);
|
|
16844
16713
|
}
|
|
16845
16714
|
}
|
|
16846
16715
|
const hyperlinksByPart = /* @__PURE__ */ new Map();
|
|
@@ -18738,20 +18607,350 @@ const guidSize = 32;
|
|
|
18738
18607
|
* const obfuscatedData = obfuscate(fontData, fontKey);
|
|
18739
18608
|
* ```
|
|
18740
18609
|
*
|
|
18741
|
-
* @internal
|
|
18610
|
+
* @internal
|
|
18611
|
+
*/
|
|
18612
|
+
const obfuscate = (buf, fontKey) => {
|
|
18613
|
+
const guid = fontKey.replace(/-/g, "");
|
|
18614
|
+
if (guid.length !== guidSize) throw new Error(`Error: Cannot extract GUID from font filename: ${fontKey}`);
|
|
18615
|
+
const hexNumbers = guid.replace(/(..)/g, "$1 ").trim().split(" ").map((hexString) => parseInt(hexString, 16));
|
|
18616
|
+
hexNumbers.reverse();
|
|
18617
|
+
const obfuscatedBytes = buf.slice(obfuscatedStartOffset, obfuscatedEndOffset).map((byte, i) => byte ^ hexNumbers[i % hexNumbers.length]);
|
|
18618
|
+
const out = new Uint8Array(obfuscatedStartOffset + obfuscatedBytes.length + Math.max(0, buf.length - obfuscatedEndOffset));
|
|
18619
|
+
out.set(buf.slice(0, obfuscatedStartOffset));
|
|
18620
|
+
out.set(obfuscatedBytes, obfuscatedStartOffset);
|
|
18621
|
+
out.set(buf.slice(obfuscatedEndOffset), obfuscatedStartOffset + obfuscatedBytes.length);
|
|
18622
|
+
return out;
|
|
18623
|
+
};
|
|
18624
|
+
//#endregion
|
|
18625
|
+
//#region src/compile/shared.ts
|
|
18626
|
+
/**
|
|
18627
|
+
* Relationship wiring shared by the docx compile phases: the XML declaration,
|
|
18628
|
+
* the OLE/PACKAGE embedding relationship resolution, and the per-part media +
|
|
18629
|
+
* embedding placeholder bridge.
|
|
18630
|
+
*
|
|
18631
|
+
* @module
|
|
18632
|
+
*/
|
|
18633
|
+
/** XML declaration prepended to every OOXML part. */
|
|
18634
|
+
const XML_DECL = OOXML_XML_DECLARATION;
|
|
18635
|
+
/** Relationship type for OLE embedding parts (word|ppt/embeddings/*). */
|
|
18636
|
+
const OLE_OBJECT_RELATIONSHIP = RELATIONSHIP_TYPES.oleObject;
|
|
18637
|
+
/** Relationship type for native-format embedding parts (embedded xlsx/docx). */
|
|
18638
|
+
const PACKAGE_RELATIONSHIP = RELATIONSHIP_TYPES.package;
|
|
18639
|
+
/** Re-emit the relationship type the source used for an embedding part — a
|
|
18640
|
+
* native OPC package (xlsx/docx) stays a package rel, an OLE compound binary
|
|
18641
|
+
* stays an oleObject rel. */
|
|
18642
|
+
const embeddingRelationship = (embeddings, fileName) => embeddings.array.find((e) => e.fileName === fileName)?.relationshipType === "package" ? PACKAGE_RELATIONSHIP : OLE_OBJECT_RELATIONSHIP;
|
|
18643
|
+
/**
|
|
18644
|
+
* Resolve a part's {fileName} media placeholders against the package media
|
|
18645
|
+
* store, then its embedding placeholders chained past the media
|
|
18646
|
+
* relationships (same ordering as the document part — headers/footers and
|
|
18647
|
+
* notes can carry w:object runs of their own).
|
|
18648
|
+
*/
|
|
18649
|
+
function resolvePartMedia(xml, ctx, relCount) {
|
|
18650
|
+
const media = findAndReplaceImagePlaceholders(xml, ctx.media.array, relCount);
|
|
18651
|
+
const embeddingOffset = relCount + media.referenced.length;
|
|
18652
|
+
const embeddings = findAndReplaceImagePlaceholders(media.xml, ctx.embeddings.array, embeddingOffset);
|
|
18653
|
+
return {
|
|
18654
|
+
xml: embeddings.xml,
|
|
18655
|
+
relCount,
|
|
18656
|
+
embeddingOffset,
|
|
18657
|
+
mediaRefs: media.referenced,
|
|
18658
|
+
embeddingRefs: embeddings.referenced
|
|
18659
|
+
};
|
|
18660
|
+
}
|
|
18661
|
+
/** Register the resolved media + embedding relationships on the part's rels. */
|
|
18662
|
+
function registerPartMedia(rels, ctx, resolved) {
|
|
18663
|
+
for (const [i, ref] of resolved.mediaRefs.entries()) rels.addRelationship(resolved.relCount + i, RELATIONSHIP_TYPES.image, `media/${ref.fileName}`);
|
|
18664
|
+
for (const [i, ref] of resolved.embeddingRefs.entries()) rels.addRelationship(resolved.embeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
18665
|
+
}
|
|
18666
|
+
/** Matches any chart/SmartArt placeholder prefix in a part's XML. */
|
|
18667
|
+
const CHART_SMARTART_PLACEHOLDER = /\{(chart:|smartart(?:-lo|-qs|-cs)?:)/;
|
|
18668
|
+
/**
|
|
18669
|
+
* Resolve a part's {chart:key} / {smartart*:key} placeholders and register the
|
|
18670
|
+
* referenced parts on the part's own rels — headers/footers and notes can
|
|
18671
|
+
* carry chart and SmartArt drawings of their own. The document part resolves
|
|
18672
|
+
* the full collections (compile/document.ts); here only keys this part
|
|
18673
|
+
* actually references get relationships, at ids continuing past the part's
|
|
18674
|
+
* media/embedding block. Targets keep the package-wide collection order
|
|
18675
|
+
* (charts/chartN.xml, diagrams/{data,layout,quickStyle,colors}N.xml), so
|
|
18676
|
+
* several parts referencing one chart all point at the same file.
|
|
18677
|
+
*/
|
|
18678
|
+
function resolvePartCharts(xml, ctx, rels, relCount) {
|
|
18679
|
+
if (!CHART_SMARTART_PLACEHOLDER.test(xml)) return xml;
|
|
18680
|
+
const entries = [];
|
|
18681
|
+
const referencedCharts = ctx.charts.array.filter((c) => xml.includes(`{chart:${c.key}}`));
|
|
18682
|
+
referencedCharts.forEach((chart, i) => {
|
|
18683
|
+
entries.push({
|
|
18684
|
+
prefix: "chart:",
|
|
18685
|
+
key: chart.key,
|
|
18686
|
+
value: `rId${relCount + i}`
|
|
18687
|
+
});
|
|
18688
|
+
rels.addRelationship(relCount + i, RELATIONSHIP_TYPES.chart, `charts/chart${ctx.charts.array.indexOf(chart) + 1}.xml`);
|
|
18689
|
+
});
|
|
18690
|
+
const referencedSmartArts = ctx.smartArts.array.filter((s) => [
|
|
18691
|
+
"",
|
|
18692
|
+
"-lo",
|
|
18693
|
+
"-qs",
|
|
18694
|
+
"-cs"
|
|
18695
|
+
].some((suffix) => xml.includes(`{smartart${suffix}:${s.key}}`)));
|
|
18696
|
+
const chartCount = referencedCharts.length;
|
|
18697
|
+
const smartArtCount = referencedSmartArts.length;
|
|
18698
|
+
const base = relCount + chartCount;
|
|
18699
|
+
const loOffset = base + smartArtCount;
|
|
18700
|
+
const qsOffset = loOffset + smartArtCount;
|
|
18701
|
+
const csOffset = qsOffset + smartArtCount;
|
|
18702
|
+
const drawingOffset = csOffset + smartArtCount;
|
|
18703
|
+
referencedSmartArts.forEach((smartArt, i) => {
|
|
18704
|
+
const fileIndex = ctx.smartArts.array.indexOf(smartArt) + 1;
|
|
18705
|
+
const relsByPrefix = [
|
|
18706
|
+
[
|
|
18707
|
+
"smartart:",
|
|
18708
|
+
base,
|
|
18709
|
+
RELATIONSHIP_TYPES.diagramData,
|
|
18710
|
+
"data"
|
|
18711
|
+
],
|
|
18712
|
+
[
|
|
18713
|
+
"smartart-lo:",
|
|
18714
|
+
loOffset,
|
|
18715
|
+
RELATIONSHIP_TYPES.diagramLayout,
|
|
18716
|
+
"layout"
|
|
18717
|
+
],
|
|
18718
|
+
[
|
|
18719
|
+
"smartart-qs:",
|
|
18720
|
+
qsOffset,
|
|
18721
|
+
RELATIONSHIP_TYPES.diagramQuickStyle,
|
|
18722
|
+
"quickStyle"
|
|
18723
|
+
],
|
|
18724
|
+
[
|
|
18725
|
+
"smartart-cs:",
|
|
18726
|
+
csOffset,
|
|
18727
|
+
RELATIONSHIP_TYPES.diagramColors,
|
|
18728
|
+
"colors"
|
|
18729
|
+
]
|
|
18730
|
+
];
|
|
18731
|
+
for (const [prefix, offset, type, file] of relsByPrefix) {
|
|
18732
|
+
entries.push({
|
|
18733
|
+
prefix,
|
|
18734
|
+
key: smartArt.key,
|
|
18735
|
+
value: `rId${offset + i}`
|
|
18736
|
+
});
|
|
18737
|
+
rels.addRelationship(offset + i, type, `diagrams/${file}${fileIndex}.xml`);
|
|
18738
|
+
}
|
|
18739
|
+
if (smartArt.raw?.drawing !== void 0) rels.addRelationship(drawingOffset + i, RELATIONSHIP_TYPES.diagramDrawingMs, `diagrams/drawing${fileIndex}.xml`);
|
|
18740
|
+
});
|
|
18741
|
+
return replaceAllPlaceholders(xml, entries);
|
|
18742
|
+
}
|
|
18743
|
+
//#endregion
|
|
18744
|
+
//#region src/compile/document.ts
|
|
18745
|
+
/**
|
|
18746
|
+
* Document part compile phase: word/document.xml (chart/SmartArt/numbering
|
|
18747
|
+
* placeholder resolution over the stringified body) and
|
|
18748
|
+
* word/_rels/document.xml.rels.
|
|
18749
|
+
*
|
|
18750
|
+
* The document part is the only one whose media/embedding relationships
|
|
18751
|
+
* re-emit the source rIds on round-trip: the body XML references them
|
|
18752
|
+
* verbatim, so registration goes through sourceRidFor before falling back to
|
|
18753
|
+
* the offset-derived id.
|
|
18754
|
+
*
|
|
18755
|
+
* @module
|
|
18756
|
+
*/
|
|
18757
|
+
/**
|
|
18758
|
+
* Look up the source rId for a document relationship by kind+target. Returns
|
|
18759
|
+
* the numeric id when the source carried the same rel, undefined otherwise.
|
|
18760
|
+
* The body XML's `r:id` references the source rId verbatim on round-trip, so
|
|
18761
|
+
* the structured compiler must emit the rel at that exact id — otherwise
|
|
18762
|
+
* `r:id="rId4"` would point at a different rel and Word refuses to open.
|
|
18763
|
+
*/
|
|
18764
|
+
function sourceRidFor(passthroughRelationships, ownerSource, relationshipType, target) {
|
|
18765
|
+
if (!passthroughRelationships) return void 0;
|
|
18766
|
+
for (const rel of passthroughRelationships) if (rel.source === ownerSource && rel.relationshipType === relationshipType && rel.target === target) {
|
|
18767
|
+
const m = /^rId(\d+)$/.exec(rel.rId);
|
|
18768
|
+
if (m) return Number(m[1]);
|
|
18769
|
+
}
|
|
18770
|
+
}
|
|
18771
|
+
/**
|
|
18772
|
+
* Build a {fileName → rId} map for source rels targeting `media/` or
|
|
18773
|
+
* `embeddings/`. findAndReplaceImagePlaceholders consults this map to
|
|
18774
|
+
* substitute the source rId in body XML (so `<a:blip r:embed="rId5"/>` points
|
|
18775
|
+
* at the rel registered at rId5 — not the rel registered at an
|
|
18776
|
+
* offset-derived id, which dangles against any source body that referenced
|
|
18777
|
+
* the source rId). Placeholder keys use the media-collection fileName; a
|
|
18778
|
+
* dedup-renamed file misses the map and falls through to the offset id on
|
|
18779
|
+
* BOTH the body and the .rels side, keeping them consistent.
|
|
18780
|
+
*/
|
|
18781
|
+
function documentSourceRids(ctx, dir) {
|
|
18782
|
+
const map = /* @__PURE__ */ new Map();
|
|
18783
|
+
const prefix = `${dir}/`;
|
|
18784
|
+
for (const rel of ctx._options.passthroughRelationships ?? []) {
|
|
18785
|
+
if (rel.source !== "word/document.xml") continue;
|
|
18786
|
+
if (!rel.target.startsWith(prefix)) continue;
|
|
18787
|
+
map.set(rel.target.slice(prefix.length), rel.rId);
|
|
18788
|
+
}
|
|
18789
|
+
return map;
|
|
18790
|
+
}
|
|
18791
|
+
/** Resolve the document body's media/embedding placeholders, then emit the
|
|
18792
|
+
* document part and its rels. The rels entry registers media, embeddings,
|
|
18793
|
+
* charts, SmartArt, the font table, and the claimed passthrough rels — in
|
|
18794
|
+
* that order, so the source rId ordering is preserved. */
|
|
18795
|
+
function compileDocumentEntries(ctx, documentXmlData, documentRelationshipCount) {
|
|
18796
|
+
const documentMedia = findAndReplaceImagePlaceholders(documentXmlData, ctx.media.array, documentRelationshipCount, "rId", documentSourceRids(ctx, "media"));
|
|
18797
|
+
const documentEmbeddingOffset = documentRelationshipCount + documentMedia.referenced.length;
|
|
18798
|
+
const documentEmbeddings = findAndReplaceImagePlaceholders(documentMedia.xml, ctx.embeddings.array, documentEmbeddingOffset, "rId", documentSourceRids(ctx, "embeddings"));
|
|
18799
|
+
return {
|
|
18800
|
+
Document: {
|
|
18801
|
+
data: (() => {
|
|
18802
|
+
let xmlData = documentEmbeddings.xml;
|
|
18803
|
+
if (hasPlaceholders(xmlData)) {
|
|
18804
|
+
const mediaCount = documentMedia.referenced.length;
|
|
18805
|
+
const embeddingCount = documentEmbeddings.referenced.length;
|
|
18806
|
+
const chartKeys = ctx.charts.array.map((c) => c.key);
|
|
18807
|
+
const smartArtKeys = ctx.smartArts.array.map((s) => s.key);
|
|
18808
|
+
const chartOffset = documentRelationshipCount + mediaCount + embeddingCount;
|
|
18809
|
+
const smartArtOffset = chartOffset + chartKeys.length;
|
|
18810
|
+
const entries = [];
|
|
18811
|
+
for (const [i, key] of chartKeys.entries()) {
|
|
18812
|
+
const chartTarget = `charts/chart${i + 1}.xml`;
|
|
18813
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.chart, chartTarget);
|
|
18814
|
+
entries.push({
|
|
18815
|
+
prefix: "chart:",
|
|
18816
|
+
key,
|
|
18817
|
+
value: sourceRid !== void 0 ? `rId${sourceRid}` : formatId(chartOffset, i, "rId")
|
|
18818
|
+
});
|
|
18819
|
+
}
|
|
18820
|
+
const saPrefixes = [
|
|
18821
|
+
"smartart:",
|
|
18822
|
+
"smartart-lo:",
|
|
18823
|
+
"smartart-qs:",
|
|
18824
|
+
"smartart-cs:"
|
|
18825
|
+
];
|
|
18826
|
+
for (const [i, key] of smartArtKeys.entries()) for (let p = 0; p < saPrefixes.length; p++) entries.push({
|
|
18827
|
+
prefix: saPrefixes[p],
|
|
18828
|
+
key,
|
|
18829
|
+
value: formatId(smartArtOffset + p * smartArtKeys.length, i, "rId")
|
|
18830
|
+
});
|
|
18831
|
+
for (const { reference, instance, numId } of ctx.numbering.concreteNumbering) entries.push({
|
|
18832
|
+
key: `${reference}-${instance}`,
|
|
18833
|
+
value: numId.toString()
|
|
18834
|
+
});
|
|
18835
|
+
xmlData = replaceAllPlaceholders(xmlData, entries);
|
|
18836
|
+
} else xmlData = replaceNumberingPlaceholders(xmlData, ctx.numbering.concreteNumbering);
|
|
18837
|
+
return xmlData;
|
|
18838
|
+
})(),
|
|
18839
|
+
path: "word/document.xml"
|
|
18840
|
+
},
|
|
18841
|
+
Relationships: {
|
|
18842
|
+
data: (() => {
|
|
18843
|
+
for (const [i, ref] of documentMedia.referenced.entries()) {
|
|
18844
|
+
const target = `media/${ref.fileName}`;
|
|
18845
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.image, target);
|
|
18846
|
+
ctx.document.relationships.addRelationship(sourceRid ?? documentRelationshipCount + i, RELATIONSHIP_TYPES.image, target);
|
|
18847
|
+
}
|
|
18848
|
+
for (const [i, ref] of documentEmbeddings.referenced.entries()) {
|
|
18849
|
+
const target = `embeddings/${ref.fileName}`;
|
|
18850
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
18851
|
+
ctx.document.relationships.addRelationship(sourceRid ?? documentEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
18852
|
+
}
|
|
18853
|
+
const chartOffset = documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length;
|
|
18854
|
+
for (let i = 0; i < ctx.charts.array.length; i++) {
|
|
18855
|
+
const target = `charts/chart${i + 1}.xml`;
|
|
18856
|
+
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", RELATIONSHIP_TYPES.chart, target);
|
|
18857
|
+
ctx.document.relationships.addRelationship(sourceRid ?? chartOffset + i, RELATIONSHIP_TYPES.chart, target);
|
|
18858
|
+
}
|
|
18859
|
+
addSmartArtRelationships(ctx.smartArts.array.map((s) => s.key), (id, type, target) => {
|
|
18860
|
+
ctx.document.relationships.addRelationship(id, type, target);
|
|
18861
|
+
}, documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length + ctx.charts.array.length, 0, {
|
|
18862
|
+
pathPrefix: "",
|
|
18863
|
+
styleRelType: RELATIONSHIP_TYPES.diagramQuickStyle,
|
|
18864
|
+
hasDrawing: (key) => ctx.smartArts.array.find((s) => s.key === key)?.raw?.drawing !== void 0
|
|
18865
|
+
});
|
|
18866
|
+
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");
|
|
18867
|
+
ctx.addPassthroughDocumentRelationships();
|
|
18868
|
+
return XML_DECL + ctx.document.relationships.serialize();
|
|
18869
|
+
})(),
|
|
18870
|
+
path: "word/_rels/document.xml.rels"
|
|
18871
|
+
}
|
|
18872
|
+
};
|
|
18873
|
+
}
|
|
18874
|
+
//#endregion
|
|
18875
|
+
//#region src/compile/drawings.ts
|
|
18876
|
+
/**
|
|
18877
|
+
* Drawing tail compile phase: the chart parts (chartSpace, userShapes, their
|
|
18878
|
+
* rels and embedded workbooks) and the SmartArt diagram part sets
|
|
18879
|
+
* (data/layout/quickStyle/colors plus the Office render-cache drawing), read
|
|
18880
|
+
* off the collections the document body stringification filled.
|
|
18881
|
+
*
|
|
18882
|
+
* @module
|
|
18742
18883
|
*/
|
|
18743
|
-
|
|
18744
|
-
|
|
18745
|
-
|
|
18746
|
-
|
|
18747
|
-
|
|
18748
|
-
|
|
18749
|
-
|
|
18750
|
-
|
|
18751
|
-
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
18884
|
+
/** Chart part → user-shapes part relationship (c:userShapes bridge). */
|
|
18885
|
+
const CHART_USER_SHAPES_REL = RELATIONSHIP_TYPES.chartUserShapes;
|
|
18886
|
+
function compileChartParts(ctx) {
|
|
18887
|
+
if (ctx.charts.array.length === 0) return {};
|
|
18888
|
+
return {
|
|
18889
|
+
Charts: ctx.charts.array.flatMap((chartData, i) => {
|
|
18890
|
+
const parts = [{
|
|
18891
|
+
data: XML_DECL + chartData.chartSpaceXml,
|
|
18892
|
+
path: `word/charts/chart${i + 1}.xml`
|
|
18893
|
+
}];
|
|
18894
|
+
if (chartData.userShapes) parts.push({
|
|
18895
|
+
data: XML_DECL + chartData.userShapes.xml,
|
|
18896
|
+
path: `word/charts/userShapes${i + 1}.xml`
|
|
18897
|
+
});
|
|
18898
|
+
const e = chartData.embedding;
|
|
18899
|
+
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"/>`] : []];
|
|
18900
|
+
if (rels.length > 0) parts.push({
|
|
18901
|
+
data: XML_DECL + `<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${rels.join("")}</Relationships>`,
|
|
18902
|
+
path: `word/charts/_rels/chart${i + 1}.xml.rels`
|
|
18903
|
+
});
|
|
18904
|
+
return parts;
|
|
18905
|
+
}),
|
|
18906
|
+
ChartEmbeddings: (() => {
|
|
18907
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18908
|
+
const parts = [];
|
|
18909
|
+
for (const c of ctx.charts.array) {
|
|
18910
|
+
const e = c.embedding;
|
|
18911
|
+
if (!e || seen.has(e.fileName)) continue;
|
|
18912
|
+
seen.add(e.fileName);
|
|
18913
|
+
parts.push({
|
|
18914
|
+
data: toUint8Array(e.data),
|
|
18915
|
+
path: `word/embeddings/${e.fileName}`
|
|
18916
|
+
});
|
|
18917
|
+
}
|
|
18918
|
+
return parts;
|
|
18919
|
+
})()
|
|
18920
|
+
};
|
|
18921
|
+
}
|
|
18922
|
+
function compileSmartArtParts(ctx) {
|
|
18923
|
+
if (ctx.smartArts.array.length === 0) return {};
|
|
18924
|
+
return {
|
|
18925
|
+
DiagramData: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18926
|
+
data: smartArtData.raw?.data !== void 0 ? toUint8Array(smartArtData.raw.data) : XML_DECL + smartArtData.dataModelXml,
|
|
18927
|
+
path: `word/diagrams/data${i + 1}.xml`
|
|
18928
|
+
})),
|
|
18929
|
+
DiagramLayout: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18930
|
+
data: smartArtData.raw?.layout !== void 0 ? toUint8Array(smartArtData.raw.layout) : typeof smartArtData.layout === "string" ? getLayoutXml(smartArtData.layout) : stringifyLayoutDefinitionPart(smartArtData.layout),
|
|
18931
|
+
path: `word/diagrams/layout${i + 1}.xml`
|
|
18932
|
+
})),
|
|
18933
|
+
DiagramStyle: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18934
|
+
data: smartArtData.raw?.style !== void 0 ? toUint8Array(smartArtData.raw.style) : typeof smartArtData.style === "string" ? getStyleXml(smartArtData.style) : stringifyStyleDefinitionPart(smartArtData.style),
|
|
18935
|
+
path: `word/diagrams/quickStyle${i + 1}.xml`
|
|
18936
|
+
})),
|
|
18937
|
+
DiagramColors: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18938
|
+
data: smartArtData.raw?.color !== void 0 ? toUint8Array(smartArtData.raw.color) : typeof smartArtData.color === "string" ? getColorXml(smartArtData.color) : stringifyColorDefinitionPart(smartArtData.color),
|
|
18939
|
+
path: `word/diagrams/colors${i + 1}.xml`
|
|
18940
|
+
})),
|
|
18941
|
+
DiagramDrawing: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
18942
|
+
smartArtData,
|
|
18943
|
+
i
|
|
18944
|
+
})).filter(({ smartArtData }) => smartArtData.raw?.drawing !== void 0).map(({ smartArtData, i }) => ({
|
|
18945
|
+
data: toUint8Array(smartArtData.raw.drawing),
|
|
18946
|
+
path: `word/diagrams/drawing${i + 1}.xml`
|
|
18947
|
+
})),
|
|
18948
|
+
...ctx.smartArts.array.some((s) => s.raw?.dataRels !== void 0) ? { SmartArtDataRels: ctx.smartArts.array.flatMap((smartArtData, i) => smartArtData.raw?.dataRels !== void 0 ? [{
|
|
18949
|
+
data: toUint8Array(smartArtData.raw.dataRels),
|
|
18950
|
+
path: `word/diagrams/_rels/data${i + 1}.xml.rels`
|
|
18951
|
+
}] : []) } : {}
|
|
18952
|
+
};
|
|
18953
|
+
}
|
|
18755
18954
|
//#endregion
|
|
18756
18955
|
//#region src/parts/header-footer.ts
|
|
18757
18956
|
/**
|
|
@@ -18831,6 +19030,151 @@ function stringifyHeaderFooter(tag, namespaces, children, ctx) {
|
|
|
18831
19030
|
return body.length === 0 ? `<${tag} ${attrStr}/>` : `<${tag} ${attrStr}>${body}</${tag}>`;
|
|
18832
19031
|
}
|
|
18833
19032
|
//#endregion
|
|
19033
|
+
//#region src/compile/headerfooter.ts
|
|
19034
|
+
/**
|
|
19035
|
+
* Header/footer compile phase: the four mapping arrays (Headers, Footers,
|
|
19036
|
+
* HeaderRelationships, FooterRelationships).
|
|
19037
|
+
*
|
|
19038
|
+
* Headers and footers are structural twins — same stringify → placeholder
|
|
19039
|
+
* resolution → relationship registration pipeline, differing only in element
|
|
19040
|
+
* name, namespaces, and default part name — so one per-part helper serves
|
|
19041
|
+
* both, and each part's body and rels are produced together (no cross-entry
|
|
19042
|
+
* state needed).
|
|
19043
|
+
*
|
|
19044
|
+
* @module
|
|
19045
|
+
*/
|
|
19046
|
+
/** Stringify one header/footer part and wire its media/embedding/chart/
|
|
19047
|
+
* SmartArt relationships. Images get per-part relationship IDs starting at
|
|
19048
|
+
* nextRelationshipId, mirroring the document part; the placeholder pass uses
|
|
19049
|
+
* referenced-local positions, so body r:embed and .rels stay aligned. */
|
|
19050
|
+
function compileHeaderFooterPart(kind, entry, index, ctx, mkCtx) {
|
|
19051
|
+
const partName = entry.partName ?? `${kind}${index + 1}.xml`;
|
|
19052
|
+
const partCtx = mkCtx({
|
|
19053
|
+
relationships: entry.relationships,
|
|
19054
|
+
partName: `word/${partName}`
|
|
19055
|
+
});
|
|
19056
|
+
const xmlData = XML_DECL + stringifyHeaderFooter(kind === "footer" ? "w:ftr" : "w:hdr", kind === "footer" ? FOOTER_NAMESPACES : HEADER_NAMESPACES, entry.children, partCtx);
|
|
19057
|
+
const relCount = entry.relationships.nextRelationshipId;
|
|
19058
|
+
const resolved = resolvePartMedia(xmlData, ctx, relCount);
|
|
19059
|
+
registerPartMedia(entry.relationships, ctx, resolved);
|
|
19060
|
+
const resolvedXml = resolvePartCharts(resolved.xml, ctx, entry.relationships, resolved.embeddingOffset + resolved.embeddingRefs.length);
|
|
19061
|
+
return {
|
|
19062
|
+
part: {
|
|
19063
|
+
data: replaceNumberingPlaceholders(resolvedXml, ctx.numbering.concreteNumbering),
|
|
19064
|
+
path: `word/${partName}`
|
|
19065
|
+
},
|
|
19066
|
+
rels: optionalRelsPart(entry.relationships, XML_DECL, `word/_rels/${partName}.rels`)
|
|
19067
|
+
};
|
|
19068
|
+
}
|
|
19069
|
+
function mapParts(entries, kind, ctx, mkCtx) {
|
|
19070
|
+
const parts = [];
|
|
19071
|
+
const rels = [];
|
|
19072
|
+
entries.forEach((entry, index) => {
|
|
19073
|
+
const compiled = compileHeaderFooterPart(kind, entry, index, ctx, mkCtx);
|
|
19074
|
+
parts.push(compiled.part);
|
|
19075
|
+
if (compiled.rels) rels.push(compiled.rels);
|
|
19076
|
+
});
|
|
19077
|
+
return {
|
|
19078
|
+
parts,
|
|
19079
|
+
rels
|
|
19080
|
+
};
|
|
19081
|
+
}
|
|
19082
|
+
function compileHeaderFooterParts(ctx, mkCtx) {
|
|
19083
|
+
const headers = mapParts(ctx.headers, "header", ctx, mkCtx);
|
|
19084
|
+
const footers = mapParts(ctx.footers, "footer", ctx, mkCtx);
|
|
19085
|
+
return {
|
|
19086
|
+
Headers: headers.parts,
|
|
19087
|
+
HeaderRelationships: headers.rels,
|
|
19088
|
+
Footers: footers.parts,
|
|
19089
|
+
FooterRelationships: footers.rels
|
|
19090
|
+
};
|
|
19091
|
+
}
|
|
19092
|
+
//#endregion
|
|
19093
|
+
//#region src/compile/notes.ts
|
|
19094
|
+
/**
|
|
19095
|
+
* Notes compile phase: comments, footnotes, and endnotes parts.
|
|
19096
|
+
*
|
|
19097
|
+
* All three share the same wiring shape — stringify the part, resolve its
|
|
19098
|
+
* {fileName} media and {oleObjectN.bin} embedding placeholders, resolve
|
|
19099
|
+
* {chart:}/{smartart:} placeholders, register the matching relationships on
|
|
19100
|
+
* the part's own rels, and replace numbering placeholders. Collected here so
|
|
19101
|
+
* the three stay symmetric.
|
|
19102
|
+
*
|
|
19103
|
+
* @module
|
|
19104
|
+
*/
|
|
19105
|
+
/**
|
|
19106
|
+
* Comments carried by the document: those the caller listed explicitly
|
|
19107
|
+
* (`options.comments`) plus entries registered by `{ comment }` sugar children
|
|
19108
|
+
* during body stringification. Drives both word/comments.xml generation and the
|
|
19109
|
+
* [Content_Types] comments Override, which must stay in sync (OPC consistency).
|
|
19110
|
+
*/
|
|
19111
|
+
function mergedCommentChildren(ctx) {
|
|
19112
|
+
return [...ctx._options.comments ?? [], ...ctx.comments.entries];
|
|
19113
|
+
}
|
|
19114
|
+
/** The three notes parts, present only when the document carries content for
|
|
19115
|
+
* them (an empty part with a dangling relationship is the OPC violation Word
|
|
19116
|
+
* rejects on open). */
|
|
19117
|
+
function compileNotesParts(ctx, mkCtx) {
|
|
19118
|
+
const result = {};
|
|
19119
|
+
const comments = mergedCommentChildren(ctx);
|
|
19120
|
+
if (comments.length > 0) {
|
|
19121
|
+
const commentCtx = mkCtx({ relationships: ctx.comments.relationships });
|
|
19122
|
+
const commentXmlData = XML_DECL + (commentsDesc.stringify(comments, commentCtx) ?? "");
|
|
19123
|
+
const commentRelCount = ctx.comments.relationships.nextRelationshipId;
|
|
19124
|
+
const resolved = resolvePartMedia(commentXmlData, ctx, commentRelCount);
|
|
19125
|
+
registerPartMedia(ctx.comments.relationships, ctx, resolved);
|
|
19126
|
+
const commentXml = resolvePartCharts(resolved.xml, ctx, ctx.comments.relationships, resolved.embeddingOffset + resolved.embeddingRefs.length);
|
|
19127
|
+
result.Comments = {
|
|
19128
|
+
data: replaceNumberingPlaceholders(commentXml, ctx.numbering.concreteNumbering),
|
|
19129
|
+
path: "word/comments.xml"
|
|
19130
|
+
};
|
|
19131
|
+
result.CommentsRelationships = optionalRelsPart(ctx.comments.relationships, XML_DECL, "word/_rels/comments.xml.rels");
|
|
19132
|
+
}
|
|
19133
|
+
const footnoteCtx = mkCtx({ relationships: ctx.footNotes.relationships });
|
|
19134
|
+
const footnoteXmlData = XML_DECL + (footnotesDesc.stringify({
|
|
19135
|
+
notes: ctx.footNotes.notes,
|
|
19136
|
+
separator: ctx.footNotes.separator,
|
|
19137
|
+
continuationSeparator: ctx.footNotes.continuationSeparator,
|
|
19138
|
+
continuationNotice: ctx.footNotes.continuationNotice
|
|
19139
|
+
}, footnoteCtx) ?? "");
|
|
19140
|
+
const footnoteRelCount = ctx.footNotes.relationships.nextRelationshipId;
|
|
19141
|
+
const footnoteResolved = resolvePartMedia(footnoteXmlData, ctx, footnoteRelCount);
|
|
19142
|
+
registerPartMedia(ctx.footNotes.relationships, ctx, footnoteResolved);
|
|
19143
|
+
const footnoteXml = resolvePartCharts(footnoteResolved.xml, ctx, ctx.footNotes.relationships, footnoteResolved.embeddingOffset + footnoteResolved.embeddingRefs.length);
|
|
19144
|
+
if (ctx.hasFootnotes) {
|
|
19145
|
+
result.FootNotes = {
|
|
19146
|
+
data: replaceNumberingPlaceholders(footnoteXml, ctx.numbering.concreteNumbering),
|
|
19147
|
+
path: "word/footnotes.xml"
|
|
19148
|
+
};
|
|
19149
|
+
if (ctx.footNotes.relationships.relationshipCount > 0) result.FootNotesRelationships = {
|
|
19150
|
+
data: XML_DECL + ctx.footNotes.relationships.serialize(),
|
|
19151
|
+
path: "word/_rels/footnotes.xml.rels"
|
|
19152
|
+
};
|
|
19153
|
+
}
|
|
19154
|
+
if (ctx.hasEndnotes) {
|
|
19155
|
+
const endnoteCtx = mkCtx({ relationships: ctx.endnotes.relationships });
|
|
19156
|
+
const endnoteXmlData = XML_DECL + (endnotesDesc.stringify({
|
|
19157
|
+
notes: ctx.endnotes.notes,
|
|
19158
|
+
separator: ctx.endnotes.separator,
|
|
19159
|
+
continuationSeparator: ctx.endnotes.continuationSeparator,
|
|
19160
|
+
continuationNotice: ctx.endnotes.continuationNotice
|
|
19161
|
+
}, endnoteCtx) ?? "");
|
|
19162
|
+
const endnoteRelCount = ctx.endnotes.relationships.nextRelationshipId;
|
|
19163
|
+
const resolved = resolvePartMedia(endnoteXmlData, ctx, endnoteRelCount);
|
|
19164
|
+
registerPartMedia(ctx.endnotes.relationships, ctx, resolved);
|
|
19165
|
+
const endnoteXml = resolvePartCharts(resolved.xml, ctx, ctx.endnotes.relationships, resolved.embeddingOffset + resolved.embeddingRefs.length);
|
|
19166
|
+
result.Endnotes = {
|
|
19167
|
+
data: replaceNumberingPlaceholders(endnoteXml, ctx.numbering.concreteNumbering),
|
|
19168
|
+
path: "word/endnotes.xml"
|
|
19169
|
+
};
|
|
19170
|
+
if (ctx.endnotes.relationships.relationshipCount > 0) result.EndnotesRelationships = {
|
|
19171
|
+
data: XML_DECL + ctx.endnotes.relationships.serialize(),
|
|
19172
|
+
path: "word/_rels/endnotes.xml.rels"
|
|
19173
|
+
};
|
|
19174
|
+
}
|
|
19175
|
+
return result;
|
|
19176
|
+
}
|
|
19177
|
+
//#endregion
|
|
18834
19178
|
//#region src/compiler.ts
|
|
18835
19179
|
/**
|
|
18836
19180
|
* DOCX document compiler — pure function entry point.
|
|
@@ -18840,58 +19184,19 @@ function stringifyHeaderFooter(tag, namespaces, children, ctx) {
|
|
|
18840
19184
|
* All XML parts are produced via descriptors or serialize() —
|
|
18841
19185
|
* no Formatter dependency.
|
|
18842
19186
|
*
|
|
19187
|
+
* The part wiring runs in phases owned by the compile/ folder: the document
|
|
19188
|
+
* body and its rels (compile/document), the notes parts (compile/notes),
|
|
19189
|
+
* headers/footers (compile/headerfooter), and the chart/SmartArt tail
|
|
19190
|
+
* (compile/drawings), with the placeholder bridge and embedding rel
|
|
19191
|
+
* resolution they share in compile/shared. This module keeps the
|
|
19192
|
+
* part-mapping orchestration.
|
|
19193
|
+
*
|
|
18843
19194
|
* @module
|
|
18844
19195
|
*/
|
|
18845
19196
|
/** Reusable TextEncoder (stateless, safe to share). */
|
|
18846
19197
|
const encoder = new TextEncoder();
|
|
18847
|
-
/** Relationship type for OLE embedding parts (word|ppt/embeddings/*). */
|
|
18848
|
-
const OLE_OBJECT_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
18849
|
-
/** Relationship type for native-format embedding parts (embedded xlsx/docx). */
|
|
18850
|
-
const PACKAGE_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
18851
|
-
/** Re-emit the relationship type the source used for an embedding part — a
|
|
18852
|
-
* native OPC package (xlsx/docx) stays a package rel, an OLE compound binary
|
|
18853
|
-
* stays an oleObject rel. */
|
|
18854
|
-
const embeddingRelationship = (embeddings, fileName) => embeddings.array.find((e) => e.fileName === fileName)?.relationshipType === "package" ? PACKAGE_RELATIONSHIP : OLE_OBJECT_RELATIONSHIP;
|
|
18855
|
-
/** XML declaration prepended to every OOXML part. */
|
|
18856
|
-
const XML_DECL = OOXML_XML_DECLARATION;
|
|
18857
|
-
/**
|
|
18858
|
-
* Look up the source rId for a document relationship by kind+target. Returns
|
|
18859
|
-
* the numeric id when the source carried the same rel, undefined otherwise.
|
|
18860
|
-
* The body XML's `r:id` references the source rId verbatim on round-trip, so
|
|
18861
|
-
* the structured compiler must emit the rel at that exact id — otherwise
|
|
18862
|
-
* `r:id="rId4"` would point at a different rel and Word refuses to open.
|
|
18863
|
-
*/
|
|
18864
|
-
function sourceRidFor(passthroughRelationships, ownerSource, relationshipType, target) {
|
|
18865
|
-
if (!passthroughRelationships) return void 0;
|
|
18866
|
-
for (const rel of passthroughRelationships) if (rel.source === ownerSource && rel.relationshipType === relationshipType && rel.target === target) {
|
|
18867
|
-
const m = /^rId(\d+)$/.exec(rel.rId);
|
|
18868
|
-
if (m) return Number(m[1]);
|
|
18869
|
-
}
|
|
18870
|
-
}
|
|
18871
|
-
/**
|
|
18872
|
-
* Build a {fileName → rId} map for source rels targeting `media/` or
|
|
18873
|
-
* `embeddings/`. findAndReplaceImagePlaceholders consults this map to
|
|
18874
|
-
* substitute the source rId in body XML (so `<a:blip r:embed="rId5"/>` points
|
|
18875
|
-
* at the rel registered at rId5 — not the rel registered at an
|
|
18876
|
-
* offset-derived id, which dangles against any source body that referenced
|
|
18877
|
-
* the source rId). Placeholder keys use the media-collection fileName; a
|
|
18878
|
-
* dedup-renamed file misses the map and falls through to the offset id on
|
|
18879
|
-
* BOTH the body and the .rels side, keeping them consistent.
|
|
18880
|
-
*/
|
|
18881
|
-
function documentSourceRids(ctx, dir) {
|
|
18882
|
-
const map = /* @__PURE__ */ new Map();
|
|
18883
|
-
const prefix = `${dir}/`;
|
|
18884
|
-
for (const rel of ctx._options.passthroughRelationships ?? []) {
|
|
18885
|
-
if (rel.source !== "word/document.xml") continue;
|
|
18886
|
-
if (!rel.target.startsWith(prefix)) continue;
|
|
18887
|
-
map.set(rel.target.slice(prefix.length), rel.rId);
|
|
18888
|
-
}
|
|
18889
|
-
return map;
|
|
18890
|
-
}
|
|
18891
19198
|
/** DOCX part path → content type, derived from the part registry. */
|
|
18892
19199
|
const DOCX_CONTENT_TYPE_RESOLVER = resolverFromRegistry(DOCX_PARTS);
|
|
18893
|
-
/** Chart part → user-shapes part relationship (c:userShapes bridge). */
|
|
18894
|
-
const CHART_USER_SHAPES_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
|
|
18895
19200
|
/** Extension → MIME for media/font/embedding Default entries. Declared only
|
|
18896
19201
|
* for extensions actually present in the package. */
|
|
18897
19202
|
const DOCX_MEDIA_CONTENT_TYPES = {
|
|
@@ -18912,87 +19217,28 @@ function compileDocument(options, overrides = [], mediaLevel = 0) {
|
|
|
18912
19217
|
const ctx = new DocxWriteContext(options);
|
|
18913
19218
|
const xmlifiedFileMapping = xmlifyContext(ctx);
|
|
18914
19219
|
const files = compileMapping(xmlifiedFileMapping, overrides);
|
|
18915
|
-
|
|
18916
|
-
for (const mediaData of mediaArray) {
|
|
18917
|
-
addBinaryFile(files, `word/media/${mediaData.fileName}`, mediaData.data, mediaLevel);
|
|
18918
|
-
if (mediaData.type === "svg") addBinaryFile(files, `word/media/${mediaData.fallback.fileName}`, mediaData.fallback.data, mediaLevel);
|
|
18919
|
-
}
|
|
18920
|
-
for (const embedding of ctx.embeddings.array) addBinaryFile(files, `word/embeddings/${embedding.fileName}`, embedding.data, mediaLevel);
|
|
19220
|
+
addModelBinaries(files, "word", ctx.media.array, ctx.embeddings.array, mediaLevel);
|
|
18921
19221
|
for (const font of ctx.fontTable.fontOptionsWithKey) {
|
|
18922
19222
|
if (font.data === void 0) continue;
|
|
18923
19223
|
const [nameWithoutExtension] = font.name.split(".");
|
|
18924
19224
|
const filePath = font.odttfPath ?? `word/fonts/${nameWithoutExtension}.odttf`;
|
|
18925
19225
|
files[filePath] = font.rawOdttf ? font.data : obfuscate(font.data, font.fontKey);
|
|
18926
19226
|
}
|
|
18927
|
-
|
|
18928
|
-
for (const part of ctx._options.rawParts ?? []) {
|
|
18929
|
-
if (files[part.path] !== void 0) {
|
|
18930
|
-
passthroughSkipped.add(part.path);
|
|
18931
|
-
continue;
|
|
18932
|
-
}
|
|
18933
|
-
files[part.path] = toUint8Array(part.data);
|
|
18934
|
-
}
|
|
18935
|
-
files["[Content_Types].xml"] = encoder.encode(buildContentTypesData(ctx, files, passthroughSkipped));
|
|
18936
|
-
dropDanglingPassthroughRels(files, ctx._options.passthroughRelationships);
|
|
18937
|
-
return files;
|
|
18938
|
-
}
|
|
18939
|
-
/**
|
|
18940
|
-
* Comments carried by the document: those the caller listed explicitly
|
|
18941
|
-
* (`options.comments`) plus entries registered by `{ comment }` sugar children
|
|
18942
|
-
* during body stringification. Drives both word/comments.xml generation and the
|
|
18943
|
-
* [Content_Types] comments Override, which must stay in sync (OPC consistency).
|
|
18944
|
-
*/
|
|
18945
|
-
function mergedCommentChildren(ctx) {
|
|
18946
|
-
return [...ctx._options.comments ?? [], ...ctx.comments.entries];
|
|
18947
|
-
}
|
|
18948
|
-
/**
|
|
18949
|
-
* Serialize [Content_Types].xml from the part registry, then backfill media/
|
|
18950
|
-
* font/embedding `<Default>` entries from the parts actually written.
|
|
18951
|
-
*
|
|
18952
|
-
* Must run after every part has been stringified (parts call `ctx.addMedia`
|
|
18953
|
-
* during stringify), so call this once `xmlifyContext` has finished — not from
|
|
18954
|
-
* inside its object literal, where ContentTypes would evaluate before the
|
|
18955
|
-
* later-defined header/footer/font parts have registered their media.
|
|
18956
|
-
*/
|
|
18957
|
-
/**
|
|
18958
|
-
* Derive [Content_Types].xml from the parts actually written to the package.
|
|
18959
|
-
*
|
|
18960
|
-
* The file set is the single source of truth: every part the resolver knows
|
|
18961
|
-
* becomes an Override, every other file falls through to an extension Default,
|
|
18962
|
-
* and altChunk/sub-document parts — whose content type is data-driven, not
|
|
18963
|
-
* path-determinable — are injected as explicit overrides.
|
|
18964
|
-
*
|
|
18965
|
-
* Round-trip no longer passes the source [Content_Types] through: the compiler
|
|
18966
|
-
* regenerates every part path (altChunks get a fresh uniqueId), so deriving
|
|
18967
|
-
* from the written files is what keeps declarations and parts in sync.
|
|
18968
|
-
*/
|
|
18969
|
-
function buildContentTypesData(ctx, files, passthroughSkipped) {
|
|
18970
|
-
const overrides = [...ctx.altChunks.array.map((ac) => ({
|
|
18971
|
-
path: `word/${ac.path}`,
|
|
18972
|
-
contentType: ac.contentType ?? "application/xhtml+xml"
|
|
18973
|
-
})), ...ctx.subDocs.array.map((sd) => ({
|
|
18974
|
-
path: `word/${sd.path}`,
|
|
18975
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
18976
|
-
}))];
|
|
18977
|
-
const input = deriveContentTypes(Object.keys(files), {
|
|
19227
|
+
files["[Content_Types].xml"] = encoder.encode(finalizeContentTypes(files, {
|
|
18978
19228
|
resolve: DOCX_CONTENT_TYPE_RESOLVER,
|
|
18979
19229
|
mediaContentTypes: DOCX_MEDIA_CONTENT_TYPES,
|
|
18980
|
-
overrides,
|
|
18981
19230
|
source: ctx._options.contentTypes,
|
|
18982
|
-
|
|
18983
|
-
|
|
18984
|
-
|
|
18985
|
-
|
|
18986
|
-
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
});
|
|
18994
|
-
}
|
|
18995
|
-
return XML_DECL + (contentTypesDesc.stringify(input, ctx) ?? "");
|
|
19231
|
+
rawParts: ctx._options.rawParts,
|
|
19232
|
+
overrides: [...ctx.altChunks.array.map((ac) => ({
|
|
19233
|
+
path: `word/${ac.path}`,
|
|
19234
|
+
contentType: ac.contentType ?? "application/xhtml+xml"
|
|
19235
|
+
})), ...ctx.subDocs.array.map((sd) => ({
|
|
19236
|
+
path: `word/${sd.path}`,
|
|
19237
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
19238
|
+
}))]
|
|
19239
|
+
}, ctx));
|
|
19240
|
+
dropDanglingPassthroughRels(files, ctx._options.passthroughRelationships);
|
|
19241
|
+
return files;
|
|
18996
19242
|
}
|
|
18997
19243
|
function xmlifyContext(ctx) {
|
|
18998
19244
|
const mkCtx = (viewWrapper = ctx.document) => {
|
|
@@ -19008,59 +19254,18 @@ function xmlifyContext(ctx) {
|
|
|
19008
19254
|
bodyCtx.stringifyChild = (child) => stringifyBodyChild(child, bodyCtx);
|
|
19009
19255
|
return bodyCtx;
|
|
19010
19256
|
};
|
|
19011
|
-
const footerMediaResults = /* @__PURE__ */ new Map();
|
|
19012
|
-
const footerEmbeddingResults = /* @__PURE__ */ new Map();
|
|
19013
|
-
const headerMediaResults = /* @__PURE__ */ new Map();
|
|
19014
|
-
const headerEmbeddingResults = /* @__PURE__ */ new Map();
|
|
19015
19257
|
const docCtx = mkCtx(ctx.document);
|
|
19016
19258
|
const documentXmlData = XML_DECL + stringifyDocumentXml(ctx, docCtx);
|
|
19017
19259
|
const documentRelationshipCount = ctx.document.relationships.nextRelationshipId;
|
|
19018
|
-
const
|
|
19019
|
-
const
|
|
19020
|
-
const
|
|
19021
|
-
const commentXmlData = commentCtx ? XML_DECL + commentsDesc.stringify(mergedCommentChildrenList, commentCtx) : "";
|
|
19022
|
-
const commentRelationshipCount = hasComments ? ctx.comments.relationships.nextRelationshipId : 0;
|
|
19023
|
-
const footnoteCtx = mkCtx({ relationships: ctx.footNotes.relationships });
|
|
19024
|
-
const footnoteXmlData = XML_DECL + (footnotesDesc.stringify({
|
|
19025
|
-
notes: ctx.footNotes.notes,
|
|
19026
|
-
separator: ctx.footNotes.separator,
|
|
19027
|
-
continuationSeparator: ctx.footNotes.continuationSeparator,
|
|
19028
|
-
continuationNotice: ctx.footNotes.continuationNotice
|
|
19029
|
-
}, footnoteCtx) ?? "");
|
|
19030
|
-
const footnoteRelationshipCount = ctx.footNotes.relationships.nextRelationshipId;
|
|
19031
|
-
const documentMedia = findAndReplaceImagePlaceholders(documentXmlData, ctx.media.array, documentRelationshipCount, "rId", documentSourceRids(ctx, "media"));
|
|
19032
|
-
const documentEmbeddingOffset = documentRelationshipCount + documentMedia.referenced.length;
|
|
19033
|
-
const documentEmbeddings = findAndReplaceImagePlaceholders(documentMedia.xml, ctx.embeddings.array, documentEmbeddingOffset, "rId", documentSourceRids(ctx, "embeddings"));
|
|
19034
|
-
const commentMedia = hasComments ? findAndReplaceImagePlaceholders(commentXmlData, ctx.media.array, commentRelationshipCount) : {
|
|
19035
|
-
xml: "",
|
|
19036
|
-
referenced: []
|
|
19037
|
-
};
|
|
19038
|
-
const commentEmbeddingOffset = commentRelationshipCount + commentMedia.referenced.length;
|
|
19039
|
-
const commentEmbeddings = hasComments ? findAndReplaceImagePlaceholders(commentMedia.xml, ctx.embeddings.array, commentEmbeddingOffset) : {
|
|
19040
|
-
xml: "",
|
|
19041
|
-
referenced: []
|
|
19042
|
-
};
|
|
19043
|
-
const footnoteMedia = findAndReplaceImagePlaceholders(footnoteXmlData, ctx.media.array, footnoteRelationshipCount);
|
|
19044
|
-
const footnoteEmbeddingOffset = footnoteRelationshipCount + footnoteMedia.referenced.length;
|
|
19045
|
-
const footnoteEmbeddings = findAndReplaceImagePlaceholders(footnoteMedia.xml, ctx.embeddings.array, footnoteEmbeddingOffset);
|
|
19046
|
-
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}`);
|
|
19047
|
-
for (const [i, ref] of footnoteEmbeddings.referenced.entries()) ctx.footNotes.relationships.addRelationship(footnoteEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19260
|
+
const notesParts = compileNotesParts(ctx, mkCtx);
|
|
19261
|
+
const headerFooterParts = compileHeaderFooterParts(ctx, mkCtx);
|
|
19262
|
+
const documentEntries = compileDocumentEntries(ctx, documentXmlData, documentRelationshipCount);
|
|
19048
19263
|
return {
|
|
19049
19264
|
AppProperties: {
|
|
19050
19265
|
data: XML_DECL + (appPropertiesDesc.stringify(ctx._options.appProperties ?? {}, ctx) ?? ""),
|
|
19051
19266
|
path: "docProps/app.xml"
|
|
19052
19267
|
},
|
|
19053
|
-
...
|
|
19054
|
-
Comments: {
|
|
19055
|
-
data: replaceNumberingPlaceholders(commentEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19056
|
-
path: "word/comments.xml"
|
|
19057
|
-
},
|
|
19058
|
-
CommentsRelationships: (() => {
|
|
19059
|
-
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}`);
|
|
19060
|
-
for (const [i, ref] of commentEmbeddings.referenced.entries()) ctx.comments.relationships.addRelationship(commentEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19061
|
-
return optionalRelsPart(ctx.comments.relationships, XML_DECL, "word/_rels/comments.xml.rels");
|
|
19062
|
-
})()
|
|
19063
|
-
} : {},
|
|
19268
|
+
...notesParts,
|
|
19064
19269
|
...ctx._options.customProperties !== void 0 ? { CustomProperties: {
|
|
19065
19270
|
data: XML_DECL + (customPropertiesDesc.stringify({ properties: ctx._options.customProperties }, ctx) ?? ""),
|
|
19066
19271
|
path: "docProps/custom.xml"
|
|
@@ -19073,76 +19278,11 @@ function xmlifyContext(ctx) {
|
|
|
19073
19278
|
data: XML_DECL + (commentsExtendedDesc.stringify(ctx._options.commentsExtended, ctx) ?? ""),
|
|
19074
19279
|
path: "word/commentsExtended.xml"
|
|
19075
19280
|
} } : {},
|
|
19076
|
-
|
|
19077
|
-
data: (() => {
|
|
19078
|
-
let xmlData = documentEmbeddings.xml;
|
|
19079
|
-
if (hasPlaceholders(xmlData)) {
|
|
19080
|
-
const mediaCount = documentMedia.referenced.length;
|
|
19081
|
-
const embeddingCount = documentEmbeddings.referenced.length;
|
|
19082
|
-
const chartKeys = ctx.charts.array.map((c) => c.key);
|
|
19083
|
-
const smartArtKeys = ctx.smartArts.array.map((s) => s.key);
|
|
19084
|
-
const chartOffset = documentRelationshipCount + mediaCount + embeddingCount;
|
|
19085
|
-
const smartArtOffset = chartOffset + chartKeys.length;
|
|
19086
|
-
const entries = [];
|
|
19087
|
-
for (const [i, key] of chartKeys.entries()) {
|
|
19088
|
-
const chartTarget = `charts/chart${i + 1}.xml`;
|
|
19089
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", chartTarget);
|
|
19090
|
-
entries.push({
|
|
19091
|
-
prefix: "chart:",
|
|
19092
|
-
key,
|
|
19093
|
-
value: sourceRid !== void 0 ? `rId${sourceRid}` : formatId(chartOffset, i, "rId")
|
|
19094
|
-
});
|
|
19095
|
-
}
|
|
19096
|
-
const saPrefixes = [
|
|
19097
|
-
"smartart:",
|
|
19098
|
-
"smartart-lo:",
|
|
19099
|
-
"smartart-qs:",
|
|
19100
|
-
"smartart-cs:"
|
|
19101
|
-
];
|
|
19102
|
-
for (const [i, key] of smartArtKeys.entries()) for (let p = 0; p < saPrefixes.length; p++) entries.push({
|
|
19103
|
-
prefix: saPrefixes[p],
|
|
19104
|
-
key,
|
|
19105
|
-
value: formatId(smartArtOffset + p * smartArtKeys.length, i, "rId")
|
|
19106
|
-
});
|
|
19107
|
-
for (const { reference, instance, numId } of ctx.numbering.concreteNumbering) entries.push({
|
|
19108
|
-
key: `${reference}-${instance}`,
|
|
19109
|
-
value: numId.toString()
|
|
19110
|
-
});
|
|
19111
|
-
xmlData = replaceAllPlaceholders(xmlData, entries);
|
|
19112
|
-
} else xmlData = replaceNumberingPlaceholders(xmlData, ctx.numbering.concreteNumbering);
|
|
19113
|
-
return xmlData;
|
|
19114
|
-
})(),
|
|
19115
|
-
path: "word/document.xml"
|
|
19116
|
-
},
|
|
19281
|
+
...documentEntries,
|
|
19117
19282
|
...ctx._options.rawParts?.some((part) => part.path.startsWith("word/theme/")) ? {} : { Theme: {
|
|
19118
19283
|
data: XML_DECL + createThemeXml(),
|
|
19119
19284
|
path: "word/theme/theme1.xml"
|
|
19120
19285
|
} },
|
|
19121
|
-
...ctx.hasEndnotes ? {
|
|
19122
|
-
Endnotes: {
|
|
19123
|
-
data: (() => {
|
|
19124
|
-
const endnoteCtx = mkCtx({ relationships: ctx.endnotes.relationships });
|
|
19125
|
-
const xmlData = XML_DECL + (endnotesDesc.stringify({
|
|
19126
|
-
notes: ctx.endnotes.notes,
|
|
19127
|
-
separator: ctx.endnotes.separator,
|
|
19128
|
-
continuationSeparator: ctx.endnotes.continuationSeparator,
|
|
19129
|
-
continuationNotice: ctx.endnotes.continuationNotice
|
|
19130
|
-
}, endnoteCtx) ?? "");
|
|
19131
|
-
const endnoteRelCount = ctx.endnotes.relationships.nextRelationshipId;
|
|
19132
|
-
const endnoteMedia = findAndReplaceImagePlaceholders(xmlData, ctx.media.array, endnoteRelCount);
|
|
19133
|
-
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}`);
|
|
19134
|
-
const endnoteEmbeddingOffset = endnoteRelCount + endnoteMedia.referenced.length;
|
|
19135
|
-
const endnoteEmbeddings = findAndReplaceImagePlaceholders(endnoteMedia.xml, ctx.embeddings.array, endnoteEmbeddingOffset);
|
|
19136
|
-
for (const [i, ref] of endnoteEmbeddings.referenced.entries()) ctx.endnotes.relationships.addRelationship(endnoteEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19137
|
-
return replaceNumberingPlaceholders(endnoteEmbeddings.xml, ctx.numbering.concreteNumbering);
|
|
19138
|
-
})(),
|
|
19139
|
-
path: "word/endnotes.xml"
|
|
19140
|
-
},
|
|
19141
|
-
EndnotesRelationships: ctx.endnotes.relationships.relationshipCount > 0 ? {
|
|
19142
|
-
data: XML_DECL + ctx.endnotes.relationships.serialize(),
|
|
19143
|
-
path: "word/_rels/endnotes.xml.rels"
|
|
19144
|
-
} : void 0
|
|
19145
|
-
} : {},
|
|
19146
19286
|
FileRelationships: {
|
|
19147
19287
|
data: XML_DECL + ctx.fileRelationships.serialize(),
|
|
19148
19288
|
path: "_rels/.rels"
|
|
@@ -19152,67 +19292,12 @@ function xmlifyContext(ctx) {
|
|
|
19152
19292
|
path: "word/fontTable.xml"
|
|
19153
19293
|
},
|
|
19154
19294
|
FontTableRelationships: optionalRelsPart(ctx.fontTable.relationships, XML_DECL, "word/_rels/fontTable.xml.rels"),
|
|
19155
|
-
...
|
|
19156
|
-
FootNotes: {
|
|
19157
|
-
data: replaceNumberingPlaceholders(footnoteEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19158
|
-
path: "word/footnotes.xml"
|
|
19159
|
-
},
|
|
19160
|
-
FootNotesRelationships: ctx.footNotes.relationships.relationshipCount > 0 ? {
|
|
19161
|
-
data: XML_DECL + ctx.footNotes.relationships.serialize(),
|
|
19162
|
-
path: "word/_rels/footnotes.xml.rels"
|
|
19163
|
-
} : void 0
|
|
19164
|
-
} : {},
|
|
19165
|
-
FooterRelationships: ctx.footers.map((entry, index) => {
|
|
19166
|
-
const footerCtx = mkCtx({
|
|
19167
|
-
relationships: entry.relationships,
|
|
19168
|
-
partName: `word/${entry.partName ?? `footer${index + 1}.xml`}`
|
|
19169
|
-
});
|
|
19170
|
-
const xmlData = XML_DECL + stringifyHeaderFooter("w:ftr", FOOTER_NAMESPACES, entry.children, footerCtx);
|
|
19171
|
-
const footerRelCount = entry.relationships.nextRelationshipId;
|
|
19172
|
-
const footerMedia = findAndReplaceImagePlaceholders(xmlData, ctx.media.array, footerRelCount);
|
|
19173
|
-
footerMediaResults.set(index, footerMedia);
|
|
19174
|
-
const footerEmbeddingOffset = footerRelCount + footerMedia.referenced.length;
|
|
19175
|
-
const footerEmbeddings = findAndReplaceImagePlaceholders(footerMedia.xml, ctx.embeddings.array, footerEmbeddingOffset);
|
|
19176
|
-
footerEmbeddingResults.set(index, footerEmbeddings);
|
|
19177
|
-
for (const [i, ref] of footerMedia.referenced.entries()) entry.relationships.addRelationship(footerRelCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19178
|
-
for (const [i, ref] of footerEmbeddings.referenced.entries()) entry.relationships.addRelationship(footerEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19179
|
-
return optionalRelsPart(entry.relationships, XML_DECL, `word/_rels/${entry.partName ?? `footer${index + 1}.xml`}.rels`);
|
|
19180
|
-
}).filter((r) => r !== void 0),
|
|
19181
|
-
Footers: ctx.footers.map((entry, index) => {
|
|
19182
|
-
const footerEmbeddings = footerEmbeddingResults.get(index);
|
|
19183
|
-
return {
|
|
19184
|
-
data: replaceNumberingPlaceholders(footerEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19185
|
-
path: `word/${entry.partName ?? `footer${index + 1}.xml`}`
|
|
19186
|
-
};
|
|
19187
|
-
}),
|
|
19188
|
-
HeaderRelationships: ctx.headers.map((entry, index) => {
|
|
19189
|
-
const headerCtx = mkCtx({
|
|
19190
|
-
relationships: entry.relationships,
|
|
19191
|
-
partName: `word/${entry.partName ?? `header${index + 1}.xml`}`
|
|
19192
|
-
});
|
|
19193
|
-
const xmlData = XML_DECL + stringifyHeaderFooter("w:hdr", HEADER_NAMESPACES, entry.children, headerCtx);
|
|
19194
|
-
const headerRelCount = entry.relationships.nextRelationshipId;
|
|
19195
|
-
const headerMedia = findAndReplaceImagePlaceholders(xmlData, ctx.media.array, headerRelCount);
|
|
19196
|
-
headerMediaResults.set(index, headerMedia);
|
|
19197
|
-
const headerEmbeddingOffset = headerRelCount + headerMedia.referenced.length;
|
|
19198
|
-
const headerEmbeddings = findAndReplaceImagePlaceholders(headerMedia.xml, ctx.embeddings.array, headerEmbeddingOffset);
|
|
19199
|
-
headerEmbeddingResults.set(index, headerEmbeddings);
|
|
19200
|
-
for (const [i, ref] of headerMedia.referenced.entries()) entry.relationships.addRelationship(headerRelCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${ref.fileName}`);
|
|
19201
|
-
for (const [i, ref] of headerEmbeddings.referenced.entries()) entry.relationships.addRelationship(headerEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), `embeddings/${ref.fileName}`);
|
|
19202
|
-
return optionalRelsPart(entry.relationships, XML_DECL, `word/_rels/${entry.partName ?? `header${index + 1}.xml`}.rels`);
|
|
19203
|
-
}).filter((r) => r !== void 0),
|
|
19204
|
-
Headers: ctx.headers.map((entry, index) => {
|
|
19205
|
-
const headerEmbeddings = headerEmbeddingResults.get(index);
|
|
19206
|
-
return {
|
|
19207
|
-
data: replaceNumberingPlaceholders(headerEmbeddings.xml, ctx.numbering.concreteNumbering),
|
|
19208
|
-
path: `word/${entry.partName ?? `header${index + 1}.xml`}`
|
|
19209
|
-
};
|
|
19210
|
-
}),
|
|
19295
|
+
...headerFooterParts,
|
|
19211
19296
|
...ctx.hasNumbering ? (() => {
|
|
19212
19297
|
const numberingXml = ctx.numbering.serialize(ctx);
|
|
19213
19298
|
const numberingMedia = findAndReplaceImagePlaceholders(numberingXml, ctx.media.array, 1);
|
|
19214
19299
|
const numberingRels = new Relationships();
|
|
19215
|
-
for (const [i, ref] of numberingMedia.referenced.entries()) numberingRels.addRelationship(1 + i,
|
|
19300
|
+
for (const [i, ref] of numberingMedia.referenced.entries()) numberingRels.addRelationship(1 + i, RELATIONSHIP_TYPES.image, `media/${ref.fileName}`);
|
|
19216
19301
|
return {
|
|
19217
19302
|
Numbering: {
|
|
19218
19303
|
data: numberingMedia.xml,
|
|
@@ -19225,44 +19310,13 @@ function xmlifyContext(ctx) {
|
|
|
19225
19310
|
data: XML_DECL + (corePropertiesDesc.stringify(ctx._options, ctx) ?? ""),
|
|
19226
19311
|
path: "docProps/core.xml"
|
|
19227
19312
|
},
|
|
19228
|
-
Relationships: {
|
|
19229
|
-
data: (() => {
|
|
19230
|
-
for (const [i, ref] of documentMedia.referenced.entries()) {
|
|
19231
|
-
const target = `media/${ref.fileName}`;
|
|
19232
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", target);
|
|
19233
|
-
ctx.document.relationships.addRelationship(sourceRid ?? documentRelationshipCount + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", target);
|
|
19234
|
-
}
|
|
19235
|
-
for (const [i, ref] of documentEmbeddings.referenced.entries()) {
|
|
19236
|
-
const target = `embeddings/${ref.fileName}`;
|
|
19237
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
19238
|
-
ctx.document.relationships.addRelationship(sourceRid ?? documentEmbeddingOffset + i, embeddingRelationship(ctx.embeddings, ref.fileName), target);
|
|
19239
|
-
}
|
|
19240
|
-
const chartOffset = documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length;
|
|
19241
|
-
for (let i = 0; i < ctx.charts.array.length; i++) {
|
|
19242
|
-
const target = `charts/chart${i + 1}.xml`;
|
|
19243
|
-
const sourceRid = sourceRidFor(ctx._options.passthroughRelationships, "word/document.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", target);
|
|
19244
|
-
ctx.document.relationships.addRelationship(sourceRid ?? chartOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", target);
|
|
19245
|
-
}
|
|
19246
|
-
addSmartArtRelationships(ctx.smartArts.array.map((s) => s.key), (id, type, target) => {
|
|
19247
|
-
ctx.document.relationships.addRelationship(id, type, target);
|
|
19248
|
-
}, documentRelationshipCount + documentMedia.referenced.length + documentEmbeddings.referenced.length + ctx.charts.array.length, 0, {
|
|
19249
|
-
pathPrefix: "",
|
|
19250
|
-
styleRelType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle",
|
|
19251
|
-
hasDrawing: (key) => ctx.smartArts.array.find((s) => s.key === key)?.raw?.drawing !== void 0
|
|
19252
|
-
});
|
|
19253
|
-
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");
|
|
19254
|
-
ctx.addPassthroughDocumentRelationships();
|
|
19255
|
-
return XML_DECL + ctx.document.relationships.serialize();
|
|
19256
|
-
})(),
|
|
19257
|
-
path: "word/_rels/document.xml.rels"
|
|
19258
|
-
},
|
|
19259
19313
|
Settings: {
|
|
19260
19314
|
data: XML_DECL + (settingsDesc.stringify(ctx._settingsOptions, ctx) ?? ""),
|
|
19261
19315
|
path: "word/settings.xml"
|
|
19262
19316
|
},
|
|
19263
19317
|
...ctx._settingsOptions.attachedTemplate !== void 0 ? (() => {
|
|
19264
19318
|
const rels = new Relationships();
|
|
19265
|
-
rels.addRelationship(1,
|
|
19319
|
+
rels.addRelationship(1, RELATIONSHIP_TYPES.attachedTemplate, ctx._settingsOptions.attachedTemplate, TargetModeType.EXTERNAL);
|
|
19266
19320
|
return { SettingsRelationships: {
|
|
19267
19321
|
data: XML_DECL + rels.serialize(),
|
|
19268
19322
|
path: "word/_rels/settings.xml.rels"
|
|
@@ -19279,68 +19333,8 @@ function xmlifyContext(ctx) {
|
|
|
19279
19333
|
data: XML_DECL + (bibliographyDesc.stringify(ctx._options.bibliography, ctx) ?? ""),
|
|
19280
19334
|
path: "word/bibliography.xml"
|
|
19281
19335
|
} } : {},
|
|
19282
|
-
...ctx
|
|
19283
|
-
|
|
19284
|
-
const parts = [{
|
|
19285
|
-
data: XML_DECL + chartData.chartSpaceXml,
|
|
19286
|
-
path: `word/charts/chart${i + 1}.xml`
|
|
19287
|
-
}];
|
|
19288
|
-
if (chartData.userShapes) parts.push({
|
|
19289
|
-
data: XML_DECL + chartData.userShapes.xml,
|
|
19290
|
-
path: `word/charts/userShapes${i + 1}.xml`
|
|
19291
|
-
});
|
|
19292
|
-
const e = chartData.embedding;
|
|
19293
|
-
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"/>`] : []];
|
|
19294
|
-
if (rels.length > 0) parts.push({
|
|
19295
|
-
data: XML_DECL + `<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${rels.join("")}</Relationships>`,
|
|
19296
|
-
path: `word/charts/_rels/chart${i + 1}.xml.rels`
|
|
19297
|
-
});
|
|
19298
|
-
return parts;
|
|
19299
|
-
}),
|
|
19300
|
-
ChartEmbeddings: (() => {
|
|
19301
|
-
const seen = /* @__PURE__ */ new Set();
|
|
19302
|
-
const parts = [];
|
|
19303
|
-
for (const c of ctx.charts.array) {
|
|
19304
|
-
const e = c.embedding;
|
|
19305
|
-
if (!e || seen.has(e.fileName)) continue;
|
|
19306
|
-
seen.add(e.fileName);
|
|
19307
|
-
parts.push({
|
|
19308
|
-
data: toUint8Array(e.data),
|
|
19309
|
-
path: `word/embeddings/${e.fileName}`
|
|
19310
|
-
});
|
|
19311
|
-
}
|
|
19312
|
-
return parts;
|
|
19313
|
-
})()
|
|
19314
|
-
} : {},
|
|
19315
|
-
...ctx.smartArts.array.length > 0 ? {
|
|
19316
|
-
DiagramData: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19317
|
-
data: smartArtData.raw?.data !== void 0 ? toUint8Array(smartArtData.raw.data) : XML_DECL + smartArtData.dataModelXml,
|
|
19318
|
-
path: `word/diagrams/data${i + 1}.xml`
|
|
19319
|
-
})),
|
|
19320
|
-
DiagramLayout: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19321
|
-
data: smartArtData.raw?.layout !== void 0 ? toUint8Array(smartArtData.raw.layout) : typeof smartArtData.layout === "string" ? getLayoutXml(smartArtData.layout) : stringifyLayoutDefinitionPart(smartArtData.layout),
|
|
19322
|
-
path: `word/diagrams/layout${i + 1}.xml`
|
|
19323
|
-
})),
|
|
19324
|
-
DiagramStyle: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19325
|
-
data: smartArtData.raw?.style !== void 0 ? toUint8Array(smartArtData.raw.style) : typeof smartArtData.style === "string" ? getStyleXml(smartArtData.style) : stringifyStyleDefinitionPart(smartArtData.style),
|
|
19326
|
-
path: `word/diagrams/quickStyle${i + 1}.xml`
|
|
19327
|
-
})),
|
|
19328
|
-
DiagramColors: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19329
|
-
data: smartArtData.raw?.color !== void 0 ? toUint8Array(smartArtData.raw.color) : typeof smartArtData.color === "string" ? getColorXml(smartArtData.color) : stringifyColorDefinitionPart(smartArtData.color),
|
|
19330
|
-
path: `word/diagrams/colors${i + 1}.xml`
|
|
19331
|
-
})),
|
|
19332
|
-
DiagramDrawing: ctx.smartArts.array.map((smartArtData, i) => ({
|
|
19333
|
-
smartArtData,
|
|
19334
|
-
i
|
|
19335
|
-
})).filter(({ smartArtData }) => smartArtData.raw?.drawing !== void 0).map(({ smartArtData, i }) => ({
|
|
19336
|
-
data: toUint8Array(smartArtData.raw.drawing),
|
|
19337
|
-
path: `word/diagrams/drawing${i + 1}.xml`
|
|
19338
|
-
})),
|
|
19339
|
-
...ctx.smartArts.array.some((s) => s.raw?.dataRels !== void 0) ? { SmartArtDataRels: ctx.smartArts.array.flatMap((smartArtData, i) => smartArtData.raw?.dataRels !== void 0 ? [{
|
|
19340
|
-
data: toUint8Array(smartArtData.raw.dataRels),
|
|
19341
|
-
path: `word/diagrams/_rels/data${i + 1}.xml.rels`
|
|
19342
|
-
}] : []) } : {}
|
|
19343
|
-
} : {},
|
|
19336
|
+
...compileChartParts(ctx),
|
|
19337
|
+
...compileSmartArtParts(ctx),
|
|
19344
19338
|
...ctx.altChunks.array.length > 0 ? { AltChunks: ctx.altChunks.array.map((altChunkData) => ({
|
|
19345
19339
|
data: altChunkData.data,
|
|
19346
19340
|
path: `word/${altChunkData.path}`
|
|
@@ -19431,6 +19425,6 @@ function generateDocumentStream(options, packerOptions) {
|
|
|
19431
19425
|
return Packer.toStream(options, packerOptions);
|
|
19432
19426
|
}
|
|
19433
19427
|
//#endregion
|
|
19434
|
-
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,
|
|
19428
|
+
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 };
|
|
19435
19429
|
|
|
19436
19430
|
//# sourceMappingURL=index.mjs.map
|