@office-open/docx 0.9.7 → 0.9.8
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/{context-BrtlmvVE.mjs → context-Bl2wL_dD.mjs} +18 -4
- package/dist/context-Bl2wL_dD.mjs.map +1 -0
- package/dist/{core-properties-CBMhgSrn.d.mts → core-properties-CZzFLDat.d.mts} +89 -49
- package/dist/core-properties-CZzFLDat.d.mts.map +1 -0
- package/dist/{generate-BMTVflV1.mjs → generate-CqKwXEWC.mjs} +42 -30
- package/dist/generate-CqKwXEWC.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +5 -17
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{parse-K59nx6MF.mjs → parse-BwZ29Ait.mjs} +18 -6
- package/dist/parse-BwZ29Ait.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/{parts-BQBGNSGm.mjs → parts-Cp_NxQFi.mjs} +296 -221
- package/dist/parts-Cp_NxQFi.mjs.map +1 -0
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-BrtlmvVE.mjs.map +0 -1
- package/dist/core-properties-CBMhgSrn.d.mts.map +0 -1
- package/dist/generate-BMTVflV1.mjs.map +0 -1
- package/dist/parse-K59nx6MF.mjs.map +0 -1
- package/dist/parts-BQBGNSGm.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Relationships, TargetModeType, ThemeColor, blipDesc, convertEmuToPixels, convertInchesToTwip, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, customGeometryDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
|
|
1
|
+
import { DOCX_PARTS, Relationships, TargetModeType, ThemeColor, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, customGeometryDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
|
|
2
2
|
import { attr, attrBool, attrNum, children, colorAttr, element, escapeXml, findChild, findDeep, stringify, textOf } from "@office-open/xml";
|
|
3
3
|
import { calculateEffectExtent, createColorElement, createEffectDag, createScene3D, createShape3D, customGeometryDesc as customGeometryDesc$1, effectListDesc as effectListDesc$1, extractBlipFillMedia, fillDesc as fillDesc$1, outlineDesc as outlineDesc$1, scene3DDesc, shape3DDesc, transform2DDesc } from "@office-open/core/drawingml";
|
|
4
4
|
import { chartSpaceDesc } from "@office-open/core/chart";
|
|
@@ -317,10 +317,26 @@ const createTransformation = (options) => ({
|
|
|
317
317
|
*/
|
|
318
318
|
var Media = class {
|
|
319
319
|
map;
|
|
320
|
+
nextMediaCounter = 0;
|
|
320
321
|
constructor() {
|
|
321
322
|
this.map = /* @__PURE__ */ new Map();
|
|
322
323
|
}
|
|
323
324
|
/**
|
|
325
|
+
* Allocates the next sequential media file name (Office-style `image1.png`,
|
|
326
|
+
* `image2.png`, …). The counter is package-global because media is shared
|
|
327
|
+
* across the document, headers, and footers, matching MS Office's numbering.
|
|
328
|
+
*
|
|
329
|
+
* Deterministic across runs (unlike random ids) so round-trip output is stable
|
|
330
|
+
* and diffable. Callers pair this with {@link findByContent} to reuse an
|
|
331
|
+
* existing entry for byte-identical content before allocating a new name.
|
|
332
|
+
*
|
|
333
|
+
* @param type - File extension / image type token (e.g. "png", "jpg")
|
|
334
|
+
* @returns A sequential file name like `image3.png`
|
|
335
|
+
*/
|
|
336
|
+
nextMediaName(type) {
|
|
337
|
+
return `image${++this.nextMediaCounter}.${type}`;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
324
340
|
* Adds an image to the media collection.
|
|
325
341
|
*
|
|
326
342
|
* @param key - Unique identifier for this image
|
|
@@ -330,6 +346,28 @@ var Media = class {
|
|
|
330
346
|
this.map.set(key, mediaData);
|
|
331
347
|
}
|
|
332
348
|
/**
|
|
349
|
+
* Finds an existing image with byte-identical content (content-based dedup).
|
|
350
|
+
*
|
|
351
|
+
* Returns the matching entry's key (fileName) so callers reuse it instead of
|
|
352
|
+
* registering a duplicate — e.g. a VML fallback image that mirrors the Choice
|
|
353
|
+
* blip should share one relationship/file, matching Office's output.
|
|
354
|
+
*
|
|
355
|
+
* @param data - Raw image bytes to search for
|
|
356
|
+
* @returns The matching entry's key, or `undefined` if no match
|
|
357
|
+
*/
|
|
358
|
+
findByContent(data) {
|
|
359
|
+
for (const [key, md] of this.map) {
|
|
360
|
+
const existing = toUint8Array(md.data);
|
|
361
|
+
if (existing.length !== data.length) continue;
|
|
362
|
+
let match = true;
|
|
363
|
+
for (let i = 0; i < existing.length; i++) if (existing[i] !== data[i]) {
|
|
364
|
+
match = false;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
if (match) return key;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
333
371
|
* Gets all images as an array.
|
|
334
372
|
*
|
|
335
373
|
* @returns Read-only array of all media data in the collection
|
|
@@ -346,11 +384,11 @@ var Media = class {
|
|
|
346
384
|
const WORKAROUND2 = "";
|
|
347
385
|
//#endregion
|
|
348
386
|
//#region src/parts/paragraph/run/image-run.ts
|
|
349
|
-
const createImageData$1 = (data, transformation, key,
|
|
387
|
+
const createImageData$1 = (data, transformation, key, sourceRectangle, nonVisualProperties) => ({
|
|
350
388
|
data,
|
|
351
389
|
fileName: key,
|
|
352
|
-
|
|
353
|
-
|
|
390
|
+
sourceRectangle,
|
|
391
|
+
nonVisualProperties,
|
|
354
392
|
transformation: createTransformation(transformation)
|
|
355
393
|
});
|
|
356
394
|
//#endregion
|
|
@@ -1562,7 +1600,7 @@ const PARSED_LINE_BREAK = Symbol("LineBreak");
|
|
|
1562
1600
|
/** Matches w:tab */
|
|
1563
1601
|
const PARSED_TAB = Symbol("Tab");
|
|
1564
1602
|
/** Matches w:cr */
|
|
1565
|
-
const
|
|
1603
|
+
const PARSED_CARRIAGE_RETURN = Symbol("CarriageReturn");
|
|
1566
1604
|
/** Matches w:noBreakHyphen */
|
|
1567
1605
|
const PARSED_NO_BREAK_HYPHEN = Symbol("NoBreakHyphen");
|
|
1568
1606
|
/** Matches w:softHyphen */
|
|
@@ -1590,7 +1628,7 @@ const PARSED_SEPARATOR = Symbol("Separator");
|
|
|
1590
1628
|
/** Matches w:continuationSeparator */
|
|
1591
1629
|
const PARSED_CONTINUATION_SEPARATOR = Symbol("ContinuationSeparator");
|
|
1592
1630
|
/** Matches w:pgNum */
|
|
1593
|
-
const
|
|
1631
|
+
const PARSED_PAGE_NUMBER = Symbol("PageNumber");
|
|
1594
1632
|
/** Matches w:lastRenderedPageBreak */
|
|
1595
1633
|
const PARSED_LAST_RENDERED_PAGE_BREAK = Symbol("LastRenderedPageBreak");
|
|
1596
1634
|
/**
|
|
@@ -1627,7 +1665,7 @@ function parseRun(el, _ctx) {
|
|
|
1627
1665
|
children.push(PARSED_TAB);
|
|
1628
1666
|
break;
|
|
1629
1667
|
case "w:cr":
|
|
1630
|
-
children.push(
|
|
1668
|
+
children.push(PARSED_CARRIAGE_RETURN);
|
|
1631
1669
|
break;
|
|
1632
1670
|
case "w:noBreakHyphen":
|
|
1633
1671
|
children.push(PARSED_NO_BREAK_HYPHEN);
|
|
@@ -1693,7 +1731,7 @@ function parseRun(el, _ctx) {
|
|
|
1693
1731
|
children.push(PARSED_CONTINUATION_SEPARATOR);
|
|
1694
1732
|
break;
|
|
1695
1733
|
case "w:pgNum":
|
|
1696
|
-
children.push(
|
|
1734
|
+
children.push(PARSED_PAGE_NUMBER);
|
|
1697
1735
|
break;
|
|
1698
1736
|
case "w:lastRenderedPageBreak":
|
|
1699
1737
|
children.push(PARSED_LAST_RENDERED_PAGE_BREAK);
|
|
@@ -1718,7 +1756,7 @@ function parseRun(el, _ctx) {
|
|
|
1718
1756
|
/** Mapping from parse symbols to RunOptions child objects for empty elements. */
|
|
1719
1757
|
const SYMBOL_TO_CHILD = new Map([
|
|
1720
1758
|
[PARSED_TAB, { tab: true }],
|
|
1721
|
-
[
|
|
1759
|
+
[PARSED_CARRIAGE_RETURN, { carriageReturn: true }],
|
|
1722
1760
|
[PARSED_NO_BREAK_HYPHEN, { noBreakHyphen: true }],
|
|
1723
1761
|
[PARSED_SOFT_HYPHEN, { softHyphen: true }],
|
|
1724
1762
|
[PARSED_DAY_SHORT, { dayShort: true }],
|
|
@@ -1730,7 +1768,7 @@ const SYMBOL_TO_CHILD = new Map([
|
|
|
1730
1768
|
[PARSED_ANNOTATION_REF, { annotationRef: true }],
|
|
1731
1769
|
[PARSED_SEPARATOR, { separator: true }],
|
|
1732
1770
|
[PARSED_CONTINUATION_SEPARATOR, { continuationSeparator: true }],
|
|
1733
|
-
[
|
|
1771
|
+
[PARSED_PAGE_NUMBER, { pgNum: true }],
|
|
1734
1772
|
[PARSED_LAST_RENDERED_PAGE_BREAK, { lastRenderedPageBreak: true }]
|
|
1735
1773
|
]);
|
|
1736
1774
|
function parsedRunToOptions(parsed) {
|
|
@@ -2190,14 +2228,14 @@ const altChunkDesc = {
|
|
|
2190
2228
|
contentType: opts.contentType
|
|
2191
2229
|
});
|
|
2192
2230
|
const rId = `rId${relId}`;
|
|
2193
|
-
if (opts.
|
|
2231
|
+
if (opts.matchSource) return `<w:altChunk r:id="${rId}"><w:altChunkPr><w:matchSrc/></w:altChunkPr></w:altChunk>`;
|
|
2194
2232
|
return `<w:altChunk r:id="${rId}"/>`;
|
|
2195
2233
|
},
|
|
2196
2234
|
parse(el, ctx) {
|
|
2197
2235
|
const rId = attr(el, "r:id");
|
|
2198
2236
|
const opts = {};
|
|
2199
2237
|
const altChunkPr = findChild(el, "w:altChunkPr");
|
|
2200
|
-
if (altChunkPr && findChild(altChunkPr, "w:matchSrc")) opts.
|
|
2238
|
+
if (altChunkPr && findChild(altChunkPr, "w:matchSrc")) opts.matchSource = true;
|
|
2201
2239
|
const dctx = ctx;
|
|
2202
2240
|
if (rId) {
|
|
2203
2241
|
const path = dctx.resolveRelationship(rId);
|
|
@@ -2231,7 +2269,7 @@ const subDocDesc = {
|
|
|
2231
2269
|
stringify(opts, ctx) {
|
|
2232
2270
|
const relId = uniqueId();
|
|
2233
2271
|
const partPath = `subdocs/subdoc${relId}.docx`;
|
|
2234
|
-
const data =
|
|
2272
|
+
const data = toUint8Array(opts.data);
|
|
2235
2273
|
ctx.fileData.document.relationships.addRelationship(relId, SUBDOC_REL_TYPE, partPath);
|
|
2236
2274
|
ctx.fileData.subDocs.addSubDoc(relId, {
|
|
2237
2275
|
data,
|
|
@@ -2483,8 +2521,8 @@ function parseSdtPr(el) {
|
|
|
2483
2521
|
}
|
|
2484
2522
|
return opts;
|
|
2485
2523
|
}
|
|
2486
|
-
/** Parse w:customXmlPr element into
|
|
2487
|
-
function
|
|
2524
|
+
/** Parse w:customXmlPr element into CustomXmlPropertiesOptions. */
|
|
2525
|
+
function parseCustomXmlProperties(el) {
|
|
2488
2526
|
const opts = {};
|
|
2489
2527
|
const placeholder = findChild(el, "w:placeholder");
|
|
2490
2528
|
if (placeholder) {
|
|
@@ -2558,7 +2596,7 @@ const sdtBlockDesc = {
|
|
|
2558
2596
|
};
|
|
2559
2597
|
}
|
|
2560
2598
|
};
|
|
2561
|
-
function
|
|
2599
|
+
function buildCustomXmlPropertiesXml(pr) {
|
|
2562
2600
|
const parts = ["<w:customXmlPr>"];
|
|
2563
2601
|
if (pr.placeholder !== void 0) parts.push(`<w:placeholder w:val="${escapeAttr$2(pr.placeholder)}"/>`);
|
|
2564
2602
|
if (pr.attributes) for (const attr of pr.attributes) {
|
|
@@ -2576,7 +2614,7 @@ function buildCustomXmlPrXml(pr) {
|
|
|
2576
2614
|
function stringifyCustomXmlShell(opts, contentXml) {
|
|
2577
2615
|
const attrs = [`w:element="${escapeAttr$2(opts.element)}"`];
|
|
2578
2616
|
if (opts.uri !== void 0) attrs.push(`w:uri="${escapeAttr$2(opts.uri)}"`);
|
|
2579
|
-
const prXml = opts.customXmlPr ?
|
|
2617
|
+
const prXml = opts.customXmlPr ? buildCustomXmlPropertiesXml(opts.customXmlPr) : "";
|
|
2580
2618
|
return `<w:customXml ${attrs.join(" ")}>${prXml}${contentXml}</w:customXml>`;
|
|
2581
2619
|
}
|
|
2582
2620
|
const customXmlBlockDesc = {
|
|
@@ -2594,7 +2632,7 @@ const customXmlBlockDesc = {
|
|
|
2594
2632
|
const uri = attr(el, "w:uri");
|
|
2595
2633
|
if (uri) opts.uri = uri;
|
|
2596
2634
|
const xmlPr = findChild(el, "w:customXmlPr");
|
|
2597
|
-
if (xmlPr) opts.customXmlPr =
|
|
2635
|
+
if (xmlPr) opts.customXmlPr = parseCustomXmlProperties(xmlPr);
|
|
2598
2636
|
const childList = [];
|
|
2599
2637
|
for (const child of el.elements ?? []) {
|
|
2600
2638
|
if (child.name === "w:customXmlPr") continue;
|
|
@@ -3262,7 +3300,7 @@ const PageOrientation = {
|
|
|
3262
3300
|
* </xsd:complexType>
|
|
3263
3301
|
* ```
|
|
3264
3302
|
*/
|
|
3265
|
-
const createPageSize = ({ width, height, orientation, code }) => {
|
|
3303
|
+
const createPageSize = ({ width = 11906, height = 16838, orientation, code }) => {
|
|
3266
3304
|
const widthTwips = twipsMeasureValue(width);
|
|
3267
3305
|
const heightTwips = twipsMeasureValue(height);
|
|
3268
3306
|
return element("w:pgSz", {
|
|
@@ -3760,6 +3798,7 @@ var FontWrapper = class {
|
|
|
3760
3798
|
this.options = options;
|
|
3761
3799
|
this.fontOptionsWithKey = options.map((o) => ({
|
|
3762
3800
|
...o,
|
|
3801
|
+
data: o.data !== void 0 ? toUint8Array(o.data) : void 0,
|
|
3763
3802
|
fontKey: o.data !== void 0 ? o.fontKey ?? uniqueUuid() : o.fontKey ?? ""
|
|
3764
3803
|
}));
|
|
3765
3804
|
this.relationships = new Relationships();
|
|
@@ -4525,7 +4564,7 @@ function stringifyDocumentBackground(opts, ctx) {
|
|
|
4525
4564
|
if (opts.rawXml) {
|
|
4526
4565
|
if (opts.rawMedia) for (const m of opts.rawMedia) ctx.file.media.addImage(m.fileName, {
|
|
4527
4566
|
type: m.type,
|
|
4528
|
-
data: m.data,
|
|
4567
|
+
data: toUint8Array(m.data),
|
|
4529
4568
|
fileName: m.fileName,
|
|
4530
4569
|
transformation: {
|
|
4531
4570
|
emus: {
|
|
@@ -4547,7 +4586,7 @@ function stringifyDocumentBackground(opts, ctx) {
|
|
|
4547
4586
|
if (opts.themeTint !== void 0) attrs.push(`w:themeTint="${uCharHexNumber(opts.themeTint)}"`);
|
|
4548
4587
|
const attrStr = attrs.join(" ");
|
|
4549
4588
|
if (opts.image) {
|
|
4550
|
-
const fileName =
|
|
4589
|
+
const fileName = ctx.file.media.nextMediaName(opts.image.type);
|
|
4551
4590
|
const rawData = toUint8Array(opts.image.data);
|
|
4552
4591
|
ctx.file.media.addImage(fileName, {
|
|
4553
4592
|
type: opts.image.type,
|
|
@@ -4724,7 +4763,8 @@ function parseParagraphProperties(el, ctx) {
|
|
|
4724
4763
|
}
|
|
4725
4764
|
if (abstractNumId !== void 0) opts.numbering = {
|
|
4726
4765
|
reference: `list_${numId}`,
|
|
4727
|
-
level
|
|
4766
|
+
level,
|
|
4767
|
+
custom: true
|
|
4728
4768
|
};
|
|
4729
4769
|
else opts.bullet = { level };
|
|
4730
4770
|
} else opts.bullet = { level };
|
|
@@ -4950,7 +4990,7 @@ function parseCustomXmlInline(el, ctx) {
|
|
|
4950
4990
|
if (uri) cx.uri = uri;
|
|
4951
4991
|
const pr = findChild(el, "w:customXmlPr");
|
|
4952
4992
|
if (pr) {
|
|
4953
|
-
const parsed =
|
|
4993
|
+
const parsed = parseCustomXmlProperties(pr);
|
|
4954
4994
|
if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.customXmlPr = parsed;
|
|
4955
4995
|
}
|
|
4956
4996
|
const content = parseContainerChildren(el, ctx);
|
|
@@ -5623,10 +5663,10 @@ function parseImageRun(el, ctx) {
|
|
|
5623
5663
|
const blipFill = findDeep(el, "pic:blipFill")[0];
|
|
5624
5664
|
if (blipFill) {
|
|
5625
5665
|
const srcRect = readSourceRectangle(blipFill);
|
|
5626
|
-
if (srcRect) imageOpts.
|
|
5666
|
+
if (srcRect) imageOpts.sourceRectangle = srcRect;
|
|
5627
5667
|
}
|
|
5628
5668
|
const cNvPr = readPicCnvPr(el);
|
|
5629
|
-
if (cNvPr) imageOpts.
|
|
5669
|
+
if (cNvPr) imageOpts.nonVisualProperties = cNvPr;
|
|
5630
5670
|
const picSpPr = findDeep(el, "pic:spPr")[0];
|
|
5631
5671
|
if (picSpPr) {
|
|
5632
5672
|
const fill = readShapeFill(picSpPr, ctx);
|
|
@@ -5688,7 +5728,7 @@ function readPicCnvPr(el) {
|
|
|
5688
5728
|
const descr = attr(cNvPr, "descr");
|
|
5689
5729
|
if (id !== void 0) result.id = id;
|
|
5690
5730
|
if (name) result.name = name;
|
|
5691
|
-
if (descr) result.
|
|
5731
|
+
if (descr) result.description = descr;
|
|
5692
5732
|
}
|
|
5693
5733
|
const cNvPicPr = findChild(nvPicPr, "pic:cNvPicPr");
|
|
5694
5734
|
if (cNvPicPr) {
|
|
@@ -5765,7 +5805,7 @@ function parseWpsShapeCore(wspEl, ctx) {
|
|
|
5765
5805
|
if (title) nvp.title = title;
|
|
5766
5806
|
}
|
|
5767
5807
|
if (cNvCnPr) nvp.connector = true;
|
|
5768
|
-
else if (txBox !== void 0) nvp.
|
|
5808
|
+
else if (txBox !== void 0) nvp.textBox = txBox;
|
|
5769
5809
|
result.nonVisualProperties = nvp;
|
|
5770
5810
|
}
|
|
5771
5811
|
const spPr = findChild(wspEl, "wps:spPr");
|
|
@@ -5880,10 +5920,10 @@ function parsePicChildMediaData(picEl, ctx) {
|
|
|
5880
5920
|
const blipFill = findChild(picEl, "pic:blipFill");
|
|
5881
5921
|
if (blipFill) {
|
|
5882
5922
|
const srcRect = readSourceRectangle(blipFill);
|
|
5883
|
-
if (srcRect) result.
|
|
5923
|
+
if (srcRect) result.sourceRectangle = srcRect;
|
|
5884
5924
|
}
|
|
5885
5925
|
const cNvPr = readPicCnvPr(picEl);
|
|
5886
|
-
if (cNvPr) result.
|
|
5926
|
+
if (cNvPr) result.nonVisualProperties = cNvPr;
|
|
5887
5927
|
if (spPr) {
|
|
5888
5928
|
const fill = readShapeFill(spPr, ctx);
|
|
5889
5929
|
if (fill) result.fill = fill;
|
|
@@ -5903,7 +5943,8 @@ function parseWpsShapeDrawing(el, ctx) {
|
|
|
5903
5943
|
...parseWpsShapeCore(wsp, ctx),
|
|
5904
5944
|
transformation: {
|
|
5905
5945
|
width: info.width ?? 0,
|
|
5906
|
-
height: info.height ?? 0
|
|
5946
|
+
height: info.height ?? 0,
|
|
5947
|
+
...info.effectExtent ? { effectExtent: info.effectExtent } : {}
|
|
5907
5948
|
}
|
|
5908
5949
|
};
|
|
5909
5950
|
if (info.floating) shape.floating = info.floating;
|
|
@@ -5919,21 +5960,22 @@ function parseWpgGroupDrawing(el, ctx) {
|
|
|
5919
5960
|
if (!wgp) return void 0;
|
|
5920
5961
|
const info = parseAnchorOrInline(el) ?? {};
|
|
5921
5962
|
const grpSpPr = findChild(wgp, "wpg:grpSpPr");
|
|
5922
|
-
const {
|
|
5963
|
+
const { childOffset, childExtent } = readGroupCoords(grpSpPr);
|
|
5923
5964
|
const group = {
|
|
5924
5965
|
children: parseGroupChildren(wgp, ctx),
|
|
5925
5966
|
transformation: {
|
|
5926
5967
|
width: info.width ?? 0,
|
|
5927
|
-
height: info.height ?? 0
|
|
5968
|
+
height: info.height ?? 0,
|
|
5969
|
+
...info.effectExtent ? { effectExtent: info.effectExtent } : {}
|
|
5928
5970
|
}
|
|
5929
5971
|
};
|
|
5930
|
-
if (
|
|
5931
|
-
if (
|
|
5972
|
+
if (childOffset) group.childOffset = childOffset;
|
|
5973
|
+
if (childExtent) group.childExtent = childExtent;
|
|
5932
5974
|
if (info.floating) group.floating = info.floating;
|
|
5933
5975
|
if (info.altText) group.altText = info.altText;
|
|
5934
5976
|
if (info.graphicFrameLocks !== void 0) group.graphicFrameLocks = info.graphicFrameLocks;
|
|
5935
5977
|
const grpSpLocks = readGrpSpLocks(findChild(wgp, "wpg:cNvGrpSpPr"));
|
|
5936
|
-
if (grpSpLocks) group.
|
|
5978
|
+
if (grpSpLocks) group.groupShapeLocks = grpSpLocks;
|
|
5937
5979
|
if (grpSpPr) {
|
|
5938
5980
|
const fill = readShapeFill(grpSpPr, ctx);
|
|
5939
5981
|
if (fill) group.fill = fill;
|
|
@@ -5950,21 +5992,21 @@ function readGroupCoords(grpSpPr) {
|
|
|
5950
5992
|
if (!grpSpPr) return {};
|
|
5951
5993
|
const xfrm = findChild(grpSpPr, "a:xfrm");
|
|
5952
5994
|
if (!xfrm) return {};
|
|
5953
|
-
let
|
|
5954
|
-
let
|
|
5995
|
+
let childOffset;
|
|
5996
|
+
let childExtent;
|
|
5955
5997
|
const off = findChild(xfrm, "a:chOff");
|
|
5956
|
-
if (off?.attributes)
|
|
5998
|
+
if (off?.attributes) childOffset = {
|
|
5957
5999
|
x: Number(off.attributes["x"] ?? 0),
|
|
5958
6000
|
y: Number(off.attributes["y"] ?? 0)
|
|
5959
6001
|
};
|
|
5960
6002
|
const ext = findChild(xfrm, "a:chExt");
|
|
5961
|
-
if (ext?.attributes)
|
|
6003
|
+
if (ext?.attributes) childExtent = {
|
|
5962
6004
|
cx: Number(ext.attributes["cx"] ?? 0),
|
|
5963
6005
|
cy: Number(ext.attributes["cy"] ?? 0)
|
|
5964
6006
|
};
|
|
5965
6007
|
return {
|
|
5966
|
-
|
|
5967
|
-
|
|
6008
|
+
childOffset,
|
|
6009
|
+
childExtent
|
|
5968
6010
|
};
|
|
5969
6011
|
}
|
|
5970
6012
|
/**
|
|
@@ -5992,16 +6034,16 @@ function parseGroupChild(el, ctx) {
|
|
|
5992
6034
|
*/
|
|
5993
6035
|
function parseNestedGroup(grpSpEl, ctx) {
|
|
5994
6036
|
const grpSpPr = findChild(grpSpEl, "wpg:grpSpPr");
|
|
5995
|
-
const {
|
|
6037
|
+
const { childOffset, childExtent } = readGroupCoords(grpSpPr);
|
|
5996
6038
|
const result = {
|
|
5997
6039
|
type: "wpg",
|
|
5998
6040
|
transformation: readChildTransformation(grpSpPr),
|
|
5999
6041
|
children: parseGroupChildren(grpSpEl, ctx)
|
|
6000
6042
|
};
|
|
6001
|
-
if (
|
|
6002
|
-
if (
|
|
6043
|
+
if (childOffset) result.childOffset = childOffset;
|
|
6044
|
+
if (childExtent) result.childExtent = childExtent;
|
|
6003
6045
|
const grpSpLocks = readGrpSpLocks(findChild(grpSpEl, "wpg:cNvGrpSpPr"));
|
|
6004
|
-
if (grpSpLocks) result.
|
|
6046
|
+
if (grpSpLocks) result.groupShapeLocks = grpSpLocks;
|
|
6005
6047
|
if (grpSpPr) {
|
|
6006
6048
|
const fill = readShapeFill(grpSpPr, ctx);
|
|
6007
6049
|
if (fill) result.fill = fill;
|
|
@@ -6364,7 +6406,7 @@ function stringifyBlipFill(mediaData, blipEffects, tile) {
|
|
|
6364
6406
|
const blipContent = (extParts.length > 0 ? `<a:extLst>${extParts.join("")}</a:extLst>` : "") + (blipEffects ? buildBlipEffectsXml(blipEffects) : "");
|
|
6365
6407
|
if (blipContent) parts.push(`<a:blip ${blipAttrs.join(" ")}>${blipContent}</a:blip>`);
|
|
6366
6408
|
else parts.push(`<a:blip ${blipAttrs.join(" ")}/>`);
|
|
6367
|
-
const srcRectXml = buildSrcRectXml(mediaData.
|
|
6409
|
+
const srcRectXml = buildSrcRectXml(mediaData.sourceRectangle);
|
|
6368
6410
|
if (srcRectXml) parts.push(srcRectXml);
|
|
6369
6411
|
if (tile) {
|
|
6370
6412
|
const tileAttrs = [];
|
|
@@ -6416,16 +6458,16 @@ function stringifyNvPicPr(hlIds, cNvPr) {
|
|
|
6416
6458
|
const hlXml = buildHyperlinkChildren(hlIds);
|
|
6417
6459
|
const id = cNvPr?.id ?? 0;
|
|
6418
6460
|
const name = escapeXml(cNvPr?.name ?? "");
|
|
6419
|
-
const descrAttr = cNvPr?.
|
|
6461
|
+
const descrAttr = cNvPr?.description ? ` descr="${escapeXml(cNvPr.description)}"` : "";
|
|
6420
6462
|
const cNvPicPrAttr = cNvPr?.preferRelativeResize === false ? " preferRelativeResize=\"0\"" : "";
|
|
6421
6463
|
return `<pic:nvPicPr><pic:cNvPr id="${id}" name="${name}"${descrAttr}${hlXml ? `>${hlXml}</pic:cNvPr>` : "/>"}<pic:cNvPicPr${cNvPicPrAttr}><a:picLocks noChangeAspect="1"/></pic:cNvPicPr></pic:nvPicPr>`;
|
|
6422
6464
|
}
|
|
6423
|
-
function stringifyGroupTransform2D(transform,
|
|
6465
|
+
function stringifyGroupTransform2D(transform, childOffset, childExtent) {
|
|
6424
6466
|
const attrs = [];
|
|
6425
6467
|
if (transform.flip?.horizontal !== void 0) attrs.push(`flipH="${transform.flip.horizontal}"`);
|
|
6426
6468
|
if (transform.flip?.vertical !== void 0) attrs.push(`flipV="${transform.flip.vertical}"`);
|
|
6427
6469
|
if (transform.rotation !== void 0) attrs.push(`rot="${transform.rotation}"`);
|
|
6428
|
-
return `<a:xfrm${attrs.length ? " " + attrs.join(" ") : ""}>${`<a:off x="${transform.offset?.emus?.x ?? 0}" y="${transform.offset?.emus?.y ?? 0}"/>`}${`<a:ext cx="${transform.emus.x}" cy="${transform.emus.y}"/>`}${
|
|
6470
|
+
return `<a:xfrm${attrs.length ? " " + attrs.join(" ") : ""}>${`<a:off x="${transform.offset?.emus?.x ?? 0}" y="${transform.offset?.emus?.y ?? 0}"/>`}${`<a:ext cx="${transform.emus.x}" cy="${transform.emus.y}"/>`}${childOffset ? `<a:chOff x="${childOffset.x}" y="${childOffset.y}"/>` : ""}${childExtent ? `<a:chExt cx="${childExtent.cx}" cy="${childExtent.cy}"/>` : ""}</a:xfrm>`;
|
|
6429
6471
|
}
|
|
6430
6472
|
function stringifyWpsShape(opts, ctx) {
|
|
6431
6473
|
const transform = opts.transformation;
|
|
@@ -6464,7 +6506,7 @@ function stringifyNonVisualShapeProperties(opts) {
|
|
|
6464
6506
|
xml += `<wps:cNvPr ${attrs.join(" ")}/>`;
|
|
6465
6507
|
}
|
|
6466
6508
|
if (opts.connector) xml += "<wps:cNvCnPr/>";
|
|
6467
|
-
else if (opts.
|
|
6509
|
+
else if (opts.textBox !== void 0) xml += `<wps:cNvSpPr txBox="${opts.textBox}"/>`;
|
|
6468
6510
|
else xml += "<wps:cNvSpPr/>";
|
|
6469
6511
|
return xml;
|
|
6470
6512
|
}
|
|
@@ -6487,11 +6529,11 @@ function stringifyBodyPr(opts) {
|
|
|
6487
6529
|
function stringifyWpgGroup(opts, ctx) {
|
|
6488
6530
|
const transform = opts.transformation;
|
|
6489
6531
|
const grpSpPrParts = [];
|
|
6490
|
-
grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.
|
|
6532
|
+
grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.childOffset, opts.childExtent));
|
|
6491
6533
|
if (opts.fill) grpSpPrParts.push(fillDesc$1.stringify(opts.fill, NOOP_CTX) ?? "");
|
|
6492
6534
|
if (opts.effects) grpSpPrParts.push(effectListDesc$1.stringify(opts.effects, NOOP_CTX) ?? "");
|
|
6493
6535
|
const childXml = opts.children.map((child) => stringifyGroupChild(child, ctx)).join("");
|
|
6494
|
-
return "<wpg:wgp>" + stringifyCnvGrpSpPr(opts.
|
|
6536
|
+
return "<wpg:wgp>" + stringifyCnvGrpSpPr(opts.groupShapeLocks) + `<wpg:grpSpPr>${grpSpPrParts.join("")}</wpg:grpSpPr>` + childXml + "</wpg:wgp>";
|
|
6495
6537
|
}
|
|
6496
6538
|
/**
|
|
6497
6539
|
* Stringify one group child: a wps shape, a nested wpg group, or a picture.
|
|
@@ -6510,11 +6552,11 @@ function stringifyGroupChild(child, ctx) {
|
|
|
6510
6552
|
if (child.type === "wpg") return stringifyNestedGroup(child, ctx);
|
|
6511
6553
|
const picData = child;
|
|
6512
6554
|
const picParts = [];
|
|
6513
|
-
picParts.push(stringifyNvPicPr({}, picData.
|
|
6555
|
+
picParts.push(stringifyNvPicPr({}, picData.nonVisualProperties));
|
|
6514
6556
|
const groupBlipParts = [];
|
|
6515
6557
|
const useLocalDpiExt = buildUseLocalDpiExt(picData.useLocalDpi);
|
|
6516
6558
|
groupBlipParts.push(useLocalDpiExt ? `<a:blip r:embed="{${escapeXml(picData.fileName)}}"><a:extLst>${useLocalDpiExt}</a:extLst></a:blip>` : `<a:blip r:embed="{${escapeXml(picData.fileName)}}"/>`);
|
|
6517
|
-
const groupSrcRectXml = buildSrcRectXml(picData.
|
|
6559
|
+
const groupSrcRectXml = buildSrcRectXml(picData.sourceRectangle);
|
|
6518
6560
|
if (groupSrcRectXml) groupBlipParts.push(groupSrcRectXml);
|
|
6519
6561
|
groupBlipParts.push("<a:stretch><a:fillRect/></a:stretch>");
|
|
6520
6562
|
picParts.push(`<pic:blipFill>${groupBlipParts.join("")}</pic:blipFill>`);
|
|
@@ -6527,10 +6569,10 @@ function stringifyGroupChild(child, ctx) {
|
|
|
6527
6569
|
*/
|
|
6528
6570
|
function stringifyNestedGroup(grp, ctx) {
|
|
6529
6571
|
const grpSpPrParts = [];
|
|
6530
|
-
grpSpPrParts.push(stringifyGroupTransform2D(grp.transformation, grp.
|
|
6572
|
+
grpSpPrParts.push(stringifyGroupTransform2D(grp.transformation, grp.childOffset, grp.childExtent));
|
|
6531
6573
|
if (grp.fill) grpSpPrParts.push(fillDesc$1.stringify(grp.fill, NOOP_CTX) ?? "");
|
|
6532
6574
|
if (grp.effects) grpSpPrParts.push(effectListDesc$1.stringify(grp.effects, NOOP_CTX) ?? "");
|
|
6533
|
-
return "<wpg:grpSp><wpg:cNvPr id=\"0\" name=\"\"/>" + stringifyCnvGrpSpPr(grp.
|
|
6575
|
+
return "<wpg:grpSp><wpg:cNvPr id=\"0\" name=\"\"/>" + stringifyCnvGrpSpPr(grp.groupShapeLocks) + `<wpg:grpSpPr>${grpSpPrParts.join("")}</wpg:grpSpPr>` + grp.children.map((c) => stringifyGroupChild(c, ctx)).join("") + "</wpg:grpSp>";
|
|
6534
6576
|
}
|
|
6535
6577
|
function stringifyGraphicDataContent(mediaData, opts, hlIds, ctx) {
|
|
6536
6578
|
const { outline, fill, effects, blipEffects, tile } = opts;
|
|
@@ -6551,15 +6593,15 @@ function stringifyGraphicDataContent(mediaData, opts, hlIds, ctx) {
|
|
|
6551
6593
|
return `<a:graphicData uri="${WPG_URI}">${stringifyWpgGroup({
|
|
6552
6594
|
children: md.children,
|
|
6553
6595
|
transformation: transform,
|
|
6554
|
-
|
|
6555
|
-
|
|
6596
|
+
childOffset: md.childOffset,
|
|
6597
|
+
childExtent: md.childExtent,
|
|
6556
6598
|
fill: md.fill,
|
|
6557
6599
|
effects: md.effects,
|
|
6558
|
-
|
|
6600
|
+
groupShapeLocks: md.groupShapeLocks
|
|
6559
6601
|
}, ctx)}</a:graphicData>`;
|
|
6560
6602
|
}
|
|
6561
6603
|
const md = mediaData;
|
|
6562
|
-
return `<a:graphicData uri="${PIC_URI}"><pic:pic xmlns:pic="${PIC_URI}">` + stringifyNvPicPr(hlIds, md.
|
|
6604
|
+
return `<a:graphicData uri="${PIC_URI}"><pic:pic xmlns:pic="${PIC_URI}">` + stringifyNvPicPr(hlIds, md.nonVisualProperties) + stringifyBlipFill(md, blipEffects, tile) + stringifyShapeProps(transform, outline, fill, effects) + `</pic:pic></a:graphicData>`;
|
|
6563
6605
|
}
|
|
6564
6606
|
function stringifyPositionH(opts) {
|
|
6565
6607
|
return `<wp:positionH relativeFrom="${opts.relative ?? HorizontalPositionRelativeFrom.PAGE}">${opts.align ? `<wp:align>${opts.align}</wp:align>` : opts.offset !== void 0 ? `<wp:posOffset>${opts.offset}</wp:posOffset>` : "<wp:align>left</wp:align>"}</wp:positionH>`;
|
|
@@ -6695,7 +6737,7 @@ const drawingDesc = {
|
|
|
6695
6737
|
kind: "custom",
|
|
6696
6738
|
stringify(opts, ctx) {
|
|
6697
6739
|
if (opts.fill) {
|
|
6698
|
-
const media = extractBlipFillMedia(opts.fill);
|
|
6740
|
+
const media = extractBlipFillMedia(opts.fill, (type) => ctx.file.media.nextMediaName(type));
|
|
6699
6741
|
if (media) ctx.file.media.addImage(media.fileName, {
|
|
6700
6742
|
data: media.data,
|
|
6701
6743
|
fileName: media.fileName,
|
|
@@ -6842,12 +6884,12 @@ function stringifyRunInline(opts, ctx) {
|
|
|
6842
6884
|
const body = parts.join("");
|
|
6843
6885
|
return body.length === 0 ? attr ? `<w:r${attr}/>` : "<w:r/>" : `<w:r${attr}>${body}</w:r>`;
|
|
6844
6886
|
}
|
|
6845
|
-
function createImageData(data, transformation, key,
|
|
6887
|
+
function createImageData(data, transformation, key, sourceRectangle, nonVisualProperties) {
|
|
6846
6888
|
return {
|
|
6847
6889
|
data,
|
|
6848
6890
|
fileName: key,
|
|
6849
|
-
|
|
6850
|
-
|
|
6891
|
+
sourceRectangle,
|
|
6892
|
+
nonVisualProperties,
|
|
6851
6893
|
transformation: createTransformation(transformation)
|
|
6852
6894
|
};
|
|
6853
6895
|
}
|
|
@@ -6874,24 +6916,37 @@ function wrapDrawingRun(drawingXml, opts) {
|
|
|
6874
6916
|
/**
|
|
6875
6917
|
* Register media carried by a VML fallback (mc:AlternateContent Fallback) so the
|
|
6876
6918
|
* compiler resolves the fallback's `{fileName}` placeholders into rIds.
|
|
6919
|
+
*
|
|
6920
|
+
* A VML fallback image mirrors its Choice blip (same source bytes). When the
|
|
6921
|
+
* blip is already registered, reuse it and remap the fallback's `{fileName}`
|
|
6922
|
+
* placeholder to the shared media — matching Office, which emits one
|
|
6923
|
+
* relationship/file per image rather than a duplicate for the VML branch.
|
|
6877
6924
|
*/
|
|
6878
6925
|
function registerVmlFallbackMedia(opts, ctx) {
|
|
6879
6926
|
if (!opts.vmlFallbackMedia) return;
|
|
6880
|
-
for (const m of opts.vmlFallbackMedia)
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
x: 0,
|
|
6887
|
-
y: 0
|
|
6888
|
-
},
|
|
6889
|
-
pixels: {
|
|
6890
|
-
x: 0,
|
|
6891
|
-
y: 0
|
|
6892
|
-
}
|
|
6927
|
+
for (const m of opts.vmlFallbackMedia) {
|
|
6928
|
+
const data = toUint8Array(m.data);
|
|
6929
|
+
const existing = ctx.file.media.findByContent(data);
|
|
6930
|
+
if (existing) {
|
|
6931
|
+
if (opts.vmlFallback) opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${existing}}`);
|
|
6932
|
+
continue;
|
|
6893
6933
|
}
|
|
6894
|
-
|
|
6934
|
+
ctx.file.media.addImage(m.fileName, {
|
|
6935
|
+
type: m.type,
|
|
6936
|
+
data,
|
|
6937
|
+
fileName: m.fileName,
|
|
6938
|
+
transformation: {
|
|
6939
|
+
emus: {
|
|
6940
|
+
x: 0,
|
|
6941
|
+
y: 0
|
|
6942
|
+
},
|
|
6943
|
+
pixels: {
|
|
6944
|
+
x: 0,
|
|
6945
|
+
y: 0
|
|
6946
|
+
}
|
|
6947
|
+
}
|
|
6948
|
+
});
|
|
6949
|
+
}
|
|
6895
6950
|
}
|
|
6896
6951
|
/**
|
|
6897
6952
|
* Resolve a break/tab run's rPr: prefer the raw rPr carried from parse (verbatim,
|
|
@@ -6939,23 +6994,23 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
6939
6994
|
}
|
|
6940
6995
|
if ("image" in child) {
|
|
6941
6996
|
const opts = child.image;
|
|
6942
|
-
const key =
|
|
6997
|
+
const key = ctx.file.media.nextMediaName(opts.type);
|
|
6943
6998
|
const rawData = toUint8Array(opts.data);
|
|
6944
6999
|
let mediaData;
|
|
6945
7000
|
if (opts.type === "svg") {
|
|
6946
7001
|
const fallbackData = toUint8Array(opts.fallback.data);
|
|
6947
7002
|
mediaData = {
|
|
6948
7003
|
type: "svg",
|
|
6949
|
-
...createImageData(rawData, opts.transformation, key, opts.
|
|
7004
|
+
...createImageData(rawData, opts.transformation, key, opts.sourceRectangle, opts.nonVisualProperties),
|
|
6950
7005
|
useLocalDpi: opts.useLocalDpi,
|
|
6951
7006
|
fallback: {
|
|
6952
7007
|
type: opts.fallback.type,
|
|
6953
|
-
...createImageData(fallbackData, opts.transformation,
|
|
7008
|
+
...createImageData(fallbackData, opts.transformation, ctx.file.media.nextMediaName(opts.fallback.type))
|
|
6954
7009
|
}
|
|
6955
7010
|
};
|
|
6956
7011
|
} else mediaData = {
|
|
6957
7012
|
type: opts.type,
|
|
6958
|
-
...createImageData(rawData, opts.transformation, key, opts.
|
|
7013
|
+
...createImageData(rawData, opts.transformation, key, opts.sourceRectangle, opts.nonVisualProperties),
|
|
6959
7014
|
useLocalDpi: opts.useLocalDpi
|
|
6960
7015
|
};
|
|
6961
7016
|
ctx.file.media.addImage(mediaData.fileName, mediaData);
|
|
@@ -7047,11 +7102,11 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7047
7102
|
const mediaData = {
|
|
7048
7103
|
children: opts.children,
|
|
7049
7104
|
transformation: createTransformation(opts.transformation),
|
|
7050
|
-
|
|
7051
|
-
|
|
7105
|
+
childOffset: opts.childOffset,
|
|
7106
|
+
childExtent: opts.childExtent,
|
|
7052
7107
|
fill: opts.fill,
|
|
7053
7108
|
effects: opts.effects,
|
|
7054
|
-
|
|
7109
|
+
groupShapeLocks: opts.groupShapeLocks,
|
|
7055
7110
|
type: "wpg"
|
|
7056
7111
|
};
|
|
7057
7112
|
const registerMedia = (children) => {
|
|
@@ -8418,7 +8473,7 @@ function parseTableRowEl(el, ctx) {
|
|
|
8418
8473
|
if (cxUri) cx.uri = cxUri;
|
|
8419
8474
|
const xmlPr = findChild(child, "w:customXmlPr");
|
|
8420
8475
|
if (xmlPr) {
|
|
8421
|
-
const parsed =
|
|
8476
|
+
const parsed = parseCustomXmlProperties(xmlPr);
|
|
8422
8477
|
if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.customXmlPr = parsed;
|
|
8423
8478
|
}
|
|
8424
8479
|
const cxCells = [];
|
|
@@ -8458,7 +8513,7 @@ function parseTableEl(el, ctx) {
|
|
|
8458
8513
|
if (cxUri) cx.uri = cxUri;
|
|
8459
8514
|
const xmlPr = findChild(child, "w:customXmlPr");
|
|
8460
8515
|
if (xmlPr) {
|
|
8461
|
-
const parsed =
|
|
8516
|
+
const parsed = parseCustomXmlProperties(xmlPr);
|
|
8462
8517
|
if (parsed.placeholder !== void 0 || parsed.attributes !== void 0) cx.customXmlPr = parsed;
|
|
8463
8518
|
}
|
|
8464
8519
|
const cxRows = [];
|
|
@@ -8818,9 +8873,10 @@ var Numbering = class {
|
|
|
8818
8873
|
};
|
|
8819
8874
|
function stringifyAbstractNumbering(id, levels, extraOptions) {
|
|
8820
8875
|
const parts = [];
|
|
8821
|
-
|
|
8876
|
+
const restartAttr = extraOptions?.restartNumberingAfterBreak !== void 0 ? ` w15:restartNumberingAfterBreak="${extraOptions.restartNumberingAfterBreak ? 1 : 0}"` : "";
|
|
8877
|
+
parts.push(`<w:abstractNum w:abstractNumId="${decimalNumber(id)}"${restartAttr}>`);
|
|
8822
8878
|
if (extraOptions?.nsid !== void 0) parts.push(`<w:nsid w:val="${extraOptions.nsid}"/>`);
|
|
8823
|
-
parts.push(`<w:multiLevelType w:val="hybridMultilevel"/>`);
|
|
8879
|
+
parts.push(`<w:multiLevelType w:val="${extraOptions?.multiLevelType ?? "hybridMultilevel"}"/>`);
|
|
8824
8880
|
if (extraOptions?.tmpl !== void 0) parts.push(`<w:tmpl w:val="${extraOptions.tmpl}"/>`);
|
|
8825
8881
|
if (extraOptions?.name !== void 0) parts.push(`<w:name w:val="${extraOptions.name}"/>`);
|
|
8826
8882
|
if (extraOptions?.styleLink !== void 0) parts.push(`<w:styleLink w:val="${extraOptions.styleLink}"/>`);
|
|
@@ -8858,7 +8914,8 @@ function stringifyLevel(opts) {
|
|
|
8858
8914
|
const rPrXml = stringifyRunProperties(opts.style && opts.style.run);
|
|
8859
8915
|
if (pPrXml) children.push(pPrXml);
|
|
8860
8916
|
if (rPrXml) children.push(rPrXml);
|
|
8861
|
-
const lvlAttrs = [`w:ilvl="${decimalNumber(Math.min(opts.level, 9))}"
|
|
8917
|
+
const lvlAttrs = [`w:ilvl="${decimalNumber(Math.min(opts.level, 9))}"`];
|
|
8918
|
+
if (opts.w15Tentative !== void 0) lvlAttrs.push(`w15:tentative="${opts.w15Tentative ? 1 : 0}"`);
|
|
8862
8919
|
if (opts.templateCode !== void 0) lvlAttrs.push(`w:tplc="${opts.templateCode}"`);
|
|
8863
8920
|
if (opts.tentative !== void 0) lvlAttrs.push(`w:tentative="${opts.tentative ? 1 : 0}"`);
|
|
8864
8921
|
return `<w:lvl ${lvlAttrs.join(" ")}>${children.join("")}</w:lvl>`;
|
|
@@ -8898,6 +8955,13 @@ function parseNumberingDefinitions(el, parseParagraphProperties, ctx) {
|
|
|
8898
8955
|
const v = attr(nsidEl, "w:val");
|
|
8899
8956
|
if (v) extraOptions.nsid = v;
|
|
8900
8957
|
}
|
|
8958
|
+
const multiLevelTypeEl = findChild(abstractEl, "w:multiLevelType");
|
|
8959
|
+
if (multiLevelTypeEl) {
|
|
8960
|
+
const v = attr(multiLevelTypeEl, "w:val");
|
|
8961
|
+
if (v) extraOptions.multiLevelType = v;
|
|
8962
|
+
}
|
|
8963
|
+
const restartVal = attrBool(abstractEl, "w15:restartNumberingAfterBreak");
|
|
8964
|
+
if (restartVal !== void 0) extraOptions.restartNumberingAfterBreak = restartVal;
|
|
8901
8965
|
const tmplEl = findChild(abstractEl, "w:tmpl");
|
|
8902
8966
|
if (tmplEl) {
|
|
8903
8967
|
const v = attr(tmplEl, "w:val");
|
|
@@ -8966,6 +9030,8 @@ function parseLevelEl(el, parseParagraphProperties, ctx) {
|
|
|
8966
9030
|
if (tplc) opts.templateCode = tplc;
|
|
8967
9031
|
const tentative = attrBool(el, "w:tentative");
|
|
8968
9032
|
if (tentative !== void 0) opts.tentative = tentative;
|
|
9033
|
+
const w15Tentative = attrBool(el, "w15:tentative");
|
|
9034
|
+
if (w15Tentative !== void 0) opts.w15Tentative = w15Tentative;
|
|
8969
9035
|
const style = {};
|
|
8970
9036
|
const rPr = findChild(el, "w:rPr");
|
|
8971
9037
|
if (rPr) {
|
|
@@ -10800,18 +10866,22 @@ function parseFieldSwitches(text) {
|
|
|
10800
10866
|
const NS$2 = "xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"";
|
|
10801
10867
|
/** XML for the footnoteRef run — auto-injected at start of first paragraph. */
|
|
10802
10868
|
const FOOTNOTE_REF_RUN = "<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteRef/></w:r>";
|
|
10803
|
-
/**
|
|
10869
|
+
/** Default separator footnote (id=-1) for freshly generated documents. */
|
|
10804
10870
|
const SEPARATOR_FOOTNOTE = "<w:footnote w:type=\"separator\" w:id=\"-1\"><w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:r><w:separator/></w:r></w:p></w:footnote>";
|
|
10805
|
-
/**
|
|
10871
|
+
/** Default continuation separator footnote (id=0) for freshly generated documents. */
|
|
10806
10872
|
const CONTINUATION_SEPARATOR_FOOTNOTE = "<w:footnote w:type=\"continuationSeparator\" w:id=\"0\"><w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:footnote>";
|
|
10873
|
+
/** Render a system footnote from round-tripped id + content, or the spec default. */
|
|
10874
|
+
function footnoteSystemNote(type, sep, fallback, ctx) {
|
|
10875
|
+
if (!sep) return fallback;
|
|
10876
|
+
const inner = sep.paragraphs.map((p) => stringifyParagraphInline(p, ctx)).join("");
|
|
10877
|
+
return `<w:footnote w:type="${type}" w:id="${sep.id}">${inner}</w:footnote>`;
|
|
10878
|
+
}
|
|
10807
10879
|
const footnotesDesc = {
|
|
10808
10880
|
kind: "custom",
|
|
10809
10881
|
stringify(data, ctx) {
|
|
10810
|
-
const parts = [
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
CONTINUATION_SEPARATOR_FOOTNOTE
|
|
10814
|
-
];
|
|
10882
|
+
const parts = [`<w:footnotes ${NS$2} mc:Ignorable="w14 w15 wp14">`];
|
|
10883
|
+
parts.push(footnoteSystemNote("separator", data.separator, SEPARATOR_FOOTNOTE, ctx));
|
|
10884
|
+
parts.push(footnoteSystemNote("continuationSeparator", data.continuationSeparator, CONTINUATION_SEPARATOR_FOOTNOTE, ctx));
|
|
10815
10885
|
for (const [id, paragraphs] of data.notes) {
|
|
10816
10886
|
parts.push(`<w:footnote w:id="${id}">`);
|
|
10817
10887
|
for (let i = 0; i < paragraphs.length; i++) {
|
|
@@ -10829,16 +10899,30 @@ const footnotesDesc = {
|
|
|
10829
10899
|
},
|
|
10830
10900
|
parse(el, ctx) {
|
|
10831
10901
|
const notes = /* @__PURE__ */ new Map();
|
|
10902
|
+
let separator;
|
|
10903
|
+
let continuationSeparator;
|
|
10832
10904
|
for (const child of el.elements ?? []) {
|
|
10833
10905
|
if (child.name !== "w:footnote") continue;
|
|
10834
10906
|
const id = attrNum(child, "w:id");
|
|
10835
10907
|
if (id === void 0) continue;
|
|
10836
|
-
|
|
10908
|
+
const type = attr(child, "w:type");
|
|
10837
10909
|
const paragraphs = [];
|
|
10838
10910
|
for (const sub of child.elements ?? []) if (sub.name === "w:p") paragraphs.push(parseParagraph(sub, ctx));
|
|
10839
|
-
|
|
10911
|
+
if (type === "separator") separator = {
|
|
10912
|
+
id,
|
|
10913
|
+
paragraphs
|
|
10914
|
+
};
|
|
10915
|
+
else if (type === "continuationSeparator") continuationSeparator = {
|
|
10916
|
+
id,
|
|
10917
|
+
paragraphs
|
|
10918
|
+
};
|
|
10919
|
+
else notes.set(id, paragraphs);
|
|
10840
10920
|
}
|
|
10841
|
-
return {
|
|
10921
|
+
return {
|
|
10922
|
+
notes,
|
|
10923
|
+
separator,
|
|
10924
|
+
continuationSeparator
|
|
10925
|
+
};
|
|
10842
10926
|
}
|
|
10843
10927
|
};
|
|
10844
10928
|
//#endregion
|
|
@@ -10846,18 +10930,22 @@ const footnotesDesc = {
|
|
|
10846
10930
|
const NS$1 = "xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"";
|
|
10847
10931
|
/** XML for the endnoteRef run — auto-injected at start of first paragraph. */
|
|
10848
10932
|
const ENDNOTE_REF_RUN = "<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteRef/></w:r>";
|
|
10849
|
-
/**
|
|
10933
|
+
/** Default separator endnote (id=-1) for freshly generated documents. */
|
|
10850
10934
|
const SEPARATOR_ENDNOTE = "<w:endnote w:type=\"separator\" w:id=\"-1\"><w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:r><w:separator/></w:r></w:p></w:endnote>";
|
|
10851
|
-
/**
|
|
10935
|
+
/** Default continuation separator endnote (id=0) for freshly generated documents. */
|
|
10852
10936
|
const CONTINUATION_SEPARATOR_ENDNOTE = "<w:endnote w:type=\"continuationSeparator\" w:id=\"0\"><w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:endnote>";
|
|
10937
|
+
/** Render a system endnote from round-tripped id + content, or the spec default. */
|
|
10938
|
+
function endnoteSystemNote(type, sep, fallback, ctx) {
|
|
10939
|
+
if (!sep) return fallback;
|
|
10940
|
+
const inner = sep.paragraphs.map((p) => stringifyParagraphInline(p, ctx)).join("");
|
|
10941
|
+
return `<w:endnote w:type="${type}" w:id="${sep.id}">${inner}</w:endnote>`;
|
|
10942
|
+
}
|
|
10853
10943
|
const endnotesDesc = {
|
|
10854
10944
|
kind: "custom",
|
|
10855
10945
|
stringify(data, ctx) {
|
|
10856
|
-
const parts = [
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
CONTINUATION_SEPARATOR_ENDNOTE
|
|
10860
|
-
];
|
|
10946
|
+
const parts = [`<w:endnotes ${NS$1} mc:Ignorable="w14 w15 wp14">`];
|
|
10947
|
+
parts.push(endnoteSystemNote("separator", data.separator, SEPARATOR_ENDNOTE, ctx));
|
|
10948
|
+
parts.push(endnoteSystemNote("continuationSeparator", data.continuationSeparator, CONTINUATION_SEPARATOR_ENDNOTE, ctx));
|
|
10861
10949
|
for (const [id, paragraphs] of data.notes) {
|
|
10862
10950
|
parts.push(`<w:endnote w:id="${id}">`);
|
|
10863
10951
|
for (let i = 0; i < paragraphs.length; i++) {
|
|
@@ -10875,16 +10963,30 @@ const endnotesDesc = {
|
|
|
10875
10963
|
},
|
|
10876
10964
|
parse(el, ctx) {
|
|
10877
10965
|
const notes = /* @__PURE__ */ new Map();
|
|
10966
|
+
let separator;
|
|
10967
|
+
let continuationSeparator;
|
|
10878
10968
|
for (const child of el.elements ?? []) {
|
|
10879
10969
|
if (child.name !== "w:endnote") continue;
|
|
10880
10970
|
const id = attrNum(child, "w:id");
|
|
10881
10971
|
if (id === void 0) continue;
|
|
10882
|
-
|
|
10972
|
+
const type = attr(child, "w:type");
|
|
10883
10973
|
const paragraphs = [];
|
|
10884
10974
|
for (const sub of child.elements ?? []) if (sub.name === "w:p") paragraphs.push(parseParagraph(sub, ctx));
|
|
10885
|
-
|
|
10975
|
+
if (type === "separator") separator = {
|
|
10976
|
+
id,
|
|
10977
|
+
paragraphs
|
|
10978
|
+
};
|
|
10979
|
+
else if (type === "continuationSeparator") continuationSeparator = {
|
|
10980
|
+
id,
|
|
10981
|
+
paragraphs
|
|
10982
|
+
};
|
|
10983
|
+
else notes.set(id, paragraphs);
|
|
10886
10984
|
}
|
|
10887
|
-
return {
|
|
10985
|
+
return {
|
|
10986
|
+
notes,
|
|
10987
|
+
separator,
|
|
10988
|
+
continuationSeparator
|
|
10989
|
+
};
|
|
10888
10990
|
}
|
|
10889
10991
|
};
|
|
10890
10992
|
//#endregion
|
|
@@ -11307,6 +11409,13 @@ const commentsDesc = {
|
|
|
11307
11409
|
};
|
|
11308
11410
|
//#endregion
|
|
11309
11411
|
//#region src/parts/contenttypes.ts
|
|
11412
|
+
/**
|
|
11413
|
+
* Content types descriptor — produces [Content_Types].xml.
|
|
11414
|
+
*
|
|
11415
|
+
* Reference: OPC, Content_Types.xsd
|
|
11416
|
+
*
|
|
11417
|
+
* @module
|
|
11418
|
+
*/
|
|
11310
11419
|
function defaultXml(ext, ct) {
|
|
11311
11420
|
return `<Default Extension="${ext}" ContentType="${ct}"/>`;
|
|
11312
11421
|
}
|
|
@@ -11436,111 +11545,69 @@ function withMediaDefaults(input, mediaFileNames) {
|
|
|
11436
11545
|
overrides: input.overrides
|
|
11437
11546
|
};
|
|
11438
11547
|
}
|
|
11439
|
-
/**
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
partName: "/word/numbering.xml",
|
|
11465
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"
|
|
11466
|
-
},
|
|
11467
|
-
{
|
|
11468
|
-
partName: "/word/footnotes.xml",
|
|
11469
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"
|
|
11470
|
-
},
|
|
11471
|
-
{
|
|
11472
|
-
partName: "/word/endnotes.xml",
|
|
11473
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"
|
|
11474
|
-
},
|
|
11475
|
-
{
|
|
11476
|
-
partName: "/word/settings.xml",
|
|
11477
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"
|
|
11478
|
-
},
|
|
11479
|
-
...extras.hasComments ? [{
|
|
11480
|
-
partName: "/word/comments.xml",
|
|
11481
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"
|
|
11482
|
-
}] : [],
|
|
11483
|
-
{
|
|
11484
|
-
partName: "/word/fontTable.xml",
|
|
11485
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"
|
|
11548
|
+
/** Default content types for altChunk part extensions. */
|
|
11549
|
+
const ALTCHUNK_DEFAULTS = {
|
|
11550
|
+
html: "text/html",
|
|
11551
|
+
rtf: "application/rtf",
|
|
11552
|
+
txt: "text/plain"
|
|
11553
|
+
};
|
|
11554
|
+
/**
|
|
11555
|
+
* Realign [Content_Types] Overrides for altChunk parts on a round-tripped
|
|
11556
|
+
* package. The pass-through content types carry Override PartNames from the
|
|
11557
|
+
* source, but the compiler regenerates altChunk part paths (uniqueId), so the
|
|
11558
|
+
* Override and the written part drift apart (O5/O6). This drops the stale
|
|
11559
|
+
* afchunk Overrides and appends ones matching the freshly generated paths,
|
|
11560
|
+
* backfilling the extension Default so the part is resolvable either way.
|
|
11561
|
+
*/
|
|
11562
|
+
function withAltChunkOverrides(input, altChunks) {
|
|
11563
|
+
const defaults = [...input.defaults];
|
|
11564
|
+
const haveExt = new Set(defaults.map((d) => d.extension));
|
|
11565
|
+
for (const ac of altChunks) {
|
|
11566
|
+
const ext = (ac.path.split(".").pop() ?? "").toLowerCase();
|
|
11567
|
+
if (ext && !haveExt.has(ext) && ALTCHUNK_DEFAULTS[ext]) {
|
|
11568
|
+
defaults.push({
|
|
11569
|
+
extension: ext,
|
|
11570
|
+
contentType: ALTCHUNK_DEFAULTS[ext]
|
|
11571
|
+
});
|
|
11572
|
+
haveExt.add(ext);
|
|
11486
11573
|
}
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
});
|
|
11492
|
-
for (let i = 1; i <= (extras.footerCount ?? 0); i++) overrides.push({
|
|
11493
|
-
partName: `/word/footer${i}.xml`,
|
|
11494
|
-
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"
|
|
11495
|
-
});
|
|
11496
|
-
for (let i = 1; i <= (extras.chartCount ?? 0); i++) overrides.push({
|
|
11497
|
-
partName: `/word/charts/chart${i}.xml`,
|
|
11498
|
-
contentType: "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
|
|
11499
|
-
});
|
|
11500
|
-
for (let i = 1; i <= (extras.smartArtCount ?? 0); i++) {
|
|
11501
|
-
overrides.push({
|
|
11502
|
-
partName: `/word/diagrams/data${i}.xml`,
|
|
11503
|
-
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml"
|
|
11504
|
-
});
|
|
11505
|
-
overrides.push({
|
|
11506
|
-
partName: `/word/diagrams/layout${i}.xml`,
|
|
11507
|
-
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml"
|
|
11508
|
-
});
|
|
11509
|
-
overrides.push({
|
|
11510
|
-
partName: `/word/diagrams/quickStyle${i}.xml`,
|
|
11511
|
-
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml"
|
|
11512
|
-
});
|
|
11513
|
-
overrides.push({
|
|
11514
|
-
partName: `/word/diagrams/colors${i}.xml`,
|
|
11515
|
-
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml"
|
|
11516
|
-
});
|
|
11574
|
+
}
|
|
11575
|
+
const overrides = input.overrides.filter((o) => !o.partName.startsWith("/word/afchunks/"));
|
|
11576
|
+
for (const ac of altChunks) {
|
|
11577
|
+
const partName = ac.path.startsWith("/") ? ac.path : `/${ac.path}`;
|
|
11517
11578
|
overrides.push({
|
|
11518
|
-
partName
|
|
11519
|
-
contentType:
|
|
11579
|
+
partName,
|
|
11580
|
+
contentType: ac.contentType
|
|
11520
11581
|
});
|
|
11521
11582
|
}
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
}
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11583
|
+
return {
|
|
11584
|
+
defaults,
|
|
11585
|
+
overrides
|
|
11586
|
+
};
|
|
11587
|
+
}
|
|
11588
|
+
/**
|
|
11589
|
+
* Build [Content_Types].xml for a fresh DOCX compile, driven by the part
|
|
11590
|
+
* registry. Static parts (document/styles/…/comments/headers/…) come from
|
|
11591
|
+
* {@link buildContentTypeOverrides} over {@link DOCX_PARTS}; dynamic parts whose
|
|
11592
|
+
* path or count is runtime-determined (altChunks, sub-documents) are appended
|
|
11593
|
+
* here — they are not enumerable in the registry.
|
|
11594
|
+
*
|
|
11595
|
+
* `facts` keys mirror the registry's `flag` / `countFrom` tokens. The Override
|
|
11596
|
+
* set (order-independent) matches the former hand-written builder, so the OPC
|
|
11597
|
+
* consistency validator stays green.
|
|
11598
|
+
*/
|
|
11599
|
+
function buildContentTypesFromRegistry(facts, dynamic = {}) {
|
|
11600
|
+
const overrides = buildContentTypeOverrides(DOCX_PARTS, facts);
|
|
11601
|
+
for (const ac of dynamic.altChunks ?? []) overrides.push({
|
|
11535
11602
|
partName: ac.path.startsWith("/") ? ac.path : `/${ac.path}`,
|
|
11536
11603
|
contentType: ac.contentType
|
|
11537
11604
|
});
|
|
11538
|
-
for (const sd of
|
|
11605
|
+
for (const sd of dynamic.subDocs ?? []) overrides.push({
|
|
11539
11606
|
partName: sd.path.startsWith("/") ? sd.path : `/${sd.path}`,
|
|
11540
11607
|
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
11541
11608
|
});
|
|
11542
11609
|
return {
|
|
11543
|
-
defaults,
|
|
11610
|
+
defaults: [...STANDARD_DEFAULTS],
|
|
11544
11611
|
overrides
|
|
11545
11612
|
};
|
|
11546
11613
|
}
|
|
@@ -11585,16 +11652,16 @@ const corePropertiesDesc = {
|
|
|
11585
11652
|
stringify(opts, _ctx) {
|
|
11586
11653
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
11587
11654
|
const p = ["<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"];
|
|
11588
|
-
|
|
11589
|
-
if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);
|
|
11655
|
+
p.push(`<dcterms:created xsi:type="dcterms:W3CDTF">${opts.created ?? now}</dcterms:created>`);
|
|
11590
11656
|
if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);
|
|
11591
|
-
if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);
|
|
11592
11657
|
if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);
|
|
11658
|
+
if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);
|
|
11593
11659
|
if (opts.lastModifiedBy) p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy)}</cp:lastModifiedBy>`);
|
|
11594
|
-
if (opts.revision !== void 0) p.push(`<cp:revision>${opts.revision}</cp:revision>`);
|
|
11595
11660
|
if (opts.lastPrinted) p.push(`<cp:lastPrinted>${escapeXml(opts.lastPrinted)}</cp:lastPrinted>`);
|
|
11596
|
-
p.push(`<dcterms:
|
|
11597
|
-
p.push(`<
|
|
11661
|
+
p.push(`<dcterms:modified xsi:type="dcterms:W3CDTF">${opts.modified ?? now}</dcterms:modified>`);
|
|
11662
|
+
if (opts.revision !== void 0) p.push(`<cp:revision>${opts.revision}</cp:revision>`);
|
|
11663
|
+
if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);
|
|
11664
|
+
if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);
|
|
11598
11665
|
p.push("</cp:coreProperties>");
|
|
11599
11666
|
return p.join("");
|
|
11600
11667
|
},
|
|
@@ -11629,6 +11696,12 @@ const corePropertiesDesc = {
|
|
|
11629
11696
|
case "cp:lastPrinted":
|
|
11630
11697
|
result.lastPrinted = text;
|
|
11631
11698
|
break;
|
|
11699
|
+
case "dcterms:created":
|
|
11700
|
+
result.created = text;
|
|
11701
|
+
break;
|
|
11702
|
+
case "dcterms:modified":
|
|
11703
|
+
result.modified = text;
|
|
11704
|
+
break;
|
|
11632
11705
|
}
|
|
11633
11706
|
}
|
|
11634
11707
|
return result;
|
|
@@ -11666,6 +11739,8 @@ const customPropertiesDesc = {
|
|
|
11666
11739
|
};
|
|
11667
11740
|
//#endregion
|
|
11668
11741
|
//#region src/parts/app-properties.ts
|
|
11742
|
+
/** xsd:boolean lexical form — spec canonical form is "true"/"false" (Word's convention). */
|
|
11743
|
+
const xsdBoolean = (value) => value ? "true" : "false";
|
|
11669
11744
|
const appPropertiesDesc = {
|
|
11670
11745
|
kind: "custom",
|
|
11671
11746
|
stringify(opts, _ctx) {
|
|
@@ -11683,12 +11758,12 @@ const appPropertiesDesc = {
|
|
|
11683
11758
|
if (opts.totalTime !== void 0) p.push(`<TotalTime>${opts.totalTime}</TotalTime>`);
|
|
11684
11759
|
if (opts.hiddenSlides !== void 0) p.push(`<HiddenSlides>${opts.hiddenSlides}</HiddenSlides>`);
|
|
11685
11760
|
if (opts.mmClips !== void 0) p.push(`<MMClips>${opts.mmClips}</MMClips>`);
|
|
11686
|
-
if (opts.scaleCrop !== void 0) p.push(`<ScaleCrop>${opts.scaleCrop
|
|
11687
|
-
if (opts.linksUpToDate !== void 0) p.push(`<LinksUpToDate>${opts.linksUpToDate
|
|
11761
|
+
if (opts.scaleCrop !== void 0) p.push(`<ScaleCrop>${xsdBoolean(opts.scaleCrop)}</ScaleCrop>`);
|
|
11762
|
+
if (opts.linksUpToDate !== void 0) p.push(`<LinksUpToDate>${xsdBoolean(opts.linksUpToDate)}</LinksUpToDate>`);
|
|
11688
11763
|
if (opts.charactersWithSpaces !== void 0) p.push(`<CharactersWithSpaces>${opts.charactersWithSpaces}</CharactersWithSpaces>`);
|
|
11689
|
-
if (opts.sharedDoc !== void 0) p.push(`<SharedDoc>${opts.sharedDoc
|
|
11764
|
+
if (opts.sharedDoc !== void 0) p.push(`<SharedDoc>${xsdBoolean(opts.sharedDoc)}</SharedDoc>`);
|
|
11690
11765
|
if (opts.hyperlinkBase !== void 0) p.push(`<HyperlinkBase>${escapeXml(opts.hyperlinkBase)}</HyperlinkBase>`);
|
|
11691
|
-
if (opts.hyperlinksChanged !== void 0) p.push(`<HyperlinksChanged>${opts.hyperlinksChanged
|
|
11766
|
+
if (opts.hyperlinksChanged !== void 0) p.push(`<HyperlinksChanged>${xsdBoolean(opts.hyperlinksChanged)}</HyperlinksChanged>`);
|
|
11692
11767
|
if (opts.application !== void 0) p.push(`<Application>${escapeXml(opts.application)}</Application>`);
|
|
11693
11768
|
if (opts.appVersion !== void 0) p.push(`<AppVersion>${escapeXml(opts.appVersion)}</AppVersion>`);
|
|
11694
11769
|
if (opts.docSecurity !== void 0) p.push(`<DocSecurity>${opts.docSecurity}</DocSecurity>`);
|
|
@@ -12039,7 +12114,7 @@ const webSettingsDesc = {
|
|
|
12039
12114
|
if (opts.doNotOrganizeInFolder !== void 0) p.push(wsOnOff("w:doNotOrganizeInFolder", opts.doNotOrganizeInFolder));
|
|
12040
12115
|
if (opts.doNotUseLongFileNames !== void 0) p.push(wsOnOff("w:doNotUseLongFileNames", opts.doNotUseLongFileNames));
|
|
12041
12116
|
if (opts.pixelsPerInch !== void 0) p.push(wsNumVal("w:pixelsPerInch", opts.pixelsPerInch));
|
|
12042
|
-
if (opts.
|
|
12117
|
+
if (opts.targetScreenSize !== void 0) p.push(wsStringVal("w:targetScreenSz", opts.targetScreenSize));
|
|
12043
12118
|
if (opts.saveSmartTagsAsXml !== void 0) p.push(wsOnOff("w:saveSmartTagsAsXml", opts.saveSmartTagsAsXml));
|
|
12044
12119
|
p.push("</w:webSettings>");
|
|
12045
12120
|
return p.join("");
|
|
@@ -12076,15 +12151,15 @@ const webSettingsDesc = {
|
|
|
12076
12151
|
const val = attrNum(ppi, "w:val");
|
|
12077
12152
|
if (val !== void 0) opts.pixelsPerInch = val;
|
|
12078
12153
|
}
|
|
12079
|
-
const
|
|
12080
|
-
if (
|
|
12081
|
-
const val = attr(
|
|
12082
|
-
if (val) opts.
|
|
12154
|
+
const targetScreenSize = findChild(el, "w:targetScreenSz");
|
|
12155
|
+
if (targetScreenSize) {
|
|
12156
|
+
const val = attr(targetScreenSize, "w:val");
|
|
12157
|
+
if (val) opts.targetScreenSize = val;
|
|
12083
12158
|
}
|
|
12084
12159
|
return opts;
|
|
12085
12160
|
}
|
|
12086
12161
|
};
|
|
12087
12162
|
//#endregion
|
|
12088
|
-
export {
|
|
12163
|
+
export { tableDesc as $, RelativeVerticalPosition as $t, buildNumberingCache as A, LineRuleType as An, SpaceType as At, createLineNumberType as B, sdtBlockDesc as Bt, footnotesDesc as C, createTransformation as Cn, createPageNumberType as Ct, StyleLevel as D, TextAlignmentType as Dn, VerticalPositionRelativeFrom as Dt, SdtLock as E, PageNumber as En, HorizontalPositionRelativeFrom as Et, HeaderFooterType as F, TextWrappingType as Ft, DocumentGridType as G, subDocDesc as Gt, PageBorderDisplay as H, stringifyCustomXmlShell as Ht, createHeaderFooterReference as I, altChunkDesc as It, Numbering as J, TABLE_BORDERS_NONE as Jt, createDocumentGrid as K, stringifyElement as Kt, SectionType as L, checkboxSymbolRunInner as Lt, parseStyleDefinitions as M, createWrapThrough as Mt, DefaultStylesFactory as N, createWrapTight as Nt, settingsDesc as O, TextboxTightWrapType as On, HorizontalPositionAlign as Ot, HeaderFooterReferenceType as P, TextWrappingSide as Pt, setTableParseChild as Q, RelativeHorizontalPosition as Qt, createSectionType as R, customXmlBlockDesc as Rt, endnotesDesc as S, Media as Sn, PageNumberSeparator as St, SdtDateMappingType as T, TextEffect as Tn, createHorizontalPosition as Tt, PageBorderOffsetFrom as U, stringifySdtPr as Ut, createPageMargin as V, setBodyParseChild as Vt, PageBorderZOrder as W, stringifySdtShell as Wt, LevelFormat as X, TableLayoutType as Xt, parseNumberingDefinitions as Y, BorderStyle as Yt, LevelSuffix as Z, OverlapType as Zt, glossaryDesc as _, VerticalAnchor as _n, sectionMarginDefaults as _t, appPropertiesDesc as a, createFormFieldData as an, parseParagraph as at, CharacterSet as b, createImageData$1 as bn, PageOrientation as bt, relationshipsDesc as c, PositionalTabAlignment as cn, stringifyDocumentXml as ct, withAltChunkOverrides as d, EmphasisMarkType as dn, parseSdtBlock as dt, TableAnchorType as en, stringifyChildDispatch as et, withMediaDefaults as f, UnderlineType as fn, parseSdtProperties as ft, DocPartType as g, TextVerticalType as gn, stringifySectionPropertiesXml as gt, DocPartGallery as h, TextVertOverflowType as hn, sectionPropertiesDesc as ht, webSettingsDesc as i, FormFieldTextType as in, resetDrawingIdGen as it, buildStyleCache as j, AlignmentType as jn, VerticalPositionAlign as jt, Styles as k, HeadingLevel as kn, NumberFormat as kt, buildContentTypesFromRegistry as l, PositionalTabLeader as ln, replaceRelsWithPlaceholders as lt, DocPartBehavior as m, TextHorzOverflowType as mn, parseSectionPropertiesEl as mt, frameXml as n, VerticalMergeType as nn, stringifyRunInline as nt, customPropertiesDesc as o, parseFormFieldData as on, parseParagraphProperties as ot, commentsDesc as p, TextBodyWrappingType as pn, FontWrapper as pt, DocumentAttributeNamespaces as q, WidthType as qt, framesetXml as r, ProofErrorType as rn, drawingDesc as rt, corePropertiesDesc as s, RubyAlign as sn, stringifyBodyChild as st, TargetScreenSize as t, TextDirection as tn, stringifyParagraphInline as tt, contentTypesDesc as u, PositionalTabRelativeTo as un, stringifyTableOfContents as ut, bibliographyDesc as v, createBodyProperties as vn, sectionPageSizeDefaults as vt, parseToc as w, HighlightColor as wn, createVerticalPosition as wt, EditGroupType as x, WORKAROUND2 as xn, createPageSize as xt, fontTableDesc as y, parseBodyProperties as yn, PageTextDirectionType as yt, LineNumberRestartFormat as z, parseCustomXmlProperties as zt };
|
|
12089
12164
|
|
|
12090
|
-
//# sourceMappingURL=parts-
|
|
12165
|
+
//# sourceMappingURL=parts-Cp_NxQFi.mjs.map
|