@office-open/docx 0.10.2 → 0.10.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/{context-vnFOOEWL.mjs → context-CI0zR7rE.mjs} +133 -56
- package/dist/context-CI0zR7rE.mjs.map +1 -0
- package/dist/{core-properties-CcpNQvVY.d.mts → core-properties-Dp-aEoX3.d.mts} +241 -175
- package/dist/core-properties-Dp-aEoX3.d.mts.map +1 -0
- package/dist/{generate-DQkv8c9y.mjs → generate-B-n09INq.mjs} +62 -55
- package/dist/generate-B-n09INq.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +2 -39
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{parse-ZZPID0vi.mjs → parse-D6c9kHXh.mjs} +11 -25
- package/dist/parse-D6c9kHXh.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/{parts-DvRRYUug.mjs → parts-DgrmHznM.mjs} +780 -559
- package/dist/parts-DgrmHznM.mjs.map +1 -0
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.d.mts.map +1 -1
- package/dist/patch/index.mjs +8 -19
- package/dist/patch/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/context-vnFOOEWL.mjs.map +0 -1
- package/dist/core-properties-CcpNQvVY.d.mts.map +0 -1
- package/dist/generate-DQkv8c9y.mjs.map +0 -1
- package/dist/parse-ZZPID0vi.mjs.map +0 -1
- package/dist/parts-DvRRYUug.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DOCX_PARTS, Relationships, TargetModeType, ThemeColor, appPropertiesDesc, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DOCX_PARTS, Media, Relationships, TargetModeType, ThemeColor, appPropertiesDesc, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip, convertToEmu, convertToTwip, customGeometryDesc, customPropertiesDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, presetGeometryDesc, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
|
|
2
|
+
import { calculateEffectExtent, createColorElement, createEffectDag, createScene3D, createShape3D, customGeometryDesc as customGeometryDesc$1, effectListDesc as effectListDesc$1, fillDesc as fillDesc$1, outlineDesc as outlineDesc$1, presetGeometryDesc as presetGeometryDesc$1, scene3DDesc, shape3DDesc, transform2DDesc } from "@office-open/core/drawingml";
|
|
3
|
+
import { attr, attrBool, attrMeasure, attrNum, children, colorAttr, element, escapeXml, findChild, findFirst, stringify, textOf } from "@office-open/xml";
|
|
4
4
|
import { chartSpaceDesc } from "@office-open/core/chart";
|
|
5
5
|
import { createDataModel } from "@office-open/core/smartart";
|
|
6
6
|
//#region src/parts/paragraph/formatting/alignment.ts
|
|
@@ -266,125 +266,42 @@ const HighlightColor = {
|
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/shared/media/media.ts
|
|
268
268
|
/**
|
|
269
|
-
* Converts user-facing transformation options (
|
|
269
|
+
* Converts user-facing transformation options (EMU or universal measure) to internal
|
|
270
270
|
* transformation data (pixels + EMUs).
|
|
271
271
|
*
|
|
272
|
-
* @param options - User-facing transformation in
|
|
272
|
+
* @param options - User-facing transformation in EMU or universal measure
|
|
273
273
|
* @returns Internal transformation data with both pixel and EMU values
|
|
274
274
|
*/
|
|
275
|
-
const createTransformation = (options) =>
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
offset: {
|
|
275
|
+
const createTransformation = (options) => {
|
|
276
|
+
const widthEmu = convertToEmu(options.width);
|
|
277
|
+
const heightEmu = convertToEmu(options.height);
|
|
278
|
+
const offsetLeftEmu = convertToEmu(options.offset?.left ?? 0);
|
|
279
|
+
const offsetTopEmu = convertToEmu(options.offset?.top ?? 0);
|
|
280
|
+
return {
|
|
282
281
|
emus: {
|
|
283
|
-
x:
|
|
284
|
-
y:
|
|
282
|
+
x: widthEmu,
|
|
283
|
+
y: heightEmu
|
|
285
284
|
},
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
rotation: options.rotation ? options.rotation * 6e4 : void 0,
|
|
296
|
-
...options.effectExtent ? { effectExtent: options.effectExtent } : {}
|
|
297
|
-
});
|
|
298
|
-
/**
|
|
299
|
-
* Manages embedded media (images) in a document.
|
|
300
|
-
*
|
|
301
|
-
* Media stores all images referenced in the document and provides
|
|
302
|
-
* access to their data for packaging into the DOCX file. Each image
|
|
303
|
-
* is stored with a unique key for retrieval.
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* ```typescript
|
|
307
|
-
* const media = new Media();
|
|
308
|
-
* media.addImage("image1", {
|
|
309
|
-
* type: "png",
|
|
310
|
-
* fileName: "image1.png",
|
|
311
|
-
* transformation: {
|
|
312
|
-
* pixels: { x: 200, y: 100 },
|
|
313
|
-
* emus: { x: 1828800, y: 914400 }
|
|
314
|
-
* },
|
|
315
|
-
* data: imageBuffer
|
|
316
|
-
* });
|
|
317
|
-
* const allImages = media.Array;
|
|
318
|
-
* ```
|
|
319
|
-
*/
|
|
320
|
-
var Media = class {
|
|
321
|
-
map;
|
|
322
|
-
nextMediaCounter = 0;
|
|
323
|
-
constructor() {
|
|
324
|
-
this.map = /* @__PURE__ */ new Map();
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Allocates the next sequential media file name (Office-style `image1.png`,
|
|
328
|
-
* `image2.png`, …). The counter is package-global because media is shared
|
|
329
|
-
* across the document, headers, and footers, matching MS Office's numbering.
|
|
330
|
-
*
|
|
331
|
-
* Deterministic across runs (unlike random ids) so round-trip output is stable
|
|
332
|
-
* and diffable. Callers pair this with {@link findByContent} to reuse an
|
|
333
|
-
* existing entry for byte-identical content before allocating a new name.
|
|
334
|
-
*
|
|
335
|
-
* @param type - File extension / image type token (e.g. "png", "jpg")
|
|
336
|
-
* @returns A sequential file name like `image3.png`
|
|
337
|
-
*/
|
|
338
|
-
nextMediaName(type) {
|
|
339
|
-
return `image${++this.nextMediaCounter}.${type}`;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Adds an image to the media collection.
|
|
343
|
-
*
|
|
344
|
-
* @param key - Unique identifier for this image
|
|
345
|
-
* @param mediaData - Complete image data including file name, transformation, and raw data
|
|
346
|
-
*/
|
|
347
|
-
addImage(key, mediaData) {
|
|
348
|
-
this.map.set(key, mediaData);
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Finds an existing image with byte-identical content (content-based dedup).
|
|
352
|
-
*
|
|
353
|
-
* Returns the matching entry's key (fileName) so callers reuse it instead of
|
|
354
|
-
* registering a duplicate — e.g. a VML fallback image that mirrors the Choice
|
|
355
|
-
* blip should share one relationship/file, matching Office's output.
|
|
356
|
-
*
|
|
357
|
-
* @param data - Raw image bytes to search for
|
|
358
|
-
* @returns The matching entry's key, or `undefined` if no match
|
|
359
|
-
*/
|
|
360
|
-
findByContent(data) {
|
|
361
|
-
for (const [key, md] of this.map) {
|
|
362
|
-
const existing = toUint8Array(md.data);
|
|
363
|
-
if (existing.length !== data.length) continue;
|
|
364
|
-
let match = true;
|
|
365
|
-
for (let i = 0; i < existing.length; i++) if (existing[i] !== data[i]) {
|
|
366
|
-
match = false;
|
|
367
|
-
break;
|
|
285
|
+
flip: options.flip,
|
|
286
|
+
offset: {
|
|
287
|
+
emus: {
|
|
288
|
+
x: offsetLeftEmu,
|
|
289
|
+
y: offsetTopEmu
|
|
290
|
+
},
|
|
291
|
+
pixels: {
|
|
292
|
+
x: Math.round(convertEmuToPixels(offsetLeftEmu)),
|
|
293
|
+
y: Math.round(convertEmuToPixels(offsetTopEmu))
|
|
368
294
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
get array() {
|
|
378
|
-
return [...this.map.values()];
|
|
379
|
-
}
|
|
295
|
+
},
|
|
296
|
+
pixels: {
|
|
297
|
+
x: Math.round(convertEmuToPixels(widthEmu)),
|
|
298
|
+
y: Math.round(convertEmuToPixels(heightEmu))
|
|
299
|
+
},
|
|
300
|
+
rotation: options.rotation ? options.rotation * 6e4 : void 0,
|
|
301
|
+
...options.effectExtent ? { effectExtent: options.effectExtent } : {}
|
|
302
|
+
};
|
|
380
303
|
};
|
|
381
304
|
//#endregion
|
|
382
|
-
//#region src/shared/media/data.ts
|
|
383
|
-
/**
|
|
384
|
-
* @ignore
|
|
385
|
-
*/
|
|
386
|
-
const WORKAROUND2 = "";
|
|
387
|
-
//#endregion
|
|
388
305
|
//#region src/parts/paragraph/run/image-run.ts
|
|
389
306
|
const createImageData$1 = (data, transformation, key, sourceRectangle, nonVisualProperties) => ({
|
|
390
307
|
data,
|
|
@@ -558,7 +475,7 @@ const createBodyProperties = (options = {}) => {
|
|
|
558
475
|
* (noAutofit/normAutofit/spAutoFit). prstTxWarp/scene3d/text-3D are not yet
|
|
559
476
|
* parsed (later phase).
|
|
560
477
|
*/
|
|
561
|
-
const parseBodyProperties = (el) => {
|
|
478
|
+
const parseBodyProperties = (el, ctx) => {
|
|
562
479
|
const result = {};
|
|
563
480
|
const rotation = attrNum(el, "rot");
|
|
564
481
|
if (rotation !== void 0) result.rotation = rotation;
|
|
@@ -610,6 +527,31 @@ const parseBodyProperties = (el) => {
|
|
|
610
527
|
result.normAutofit = normOpts;
|
|
611
528
|
} else if (findChild(el, "a:spAutoFit")) result.spAutoFit = true;
|
|
612
529
|
}
|
|
530
|
+
const prstTxWarp = findChild(el, "a:prstTxWarp");
|
|
531
|
+
if (prstTxWarp) {
|
|
532
|
+
const preset = attr(prstTxWarp, "prst") ?? "";
|
|
533
|
+
const avLst = findChild(prstTxWarp, "a:avLst");
|
|
534
|
+
const adjustments = [];
|
|
535
|
+
for (const gd of avLst?.elements ?? []) if (gd.type === "element" && gd.name === "a:gd") adjustments.push({
|
|
536
|
+
name: attr(gd, "name") ?? "",
|
|
537
|
+
formula: attr(gd, "fmla") ?? ""
|
|
538
|
+
});
|
|
539
|
+
result.prstTxWarp = {
|
|
540
|
+
preset,
|
|
541
|
+
...adjustments.length > 0 ? { adjustments } : {}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
const scene3d = findChild(el, "a:scene3d");
|
|
545
|
+
if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);
|
|
546
|
+
const sp3d = findChild(el, "a:sp3d");
|
|
547
|
+
if (sp3d) result.sp3d = shape3DDesc.parse(sp3d, ctx);
|
|
548
|
+
else {
|
|
549
|
+
const flatTx = findChild(el, "a:flatTx");
|
|
550
|
+
if (flatTx) {
|
|
551
|
+
const z = attrNum(flatTx, "z");
|
|
552
|
+
result.flatTx = z !== void 0 ? { z } : {};
|
|
553
|
+
}
|
|
554
|
+
}
|
|
613
555
|
return result;
|
|
614
556
|
};
|
|
615
557
|
//#endregion
|
|
@@ -1356,15 +1298,15 @@ const objectDesc = {
|
|
|
1356
1298
|
const styleHeight = typeof heightVal === "number" ? `${heightVal}px` : heightVal;
|
|
1357
1299
|
const shapeChildren = [];
|
|
1358
1300
|
if (opts.iconImage) {
|
|
1359
|
-
const
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1362
|
-
|
|
1301
|
+
const rawData = toUint8Array(opts.iconImage.data);
|
|
1302
|
+
const iconType = opts.iconImage.type;
|
|
1303
|
+
const { fileName: iconFileName } = ctx.file.media.addMedia(rawData, iconType, (fileName) => ({
|
|
1304
|
+
type: iconType,
|
|
1305
|
+
...createImageData$1(rawData, {
|
|
1363
1306
|
width: widthVal,
|
|
1364
1307
|
height: heightVal
|
|
1365
|
-
},
|
|
1366
|
-
};
|
|
1367
|
-
ctx.file.media.addImage(iconFileName, iconMediaData);
|
|
1308
|
+
}, fileName)
|
|
1309
|
+
}));
|
|
1368
1310
|
const titleAttr = opts.iconImage.title ? ` o:title="${opts.iconImage.title}"` : "";
|
|
1369
1311
|
shapeChildren.push(`<v:imagedata r:id="{${iconFileName}}"${titleAttr}/>`);
|
|
1370
1312
|
}
|
|
@@ -2392,9 +2334,6 @@ function stringifyRunProperties(opts) {
|
|
|
2392
2334
|
*
|
|
2393
2335
|
* @module
|
|
2394
2336
|
*/
|
|
2395
|
-
function escapeAttr$2(s) {
|
|
2396
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2397
|
-
}
|
|
2398
2337
|
const ALTCHUNK_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk";
|
|
2399
2338
|
function wrapHtmlDocument(fragment) {
|
|
2400
2339
|
if (/<(!DOCTYPE|html|HTML)/i.test(fragment)) return fragment;
|
|
@@ -2406,8 +2345,8 @@ const altChunkDesc = {
|
|
|
2406
2345
|
const relId = uniqueId();
|
|
2407
2346
|
const extension = opts.extension;
|
|
2408
2347
|
const partPath = `afchunks/afchunk${relId}.${extension}`;
|
|
2409
|
-
const rawData = typeof opts.data === "string" ?
|
|
2410
|
-
const data = opts.contentType === "text/html" && typeof opts.data === "string" ?
|
|
2348
|
+
const rawData = typeof opts.data === "string" ? toUint8Array(opts.data) : opts.data;
|
|
2349
|
+
const data = opts.contentType === "text/html" && typeof opts.data === "string" ? toUint8Array(wrapHtmlDocument(opts.data)) : rawData;
|
|
2411
2350
|
ctx.fileData.document.relationships.addRelationship(relId, ALTCHUNK_REL_TYPE, partPath);
|
|
2412
2351
|
ctx.fileData.altChunks.addAltChunk(relId, {
|
|
2413
2352
|
key: relId,
|
|
@@ -2479,28 +2418,25 @@ const subDocDesc = {
|
|
|
2479
2418
|
return { data: new Uint8Array(0) };
|
|
2480
2419
|
}
|
|
2481
2420
|
};
|
|
2482
|
-
function escapeXml$2(s) {
|
|
2483
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2484
|
-
}
|
|
2485
2421
|
function sdtListItemXml(item, forceValue) {
|
|
2486
2422
|
const attrs = [];
|
|
2487
|
-
if (item.displayText !== void 0) attrs.push(`w:displayText="${escapeXml
|
|
2423
|
+
if (item.displayText !== void 0) attrs.push(`w:displayText="${escapeXml(item.displayText)}"`);
|
|
2488
2424
|
const value = item.value ?? (forceValue ? item.displayText : void 0);
|
|
2489
|
-
if (value !== void 0) attrs.push(`w:value="${escapeXml
|
|
2425
|
+
if (value !== void 0) attrs.push(`w:value="${escapeXml(value)}"`);
|
|
2490
2426
|
return `<w:listItem ${attrs.join(" ")}/>`;
|
|
2491
2427
|
}
|
|
2492
2428
|
function sdtListTypeXml(name, options) {
|
|
2493
2429
|
const parts = [];
|
|
2494
2430
|
if (options.items) for (const item of options.items) parts.push(sdtListItemXml(item, name === "w:dropDownList"));
|
|
2495
2431
|
const attrs = [];
|
|
2496
|
-
if (options.lastValue !== void 0) attrs.push(`w:lastValue="${escapeXml
|
|
2432
|
+
if (options.lastValue !== void 0) attrs.push(`w:lastValue="${escapeXml(options.lastValue)}"`);
|
|
2497
2433
|
const attrStr = attrs.length ? " " + attrs.join(" ") : "";
|
|
2498
2434
|
return parts.length ? `<${name}${attrStr}>${parts.join("")}</${name}>` : `<${name}${attrStr}/>`;
|
|
2499
2435
|
}
|
|
2500
2436
|
function sdtDateXml(options) {
|
|
2501
2437
|
const parts = [];
|
|
2502
|
-
if (options.dateFormat !== void 0) parts.push(`<w:dateFormat w:val="${escapeXml
|
|
2503
|
-
if (options.languageId !== void 0) parts.push(`<w:lid w:val="${escapeXml
|
|
2438
|
+
if (options.dateFormat !== void 0) parts.push(`<w:dateFormat w:val="${escapeXml(options.dateFormat)}"/>`);
|
|
2439
|
+
if (options.languageId !== void 0) parts.push(`<w:lid w:val="${escapeXml(options.languageId)}"/>`);
|
|
2504
2440
|
if (options.storeMappedDataAs !== void 0) parts.push(`<w:storeMappedDataAs w:val="${options.storeMappedDataAs}"/>`);
|
|
2505
2441
|
if (options.calendar !== void 0) parts.push(`<w:calendar w:val="${options.calendar}"/>`);
|
|
2506
2442
|
const attrs = [];
|
|
@@ -2509,14 +2445,14 @@ function sdtDateXml(options) {
|
|
|
2509
2445
|
return parts.length ? `<w:date${attrStr}>${parts.join("")}</w:date>` : `<w:date${attrStr}/>`;
|
|
2510
2446
|
}
|
|
2511
2447
|
function sdtDataBindingXml(options) {
|
|
2512
|
-
const attrs = [`w:xpath="${escapeXml
|
|
2513
|
-
if (options.prefixMappings !== void 0) attrs.push(`w:prefixMappings="${escapeXml
|
|
2448
|
+
const attrs = [`w:xpath="${escapeXml(options.xpath)}"`, `w:storeItemID="${escapeXml(options.storeItemID)}"`];
|
|
2449
|
+
if (options.prefixMappings !== void 0) attrs.push(`w:prefixMappings="${escapeXml(options.prefixMappings)}"`);
|
|
2514
2450
|
return `<w:dataBinding ${attrs.join(" ")}/>`;
|
|
2515
2451
|
}
|
|
2516
2452
|
function sdtDocPartXml(name, options) {
|
|
2517
2453
|
const parts = [];
|
|
2518
|
-
if (options.gallery !== void 0) parts.push(`<w:docPartGallery w:val="${escapeXml
|
|
2519
|
-
if (options.category !== void 0) parts.push(`<w:docPartCategory w:val="${escapeXml
|
|
2454
|
+
if (options.gallery !== void 0) parts.push(`<w:docPartGallery w:val="${escapeXml(options.gallery)}"/>`);
|
|
2455
|
+
if (options.category !== void 0) parts.push(`<w:docPartCategory w:val="${escapeXml(options.category)}"/>`);
|
|
2520
2456
|
if (options.unique !== void 0) parts.push(options.unique ? "<w:docPartUnique/>" : "<w:docPartUnique w:val=\"0\"/>");
|
|
2521
2457
|
return parts.length ? `<${name}>${parts.join("")}</${name}>` : `<${name}/>`;
|
|
2522
2458
|
}
|
|
@@ -2543,18 +2479,18 @@ const DEFAULT_UNCHECKED = {
|
|
|
2543
2479
|
function sdtCheckboxXml(opts) {
|
|
2544
2480
|
const checked = opts.checkedState ?? DEFAULT_CHECKED;
|
|
2545
2481
|
const unchecked = opts.uncheckedState ?? DEFAULT_UNCHECKED;
|
|
2546
|
-
return `<w14:checkbox ${W14_NS}>${(opts.checked ? "<w14:checked/>" : "<w14:checked w14:val=\"0\"/>") + `<w14:checkedState w14:val="${escapeXml
|
|
2482
|
+
return `<w14:checkbox ${W14_NS}>${(opts.checked ? "<w14:checked/>" : "<w14:checked w14:val=\"0\"/>") + `<w14:checkedState w14:val="${escapeXml(checked.val)}" w14:font="${escapeXml(checked.font ?? CHECKBOX_FONT)}"/><w14:uncheckedState w14:val="${escapeXml(unchecked.val)}" w14:font="${escapeXml(unchecked.font ?? CHECKBOX_FONT)}"/>`}</w14:checkbox>`;
|
|
2547
2483
|
}
|
|
2548
2484
|
/** Build the run that renders a checkbox content control's current state symbol. */
|
|
2549
2485
|
function checkboxSymbolRunInner(cb) {
|
|
2550
2486
|
const symbol = cb.checked ?? false ? cb.checkedState ?? DEFAULT_CHECKED : cb.uncheckedState ?? DEFAULT_UNCHECKED;
|
|
2551
|
-
const font = escapeXml
|
|
2552
|
-
return `<w:r><w:rPr><w:rFonts w:ascii="${font}" w:hAnsi="${font}"/></w:rPr><w:t>${escapeXml
|
|
2487
|
+
const font = escapeXml(symbol.font ?? CHECKBOX_FONT);
|
|
2488
|
+
return `<w:r><w:rPr><w:rFonts w:ascii="${font}" w:hAnsi="${font}"/></w:rPr><w:t>${escapeXml(String.fromCodePoint(parseInt(symbol.val, 16)))}</w:t></w:r>`;
|
|
2553
2489
|
}
|
|
2554
2490
|
function stringifySdtPr(opts) {
|
|
2555
2491
|
const parts = [];
|
|
2556
|
-
if (opts.alias !== void 0) parts.push(`<w:alias w:val="${escapeXml
|
|
2557
|
-
if (opts.tag !== void 0) parts.push(`<w:tag w:val="${escapeXml
|
|
2492
|
+
if (opts.alias !== void 0) parts.push(`<w:alias w:val="${escapeXml(opts.alias)}"/>`);
|
|
2493
|
+
if (opts.tag !== void 0) parts.push(`<w:tag w:val="${escapeXml(opts.tag)}"/>`);
|
|
2558
2494
|
if (opts.id !== void 0) parts.push(`<w:id w:val="${opts.id}"/>`);
|
|
2559
2495
|
if (opts.lock !== void 0) parts.push(`<w:lock w:val="${opts.lock}"/>`);
|
|
2560
2496
|
if (opts.temporary !== void 0) parts.push(onOffAttr("w:temporary", opts.temporary));
|
|
@@ -2787,10 +2723,10 @@ const sdtBlockDesc = {
|
|
|
2787
2723
|
};
|
|
2788
2724
|
function buildCustomXmlPropertiesXml(pr) {
|
|
2789
2725
|
const parts = ["<w:customXmlPr>"];
|
|
2790
|
-
if (pr.placeholder !== void 0) parts.push(`<w:placeholder w:val="${
|
|
2726
|
+
if (pr.placeholder !== void 0) parts.push(`<w:placeholder w:val="${escapeXml(pr.placeholder)}"/>`);
|
|
2791
2727
|
if (pr.attributes) for (const attr of pr.attributes) {
|
|
2792
|
-
const attrParts = [`w:name="${
|
|
2793
|
-
if (attr.uri !== void 0) attrParts.push(`w:uri="${
|
|
2728
|
+
const attrParts = [`w:name="${escapeXml(attr.name)}"`, `w:val="${escapeXml(attr.val)}"`];
|
|
2729
|
+
if (attr.uri !== void 0) attrParts.push(`w:uri="${escapeXml(attr.uri)}"`);
|
|
2794
2730
|
parts.push(`<w:attr ${attrParts.join(" ")}/>`);
|
|
2795
2731
|
}
|
|
2796
2732
|
parts.push("</w:customXmlPr>");
|
|
@@ -2799,10 +2735,14 @@ function buildCustomXmlPropertiesXml(pr) {
|
|
|
2799
2735
|
/**
|
|
2800
2736
|
* Serialize the common customXml shell (element/uri/customXmlPr) wrapping
|
|
2801
2737
|
* arbitrary content. Shared by all four customXml levels (block/run/row/cell).
|
|
2738
|
+
*
|
|
2739
|
+
* @deprecated Microsoft Word removed support for `w:customXml` inline markup on
|
|
2740
|
+
* 2010-01-10 (i4i Inc. v. Microsoft ruling); Word deletes these elements on
|
|
2741
|
+
* open. Prefer content controls (`w:sdt`) or a `customXml` part.
|
|
2802
2742
|
*/
|
|
2803
2743
|
function stringifyCustomXmlShell(opts, contentXml) {
|
|
2804
|
-
const attrs = [`w:element="${
|
|
2805
|
-
if (opts.uri !== void 0) attrs.push(`w:uri="${
|
|
2744
|
+
const attrs = [`w:element="${escapeXml(opts.element)}"`];
|
|
2745
|
+
if (opts.uri !== void 0) attrs.push(`w:uri="${escapeXml(opts.uri)}"`);
|
|
2806
2746
|
const prXml = opts.customXmlPr ? buildCustomXmlPropertiesXml(opts.customXmlPr) : "";
|
|
2807
2747
|
return `<w:customXml ${attrs.join(" ")}>${prXml}${contentXml}</w:customXml>`;
|
|
2808
2748
|
}
|
|
@@ -3318,7 +3258,7 @@ const VerticalPositionRelativeFrom = {
|
|
|
3318
3258
|
* ```
|
|
3319
3259
|
*/
|
|
3320
3260
|
const createHorizontalPosition = ({ relative, align, offset }) => {
|
|
3321
|
-
const child = align ? `<wp:align>${align}</wp:align>` : offset !== void 0 ? `<wp:posOffset>${offset}</wp:posOffset>` : `<wp:align>${HorizontalPositionAlign.LEFT}</wp:align>`;
|
|
3261
|
+
const child = align ? `<wp:align>${align}</wp:align>` : offset !== void 0 ? `<wp:posOffset>${convertToEmu(offset)}</wp:posOffset>` : `<wp:align>${HorizontalPositionAlign.LEFT}</wp:align>`;
|
|
3322
3262
|
return element("wp:positionH", { relativeFrom: relative ?? HorizontalPositionRelativeFrom.PAGE }, [child]);
|
|
3323
3263
|
};
|
|
3324
3264
|
//#endregion
|
|
@@ -3371,7 +3311,7 @@ const createHorizontalPosition = ({ relative, align, offset }) => {
|
|
|
3371
3311
|
* ```
|
|
3372
3312
|
*/
|
|
3373
3313
|
const createVerticalPosition = ({ relative, align, offset }) => {
|
|
3374
|
-
const child = align ? `<wp:align>${align}</wp:align>` : offset !== void 0 ? `<wp:posOffset>${offset}</wp:posOffset>` : `<wp:align>${VerticalPositionAlign.TOP}</wp:align>`;
|
|
3314
|
+
const child = align ? `<wp:align>${align}</wp:align>` : offset !== void 0 ? `<wp:posOffset>${convertToEmu(offset)}</wp:posOffset>` : `<wp:align>${VerticalPositionAlign.TOP}</wp:align>`;
|
|
3375
3315
|
return element("wp:positionV", { relativeFrom: relative ?? VerticalPositionRelativeFrom.PAGE }, [child]);
|
|
3376
3316
|
};
|
|
3377
3317
|
//#endregion
|
|
@@ -4264,15 +4204,15 @@ function stringifyMathInput(value) {
|
|
|
4264
4204
|
if ("integral" in value) return stringifyNAry(value.integral, "∫");
|
|
4265
4205
|
if ("limitLower" in value) {
|
|
4266
4206
|
const opts = value.limitLower;
|
|
4267
|
-
return `<m:limLow
|
|
4207
|
+
return `<m:limLow><m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limLow>`;
|
|
4268
4208
|
}
|
|
4269
4209
|
if ("limitUpper" in value) {
|
|
4270
4210
|
const opts = value.limitUpper;
|
|
4271
|
-
return `<m:limUpp
|
|
4211
|
+
return `<m:limUpp><m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limUpp>`;
|
|
4272
4212
|
}
|
|
4273
4213
|
if ("function" in value) {
|
|
4274
4214
|
const opts = value.function;
|
|
4275
|
-
return `<m:func
|
|
4215
|
+
return `<m:func><m:fName>${stringifyChildren(opts.name)}</m:fName><m:e>${stringifyChildren(opts.children)}</m:e></m:func>`;
|
|
4276
4216
|
}
|
|
4277
4217
|
if ("matrix" in value) {
|
|
4278
4218
|
const opts = value.matrix;
|
|
@@ -4836,13 +4776,17 @@ function stringifyBodyChild(child, ctx) {
|
|
|
4836
4776
|
if ("customXml" in child) return customXmlBlockDesc.stringify(child.customXml, ctx) ?? "";
|
|
4837
4777
|
if ("bookmarkStart" in child) {
|
|
4838
4778
|
const bs = child.bookmarkStart;
|
|
4839
|
-
const
|
|
4840
|
-
|
|
4779
|
+
const a = [`w:id="${bs.id}"`, `w:name="${escapeXml(bs.name)}"`];
|
|
4780
|
+
if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml="${bs.displacedByCustomXml}"`);
|
|
4781
|
+
if (bs.colFirst !== void 0) a.push(`w:colFirst="${bs.colFirst}"`);
|
|
4782
|
+
if (bs.colLast !== void 0) a.push(`w:colLast="${bs.colLast}"`);
|
|
4783
|
+
return `<w:bookmarkStart ${a.join(" ")}/>`;
|
|
4841
4784
|
}
|
|
4842
4785
|
if ("bookmarkEnd" in child) {
|
|
4843
4786
|
const be = child.bookmarkEnd;
|
|
4844
|
-
const
|
|
4845
|
-
|
|
4787
|
+
const a = [`w:id="${be.id}"`];
|
|
4788
|
+
if (be.displacedByCustomXml) a.push(`w:displacedByCustomXml="${be.displacedByCustomXml}"`);
|
|
4789
|
+
return `<w:bookmarkEnd ${a.join(" ")}/>`;
|
|
4846
4790
|
}
|
|
4847
4791
|
if ("rawXml" in child) return child.rawXml;
|
|
4848
4792
|
throw new Error("Unknown section child type");
|
|
@@ -4851,21 +4795,25 @@ function stringifyBodyChild(child, ctx) {
|
|
|
4851
4795
|
const vmlStyleMap = styleToKeyMap;
|
|
4852
4796
|
function stringifyDocumentBackground(opts, ctx) {
|
|
4853
4797
|
if (opts.rawXml) {
|
|
4854
|
-
if (opts.rawMedia) for (const m of opts.rawMedia)
|
|
4855
|
-
|
|
4856
|
-
data
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4798
|
+
if (opts.rawMedia) for (const m of opts.rawMedia) {
|
|
4799
|
+
const data = toUint8Array(m.data);
|
|
4800
|
+
const entry = ctx.file.media.addMedia(data, m.type, (fileName) => ({
|
|
4801
|
+
type: m.type,
|
|
4802
|
+
data,
|
|
4803
|
+
fileName,
|
|
4804
|
+
transformation: {
|
|
4805
|
+
emus: {
|
|
4806
|
+
x: 0,
|
|
4807
|
+
y: 0
|
|
4808
|
+
},
|
|
4809
|
+
pixels: {
|
|
4810
|
+
x: 0,
|
|
4811
|
+
y: 0
|
|
4812
|
+
}
|
|
4866
4813
|
}
|
|
4867
|
-
}
|
|
4868
|
-
|
|
4814
|
+
}), m.fileName);
|
|
4815
|
+
if (entry.fileName !== m.fileName) opts.rawXml = opts.rawXml.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
4816
|
+
}
|
|
4869
4817
|
return opts.rawXml;
|
|
4870
4818
|
}
|
|
4871
4819
|
const attrs = [];
|
|
@@ -4875,12 +4823,12 @@ function stringifyDocumentBackground(opts, ctx) {
|
|
|
4875
4823
|
if (opts.themeTint !== void 0) attrs.push(`w:themeTint="${uCharHexNumber(opts.themeTint)}"`);
|
|
4876
4824
|
const attrStr = attrs.join(" ");
|
|
4877
4825
|
if (opts.image) {
|
|
4878
|
-
const
|
|
4879
|
-
const rawData = toUint8Array(
|
|
4880
|
-
ctx.file.media.
|
|
4881
|
-
type:
|
|
4826
|
+
const image = opts.image;
|
|
4827
|
+
const rawData = toUint8Array(image.data);
|
|
4828
|
+
const { fileName } = ctx.file.media.addMedia(rawData, image.type, (name) => ({
|
|
4829
|
+
type: image.type,
|
|
4882
4830
|
data: rawData,
|
|
4883
|
-
fileName,
|
|
4831
|
+
fileName: name,
|
|
4884
4832
|
transformation: {
|
|
4885
4833
|
emus: {
|
|
4886
4834
|
x: 0,
|
|
@@ -4891,7 +4839,7 @@ function stringifyDocumentBackground(opts, ctx) {
|
|
|
4891
4839
|
y: 0
|
|
4892
4840
|
}
|
|
4893
4841
|
}
|
|
4894
|
-
});
|
|
4842
|
+
}));
|
|
4895
4843
|
return `<w:background ${attrStr}>${`<v:background id="_x0000_s1025"><v:fill r:id="{${fileName}}" o:title="${fileName}" recolor="t" type="frame"/></v:background>`}</w:background>`;
|
|
4896
4844
|
}
|
|
4897
4845
|
return `<w:background ${attrStr}/>`;
|
|
@@ -5334,6 +5282,12 @@ function parseMoveRangeStart(el) {
|
|
|
5334
5282
|
if (author !== void 0) m.author = author;
|
|
5335
5283
|
const date = attr(el, "w:date");
|
|
5336
5284
|
if (date !== void 0) m.date = date;
|
|
5285
|
+
const disp = attr(el, "w:displacedByCustomXml");
|
|
5286
|
+
if (disp === "before" || disp === "after") m.displacedByCustomXml = disp;
|
|
5287
|
+
const colFirst = attrNum(el, "w:colFirst");
|
|
5288
|
+
if (colFirst !== void 0) m.colFirst = colFirst;
|
|
5289
|
+
const colLast = attrNum(el, "w:colLast");
|
|
5290
|
+
if (colLast !== void 0) m.colLast = colLast;
|
|
5337
5291
|
return m;
|
|
5338
5292
|
}
|
|
5339
5293
|
/** Parse a customXml range start (Ins/Del/MoveFrom/MoveTo). */
|
|
@@ -5347,6 +5301,15 @@ function parseCustomXmlRangeStart(el) {
|
|
|
5347
5301
|
if (date !== void 0) m.date = date;
|
|
5348
5302
|
return m;
|
|
5349
5303
|
}
|
|
5304
|
+
/** Parse a CT_MarkupRange end marker (id + displacedByCustomXml). */
|
|
5305
|
+
function parseMarkupRangeOptions(el) {
|
|
5306
|
+
const id = attrNum(el, "w:id");
|
|
5307
|
+
if (id === void 0) return void 0;
|
|
5308
|
+
const m = { id };
|
|
5309
|
+
const disp = attr(el, "w:displacedByCustomXml");
|
|
5310
|
+
if (disp === "before" || disp === "after") m.displacedByCustomXml = disp;
|
|
5311
|
+
return m;
|
|
5312
|
+
}
|
|
5350
5313
|
/**
|
|
5351
5314
|
* Parse a w:p element into ParagraphOptions.
|
|
5352
5315
|
*/
|
|
@@ -5508,6 +5471,10 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5508
5471
|
};
|
|
5509
5472
|
const disp = attr(child, "w:displacedByCustomXml");
|
|
5510
5473
|
if (disp === "before" || disp === "after") bookmarkStart.displacedByCustomXml = disp;
|
|
5474
|
+
const colFirst = attrNum(child, "w:colFirst");
|
|
5475
|
+
if (colFirst !== void 0) bookmarkStart.colFirst = colFirst;
|
|
5476
|
+
const colLast = attrNum(child, "w:colLast");
|
|
5477
|
+
if (colLast !== void 0) bookmarkStart.colLast = colLast;
|
|
5511
5478
|
childList.push({ bookmarkStart });
|
|
5512
5479
|
}
|
|
5513
5480
|
break;
|
|
@@ -5523,13 +5490,13 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5523
5490
|
break;
|
|
5524
5491
|
}
|
|
5525
5492
|
case "w:commentRangeStart": {
|
|
5526
|
-
const
|
|
5527
|
-
if (
|
|
5493
|
+
const m = parseMarkupRangeOptions(child);
|
|
5494
|
+
if (m) childList.push({ commentRangeStart: m });
|
|
5528
5495
|
break;
|
|
5529
5496
|
}
|
|
5530
5497
|
case "w:commentRangeEnd": {
|
|
5531
|
-
const
|
|
5532
|
-
if (
|
|
5498
|
+
const m = parseMarkupRangeOptions(child);
|
|
5499
|
+
if (m) childList.push({ commentRangeEnd: m });
|
|
5533
5500
|
break;
|
|
5534
5501
|
}
|
|
5535
5502
|
case "w:commentReference": {
|
|
@@ -5721,8 +5688,8 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5721
5688
|
break;
|
|
5722
5689
|
}
|
|
5723
5690
|
case "w:moveFromRangeEnd": {
|
|
5724
|
-
const
|
|
5725
|
-
if (
|
|
5691
|
+
const m = parseMarkupRangeOptions(child);
|
|
5692
|
+
if (m) childList.push({ moveFromRangeEnd: m });
|
|
5726
5693
|
break;
|
|
5727
5694
|
}
|
|
5728
5695
|
case "w:moveToRangeStart": {
|
|
@@ -5731,8 +5698,8 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5731
5698
|
break;
|
|
5732
5699
|
}
|
|
5733
5700
|
case "w:moveToRangeEnd": {
|
|
5734
|
-
const
|
|
5735
|
-
if (
|
|
5701
|
+
const m = parseMarkupRangeOptions(child);
|
|
5702
|
+
if (m) childList.push({ moveToRangeEnd: m });
|
|
5736
5703
|
break;
|
|
5737
5704
|
}
|
|
5738
5705
|
case "w:customXmlInsRangeStart": {
|
|
@@ -5841,7 +5808,7 @@ function parseParagraph(el, ctx) {
|
|
|
5841
5808
|
* based on the graphicData URI.
|
|
5842
5809
|
*/
|
|
5843
5810
|
function parseDrawingRun(el, ctx) {
|
|
5844
|
-
const graphicData =
|
|
5811
|
+
const graphicData = findFirst(el, "a:graphicData");
|
|
5845
5812
|
if (!graphicData) return void 0;
|
|
5846
5813
|
const uri = attr(graphicData, "uri") ?? "";
|
|
5847
5814
|
if (uri.includes("/chart")) return parseChartDrawing(el, ctx);
|
|
@@ -5907,8 +5874,8 @@ function readGrpSpLocks(cNvGrpSpPr) {
|
|
|
5907
5874
|
* Returns `null` when the drawing has neither wrapper.
|
|
5908
5875
|
*/
|
|
5909
5876
|
function parseAnchorOrInline(el) {
|
|
5910
|
-
const inline =
|
|
5911
|
-
const anchor = inline ? void 0 :
|
|
5877
|
+
const inline = findFirst(el, "wp:inline");
|
|
5878
|
+
const anchor = inline ? void 0 : findFirst(el, "wp:anchor");
|
|
5912
5879
|
const parent = inline ?? anchor;
|
|
5913
5880
|
if (!parent) return null;
|
|
5914
5881
|
const info = {};
|
|
@@ -5916,8 +5883,8 @@ function parseAnchorOrInline(el) {
|
|
|
5916
5883
|
if (extent) {
|
|
5917
5884
|
const cxEmu = attrNum(extent, "cx");
|
|
5918
5885
|
const cyEmu = attrNum(extent, "cy");
|
|
5919
|
-
if (cxEmu !== void 0) info.width =
|
|
5920
|
-
if (cyEmu !== void 0) info.height =
|
|
5886
|
+
if (cxEmu !== void 0) info.width = cxEmu;
|
|
5887
|
+
if (cyEmu !== void 0) info.height = cyEmu;
|
|
5921
5888
|
}
|
|
5922
5889
|
const ee = findChild(parent, "wp:effectExtent");
|
|
5923
5890
|
if (ee) info.effectExtent = {
|
|
@@ -5987,7 +5954,7 @@ function parseAnchorOrInline(el) {
|
|
|
5987
5954
|
function parseImageRun(el, ctx) {
|
|
5988
5955
|
const info = parseAnchorOrInline(el);
|
|
5989
5956
|
if (!info) return void 0;
|
|
5990
|
-
const blip =
|
|
5957
|
+
const blip = findFirst(el, "a:blip");
|
|
5991
5958
|
if (!blip) return void 0;
|
|
5992
5959
|
const rEmbed = attr(blip, "r:embed");
|
|
5993
5960
|
if (!rEmbed) return void 0;
|
|
@@ -6007,14 +5974,14 @@ function parseImageRun(el, ctx) {
|
|
|
6007
5974
|
if (info.altText) imageOpts.altText = info.altText;
|
|
6008
5975
|
if (info.floating) imageOpts.floating = info.floating;
|
|
6009
5976
|
if (info.graphicFrameLocks !== void 0) imageOpts.graphicFrameLocks = info.graphicFrameLocks;
|
|
6010
|
-
const blipFill =
|
|
5977
|
+
const blipFill = findFirst(el, "pic:blipFill");
|
|
6011
5978
|
if (blipFill) {
|
|
6012
5979
|
const srcRect = readSourceRectangle(blipFill);
|
|
6013
5980
|
if (srcRect) imageOpts.sourceRectangle = srcRect;
|
|
6014
5981
|
}
|
|
6015
5982
|
const cNvPr = readPicCnvPr(el);
|
|
6016
5983
|
if (cNvPr) imageOpts.nonVisualProperties = cNvPr;
|
|
6017
|
-
const picSpPr =
|
|
5984
|
+
const picSpPr = findFirst(el, "pic:spPr");
|
|
6018
5985
|
if (picSpPr) {
|
|
6019
5986
|
const fill = readShapeFill(picSpPr, ctx);
|
|
6020
5987
|
if (fill) imageOpts.fill = fill;
|
|
@@ -6065,7 +6032,7 @@ function readSourceRectangle(parent) {
|
|
|
6065
6032
|
* undefined when there is no non-visual properties block.
|
|
6066
6033
|
*/
|
|
6067
6034
|
function readPicCnvPr(el) {
|
|
6068
|
-
const nvPicPr =
|
|
6035
|
+
const nvPicPr = findFirst(el, "pic:nvPicPr");
|
|
6069
6036
|
if (!nvPicPr) return void 0;
|
|
6070
6037
|
const result = {};
|
|
6071
6038
|
const cNvPr = findChild(nvPicPr, "pic:cNvPr");
|
|
@@ -6090,7 +6057,7 @@ function readPicCnvPr(el) {
|
|
|
6090
6057
|
* through the shared descriptor.
|
|
6091
6058
|
*/
|
|
6092
6059
|
function readShapeFill(parent, ctx) {
|
|
6093
|
-
if (!(findChild(parent, "a:noFill") ?? findChild(parent, "a:solidFill") ?? findChild(parent, "a:gradFill") ?? findChild(parent, "a:pattFill") ?? findChild(parent, "a:grpFill"))) return void 0;
|
|
6060
|
+
if (!(findChild(parent, "a:noFill") ?? findChild(parent, "a:solidFill") ?? findChild(parent, "a:gradFill") ?? findChild(parent, "a:pattFill") ?? findChild(parent, "a:grpFill") ?? findChild(parent, "a:blipFill"))) return void 0;
|
|
6094
6061
|
return fillDesc.parse(parent, ctx);
|
|
6095
6062
|
}
|
|
6096
6063
|
/**
|
|
@@ -6129,7 +6096,7 @@ function parseShapeStyle(styleEl, ctx) {
|
|
|
6129
6096
|
*/
|
|
6130
6097
|
function parseWpsShapeCore(wspEl, ctx) {
|
|
6131
6098
|
const result = {};
|
|
6132
|
-
const txbxContent =
|
|
6099
|
+
const txbxContent = findFirst(wspEl, "w:txbxContent");
|
|
6133
6100
|
const children = [];
|
|
6134
6101
|
if (txbxContent) {
|
|
6135
6102
|
for (const child of txbxContent.elements ?? []) if (child.name === "w:p") children.push(parseParagraph(child, ctx));
|
|
@@ -6167,9 +6134,13 @@ function parseWpsShapeCore(wspEl, ctx) {
|
|
|
6167
6134
|
if (custGeom) result.customGeometry = customGeometryDesc.parse(custGeom, ctx);
|
|
6168
6135
|
const prstGeom = findChild(spPr, "a:prstGeom");
|
|
6169
6136
|
if (prstGeom) result.presetGeometry = presetGeometryDesc.parse(prstGeom, ctx);
|
|
6137
|
+
const scene3d = findChild(spPr, "a:scene3d");
|
|
6138
|
+
if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);
|
|
6139
|
+
const sp3d = findChild(spPr, "a:sp3d");
|
|
6140
|
+
if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, ctx);
|
|
6170
6141
|
}
|
|
6171
6142
|
const bodyPr = findChild(wspEl, "wps:bodyPr");
|
|
6172
|
-
if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr);
|
|
6143
|
+
if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr, ctx);
|
|
6173
6144
|
const styleEl = findChild(wspEl, "wps:style");
|
|
6174
6145
|
if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
|
|
6175
6146
|
return result;
|
|
@@ -6251,7 +6222,7 @@ function parseWpsChildMediaData(wspEl, ctx) {
|
|
|
6251
6222
|
* to the same image collapse to one media entry.
|
|
6252
6223
|
*/
|
|
6253
6224
|
function parsePicChildMediaData(picEl, ctx) {
|
|
6254
|
-
const blip =
|
|
6225
|
+
const blip = findFirst(picEl, "a:blip");
|
|
6255
6226
|
if (!blip) return void 0;
|
|
6256
6227
|
const rEmbed = attr(blip, "r:embed");
|
|
6257
6228
|
if (!rEmbed) return void 0;
|
|
@@ -6285,7 +6256,7 @@ function parsePicChildMediaData(picEl, ctx) {
|
|
|
6285
6256
|
* Parse a standalone wps shape drawing (graphicData URI wordprocessingShape).
|
|
6286
6257
|
*/
|
|
6287
6258
|
function parseWpsShapeDrawing(el, ctx) {
|
|
6288
|
-
const wsp =
|
|
6259
|
+
const wsp = findFirst(el, "wps:wsp");
|
|
6289
6260
|
if (!wsp) return void 0;
|
|
6290
6261
|
const info = parseAnchorOrInline(el) ?? {};
|
|
6291
6262
|
const shape = {
|
|
@@ -6305,7 +6276,7 @@ function parseWpsShapeDrawing(el, ctx) {
|
|
|
6305
6276
|
* Parse a wpg group drawing (graphicData URI wordprocessingGroup).
|
|
6306
6277
|
*/
|
|
6307
6278
|
function parseWpgGroupDrawing(el, ctx) {
|
|
6308
|
-
const wgp =
|
|
6279
|
+
const wgp = findFirst(el, "wpg:wgp");
|
|
6309
6280
|
if (!wgp) return void 0;
|
|
6310
6281
|
const info = parseAnchorOrInline(el) ?? {};
|
|
6311
6282
|
const grpSpPr = findChild(wgp, "wpg:grpSpPr");
|
|
@@ -6434,8 +6405,8 @@ function readWrap(anchor) {
|
|
|
6434
6405
|
}
|
|
6435
6406
|
}
|
|
6436
6407
|
function getDrawingExtent(el) {
|
|
6437
|
-
const inline =
|
|
6438
|
-
const anchor = inline ? void 0 :
|
|
6408
|
+
const inline = findFirst(el, "wp:inline");
|
|
6409
|
+
const anchor = inline ? void 0 : findFirst(el, "wp:anchor");
|
|
6439
6410
|
const parent = inline ?? anchor;
|
|
6440
6411
|
if (!parent) return {};
|
|
6441
6412
|
const extent = findChild(parent, "wp:extent");
|
|
@@ -6443,8 +6414,8 @@ function getDrawingExtent(el) {
|
|
|
6443
6414
|
const cxEmu = attrNum(extent, "cx");
|
|
6444
6415
|
const cyEmu = attrNum(extent, "cy");
|
|
6445
6416
|
return {
|
|
6446
|
-
...cxEmu !== void 0 ? { width:
|
|
6447
|
-
...cyEmu !== void 0 ? { height:
|
|
6417
|
+
...cxEmu !== void 0 ? { width: cxEmu } : {},
|
|
6418
|
+
...cyEmu !== void 0 ? { height: cyEmu } : {}
|
|
6448
6419
|
};
|
|
6449
6420
|
}
|
|
6450
6421
|
/**
|
|
@@ -6458,7 +6429,7 @@ function lookupRId(map, rId) {
|
|
|
6458
6429
|
if (rId.startsWith("rIdrId")) return map.get(rId.slice(3));
|
|
6459
6430
|
}
|
|
6460
6431
|
function parseChartDrawing(el, ctx) {
|
|
6461
|
-
const chartRef =
|
|
6432
|
+
const chartRef = findFirst(el, "c:chart");
|
|
6462
6433
|
if (!chartRef) return void 0;
|
|
6463
6434
|
const rId = attr(chartRef, "r:id");
|
|
6464
6435
|
const chartPath = lookupRId(ctx.docx.partRefs.charts, rId);
|
|
@@ -6480,9 +6451,9 @@ function parseChartXml(el) {
|
|
|
6480
6451
|
const opts = {};
|
|
6481
6452
|
const titleEl = findChild(chart, "c:title");
|
|
6482
6453
|
if (titleEl) {
|
|
6483
|
-
const rich =
|
|
6454
|
+
const rich = findFirst(titleEl, "c:rich");
|
|
6484
6455
|
if (rich) {
|
|
6485
|
-
const t =
|
|
6456
|
+
const t = findFirst(rich, "a:t");
|
|
6486
6457
|
if (t) {
|
|
6487
6458
|
const title = textOf(t);
|
|
6488
6459
|
if (title) opts.title = title;
|
|
@@ -6551,7 +6522,7 @@ function parseChartXml(el) {
|
|
|
6551
6522
|
function extractStrCache(parent, containerName) {
|
|
6552
6523
|
const container = findChild(parent, containerName);
|
|
6553
6524
|
if (!container) return [];
|
|
6554
|
-
const cache =
|
|
6525
|
+
const cache = findFirst(container, "c:strCache");
|
|
6555
6526
|
if (!cache) return [];
|
|
6556
6527
|
const values = [];
|
|
6557
6528
|
for (const pt of cache.elements ?? []) {
|
|
@@ -6567,7 +6538,7 @@ function extractStrCache(parent, containerName) {
|
|
|
6567
6538
|
function extractNumCache(parent) {
|
|
6568
6539
|
const valEl = findChild(parent, "c:val");
|
|
6569
6540
|
if (!valEl) return [];
|
|
6570
|
-
const cache =
|
|
6541
|
+
const cache = findFirst(valEl, "c:numCache");
|
|
6571
6542
|
if (!cache) return [];
|
|
6572
6543
|
const values = [];
|
|
6573
6544
|
for (const pt of cache.elements ?? []) {
|
|
@@ -6581,7 +6552,7 @@ function extractNumCache(parent) {
|
|
|
6581
6552
|
return values;
|
|
6582
6553
|
}
|
|
6583
6554
|
function parseSmartArtDrawing(el, ctx) {
|
|
6584
|
-
const relIds =
|
|
6555
|
+
const relIds = findFirst(el, "dgm:relIds");
|
|
6585
6556
|
if (!relIds) return void 0;
|
|
6586
6557
|
const rId = attr(relIds, "r:dm");
|
|
6587
6558
|
const dataPath = lookupRId(ctx.docx.partRefs.diagramData, rId);
|
|
@@ -6620,7 +6591,7 @@ function parseSmartArtDataXml(el) {
|
|
|
6620
6591
|
if (color) opts.color = color;
|
|
6621
6592
|
}
|
|
6622
6593
|
} else if (type === "node" && modelId) {
|
|
6623
|
-
const t =
|
|
6594
|
+
const t = findFirst(pt, "a:t");
|
|
6624
6595
|
nodeMap.set(modelId, t ? textOf(t) ?? "" : "");
|
|
6625
6596
|
}
|
|
6626
6597
|
}
|
|
@@ -6833,7 +6804,7 @@ function stringifyWpsShape(opts, ctx) {
|
|
|
6833
6804
|
if (opts.customGeometry) spPrParts.push(customGeometryDesc$1.stringify(opts.customGeometry, NOOP_CTX) ?? "");
|
|
6834
6805
|
else if (opts.presetGeometry) spPrParts.push(presetGeometryDesc$1.stringify(opts.presetGeometry, NOOP_CTX) ?? "");
|
|
6835
6806
|
else spPrParts.push("<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>");
|
|
6836
|
-
if (opts.fill) spPrParts.push(fillDesc$1.stringify(opts.fill,
|
|
6807
|
+
if (opts.fill) spPrParts.push(fillDesc$1.stringify(opts.fill, ctx) ?? "");
|
|
6837
6808
|
if (opts.outline) spPrParts.push(outlineDesc$1.stringify(opts.outline, NOOP_CTX) ?? "");
|
|
6838
6809
|
if (opts.effectDag) spPrParts.push(createEffectDag(opts.effectDag));
|
|
6839
6810
|
else if (opts.effects) spPrParts.push(effectListDesc$1.stringify(opts.effects, NOOP_CTX) ?? "");
|
|
@@ -6880,7 +6851,7 @@ function stringifyWpgGroup(opts, ctx) {
|
|
|
6880
6851
|
const transform = opts.transformation;
|
|
6881
6852
|
const grpSpPrParts = [];
|
|
6882
6853
|
grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.childOffset, opts.childExtent));
|
|
6883
|
-
if (opts.fill) grpSpPrParts.push(fillDesc$1.stringify(opts.fill,
|
|
6854
|
+
if (opts.fill) grpSpPrParts.push(fillDesc$1.stringify(opts.fill, ctx) ?? "");
|
|
6884
6855
|
if (opts.effects) grpSpPrParts.push(effectListDesc$1.stringify(opts.effects, NOOP_CTX) ?? "");
|
|
6885
6856
|
const childXml = opts.children.map((child) => stringifyGroupChild(child, ctx)).join("");
|
|
6886
6857
|
return "<wpg:wgp>" + stringifyCnvGrpSpPr(opts.groupShapeLocks) + `<wpg:grpSpPr>${grpSpPrParts.join("")}</wpg:grpSpPr>` + childXml + "</wpg:wgp>";
|
|
@@ -6920,7 +6891,7 @@ function stringifyGroupChild(child, ctx) {
|
|
|
6920
6891
|
function stringifyNestedGroup(grp, ctx) {
|
|
6921
6892
|
const grpSpPrParts = [];
|
|
6922
6893
|
grpSpPrParts.push(stringifyGroupTransform2D(grp.transformation, grp.childOffset, grp.childExtent));
|
|
6923
|
-
if (grp.fill) grpSpPrParts.push(fillDesc$1.stringify(grp.fill,
|
|
6894
|
+
if (grp.fill) grpSpPrParts.push(fillDesc$1.stringify(grp.fill, ctx) ?? "");
|
|
6924
6895
|
if (grp.effects) grpSpPrParts.push(effectListDesc$1.stringify(grp.effects, NOOP_CTX) ?? "");
|
|
6925
6896
|
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>";
|
|
6926
6897
|
}
|
|
@@ -6954,10 +6925,10 @@ function stringifyGraphicDataContent(mediaData, opts, hlIds, ctx) {
|
|
|
6954
6925
|
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>`;
|
|
6955
6926
|
}
|
|
6956
6927
|
function stringifyPositionH(opts) {
|
|
6957
|
-
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>`;
|
|
6928
|
+
return `<wp:positionH relativeFrom="${opts.relative ?? HorizontalPositionRelativeFrom.PAGE}">${opts.align ? `<wp:align>${opts.align}</wp:align>` : opts.offset !== void 0 ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>` : "<wp:align>left</wp:align>"}</wp:positionH>`;
|
|
6958
6929
|
}
|
|
6959
6930
|
function stringifyPositionV(opts) {
|
|
6960
|
-
return `<wp:positionV relativeFrom="${opts.relative ?? VerticalPositionRelativeFrom.PAGE}">${opts.align ? `<wp:align>${opts.align}</wp:align>` : opts.offset !== void 0 ? `<wp:posOffset>${opts.offset}</wp:posOffset>` : "<wp:align>top</wp:align>"}</wp:positionV>`;
|
|
6931
|
+
return `<wp:positionV relativeFrom="${opts.relative ?? VerticalPositionRelativeFrom.PAGE}">${opts.align ? `<wp:align>${opts.align}</wp:align>` : opts.offset !== void 0 ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>` : "<wp:align>top</wp:align>"}</wp:positionV>`;
|
|
6961
6932
|
}
|
|
6962
6933
|
function wrapPolygonStr(cx, cy) {
|
|
6963
6934
|
return `<wp:wrapPolygon edited="0"><wp:start x="0" y="0"/><wp:lineTo x="0" y="${-cy}"/><wp:lineTo x="${cx}" y="${-cy}"/><wp:lineTo x="${cx}" y="0"/><wp:lineTo x="0" y="0"/></wp:wrapPolygon>`;
|
|
@@ -6967,27 +6938,27 @@ function wrapSquareStr(textWrapping, margins) {
|
|
|
6967
6938
|
const m = margins ?? {};
|
|
6968
6939
|
return `<wp:wrapSquare ${[
|
|
6969
6940
|
`wrapText="${side}"`,
|
|
6970
|
-
...m.top != null ? [`distT="${m.top}"`] : [],
|
|
6971
|
-
...m.bottom != null ? [`distB="${m.bottom}"`] : [],
|
|
6972
|
-
...m.left != null ? [`distL="${m.left}"`] : [],
|
|
6973
|
-
...m.right != null ? [`distR="${m.right}"`] : []
|
|
6941
|
+
...m.top != null ? [`distT="${convertToEmu(m.top)}"`] : [],
|
|
6942
|
+
...m.bottom != null ? [`distB="${convertToEmu(m.bottom)}"`] : [],
|
|
6943
|
+
...m.left != null ? [`distL="${convertToEmu(m.left)}"`] : [],
|
|
6944
|
+
...m.right != null ? [`distR="${convertToEmu(m.right)}"`] : []
|
|
6974
6945
|
].join(" ")}/>`;
|
|
6975
6946
|
}
|
|
6976
6947
|
function wrapTightStr(textWrapping, margins, cx, cy) {
|
|
6977
6948
|
const a = [`wrapText="${textWrapping.side ?? TextWrappingSide.BOTH_SIDES}"`];
|
|
6978
|
-
if (margins.left != null) a.push(`distL="${margins.left}"`);
|
|
6979
|
-
if (margins.right != null) a.push(`distR="${margins.right}"`);
|
|
6949
|
+
if (margins.left != null) a.push(`distL="${convertToEmu(margins.left)}"`);
|
|
6950
|
+
if (margins.right != null) a.push(`distR="${convertToEmu(margins.right)}"`);
|
|
6980
6951
|
return `<wp:wrapTight ${a.join(" ")}>${wrapPolygonStr(cx, cy)}</wp:wrapTight>`;
|
|
6981
6952
|
}
|
|
6982
6953
|
function wrapThroughStr(textWrapping, margins, cx, cy) {
|
|
6983
6954
|
const a = [`wrapText="${textWrapping.side ?? TextWrappingSide.BOTH_SIDES}"`];
|
|
6984
|
-
if (margins.left != null) a.push(`distL="${margins.left}"`);
|
|
6985
|
-
if (margins.right != null) a.push(`distR="${margins.right}"`);
|
|
6955
|
+
if (margins.left != null) a.push(`distL="${convertToEmu(margins.left)}"`);
|
|
6956
|
+
if (margins.right != null) a.push(`distR="${convertToEmu(margins.right)}"`);
|
|
6986
6957
|
return `<wp:wrapThrough ${a.join(" ")}>${wrapPolygonStr(cx, cy)}</wp:wrapThrough>`;
|
|
6987
6958
|
}
|
|
6988
6959
|
function wrapTopAndBottomStr(margins) {
|
|
6989
6960
|
const m = margins ?? {};
|
|
6990
|
-
const a = [...m.top != null ? [`distT="${m.top}"`] : [], ...m.bottom != null ? [`distB="${m.bottom}"`] : []].join(" ");
|
|
6961
|
+
const a = [...m.top != null ? [`distT="${convertToEmu(m.top)}"`] : [], ...m.bottom != null ? [`distB="${convertToEmu(m.bottom)}"`] : []].join(" ");
|
|
6991
6962
|
return a ? `<wp:wrapTopAndBottom ${a}/>` : "<wp:wrapTopAndBottom/>";
|
|
6992
6963
|
}
|
|
6993
6964
|
/** Render wp:cNvGraphicFramePr. Undefined → authoring default (noChangeAspect=1);
|
|
@@ -7048,10 +7019,10 @@ function stringifyAnchor(opts, hlIds, ctx) {
|
|
|
7048
7019
|
...rawFloating
|
|
7049
7020
|
};
|
|
7050
7021
|
const attrParts = [
|
|
7051
|
-
`distT="${floating.margins?.top ?? 0}"`,
|
|
7052
|
-
`distB="${floating.margins?.bottom ?? 0}"`,
|
|
7053
|
-
`distL="${floating.margins?.left ?? 0}"`,
|
|
7054
|
-
`distR="${floating.margins?.right ?? 0}"`,
|
|
7022
|
+
`distT="${convertToEmu(floating.margins?.top ?? 0)}"`,
|
|
7023
|
+
`distB="${convertToEmu(floating.margins?.bottom ?? 0)}"`,
|
|
7024
|
+
`distL="${convertToEmu(floating.margins?.left ?? 0)}"`,
|
|
7025
|
+
`distR="${convertToEmu(floating.margins?.right ?? 0)}"`,
|
|
7055
7026
|
"simplePos=\"0\"",
|
|
7056
7027
|
`allowOverlap="${floating.allowOverlap ? 1 : 0}"`,
|
|
7057
7028
|
`behindDoc="${floating.behindDocument ? 1 : 0}"`,
|
|
@@ -7086,24 +7057,6 @@ function stringifyAnchor(opts, hlIds, ctx) {
|
|
|
7086
7057
|
const drawingDesc = {
|
|
7087
7058
|
kind: "custom",
|
|
7088
7059
|
stringify(opts, ctx) {
|
|
7089
|
-
if (opts.fill) {
|
|
7090
|
-
const media = extractBlipFillMedia(opts.fill, (type) => ctx.file.media.nextMediaName(type));
|
|
7091
|
-
if (media) ctx.file.media.addImage(media.fileName, {
|
|
7092
|
-
data: media.data,
|
|
7093
|
-
fileName: media.fileName,
|
|
7094
|
-
type: media.type,
|
|
7095
|
-
transformation: {
|
|
7096
|
-
pixels: {
|
|
7097
|
-
x: 0,
|
|
7098
|
-
y: 0
|
|
7099
|
-
},
|
|
7100
|
-
emus: {
|
|
7101
|
-
x: 0,
|
|
7102
|
-
y: 0
|
|
7103
|
-
}
|
|
7104
|
-
}
|
|
7105
|
-
});
|
|
7106
|
-
}
|
|
7107
7060
|
const hlIds = registerHyperlinks(opts.docProperties?.hyperlink, ctx);
|
|
7108
7061
|
if (opts.floating) return stringifyAnchor(opts, hlIds, ctx);
|
|
7109
7062
|
return stringifyInline(opts, hlIds, ctx);
|
|
@@ -7298,15 +7251,10 @@ function registerVmlFallbackMedia(opts, ctx) {
|
|
|
7298
7251
|
if (!opts.vmlFallbackMedia) return;
|
|
7299
7252
|
for (const m of opts.vmlFallbackMedia) {
|
|
7300
7253
|
const data = toUint8Array(m.data);
|
|
7301
|
-
const
|
|
7302
|
-
if (existing) {
|
|
7303
|
-
if (opts.vmlFallback) opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${existing}}`);
|
|
7304
|
-
continue;
|
|
7305
|
-
}
|
|
7306
|
-
ctx.file.media.addImage(m.fileName, {
|
|
7254
|
+
const entry = ctx.file.media.addMedia(data, m.type, (fileName) => ({
|
|
7307
7255
|
type: m.type,
|
|
7308
7256
|
data,
|
|
7309
|
-
fileName
|
|
7257
|
+
fileName,
|
|
7310
7258
|
transformation: {
|
|
7311
7259
|
emus: {
|
|
7312
7260
|
x: 0,
|
|
@@ -7317,12 +7265,109 @@ function registerVmlFallbackMedia(opts, ctx) {
|
|
|
7317
7265
|
y: 0
|
|
7318
7266
|
}
|
|
7319
7267
|
}
|
|
7320
|
-
});
|
|
7268
|
+
}), m.fileName);
|
|
7269
|
+
if (entry.fileName !== m.fileName && opts.vmlFallback) opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);
|
|
7321
7270
|
}
|
|
7322
7271
|
}
|
|
7323
7272
|
/**
|
|
7324
7273
|
* Build the rPr XML for a break/tab run from its structured run properties.
|
|
7325
7274
|
*/
|
|
7275
|
+
/** Shared attribute string for CT_MarkupRange end markers (commentRange, move range end). */
|
|
7276
|
+
function buildMarkupRangeAttrs(m) {
|
|
7277
|
+
const a = [`w:id="${m.id}"`];
|
|
7278
|
+
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
7279
|
+
return a.join(" ");
|
|
7280
|
+
}
|
|
7281
|
+
/** Shared attribute string for w:bookmarkStart (CT_Bookmark). */
|
|
7282
|
+
function buildBookmarkStartAttrs(bs) {
|
|
7283
|
+
const a = [`w:id="${bs.id}"`, `w:name="${escapeXml(bs.name)}"`];
|
|
7284
|
+
if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml="${bs.displacedByCustomXml}"`);
|
|
7285
|
+
if (bs.colFirst !== void 0) a.push(`w:colFirst="${bs.colFirst}"`);
|
|
7286
|
+
if (bs.colLast !== void 0) a.push(`w:colLast="${bs.colLast}"`);
|
|
7287
|
+
return a.join(" ");
|
|
7288
|
+
}
|
|
7289
|
+
/** Shared attribute string for w:moveFromRangeStart / w:moveToRangeStart (CT_MoveBookmark). */
|
|
7290
|
+
function buildMoveRangeStartAttrs(m) {
|
|
7291
|
+
const a = [`w:id="${m.id}"`];
|
|
7292
|
+
if (m.name) a.push(`w:name="${escapeXml(m.name)}"`);
|
|
7293
|
+
if (m.author) a.push(`w:author="${escapeXml(m.author)}"`);
|
|
7294
|
+
if (m.date) a.push(`w:date="${m.date}"`);
|
|
7295
|
+
if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml="${m.displacedByCustomXml}"`);
|
|
7296
|
+
if (m.colFirst !== void 0) a.push(`w:colFirst="${m.colFirst}"`);
|
|
7297
|
+
if (m.colLast !== void 0) a.push(`w:colLast="${m.colLast}"`);
|
|
7298
|
+
return a.join(" ");
|
|
7299
|
+
}
|
|
7300
|
+
/** Stringify inline run/text content — the `wrap` shared by every sugar child. */
|
|
7301
|
+
function stringifyInlineWrap(wrap, ctx) {
|
|
7302
|
+
const parts = [];
|
|
7303
|
+
for (const item of wrap ?? []) parts.push(typeof item === "string" ? stringifyRunInline({ text: item }, ctx) : stringifyRunInline(item, ctx));
|
|
7304
|
+
return parts.join("");
|
|
7305
|
+
}
|
|
7306
|
+
/**
|
|
7307
|
+
* Expand a `{ comment }` sugar child: allocate the comment id, register the
|
|
7308
|
+
* comment entry (side effect, consumed when word/comments.xml is stringified),
|
|
7309
|
+
* and emit the range markers + anchored content + reference with one shared id.
|
|
7310
|
+
*
|
|
7311
|
+
* The caller never supplies an id — the library owns id allocation and pairing.
|
|
7312
|
+
*/
|
|
7313
|
+
function stringifyCommentChild(c, ctx) {
|
|
7314
|
+
const id = ctx.file.comments.nextId++;
|
|
7315
|
+
ctx.file.comments.entries.push({
|
|
7316
|
+
id,
|
|
7317
|
+
author: c.author,
|
|
7318
|
+
initials: c.initials,
|
|
7319
|
+
date: c.date,
|
|
7320
|
+
children: c.children
|
|
7321
|
+
});
|
|
7322
|
+
return `<w:commentRangeStart w:id="${id}"/>` + stringifyInlineWrap(c.wrap, ctx) + `<w:commentRangeEnd w:id="${id}"/><w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${id}"/></w:r>`;
|
|
7323
|
+
}
|
|
7324
|
+
/**
|
|
7325
|
+
* Expand a `{ bookmark }` sugar child: allocate the bookmark id and emit the
|
|
7326
|
+
* paired bookmarkStart/bookmarkEnd with the anchored content between them.
|
|
7327
|
+
* Bookmarks are pure markup — the only effect is the two markers.
|
|
7328
|
+
*/
|
|
7329
|
+
function stringifyBookmarkChild(b, ctx) {
|
|
7330
|
+
const id = ctx.file.markupIds.rangeNext++;
|
|
7331
|
+
const startAttrs = buildBookmarkStartAttrs({
|
|
7332
|
+
id,
|
|
7333
|
+
name: b.name,
|
|
7334
|
+
displacedByCustomXml: b.displacedByCustomXml,
|
|
7335
|
+
colFirst: b.colFirst,
|
|
7336
|
+
colLast: b.colLast
|
|
7337
|
+
});
|
|
7338
|
+
const endAttrs = buildMarkupRangeAttrs({
|
|
7339
|
+
id,
|
|
7340
|
+
displacedByCustomXml: b.displacedByCustomXml
|
|
7341
|
+
});
|
|
7342
|
+
return `<w:bookmarkStart ${startAttrs}/>${stringifyInlineWrap(b.wrap, ctx)}<w:bookmarkEnd ${endAttrs}/>`;
|
|
7343
|
+
}
|
|
7344
|
+
/**
|
|
7345
|
+
* Expand a `{ moveFrom }` / `{ moveTo }` sugar child: allocate the range id and
|
|
7346
|
+
* the move-run id, then emit the paired range markers with the moved run between
|
|
7347
|
+
* them. The move run (CT_TrackChange) carries the moved content.
|
|
7348
|
+
*/
|
|
7349
|
+
function stringifyMoveRangeChild(kind, opts, ctx) {
|
|
7350
|
+
const rangeId = ctx.file.markupIds.rangeNext++;
|
|
7351
|
+
const runId = ctx.file.markupIds.moveRunNext++;
|
|
7352
|
+
const isMoveFrom = kind === "moveFrom";
|
|
7353
|
+
const startTag = isMoveFrom ? "w:moveFromRangeStart" : "w:moveToRangeStart";
|
|
7354
|
+
const endTag = isMoveFrom ? "w:moveFromRangeEnd" : "w:moveToRangeEnd";
|
|
7355
|
+
const runTag = isMoveFrom ? "w:moveFrom" : "w:moveTo";
|
|
7356
|
+
const rangeStartAttrs = buildMoveRangeStartAttrs({
|
|
7357
|
+
id: rangeId,
|
|
7358
|
+
name: opts.name,
|
|
7359
|
+
author: opts.author,
|
|
7360
|
+
date: opts.date,
|
|
7361
|
+
displacedByCustomXml: opts.displacedByCustomXml,
|
|
7362
|
+
colFirst: opts.colFirst,
|
|
7363
|
+
colLast: opts.colLast
|
|
7364
|
+
});
|
|
7365
|
+
const endAttrs = buildMarkupRangeAttrs({
|
|
7366
|
+
id: rangeId,
|
|
7367
|
+
displacedByCustomXml: opts.displacedByCustomXml
|
|
7368
|
+
});
|
|
7369
|
+
return `<${startTag} ${rangeStartAttrs}/><${runTag} w:id="${runId}" w:author="${escapeXml(opts.author)}" w:date="${opts.date}">${stringifyInlineWrap(opts.wrap, ctx)}</${runTag}><${endTag} ${endAttrs}/>`;
|
|
7370
|
+
}
|
|
7326
7371
|
function runPropertiesXml(child) {
|
|
7327
7372
|
return stringifyRunProperties(child) ?? "";
|
|
7328
7373
|
}
|
|
@@ -7338,19 +7383,13 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7338
7383
|
const ref = child.endnoteReference;
|
|
7339
7384
|
return `<w:r><w:rPr><w:rStyle w:val="EndnoteReference"/></w:rPr><w:endnoteReference w:id="${typeof ref === "number" ? ref : ref.id}"${typeof ref === "object" && ref.customMarkFollows ? " w:customMarkFollows=\"true\"" : ""}/></w:r>`;
|
|
7340
7385
|
}
|
|
7341
|
-
if ("
|
|
7342
|
-
if ("
|
|
7386
|
+
if ("comment" in child) return stringifyCommentChild(child.comment, ctx);
|
|
7387
|
+
if ("commentRangeStart" in child) return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;
|
|
7388
|
+
if ("commentRangeEnd" in child) return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;
|
|
7343
7389
|
if ("commentReference" in child) return `<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${child.commentReference}"/></w:r>`;
|
|
7344
|
-
if ("bookmarkStart" in child) {
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
return `<w:bookmarkStart w:id="${bs.id}" w:name="${bs.name}"${bsDisp}/>`;
|
|
7348
|
-
}
|
|
7349
|
-
if ("bookmarkEnd" in child) {
|
|
7350
|
-
const be = child.bookmarkEnd;
|
|
7351
|
-
const beDisp = be.displacedByCustomXml ? ` w:displacedByCustomXml="${be.displacedByCustomXml}"` : "";
|
|
7352
|
-
return `<w:bookmarkEnd w:id="${be.id}"${beDisp}/>`;
|
|
7353
|
-
}
|
|
7390
|
+
if ("bookmarkStart" in child) return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;
|
|
7391
|
+
if ("bookmarkEnd" in child) return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;
|
|
7392
|
+
if ("bookmark" in child) return stringifyBookmarkChild(child.bookmark, ctx);
|
|
7354
7393
|
if ("symbolRun" in child) {
|
|
7355
7394
|
const opts = child.symbolRun;
|
|
7356
7395
|
return `<w:r>${stringifyRunProperties(opts) ?? ""}<w:sym w:char="${opts.char}" w:font="${opts.symbolfont ?? "Wingdings"}"/></w:r>`;
|
|
@@ -7377,27 +7416,29 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7377
7416
|
}
|
|
7378
7417
|
if ("image" in child) {
|
|
7379
7418
|
const opts = child.image;
|
|
7380
|
-
const
|
|
7381
|
-
const rawData = toUint8Array(opts.data);
|
|
7419
|
+
const rawData = toUint8Array(opts.data, { encoding: "base64" });
|
|
7382
7420
|
let mediaData;
|
|
7383
7421
|
if (opts.type === "svg") {
|
|
7384
|
-
const fallbackData = toUint8Array(opts.fallback.data);
|
|
7385
|
-
|
|
7422
|
+
const fallbackData = toUint8Array(opts.fallback.data, { encoding: "base64" });
|
|
7423
|
+
const fallbackType = opts.fallback.type;
|
|
7424
|
+
const fallback = ctx.file.media.addMedia(fallbackData, fallbackType, (fileName) => ({
|
|
7425
|
+
type: fallbackType,
|
|
7426
|
+
...createImageData(fallbackData, opts.transformation, fileName)
|
|
7427
|
+
}));
|
|
7428
|
+
mediaData = ctx.file.media.addMedia(rawData, "svg", (fileName) => ({
|
|
7386
7429
|
type: "svg",
|
|
7387
|
-
...createImageData(rawData, opts.transformation,
|
|
7430
|
+
...createImageData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
7388
7431
|
useLocalDpi: opts.useLocalDpi,
|
|
7389
|
-
fallback
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
}
|
|
7399
|
-
ctx.file.media.addImage(mediaData.fileName, mediaData);
|
|
7400
|
-
if (mediaData.type === "svg") ctx.file.media.addImage(mediaData.fallback.fileName, mediaData.fallback);
|
|
7432
|
+
fallback
|
|
7433
|
+
}));
|
|
7434
|
+
} else {
|
|
7435
|
+
const type = opts.type;
|
|
7436
|
+
mediaData = ctx.file.media.addMedia(rawData, type, (fileName) => ({
|
|
7437
|
+
type,
|
|
7438
|
+
...createImageData(rawData, opts.transformation, fileName, opts.sourceRectangle, opts.nonVisualProperties),
|
|
7439
|
+
useLocalDpi: opts.useLocalDpi
|
|
7440
|
+
}));
|
|
7441
|
+
}
|
|
7401
7442
|
return wrapDrawingRun(drawingDesc.stringify({
|
|
7402
7443
|
mediaData,
|
|
7403
7444
|
docProperties: opts.altText,
|
|
@@ -7499,7 +7540,7 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7499
7540
|
registerMedia(c.children);
|
|
7500
7541
|
continue;
|
|
7501
7542
|
}
|
|
7502
|
-
ctx.file.media.
|
|
7543
|
+
ctx.file.media.addMedia(c.data, c.type, () => c, c.fileName);
|
|
7503
7544
|
}
|
|
7504
7545
|
};
|
|
7505
7546
|
registerMedia(opts.children);
|
|
@@ -7545,6 +7586,7 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7545
7586
|
if ("hyperlink" in child) {
|
|
7546
7587
|
const hl = child.hyperlink;
|
|
7547
7588
|
const childParts = [];
|
|
7589
|
+
if (child.text !== void 0) childParts.push(stringifyRunInline({ text: child.text }, ctx));
|
|
7548
7590
|
if (hl.children) for (const rc of hl.children) if (typeof rc === "string") childParts.push(stringifyRunInline({ text: rc }, ctx));
|
|
7549
7591
|
else childParts.push(stringifyRunInline(rc, ctx));
|
|
7550
7592
|
const body = childParts.join("");
|
|
@@ -7583,24 +7625,12 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7583
7625
|
return `<w:permStart ${a.join(" ")}/>`;
|
|
7584
7626
|
}
|
|
7585
7627
|
if ("permEnd" in child) return `<w:permEnd w:id="${child.permEnd}"/>`;
|
|
7586
|
-
if ("moveFromRangeStart" in child) {
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
return `<w:moveFromRangeStart ${a.join(" ")}/>`;
|
|
7593
|
-
}
|
|
7594
|
-
if ("moveFromRangeEnd" in child) return `<w:moveFromRangeEnd w:id="${child.moveFromRangeEnd}"/>`;
|
|
7595
|
-
if ("moveToRangeStart" in child) {
|
|
7596
|
-
const m = child.moveToRangeStart;
|
|
7597
|
-
const a = [`w:id="${m.id}"`];
|
|
7598
|
-
if (m.name) a.push(`w:name="${escapeXml(m.name)}"`);
|
|
7599
|
-
if (m.author) a.push(`w:author="${escapeXml(m.author)}"`);
|
|
7600
|
-
if (m.date) a.push(`w:date="${m.date}"`);
|
|
7601
|
-
return `<w:moveToRangeStart ${a.join(" ")}/>`;
|
|
7602
|
-
}
|
|
7603
|
-
if ("moveToRangeEnd" in child) return `<w:moveToRangeEnd w:id="${child.moveToRangeEnd}"/>`;
|
|
7628
|
+
if ("moveFromRangeStart" in child) return `<w:moveFromRangeStart ${buildMoveRangeStartAttrs(child.moveFromRangeStart)}/>`;
|
|
7629
|
+
if ("moveFromRangeEnd" in child) return `<w:moveFromRangeEnd ${buildMarkupRangeAttrs(child.moveFromRangeEnd)}/>`;
|
|
7630
|
+
if ("moveToRangeStart" in child) return `<w:moveToRangeStart ${buildMoveRangeStartAttrs(child.moveToRangeStart)}/>`;
|
|
7631
|
+
if ("moveToRangeEnd" in child) return `<w:moveToRangeEnd ${buildMarkupRangeAttrs(child.moveToRangeEnd)}/>`;
|
|
7632
|
+
if ("moveFrom" in child) return stringifyMoveRangeChild("moveFrom", child.moveFrom, ctx);
|
|
7633
|
+
if ("moveTo" in child) return stringifyMoveRangeChild("moveTo", child.moveTo, ctx);
|
|
7604
7634
|
if ("movedFrom" in child) {
|
|
7605
7635
|
const { id, author, date, children } = child.movedFrom;
|
|
7606
7636
|
const body = children.map((c) => stringifyRunInline(typeof c === "string" ? { text: c } : c, ctx)).join("");
|
|
@@ -9822,10 +9852,6 @@ const HeaderFooterType = {
|
|
|
9822
9852
|
const createHeaderFooterReference = (type, options) => `<${type} r:id="rId${options.id}" w:type="${options.type || HeaderFooterReferenceType.DEFAULT}"/>`;
|
|
9823
9853
|
//#endregion
|
|
9824
9854
|
//#region src/parts/styles/factory.ts
|
|
9825
|
-
/** Escape special XML characters. */
|
|
9826
|
-
function esc(s) {
|
|
9827
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
9828
|
-
}
|
|
9829
9855
|
/**
|
|
9830
9856
|
* Build CT_Style style-level children (name…rsid), shared by paragraph/character/table styles.
|
|
9831
9857
|
* Order follows CT_Style sequence: name, aliases, basedOn, next, link, autoRedefine, hidden,
|
|
@@ -9833,11 +9859,11 @@ function esc(s) {
|
|
|
9833
9859
|
* personalReply, rsid.
|
|
9834
9860
|
*/
|
|
9835
9861
|
function stringifyStyleLevelChildren(opts) {
|
|
9836
|
-
const parts = [`<w:name w:val="${
|
|
9837
|
-
if (opts.aliases) parts.push(`<w:aliases w:val="${
|
|
9838
|
-
if (opts.basedOn) parts.push(`<w:basedOn w:val="${
|
|
9839
|
-
if (opts.next) parts.push(`<w:next w:val="${
|
|
9840
|
-
if (opts.link) parts.push(`<w:link w:val="${
|
|
9862
|
+
const parts = [`<w:name w:val="${escapeXml(opts.name ?? opts.id ?? "")}"/>`];
|
|
9863
|
+
if (opts.aliases) parts.push(`<w:aliases w:val="${escapeXml(opts.aliases)}"/>`);
|
|
9864
|
+
if (opts.basedOn) parts.push(`<w:basedOn w:val="${escapeXml(opts.basedOn)}"/>`);
|
|
9865
|
+
if (opts.next) parts.push(`<w:next w:val="${escapeXml(opts.next)}"/>`);
|
|
9866
|
+
if (opts.link) parts.push(`<w:link w:val="${escapeXml(opts.link)}"/>`);
|
|
9841
9867
|
if (opts.autoRedefine) parts.push("<w:autoRedefine/>");
|
|
9842
9868
|
if (opts.hidden) parts.push("<w:hidden/>");
|
|
9843
9869
|
if (opts.uiPriority !== void 0) parts.push(`<w:uiPriority w:val="${opts.uiPriority}"/>`);
|
|
@@ -9851,6 +9877,17 @@ function stringifyStyleLevelChildren(opts) {
|
|
|
9851
9877
|
if (opts.rsid) parts.push(`<w:rsid w:val="${opts.rsid}"/>`);
|
|
9852
9878
|
return parts.join("");
|
|
9853
9879
|
}
|
|
9880
|
+
/**
|
|
9881
|
+
* Build the `<w:style>` opening tag: type/styleId plus the optional w:default
|
|
9882
|
+
* and w:customStyle element attributes (CT_Style). Shared by paragraph/
|
|
9883
|
+
* character/table styles.
|
|
9884
|
+
*/
|
|
9885
|
+
function styleOpenTag(type, opts) {
|
|
9886
|
+
let attrs = ` w:type="${type}" w:styleId="${escapeXml(opts.id ?? "")}"`;
|
|
9887
|
+
if (opts.default) attrs += " w:default=\"1\"";
|
|
9888
|
+
if (opts.customStyle) attrs += " w:customStyle=\"1\"";
|
|
9889
|
+
return `<w:style${attrs}>`;
|
|
9890
|
+
}
|
|
9854
9891
|
/** Build `<w:style>` XML for a paragraph style. */
|
|
9855
9892
|
function stringifyParagraphStyle(opts) {
|
|
9856
9893
|
const children = [stringifyStyleLevelChildren(opts)];
|
|
@@ -9858,14 +9895,14 @@ function stringifyParagraphStyle(opts) {
|
|
|
9858
9895
|
if (pPr) children.push(pPr);
|
|
9859
9896
|
const rPr = stringifyRunProperties(opts.run);
|
|
9860
9897
|
if (rPr) children.push(rPr);
|
|
9861
|
-
return
|
|
9898
|
+
return `${styleOpenTag("paragraph", opts)}${children.join("")}</w:style>`;
|
|
9862
9899
|
}
|
|
9863
9900
|
/** Build `<w:style>` XML for a character style. */
|
|
9864
9901
|
function stringifyCharacterStyle(opts) {
|
|
9865
9902
|
const children = [stringifyStyleLevelChildren(opts)];
|
|
9866
9903
|
const rPr = stringifyRunProperties(opts.run);
|
|
9867
9904
|
if (rPr) children.push(rPr);
|
|
9868
|
-
return
|
|
9905
|
+
return `${styleOpenTag("character", opts)}${children.join("")}</w:style>`;
|
|
9869
9906
|
}
|
|
9870
9907
|
/** Build `<w:tblStylePr>` XML for a conditional table style format. */
|
|
9871
9908
|
function stringifyConditionalTableStyle(opts) {
|
|
@@ -9908,7 +9945,16 @@ function stringifyTableStyle(opts) {
|
|
|
9908
9945
|
if (tcPr) children.push(tcPr);
|
|
9909
9946
|
}
|
|
9910
9947
|
for (const cf of opts.conditionalFormats ?? []) children.push(stringifyConditionalTableStyle(cf));
|
|
9911
|
-
return
|
|
9948
|
+
return `${styleOpenTag("table", opts)}${children.join("")}</w:style>`;
|
|
9949
|
+
}
|
|
9950
|
+
/** Build `<w:style type="numbering">` XML for a numbering style. */
|
|
9951
|
+
function stringifyNumberingStyle(opts) {
|
|
9952
|
+
const children = [stringifyStyleLevelChildren(opts)];
|
|
9953
|
+
const pPr = stringifyParagraphProperties(opts.paragraph).xml;
|
|
9954
|
+
if (pPr) children.push(pPr);
|
|
9955
|
+
const rPr = stringifyRunProperties(opts.run);
|
|
9956
|
+
if (rPr) children.push(rPr);
|
|
9957
|
+
return `${styleOpenTag("numbering", opts)}${children.join("")}</w:style>`;
|
|
9912
9958
|
}
|
|
9913
9959
|
/** Resolve a user override for heading level N (1-9) from default styles options. */
|
|
9914
9960
|
function headingOverride(options, level) {
|
|
@@ -9925,45 +9971,6 @@ function headingOverride(options, level) {
|
|
|
9925
9971
|
default: return;
|
|
9926
9972
|
}
|
|
9927
9973
|
}
|
|
9928
|
-
/**
|
|
9929
|
-
* Maps DefaultStylesOptions override fields to every built-in styleId the
|
|
9930
|
-
* factory (re)emits when that field is provided — the main style plus its
|
|
9931
|
-
* linked character style (e.g. heading1 -> Heading1 + Heading1Char).
|
|
9932
|
-
*/
|
|
9933
|
-
const DEFAULT_STYLE_FIELDS = [
|
|
9934
|
-
["title", ["Title", "TitleChar"]],
|
|
9935
|
-
["subtitle", ["Subtitle", "SubtitleChar"]],
|
|
9936
|
-
["heading1", ["Heading1", "Heading1Char"]],
|
|
9937
|
-
["heading2", ["Heading2", "Heading2Char"]],
|
|
9938
|
-
["heading3", ["Heading3", "Heading3Char"]],
|
|
9939
|
-
["heading4", ["Heading4", "Heading4Char"]],
|
|
9940
|
-
["heading5", ["Heading5", "Heading5Char"]],
|
|
9941
|
-
["heading6", ["Heading6", "Heading6Char"]],
|
|
9942
|
-
["heading7", ["Heading7", "Heading7Char"]],
|
|
9943
|
-
["heading8", ["Heading8", "Heading8Char"]],
|
|
9944
|
-
["heading9", ["Heading9", "Heading9Char"]],
|
|
9945
|
-
["listParagraph", ["ListParagraph"]],
|
|
9946
|
-
["quote", ["Quote", "QuoteChar"]],
|
|
9947
|
-
["strong", ["Strong"]],
|
|
9948
|
-
["emphasis", ["Emphasis"]]
|
|
9949
|
-
];
|
|
9950
|
-
/**
|
|
9951
|
-
* Reverse map: main built-in styleId -> the DefaultStylesOptions field that
|
|
9952
|
-
* overrides it. Linked char ids (Heading1Char, TitleChar, ...) are excluded —
|
|
9953
|
-
* they ride along with their main style.
|
|
9954
|
-
*/
|
|
9955
|
-
const STYLE_ID_TO_DEFAULT_FIELD = Object.fromEntries(DEFAULT_STYLE_FIELDS.map(([field, [mainId]]) => [mainId, field]));
|
|
9956
|
-
/**
|
|
9957
|
-
* Collect every styleId the factory (re)emits for the default-styles fields the
|
|
9958
|
-
* user explicitly provided — including linked character styles, so the
|
|
9959
|
-
* round-trip path drops the matching verbatim entries (no duplicate styleId).
|
|
9960
|
-
*/
|
|
9961
|
-
function collectDefaultOverrideIds(defaultOpts) {
|
|
9962
|
-
const ids = /* @__PURE__ */ new Set();
|
|
9963
|
-
if (!defaultOpts) return ids;
|
|
9964
|
-
for (const [field, styleIds] of DEFAULT_STYLE_FIELDS) if (defaultOpts[field] !== void 0) for (const id of styleIds) ids.add(id);
|
|
9965
|
-
return ids;
|
|
9966
|
-
}
|
|
9967
9974
|
/** Build `<w:docDefaults>` XML matching Word's default settings. */
|
|
9968
9975
|
function stringifyDocDefaults(opts) {
|
|
9969
9976
|
const children = [];
|
|
@@ -9992,6 +9999,10 @@ var DefaultStylesFactory = class {
|
|
|
9992
9999
|
}
|
|
9993
10000
|
build(options) {
|
|
9994
10001
|
const importedStyles = [];
|
|
10002
|
+
const paragraphStyles = [];
|
|
10003
|
+
const characterStyles = [];
|
|
10004
|
+
const tableStyles = [];
|
|
10005
|
+
const numberingStyles = [];
|
|
9995
10006
|
const initialAttributes = {
|
|
9996
10007
|
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
9997
10008
|
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
@@ -10002,70 +10013,76 @@ var DefaultStylesFactory = class {
|
|
|
10002
10013
|
};
|
|
10003
10014
|
importedStyles.push({ _raw: stringifyDocDefaults(options.document ?? {}) });
|
|
10004
10015
|
importedStyles.push({ _raw: "<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>" });
|
|
10005
|
-
|
|
10016
|
+
paragraphStyles.push({
|
|
10017
|
+
id: "Normal",
|
|
10018
|
+
name: "Normal",
|
|
10019
|
+
default: true,
|
|
10020
|
+
quickFormat: true,
|
|
10021
|
+
paragraph: { widowControl: false }
|
|
10022
|
+
});
|
|
10006
10023
|
const headings = [
|
|
10007
10024
|
{
|
|
10008
10025
|
id: "Heading1",
|
|
10009
10026
|
name: "heading 1",
|
|
10010
10027
|
link: "Heading1Char",
|
|
10011
|
-
sz:
|
|
10012
|
-
before:
|
|
10013
|
-
after:
|
|
10014
|
-
outlineLvl:
|
|
10028
|
+
sz: 48,
|
|
10029
|
+
before: 480,
|
|
10030
|
+
after: 80,
|
|
10031
|
+
outlineLvl: 0
|
|
10015
10032
|
},
|
|
10016
10033
|
{
|
|
10017
10034
|
id: "Heading2",
|
|
10018
10035
|
name: "heading 2",
|
|
10019
10036
|
link: "Heading2Char",
|
|
10020
|
-
sz:
|
|
10021
|
-
before:
|
|
10022
|
-
after:
|
|
10023
|
-
outlineLvl:
|
|
10037
|
+
sz: 40,
|
|
10038
|
+
before: 160,
|
|
10039
|
+
after: 80,
|
|
10040
|
+
outlineLvl: 1
|
|
10024
10041
|
},
|
|
10025
10042
|
{
|
|
10026
10043
|
id: "Heading3",
|
|
10027
10044
|
name: "heading 3",
|
|
10028
10045
|
link: "Heading3Char",
|
|
10029
|
-
sz:
|
|
10030
|
-
before:
|
|
10031
|
-
after:
|
|
10032
|
-
outlineLvl:
|
|
10046
|
+
sz: 32,
|
|
10047
|
+
before: 160,
|
|
10048
|
+
after: 80,
|
|
10049
|
+
outlineLvl: 2
|
|
10033
10050
|
},
|
|
10034
10051
|
{
|
|
10035
10052
|
id: "Heading4",
|
|
10036
10053
|
name: "heading 4",
|
|
10037
10054
|
link: "Heading4Char",
|
|
10038
|
-
sz:
|
|
10039
|
-
before:
|
|
10040
|
-
after:
|
|
10041
|
-
outlineLvl:
|
|
10055
|
+
sz: 28,
|
|
10056
|
+
before: 80,
|
|
10057
|
+
after: 40,
|
|
10058
|
+
outlineLvl: 3
|
|
10042
10059
|
},
|
|
10043
10060
|
{
|
|
10044
10061
|
id: "Heading5",
|
|
10045
10062
|
name: "heading 5",
|
|
10046
10063
|
link: "Heading5Char",
|
|
10047
|
-
sz:
|
|
10048
|
-
before:
|
|
10049
|
-
after:
|
|
10050
|
-
outlineLvl:
|
|
10064
|
+
sz: 24,
|
|
10065
|
+
before: 80,
|
|
10066
|
+
after: 40,
|
|
10067
|
+
outlineLvl: 4
|
|
10051
10068
|
},
|
|
10052
10069
|
{
|
|
10053
10070
|
id: "Heading6",
|
|
10054
10071
|
name: "heading 6",
|
|
10055
10072
|
link: "Heading6Char",
|
|
10056
10073
|
sz: void 0,
|
|
10057
|
-
before:
|
|
10058
|
-
after:
|
|
10059
|
-
outlineLvl:
|
|
10074
|
+
before: 40,
|
|
10075
|
+
after: 0,
|
|
10076
|
+
outlineLvl: 5
|
|
10060
10077
|
},
|
|
10061
10078
|
{
|
|
10062
10079
|
id: "Heading7",
|
|
10063
10080
|
name: "heading 7",
|
|
10064
10081
|
link: "Heading7Char",
|
|
10065
10082
|
sz: void 0,
|
|
10066
|
-
before:
|
|
10067
|
-
after:
|
|
10068
|
-
outlineLvl:
|
|
10083
|
+
before: 40,
|
|
10084
|
+
after: 0,
|
|
10085
|
+
outlineLvl: 6
|
|
10069
10086
|
},
|
|
10070
10087
|
{
|
|
10071
10088
|
id: "Heading8",
|
|
@@ -10073,8 +10090,8 @@ var DefaultStylesFactory = class {
|
|
|
10073
10090
|
link: "Heading8Char",
|
|
10074
10091
|
sz: void 0,
|
|
10075
10092
|
before: void 0,
|
|
10076
|
-
after:
|
|
10077
|
-
outlineLvl:
|
|
10093
|
+
after: 0,
|
|
10094
|
+
outlineLvl: 7
|
|
10078
10095
|
},
|
|
10079
10096
|
{
|
|
10080
10097
|
id: "Heading9",
|
|
@@ -10082,15 +10099,16 @@ var DefaultStylesFactory = class {
|
|
|
10082
10099
|
link: "Heading9Char",
|
|
10083
10100
|
sz: void 0,
|
|
10084
10101
|
before: void 0,
|
|
10085
|
-
after:
|
|
10086
|
-
outlineLvl:
|
|
10102
|
+
after: 0,
|
|
10103
|
+
outlineLvl: 8
|
|
10087
10104
|
}
|
|
10088
10105
|
];
|
|
10089
10106
|
for (let headingIdx = 0; headingIdx < headings.length; headingIdx++) {
|
|
10090
10107
|
const h = headings[headingIdx];
|
|
10108
|
+
const outlineLvl = h.outlineLvl;
|
|
10091
10109
|
const headingOverrideOpts = headingOverride(options, headingIdx + 1);
|
|
10092
10110
|
if (headingOverrideOpts) {
|
|
10093
|
-
|
|
10111
|
+
paragraphStyles.push({
|
|
10094
10112
|
id: h.id,
|
|
10095
10113
|
name: headingOverrideOpts.name ?? h.name,
|
|
10096
10114
|
basedOn: headingOverrideOpts.basedOn ?? "Normal",
|
|
@@ -10105,42 +10123,124 @@ var DefaultStylesFactory = class {
|
|
|
10105
10123
|
...headingOverrideOpts.paragraph
|
|
10106
10124
|
},
|
|
10107
10125
|
run: headingOverrideOpts.run
|
|
10108
|
-
})
|
|
10109
|
-
|
|
10126
|
+
});
|
|
10127
|
+
characterStyles.push({
|
|
10110
10128
|
id: h.link,
|
|
10111
10129
|
name: `${h.name} Char`,
|
|
10112
10130
|
basedOn: "DefaultParagraphFont",
|
|
10113
10131
|
link: h.id,
|
|
10114
10132
|
run: headingOverrideOpts.run
|
|
10115
|
-
})
|
|
10133
|
+
});
|
|
10116
10134
|
continue;
|
|
10117
10135
|
}
|
|
10118
|
-
const
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10136
|
+
const accentRange = outlineLvl < 6;
|
|
10137
|
+
const runProps = {
|
|
10138
|
+
font: accentRange ? {
|
|
10139
|
+
asciiTheme: "majorHAnsi",
|
|
10140
|
+
eastAsiaTheme: "majorEastAsia",
|
|
10141
|
+
hAnsiTheme: "majorHAnsi",
|
|
10142
|
+
cstheme: "majorBidi"
|
|
10143
|
+
} : { cstheme: "majorBidi" },
|
|
10144
|
+
color: accentRange ? {
|
|
10145
|
+
val: "0F4761",
|
|
10146
|
+
themeColor: "accent1",
|
|
10147
|
+
themeShade: "BF"
|
|
10148
|
+
} : {
|
|
10149
|
+
val: "595959",
|
|
10150
|
+
themeColor: "text1",
|
|
10151
|
+
themeTint: "A6"
|
|
10152
|
+
}
|
|
10153
|
+
};
|
|
10154
|
+
if (h.sz) {
|
|
10155
|
+
const sizePt = h.sz / 2;
|
|
10156
|
+
runProps.size = sizePt;
|
|
10157
|
+
runProps.sizeComplexScript = sizePt;
|
|
10124
10158
|
}
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
rPrParts.push(`<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/>`);
|
|
10129
|
-
rPrParts.push(`<w:color w:val="0F4761" w:themeColor="accent1" w:themeShade="BF"/>`);
|
|
10130
|
-
} else {
|
|
10131
|
-
rPrParts.push(`<w:rFonts w:cstheme="majorBidi"/>`);
|
|
10132
|
-
rPrParts.push(`<w:color w:val="595959" w:themeColor="text1" w:themeTint="A6"/>`);
|
|
10159
|
+
if (outlineLvl >= 5) {
|
|
10160
|
+
runProps.bold = true;
|
|
10161
|
+
runProps.boldComplexScript = true;
|
|
10133
10162
|
}
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10163
|
+
paragraphStyles.push({
|
|
10164
|
+
id: h.id,
|
|
10165
|
+
name: h.name,
|
|
10166
|
+
basedOn: "Normal",
|
|
10167
|
+
next: "Normal",
|
|
10168
|
+
link: h.link,
|
|
10169
|
+
uiPriority: 9,
|
|
10170
|
+
semiHidden: outlineLvl > 0,
|
|
10171
|
+
unhideWhenUsed: outlineLvl > 0,
|
|
10172
|
+
quickFormat: true,
|
|
10173
|
+
paragraph: {
|
|
10174
|
+
keepNext: true,
|
|
10175
|
+
keepLines: true,
|
|
10176
|
+
spacing: {
|
|
10177
|
+
before: h.before,
|
|
10178
|
+
after: h.after
|
|
10179
|
+
},
|
|
10180
|
+
outlineLevel: outlineLvl
|
|
10181
|
+
},
|
|
10182
|
+
run: runProps
|
|
10183
|
+
});
|
|
10184
|
+
characterStyles.push({
|
|
10185
|
+
id: h.link,
|
|
10186
|
+
name: `${h.name} Char`,
|
|
10187
|
+
basedOn: "DefaultParagraphFont",
|
|
10188
|
+
link: h.id,
|
|
10189
|
+
uiPriority: 9,
|
|
10190
|
+
semiHidden: outlineLvl > 0,
|
|
10191
|
+
run: runProps
|
|
10192
|
+
});
|
|
10193
|
+
}
|
|
10194
|
+
characterStyles.push({
|
|
10195
|
+
id: "DefaultParagraphFont",
|
|
10196
|
+
name: "Default Paragraph Font",
|
|
10197
|
+
default: true,
|
|
10198
|
+
uiPriority: 1,
|
|
10199
|
+
semiHidden: true,
|
|
10200
|
+
unhideWhenUsed: true
|
|
10201
|
+
});
|
|
10202
|
+
tableStyles.push({
|
|
10203
|
+
id: "NormalTable",
|
|
10204
|
+
name: "Normal Table",
|
|
10205
|
+
default: true,
|
|
10206
|
+
uiPriority: 99,
|
|
10207
|
+
semiHidden: true,
|
|
10208
|
+
unhideWhenUsed: true,
|
|
10209
|
+
table: {
|
|
10210
|
+
indent: {
|
|
10211
|
+
size: 0,
|
|
10212
|
+
type: WidthType.DXA
|
|
10213
|
+
},
|
|
10214
|
+
cellMargin: {
|
|
10215
|
+
top: {
|
|
10216
|
+
size: 0,
|
|
10217
|
+
type: WidthType.DXA
|
|
10218
|
+
},
|
|
10219
|
+
left: {
|
|
10220
|
+
size: 108,
|
|
10221
|
+
type: WidthType.DXA
|
|
10222
|
+
},
|
|
10223
|
+
bottom: {
|
|
10224
|
+
size: 0,
|
|
10225
|
+
type: WidthType.DXA
|
|
10226
|
+
},
|
|
10227
|
+
right: {
|
|
10228
|
+
size: 108,
|
|
10229
|
+
type: WidthType.DXA
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
}
|
|
10233
|
+
});
|
|
10234
|
+
numberingStyles.push({
|
|
10235
|
+
id: "NoList",
|
|
10236
|
+
name: "No List",
|
|
10237
|
+
default: true,
|
|
10238
|
+
uiPriority: 99,
|
|
10239
|
+
semiHidden: true,
|
|
10240
|
+
unhideWhenUsed: true
|
|
10241
|
+
});
|
|
10142
10242
|
if (options.title) {
|
|
10143
|
-
|
|
10243
|
+
paragraphStyles.push({
|
|
10144
10244
|
id: "Title",
|
|
10145
10245
|
name: options.title.name ?? "Title",
|
|
10146
10246
|
basedOn: options.title.basedOn ?? "Normal",
|
|
@@ -10150,20 +10250,57 @@ var DefaultStylesFactory = class {
|
|
|
10150
10250
|
quickFormat: options.title.quickFormat ?? true,
|
|
10151
10251
|
paragraph: options.title.paragraph,
|
|
10152
10252
|
run: options.title.run
|
|
10153
|
-
})
|
|
10154
|
-
|
|
10253
|
+
});
|
|
10254
|
+
characterStyles.push({
|
|
10155
10255
|
id: "TitleChar",
|
|
10156
10256
|
name: "Title Char",
|
|
10157
10257
|
basedOn: "DefaultParagraphFont",
|
|
10158
10258
|
link: "Title",
|
|
10159
10259
|
run: options.title.run
|
|
10160
|
-
})
|
|
10260
|
+
});
|
|
10161
10261
|
} else {
|
|
10162
|
-
|
|
10163
|
-
|
|
10262
|
+
const titleRun = {
|
|
10263
|
+
font: {
|
|
10264
|
+
asciiTheme: "majorHAnsi",
|
|
10265
|
+
eastAsiaTheme: "majorEastAsia",
|
|
10266
|
+
hAnsiTheme: "majorHAnsi",
|
|
10267
|
+
cstheme: "majorBidi"
|
|
10268
|
+
},
|
|
10269
|
+
characterSpacing: -10,
|
|
10270
|
+
kern: 28,
|
|
10271
|
+
size: 28,
|
|
10272
|
+
sizeComplexScript: 28
|
|
10273
|
+
};
|
|
10274
|
+
paragraphStyles.push({
|
|
10275
|
+
id: "Title",
|
|
10276
|
+
name: "Title",
|
|
10277
|
+
basedOn: "Normal",
|
|
10278
|
+
next: "Normal",
|
|
10279
|
+
link: "TitleChar",
|
|
10280
|
+
uiPriority: 10,
|
|
10281
|
+
quickFormat: true,
|
|
10282
|
+
paragraph: {
|
|
10283
|
+
spacing: {
|
|
10284
|
+
after: 80,
|
|
10285
|
+
line: 240,
|
|
10286
|
+
lineRule: "auto"
|
|
10287
|
+
},
|
|
10288
|
+
contextualSpacing: true,
|
|
10289
|
+
alignment: AlignmentType.CENTER
|
|
10290
|
+
},
|
|
10291
|
+
run: titleRun
|
|
10292
|
+
});
|
|
10293
|
+
characterStyles.push({
|
|
10294
|
+
id: "TitleChar",
|
|
10295
|
+
name: "Title Char",
|
|
10296
|
+
basedOn: "DefaultParagraphFont",
|
|
10297
|
+
link: "Title",
|
|
10298
|
+
uiPriority: 10,
|
|
10299
|
+
run: titleRun
|
|
10300
|
+
});
|
|
10164
10301
|
}
|
|
10165
10302
|
if (options.subtitle) {
|
|
10166
|
-
|
|
10303
|
+
paragraphStyles.push({
|
|
10167
10304
|
id: "Subtitle",
|
|
10168
10305
|
name: options.subtitle.name ?? "Subtitle",
|
|
10169
10306
|
basedOn: options.subtitle.basedOn ?? "Normal",
|
|
@@ -10173,19 +10310,52 @@ var DefaultStylesFactory = class {
|
|
|
10173
10310
|
quickFormat: options.subtitle.quickFormat ?? true,
|
|
10174
10311
|
paragraph: options.subtitle.paragraph,
|
|
10175
10312
|
run: options.subtitle.run
|
|
10176
|
-
})
|
|
10177
|
-
|
|
10313
|
+
});
|
|
10314
|
+
characterStyles.push({
|
|
10178
10315
|
id: "SubtitleChar",
|
|
10179
10316
|
name: "Subtitle Char",
|
|
10180
10317
|
basedOn: "DefaultParagraphFont",
|
|
10181
10318
|
link: "Subtitle",
|
|
10182
10319
|
run: options.subtitle.run
|
|
10183
|
-
})
|
|
10320
|
+
});
|
|
10184
10321
|
} else {
|
|
10185
|
-
|
|
10186
|
-
|
|
10322
|
+
const subtitleRun = {
|
|
10323
|
+
font: {
|
|
10324
|
+
asciiTheme: "majorHAnsi",
|
|
10325
|
+
eastAsiaTheme: "majorEastAsia",
|
|
10326
|
+
hAnsiTheme: "majorHAnsi",
|
|
10327
|
+
cstheme: "majorBidi"
|
|
10328
|
+
},
|
|
10329
|
+
color: {
|
|
10330
|
+
val: "595959",
|
|
10331
|
+
themeColor: "text1",
|
|
10332
|
+
themeTint: "A6"
|
|
10333
|
+
},
|
|
10334
|
+
characterSpacing: 15,
|
|
10335
|
+
size: 14,
|
|
10336
|
+
sizeComplexScript: 14
|
|
10337
|
+
};
|
|
10338
|
+
paragraphStyles.push({
|
|
10339
|
+
id: "Subtitle",
|
|
10340
|
+
name: "Subtitle",
|
|
10341
|
+
basedOn: "Normal",
|
|
10342
|
+
next: "Normal",
|
|
10343
|
+
link: "SubtitleChar",
|
|
10344
|
+
uiPriority: 11,
|
|
10345
|
+
quickFormat: true,
|
|
10346
|
+
paragraph: { alignment: AlignmentType.CENTER },
|
|
10347
|
+
run: subtitleRun
|
|
10348
|
+
});
|
|
10349
|
+
characterStyles.push({
|
|
10350
|
+
id: "SubtitleChar",
|
|
10351
|
+
name: "Subtitle Char",
|
|
10352
|
+
basedOn: "DefaultParagraphFont",
|
|
10353
|
+
link: "Subtitle",
|
|
10354
|
+
uiPriority: 11,
|
|
10355
|
+
run: subtitleRun
|
|
10356
|
+
});
|
|
10187
10357
|
}
|
|
10188
|
-
if (options.listParagraph)
|
|
10358
|
+
if (options.listParagraph) paragraphStyles.push({
|
|
10189
10359
|
id: "ListParagraph",
|
|
10190
10360
|
name: options.listParagraph.name ?? "List Paragraph",
|
|
10191
10361
|
basedOn: options.listParagraph.basedOn ?? "Normal",
|
|
@@ -10193,9 +10363,19 @@ var DefaultStylesFactory = class {
|
|
|
10193
10363
|
quickFormat: options.listParagraph.quickFormat ?? true,
|
|
10194
10364
|
paragraph: options.listParagraph.paragraph,
|
|
10195
10365
|
run: options.listParagraph.run
|
|
10196
|
-
})
|
|
10197
|
-
else
|
|
10198
|
-
|
|
10366
|
+
});
|
|
10367
|
+
else paragraphStyles.push({
|
|
10368
|
+
id: "ListParagraph",
|
|
10369
|
+
name: "List Paragraph",
|
|
10370
|
+
basedOn: "Normal",
|
|
10371
|
+
uiPriority: 34,
|
|
10372
|
+
quickFormat: true,
|
|
10373
|
+
paragraph: {
|
|
10374
|
+
indent: { left: 720 },
|
|
10375
|
+
contextualSpacing: true
|
|
10376
|
+
}
|
|
10377
|
+
});
|
|
10378
|
+
if (options.strong) paragraphStyles.push({
|
|
10199
10379
|
id: "Strong",
|
|
10200
10380
|
name: options.strong.name ?? "Strong",
|
|
10201
10381
|
basedOn: options.strong.basedOn ?? "Normal",
|
|
@@ -10203,8 +10383,8 @@ var DefaultStylesFactory = class {
|
|
|
10203
10383
|
quickFormat: options.strong.quickFormat ?? true,
|
|
10204
10384
|
paragraph: options.strong.paragraph,
|
|
10205
10385
|
run: options.strong.run
|
|
10206
|
-
})
|
|
10207
|
-
if (options.emphasis)
|
|
10386
|
+
});
|
|
10387
|
+
if (options.emphasis) paragraphStyles.push({
|
|
10208
10388
|
id: "Emphasis",
|
|
10209
10389
|
name: options.emphasis.name ?? "Emphasis",
|
|
10210
10390
|
basedOn: options.emphasis.basedOn ?? "Normal",
|
|
@@ -10212,9 +10392,18 @@ var DefaultStylesFactory = class {
|
|
|
10212
10392
|
quickFormat: options.emphasis.quickFormat ?? true,
|
|
10213
10393
|
paragraph: options.emphasis.paragraph,
|
|
10214
10394
|
run: options.emphasis.run
|
|
10215
|
-
})
|
|
10395
|
+
});
|
|
10396
|
+
const quoteRun = {
|
|
10397
|
+
italic: true,
|
|
10398
|
+
italicComplexScript: true,
|
|
10399
|
+
color: {
|
|
10400
|
+
val: "404040",
|
|
10401
|
+
themeColor: "text1",
|
|
10402
|
+
themeTint: "BF"
|
|
10403
|
+
}
|
|
10404
|
+
};
|
|
10216
10405
|
if (options.quote) {
|
|
10217
|
-
|
|
10406
|
+
paragraphStyles.push({
|
|
10218
10407
|
id: "Quote",
|
|
10219
10408
|
name: options.quote.name ?? "Quote",
|
|
10220
10409
|
basedOn: options.quote.basedOn ?? "Normal",
|
|
@@ -10224,21 +10413,89 @@ var DefaultStylesFactory = class {
|
|
|
10224
10413
|
quickFormat: options.quote.quickFormat ?? true,
|
|
10225
10414
|
paragraph: options.quote.paragraph,
|
|
10226
10415
|
run: options.quote.run
|
|
10227
|
-
})
|
|
10228
|
-
|
|
10416
|
+
});
|
|
10417
|
+
characterStyles.push({
|
|
10229
10418
|
id: "QuoteChar",
|
|
10230
10419
|
name: "Quote Char",
|
|
10231
10420
|
basedOn: "DefaultParagraphFont",
|
|
10232
10421
|
link: "Quote",
|
|
10233
10422
|
run: options.quote.run
|
|
10234
|
-
})
|
|
10423
|
+
});
|
|
10235
10424
|
} else {
|
|
10236
|
-
|
|
10237
|
-
|
|
10425
|
+
paragraphStyles.push({
|
|
10426
|
+
id: "Quote",
|
|
10427
|
+
name: "Quote",
|
|
10428
|
+
basedOn: "Normal",
|
|
10429
|
+
next: "Normal",
|
|
10430
|
+
link: "QuoteChar",
|
|
10431
|
+
uiPriority: 29,
|
|
10432
|
+
quickFormat: true,
|
|
10433
|
+
paragraph: {
|
|
10434
|
+
spacing: { before: 160 },
|
|
10435
|
+
alignment: AlignmentType.CENTER
|
|
10436
|
+
},
|
|
10437
|
+
run: quoteRun
|
|
10438
|
+
});
|
|
10439
|
+
characterStyles.push({
|
|
10440
|
+
id: "QuoteChar",
|
|
10441
|
+
name: "Quote Char",
|
|
10442
|
+
basedOn: "DefaultParagraphFont",
|
|
10443
|
+
link: "Quote",
|
|
10444
|
+
uiPriority: 29,
|
|
10445
|
+
run: quoteRun
|
|
10446
|
+
});
|
|
10238
10447
|
}
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10448
|
+
const intenseQuoteRun = {
|
|
10449
|
+
italic: true,
|
|
10450
|
+
italicComplexScript: true,
|
|
10451
|
+
color: {
|
|
10452
|
+
val: "0F4761",
|
|
10453
|
+
themeColor: "accent1",
|
|
10454
|
+
themeShade: "BF"
|
|
10455
|
+
}
|
|
10456
|
+
};
|
|
10457
|
+
const intenseQuoteBorder = {
|
|
10458
|
+
style: BorderStyle.SINGLE,
|
|
10459
|
+
size: 4,
|
|
10460
|
+
space: 10,
|
|
10461
|
+
color: "0F4761",
|
|
10462
|
+
themeColor: "accent1",
|
|
10463
|
+
themeShade: "BF"
|
|
10464
|
+
};
|
|
10465
|
+
paragraphStyles.push({
|
|
10466
|
+
id: "IntenseQuote",
|
|
10467
|
+
name: "Intense Quote",
|
|
10468
|
+
basedOn: "Normal",
|
|
10469
|
+
next: "Normal",
|
|
10470
|
+
link: "IntenseQuoteChar",
|
|
10471
|
+
uiPriority: 30,
|
|
10472
|
+
quickFormat: true,
|
|
10473
|
+
paragraph: {
|
|
10474
|
+
border: {
|
|
10475
|
+
top: intenseQuoteBorder,
|
|
10476
|
+
bottom: intenseQuoteBorder
|
|
10477
|
+
},
|
|
10478
|
+
spacing: {
|
|
10479
|
+
before: 360,
|
|
10480
|
+
after: 360
|
|
10481
|
+
},
|
|
10482
|
+
indent: {
|
|
10483
|
+
left: 864,
|
|
10484
|
+
right: 864
|
|
10485
|
+
},
|
|
10486
|
+
alignment: AlignmentType.CENTER
|
|
10487
|
+
},
|
|
10488
|
+
run: intenseQuoteRun
|
|
10489
|
+
});
|
|
10490
|
+
characterStyles.push({
|
|
10491
|
+
id: "IntenseQuoteChar",
|
|
10492
|
+
name: "Intense Quote Char",
|
|
10493
|
+
basedOn: "DefaultParagraphFont",
|
|
10494
|
+
link: "IntenseQuote",
|
|
10495
|
+
uiPriority: 30,
|
|
10496
|
+
run: intenseQuoteRun
|
|
10497
|
+
});
|
|
10498
|
+
characterStyles.push({
|
|
10242
10499
|
id: "Hyperlink",
|
|
10243
10500
|
name: "Hyperlink",
|
|
10244
10501
|
basedOn: "DefaultParagraphFont",
|
|
@@ -10249,8 +10506,8 @@ var DefaultStylesFactory = class {
|
|
|
10249
10506
|
underline: { type: "single" }
|
|
10250
10507
|
},
|
|
10251
10508
|
...options.hyperlink
|
|
10252
|
-
})
|
|
10253
|
-
|
|
10509
|
+
});
|
|
10510
|
+
characterStyles.push({
|
|
10254
10511
|
id: "FootnoteReference",
|
|
10255
10512
|
name: "footnote reference",
|
|
10256
10513
|
basedOn: "DefaultParagraphFont",
|
|
@@ -10258,8 +10515,8 @@ var DefaultStylesFactory = class {
|
|
|
10258
10515
|
unhideWhenUsed: true,
|
|
10259
10516
|
run: { superScript: true },
|
|
10260
10517
|
...options.footnoteReference
|
|
10261
|
-
})
|
|
10262
|
-
|
|
10518
|
+
});
|
|
10519
|
+
paragraphStyles.push({
|
|
10263
10520
|
id: "FootnoteText",
|
|
10264
10521
|
name: "footnote text",
|
|
10265
10522
|
basedOn: "Normal",
|
|
@@ -10274,8 +10531,8 @@ var DefaultStylesFactory = class {
|
|
|
10274
10531
|
} },
|
|
10275
10532
|
run: { size: 20 },
|
|
10276
10533
|
...options.footnoteText
|
|
10277
|
-
})
|
|
10278
|
-
|
|
10534
|
+
});
|
|
10535
|
+
characterStyles.push({
|
|
10279
10536
|
id: "FootnoteTextChar",
|
|
10280
10537
|
name: "Footnote Text Char",
|
|
10281
10538
|
basedOn: "DefaultParagraphFont",
|
|
@@ -10283,8 +10540,8 @@ var DefaultStylesFactory = class {
|
|
|
10283
10540
|
semiHidden: true,
|
|
10284
10541
|
run: { size: 20 },
|
|
10285
10542
|
...options.footnoteTextChar
|
|
10286
|
-
})
|
|
10287
|
-
|
|
10543
|
+
});
|
|
10544
|
+
characterStyles.push({
|
|
10288
10545
|
id: "EndnoteReference",
|
|
10289
10546
|
name: "endnote reference",
|
|
10290
10547
|
basedOn: "DefaultParagraphFont",
|
|
@@ -10292,8 +10549,8 @@ var DefaultStylesFactory = class {
|
|
|
10292
10549
|
unhideWhenUsed: true,
|
|
10293
10550
|
run: { superScript: true },
|
|
10294
10551
|
...options.endnoteReference
|
|
10295
|
-
})
|
|
10296
|
-
|
|
10552
|
+
});
|
|
10553
|
+
paragraphStyles.push({
|
|
10297
10554
|
id: "EndnoteText",
|
|
10298
10555
|
name: "endnote text",
|
|
10299
10556
|
basedOn: "Normal",
|
|
@@ -10308,8 +10565,8 @@ var DefaultStylesFactory = class {
|
|
|
10308
10565
|
} },
|
|
10309
10566
|
run: { size: 20 },
|
|
10310
10567
|
...options.endnoteText
|
|
10311
|
-
})
|
|
10312
|
-
|
|
10568
|
+
});
|
|
10569
|
+
characterStyles.push({
|
|
10313
10570
|
id: "EndnoteTextChar",
|
|
10314
10571
|
name: "Endnote Text Char",
|
|
10315
10572
|
basedOn: "DefaultParagraphFont",
|
|
@@ -10317,10 +10574,31 @@ var DefaultStylesFactory = class {
|
|
|
10317
10574
|
semiHidden: true,
|
|
10318
10575
|
run: { size: 20 },
|
|
10319
10576
|
...options.endnoteTextChar
|
|
10320
|
-
})
|
|
10321
|
-
|
|
10577
|
+
});
|
|
10578
|
+
characterStyles.push({
|
|
10579
|
+
id: "IntenseReference",
|
|
10580
|
+
name: "Intense Reference",
|
|
10581
|
+
basedOn: "DefaultParagraphFont",
|
|
10582
|
+
uiPriority: 32,
|
|
10583
|
+
quickFormat: true,
|
|
10584
|
+
run: {
|
|
10585
|
+
bold: true,
|
|
10586
|
+
boldComplexScript: true,
|
|
10587
|
+
smallCaps: true,
|
|
10588
|
+
color: {
|
|
10589
|
+
val: "0F4761",
|
|
10590
|
+
themeColor: "accent1",
|
|
10591
|
+
themeShade: "BF"
|
|
10592
|
+
},
|
|
10593
|
+
characterSpacing: 5
|
|
10594
|
+
}
|
|
10595
|
+
});
|
|
10322
10596
|
return {
|
|
10323
10597
|
importedStyles,
|
|
10598
|
+
paragraphStyles,
|
|
10599
|
+
characterStyles,
|
|
10600
|
+
tableStyles,
|
|
10601
|
+
numberingStyles,
|
|
10324
10602
|
initialAttributes
|
|
10325
10603
|
};
|
|
10326
10604
|
}
|
|
@@ -10370,42 +10648,10 @@ var Styles = class {
|
|
|
10370
10648
|
}
|
|
10371
10649
|
this.parts.push(style._raw);
|
|
10372
10650
|
}
|
|
10373
|
-
if (options.paragraphStyles) for (const style of options.paragraphStyles) this.parts.push(stringifyParagraphStyle(
|
|
10374
|
-
|
|
10375
|
-
name: style.name ?? style.id,
|
|
10376
|
-
aliases: style.aliases,
|
|
10377
|
-
basedOn: style.basedOn,
|
|
10378
|
-
next: style.next,
|
|
10379
|
-
link: style.link,
|
|
10380
|
-
autoRedefine: style.autoRedefine,
|
|
10381
|
-
quickFormat: style.quickFormat,
|
|
10382
|
-
semiHidden: style.semiHidden,
|
|
10383
|
-
uiPriority: style.uiPriority,
|
|
10384
|
-
unhideWhenUsed: style.unhideWhenUsed,
|
|
10385
|
-
locked: style.locked,
|
|
10386
|
-
personal: style.personal,
|
|
10387
|
-
personalCompose: style.personalCompose,
|
|
10388
|
-
personalReply: style.personalReply,
|
|
10389
|
-
paragraph: style.paragraph,
|
|
10390
|
-
run: style.run
|
|
10391
|
-
}));
|
|
10392
|
-
if (options.characterStyles) for (const style of options.characterStyles) this.parts.push(stringifyCharacterStyle({
|
|
10393
|
-
id: style.id,
|
|
10394
|
-
name: style.name ?? style.id,
|
|
10395
|
-
aliases: style.aliases,
|
|
10396
|
-
basedOn: style.basedOn,
|
|
10397
|
-
link: style.link,
|
|
10398
|
-
autoRedefine: style.autoRedefine,
|
|
10399
|
-
semiHidden: style.semiHidden,
|
|
10400
|
-
uiPriority: style.uiPriority,
|
|
10401
|
-
unhideWhenUsed: style.unhideWhenUsed,
|
|
10402
|
-
locked: style.locked,
|
|
10403
|
-
personal: style.personal,
|
|
10404
|
-
personalCompose: style.personalCompose,
|
|
10405
|
-
personalReply: style.personalReply,
|
|
10406
|
-
run: style.run
|
|
10407
|
-
}));
|
|
10651
|
+
if (options.paragraphStyles) for (const style of options.paragraphStyles) this.parts.push(stringifyParagraphStyle(style));
|
|
10652
|
+
if (options.characterStyles) for (const style of options.characterStyles) this.parts.push(stringifyCharacterStyle(style));
|
|
10408
10653
|
if (options.tableStyles) for (const style of options.tableStyles) this.parts.push(stringifyTableStyle(style));
|
|
10654
|
+
if (options.numberingStyles) for (const style of options.numberingStyles) this.parts.push(stringifyNumberingStyle(style));
|
|
10409
10655
|
}
|
|
10410
10656
|
/**
|
|
10411
10657
|
* Serialize to word/styles.xml content (with XML declaration).
|
|
@@ -10416,25 +10662,6 @@ var Styles = class {
|
|
|
10416
10662
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles${attrParts.join("")}>${this.parts.join("")}</w:styles>`;
|
|
10417
10663
|
}
|
|
10418
10664
|
};
|
|
10419
|
-
/** Style IDs generated by DefaultStylesFactory — skip these during parsing. */
|
|
10420
|
-
const BUILTIN_STYLE_IDS = new Set([
|
|
10421
|
-
"Title",
|
|
10422
|
-
"Heading1",
|
|
10423
|
-
"Heading2",
|
|
10424
|
-
"Heading3",
|
|
10425
|
-
"Heading4",
|
|
10426
|
-
"Heading5",
|
|
10427
|
-
"Heading6",
|
|
10428
|
-
"Strong",
|
|
10429
|
-
"ListParagraph",
|
|
10430
|
-
"Hyperlink",
|
|
10431
|
-
"FootnoteText",
|
|
10432
|
-
"FootnoteTextChar",
|
|
10433
|
-
"EndnoteText",
|
|
10434
|
-
"EndnoteTextChar",
|
|
10435
|
-
"FootnoteReference",
|
|
10436
|
-
"EndnoteReference"
|
|
10437
|
-
]);
|
|
10438
10665
|
/**
|
|
10439
10666
|
* Build a cache of style elements keyed by styleId.
|
|
10440
10667
|
*/
|
|
@@ -10472,6 +10699,7 @@ function parseStyleDefinitions(el, parseParagraphProperties, ctx) {
|
|
|
10472
10699
|
const paragraphStyles = [];
|
|
10473
10700
|
const characterStyles = [];
|
|
10474
10701
|
const tableStyles = [];
|
|
10702
|
+
const numberingStyles = [];
|
|
10475
10703
|
for (const child of el.elements ?? []) if (child.name === "w:docDefaults") {
|
|
10476
10704
|
const defOpts = parseDocDefaults(child, parseParagraphProperties, ctx);
|
|
10477
10705
|
if (defOpts) opts.default = defOpts;
|
|
@@ -10480,28 +10708,18 @@ function parseStyleDefinitions(el, parseParagraphProperties, ctx) {
|
|
|
10480
10708
|
else if (child.name === "w:style") {
|
|
10481
10709
|
const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);
|
|
10482
10710
|
if (!styleOpts?._type || !styleOpts.id) continue;
|
|
10483
|
-
if (styleOpts._type === "table") {
|
|
10484
|
-
delete styleOpts._type;
|
|
10485
|
-
tableStyles.push(styleOpts);
|
|
10486
|
-
continue;
|
|
10487
|
-
}
|
|
10488
|
-
(opts.importedStyles ??= []).push({ _raw: stringifyElement(child) });
|
|
10489
|
-
const defaultField = STYLE_ID_TO_DEFAULT_FIELD[styleOpts.id];
|
|
10490
|
-
if (defaultField) {
|
|
10491
|
-
const { _type: _omitType, id: _omitId, ...rest } = styleOpts;
|
|
10492
|
-
opts.default ??= {};
|
|
10493
|
-
opts.default[defaultField] = rest;
|
|
10494
|
-
continue;
|
|
10495
|
-
}
|
|
10496
|
-
if (BUILTIN_STYLE_IDS.has(styleOpts.id)) continue;
|
|
10497
10711
|
const type = styleOpts._type;
|
|
10498
10712
|
delete styleOpts._type;
|
|
10499
|
-
if (type === "
|
|
10713
|
+
if (type === "table") tableStyles.push(styleOpts);
|
|
10714
|
+
else if (type === "numbering") numberingStyles.push(styleOpts);
|
|
10715
|
+
else if (type === "paragraph") paragraphStyles.push(styleOpts);
|
|
10500
10716
|
else if (type === "character") characterStyles.push(styleOpts);
|
|
10501
10717
|
}
|
|
10502
10718
|
if (paragraphStyles.length > 0) opts.paragraphStyles = paragraphStyles;
|
|
10503
10719
|
if (characterStyles.length > 0) opts.characterStyles = characterStyles;
|
|
10504
10720
|
if (tableStyles.length > 0) opts.tableStyles = tableStyles;
|
|
10721
|
+
if (numberingStyles.length > 0) opts.numberingStyles = numberingStyles;
|
|
10722
|
+
opts.roundTripped = true;
|
|
10505
10723
|
return Object.keys(opts).length > 0 ? opts : void 0;
|
|
10506
10724
|
}
|
|
10507
10725
|
function parseDocDefaults(el, parseParagraphProperties, ctx) {
|
|
@@ -10531,7 +10749,7 @@ function parseStyleElement(el, parseParagraphProperties, ctx) {
|
|
|
10531
10749
|
const id = attr(el, "w:styleId");
|
|
10532
10750
|
if (id) opts.id = id;
|
|
10533
10751
|
if (attrBool(el, "w:default")) opts.default = true;
|
|
10534
|
-
if (attrBool(el, "w:customStyle")) opts.customStyle =
|
|
10752
|
+
if (attrBool(el, "w:customStyle")) opts.customStyle = true;
|
|
10535
10753
|
const nameEl = findChild(el, "w:name");
|
|
10536
10754
|
if (nameEl) {
|
|
10537
10755
|
const name = attr(nameEl, "w:val");
|
|
@@ -10648,9 +10866,6 @@ function parseStyleElement(el, parseParagraphProperties, ctx) {
|
|
|
10648
10866
|
*
|
|
10649
10867
|
* @module
|
|
10650
10868
|
*/
|
|
10651
|
-
function escapeAttr$1(s) {
|
|
10652
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
10653
|
-
}
|
|
10654
10869
|
/** Derive the namespace-prefixed val attribute from the element tag. */
|
|
10655
10870
|
function valAttr(tag) {
|
|
10656
10871
|
return `${tag.split(":")[0]}:val`;
|
|
@@ -10662,12 +10877,12 @@ function numVal(tag, val) {
|
|
|
10662
10877
|
return val !== void 0 ? `<${tag} ${valAttr(tag)}="${val}"/>` : "";
|
|
10663
10878
|
}
|
|
10664
10879
|
function strVal(tag, val) {
|
|
10665
|
-
return val !== void 0 ? `<${tag} ${valAttr(tag)}="${
|
|
10880
|
+
return val !== void 0 ? `<${tag} ${valAttr(tag)}="${escapeXml(val)}"/>` : "";
|
|
10666
10881
|
}
|
|
10667
10882
|
/** Build attribute string from key-value pairs, skipping undefined. */
|
|
10668
10883
|
function attrStr(attrs) {
|
|
10669
10884
|
const parts = [];
|
|
10670
|
-
for (const [k, v] of Object.entries(attrs)) if (v !== void 0) parts.push(`${k}="${
|
|
10885
|
+
for (const [k, v] of Object.entries(attrs)) if (v !== void 0) parts.push(`${k}="${escapeXml(String(v))}"`);
|
|
10671
10886
|
return parts.join(" ");
|
|
10672
10887
|
}
|
|
10673
10888
|
/** Self-closing element with attributes only. */
|
|
@@ -10677,7 +10892,7 @@ function attrEl(tag, attrs) {
|
|
|
10677
10892
|
}
|
|
10678
10893
|
function compatSetting(name, val, uri) {
|
|
10679
10894
|
const u = uri ?? "http://schemas.microsoft.com/office/word";
|
|
10680
|
-
return `<w:compatSetting w:name="${
|
|
10895
|
+
return `<w:compatSetting w:name="${escapeXml(name)}" w:uri="${u}" w:val="${val}"/>`;
|
|
10681
10896
|
}
|
|
10682
10897
|
/** Read a CT_OnOff child as boolean (presence true unless val is explicitly false). */
|
|
10683
10898
|
function readOnOff(el) {
|
|
@@ -12447,9 +12662,6 @@ const fontTableDesc = {
|
|
|
12447
12662
|
};
|
|
12448
12663
|
//#endregion
|
|
12449
12664
|
//#region src/parts/bibliography.ts
|
|
12450
|
-
function escapeXml$1(s) {
|
|
12451
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
12452
|
-
}
|
|
12453
12665
|
const SOURCE_FIELDS = [
|
|
12454
12666
|
["SourceType", "type"],
|
|
12455
12667
|
["Title", "title"],
|
|
@@ -12472,13 +12684,13 @@ const bibliographyDesc = {
|
|
|
12472
12684
|
kind: "custom",
|
|
12473
12685
|
stringify(opts, _ctx) {
|
|
12474
12686
|
const attrParts = ["xmlns:b=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\""];
|
|
12475
|
-
if (opts.styleName !== void 0) attrParts.push(`StyleName="${escapeXml
|
|
12687
|
+
if (opts.styleName !== void 0) attrParts.push(`StyleName="${escapeXml(opts.styleName)}"`);
|
|
12476
12688
|
const parts = [`<b:Sources ${attrParts.join(" ")}>`];
|
|
12477
12689
|
for (const source of opts.sources) {
|
|
12478
12690
|
const sourceParts = [];
|
|
12479
12691
|
for (const [tagName, key] of SOURCE_FIELDS) {
|
|
12480
12692
|
const value = source[key];
|
|
12481
|
-
if (value !== void 0) sourceParts.push(`<b:${tagName}>${escapeXml
|
|
12693
|
+
if (value !== void 0) sourceParts.push(`<b:${tagName}>${escapeXml(value)}</b:${tagName}>`);
|
|
12482
12694
|
}
|
|
12483
12695
|
parts.push(`<b:Source>${sourceParts.join("")}</b:Source>`);
|
|
12484
12696
|
}
|
|
@@ -12565,15 +12777,12 @@ const DocPartBehavior = {
|
|
|
12565
12777
|
PAGE: "pg"
|
|
12566
12778
|
};
|
|
12567
12779
|
const GLOSSARY_NS = "xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" 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:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"";
|
|
12568
|
-
function glossaryEscapeAttr(text) {
|
|
12569
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
12570
|
-
}
|
|
12571
12780
|
function docPartPrXml(part) {
|
|
12572
12781
|
const prParts = [];
|
|
12573
|
-
prParts.push(`<w:name w:val="${
|
|
12782
|
+
prParts.push(`<w:name w:val="${escapeXml(part.name)}"${part.decorated ? " w:decorated=\"1\"" : ""}/>`);
|
|
12574
12783
|
if (part.category || part.gallery) {
|
|
12575
12784
|
const catParts = [];
|
|
12576
|
-
if (part.category) catParts.push(`<w:name w:val="${
|
|
12785
|
+
if (part.category) catParts.push(`<w:name w:val="${escapeXml(part.category)}"/>`);
|
|
12577
12786
|
catParts.push(`<w:gallery w:val="${part.gallery}"/>`);
|
|
12578
12787
|
prParts.push(`<w:category>${catParts.join("")}</w:category>`);
|
|
12579
12788
|
}
|
|
@@ -12586,8 +12795,8 @@ function docPartPrXml(part) {
|
|
|
12586
12795
|
const behaviorXml = part.behaviors.map((b) => `<w:behavior w:val="${b}"/>`).join("");
|
|
12587
12796
|
prParts.push(`<w:behaviors>${behaviorXml}</w:behaviors>`);
|
|
12588
12797
|
}
|
|
12589
|
-
if (part.description) prParts.push(`<w:description w:val="${
|
|
12590
|
-
if (part.guid) prParts.push(`<w:guid w:val="${
|
|
12798
|
+
if (part.description) prParts.push(`<w:description w:val="${escapeXml(part.description)}"/>`);
|
|
12799
|
+
if (part.guid) prParts.push(`<w:guid w:val="${escapeXml(part.guid)}"/>`);
|
|
12591
12800
|
return `<w:docPartPr>${prParts.join("")}</w:docPartPr>`;
|
|
12592
12801
|
}
|
|
12593
12802
|
const glossaryDesc = {
|
|
@@ -12663,18 +12872,15 @@ const glossaryDesc = {
|
|
|
12663
12872
|
};
|
|
12664
12873
|
//#endregion
|
|
12665
12874
|
//#region src/parts/comments.ts
|
|
12666
|
-
function escapeAttr(s) {
|
|
12667
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
12668
|
-
}
|
|
12669
12875
|
const COMMENTS_NS = "xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" 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:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" 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: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\"";
|
|
12670
12876
|
function stringifyComment(opts, ctx) {
|
|
12671
12877
|
const dateStr = typeof opts.date === "string" ? opts.date : (opts.date ?? /* @__PURE__ */ new Date()).toISOString();
|
|
12672
12878
|
const attrs = [
|
|
12673
12879
|
`w:id="${opts.id}"`,
|
|
12674
|
-
`w:author="${
|
|
12675
|
-
`w:date="${
|
|
12880
|
+
`w:author="${escapeXml(opts.author ?? "")}"`,
|
|
12881
|
+
`w:date="${escapeXml(dateStr)}"`
|
|
12676
12882
|
];
|
|
12677
|
-
if (opts.initials !== void 0) attrs.push(`w:initials="${
|
|
12883
|
+
if (opts.initials !== void 0) attrs.push(`w:initials="${escapeXml(opts.initials)}"`);
|
|
12678
12884
|
const parts = [];
|
|
12679
12885
|
for (const child of opts.children) parts.push(stringifyParagraphInline(child, ctx));
|
|
12680
12886
|
return `<w:comment ${attrs.join(" ")}>${parts.join("")}</w:comment>`;
|
|
@@ -12911,8 +13117,26 @@ function buildContentTypesFromRegistry(facts, dynamic = {}) {
|
|
|
12911
13117
|
partName: sd.path.startsWith("/") ? sd.path : `/${sd.path}`,
|
|
12912
13118
|
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
12913
13119
|
});
|
|
13120
|
+
const defaults = [{
|
|
13121
|
+
extension: "rels",
|
|
13122
|
+
contentType: "application/vnd.openxmlformats-package.relationships+xml"
|
|
13123
|
+
}, {
|
|
13124
|
+
extension: "xml",
|
|
13125
|
+
contentType: "application/xml"
|
|
13126
|
+
}];
|
|
13127
|
+
const haveExt = new Set(["rels", "xml"]);
|
|
13128
|
+
for (const ac of dynamic.altChunks ?? []) {
|
|
13129
|
+
const ext = (ac.path.split(".").pop() ?? "").toLowerCase();
|
|
13130
|
+
if (ext && !haveExt.has(ext) && ALTCHUNK_DEFAULTS[ext]) {
|
|
13131
|
+
defaults.push({
|
|
13132
|
+
extension: ext,
|
|
13133
|
+
contentType: ALTCHUNK_DEFAULTS[ext]
|
|
13134
|
+
});
|
|
13135
|
+
haveExt.add(ext);
|
|
13136
|
+
}
|
|
13137
|
+
}
|
|
12914
13138
|
return {
|
|
12915
|
-
defaults
|
|
13139
|
+
defaults,
|
|
12916
13140
|
overrides
|
|
12917
13141
|
};
|
|
12918
13142
|
}
|
|
@@ -13035,14 +13259,11 @@ function wsOnOff(tag, val) {
|
|
|
13035
13259
|
return `<${tag} w:val="${val ? "true" : "false"}"/>`;
|
|
13036
13260
|
}
|
|
13037
13261
|
function wsStringVal(tag, val) {
|
|
13038
|
-
return `<${tag} w:val="${
|
|
13262
|
+
return `<${tag} w:val="${escapeXml(val)}"/>`;
|
|
13039
13263
|
}
|
|
13040
13264
|
function wsNumVal(tag, val) {
|
|
13041
13265
|
return `<${tag} w:val="${val}"/>`;
|
|
13042
13266
|
}
|
|
13043
|
-
function wsEscapeAttr(s) {
|
|
13044
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13045
|
-
}
|
|
13046
13267
|
function parseFramesetEl(el) {
|
|
13047
13268
|
const opts = {};
|
|
13048
13269
|
const sz = findChild(el, "w:sz");
|
|
@@ -13202,8 +13423,8 @@ function wsDivBorderXml(b) {
|
|
|
13202
13423
|
];
|
|
13203
13424
|
for (const [tag, side] of sides) {
|
|
13204
13425
|
if (!side) continue;
|
|
13205
|
-
const attrParts = [`w:val="${
|
|
13206
|
-
if (side.color) attrParts.push(`w:color="${
|
|
13426
|
+
const attrParts = [`w:val="${escapeXml(side.style)}"`];
|
|
13427
|
+
if (side.color) attrParts.push(`w:color="${escapeXml(side.color)}"`);
|
|
13207
13428
|
if (side.size !== void 0) attrParts.push(`w:sz="${side.size}"`);
|
|
13208
13429
|
parts.push(`<${tag} ${attrParts.join(" ")}/>`);
|
|
13209
13430
|
}
|
|
@@ -13250,13 +13471,13 @@ function frameXml(f) {
|
|
|
13250
13471
|
if (f.size !== void 0) parts.push(wsStringVal("w:sz", f.size));
|
|
13251
13472
|
if (f.name !== void 0) parts.push(wsStringVal("w:name", f.name));
|
|
13252
13473
|
if (f.title !== void 0) parts.push(wsStringVal("w:title", f.title));
|
|
13253
|
-
if (f.sourceRId !== void 0) parts.push(`<w:sourceFileName r:id="${
|
|
13474
|
+
if (f.sourceRId !== void 0) parts.push(`<w:sourceFileName r:id="${escapeXml(f.sourceRId)}"/>`);
|
|
13254
13475
|
if (f.marginWidth !== void 0) parts.push(wsNumVal("w:marW", f.marginWidth));
|
|
13255
13476
|
if (f.marginHeight !== void 0) parts.push(wsNumVal("w:marH", f.marginHeight));
|
|
13256
13477
|
if (f.scrollbar !== void 0) parts.push(`<w:scrollbar w:val="${f.scrollbar}"/>`);
|
|
13257
13478
|
if (f.noResizeAllowed) parts.push("<w:noResizeAllowed/>");
|
|
13258
13479
|
if (f.linkedToFile) parts.push("<w:linkedToFile/>");
|
|
13259
|
-
if (f.longDescRId !== void 0) parts.push(`<w:longDesc r:id="${
|
|
13480
|
+
if (f.longDescRId !== void 0) parts.push(`<w:longDesc r:id="${escapeXml(f.longDescRId)}"/>`);
|
|
13260
13481
|
parts.push("</w:frame>");
|
|
13261
13482
|
return parts.join("");
|
|
13262
13483
|
}
|
|
@@ -13276,7 +13497,7 @@ const webSettingsDesc = {
|
|
|
13276
13497
|
if (typeof ob === "boolean") p.push(wsOnOff("w:optimizeForBrowser", ob));
|
|
13277
13498
|
else {
|
|
13278
13499
|
const valAttr = ob.value === false ? " w:val=\"false\"" : "";
|
|
13279
|
-
const targetAttr = ob.target ? ` w:target="${
|
|
13500
|
+
const targetAttr = ob.target ? ` w:target="${escapeXml(ob.target)}"` : "";
|
|
13280
13501
|
p.push(`<w:optimizeForBrowser${valAttr}${targetAttr}/>`);
|
|
13281
13502
|
}
|
|
13282
13503
|
}
|
|
@@ -13341,6 +13562,6 @@ const webSettingsDesc = {
|
|
|
13341
13562
|
}
|
|
13342
13563
|
};
|
|
13343
13564
|
//#endregion
|
|
13344
|
-
export {
|
|
13565
|
+
export { DocumentGridType as $, stringifySdtPr as $t, settingsDesc as A, parseBodyProperties as An, PageTextDirectionType as At, stringifyParagraphStyle as B, HeadingLevel as Bn, SpaceType as Bt, footnotesDesc as C, UnderlineType as Cn, parseSdtProperties as Ct, SdtDateMappingType as D, TextVerticalType as Dn, stringifySectionPropertiesXml as Dt, parseTocFieldInstruction as E, TextVertOverflowType as En, sectionPropertiesDesc as Et, parseStyleDefinitions as F, TextEffect as Fn, createHorizontalPosition as Ft, SectionType as G, TextWrappingType as Gt, HeaderFooterReferenceType as H, AlignmentType as Hn, createWrapThrough as Ht, DefaultStylesFactory as I, PageNumber as In, HorizontalPositionRelativeFrom as It, createLineNumberType as J, customXmlBlockDesc as Jt, createSectionType as K, altChunkDesc as Kt, stringifyCharacterStyle as L, breakXml as Ln, VerticalPositionRelativeFrom as Lt, buildNumberingCache as M, Media as Mn, PageNumberSeparator as Mt, buildStyleCache as N, createTransformation as Nn, createPageNumberType as Nt, SdtLock as O, VerticalAnchor as On, sectionMarginDefaults as Ot, extractStyleId as P, HighlightColor as Pn, createVerticalPosition as Pt, PageBorderZOrder as Q, stringifyCustomXmlShell as Qt, stringifyConditionalTableStyle as R, TextAlignmentType as Rn, HorizontalPositionAlign as Rt, endnotesDesc as S, EmphasisMarkType as Sn, parseSdtBlock as St, parseTocFieldFromElements as T, TextHorzOverflowType as Tn, parseSectionPropertiesEl as Tt, HeaderFooterType as U, createWrapTight as Ut, stringifyTableStyle as V, LineRuleType as Vn, VerticalPositionAlign as Vt, createHeaderFooterReference as W, TextWrappingSide as Wt, PageBorderDisplay as X, sdtBlockDesc as Xt, createPageMargin as Y, parseCustomXmlProperties as Yt, PageBorderOffsetFrom as Z, setBodyParseChild as Zt, glossaryDesc as _, parseFormFieldData as _n, parseParagraphProperties as _t, appPropertiesDesc as a, TABLE_BORDERS_NONE as an, LevelSuffix as at, CharacterSet as b, PositionalTabLeader as bn, replaceRelsWithPlaceholders as bt, relationshipsDesc as c, OverlapType as cn, parseTableRowPropertiesEl as ct, withAltChunkOverrides as d, TableAnchorType as dn, stringifyChildDispatch as dt, stringifySdtShell as en, createDocumentGrid as et, withMediaDefaults as f, TextDirection as fn, stringifyParagraphInline as ft, DocPartType as g, createFormFieldData as gn, parseParagraph as gt, DocPartGallery as h, FormFieldTextType as hn, resetDrawingIdGen as ht, webSettingsDesc as i, WidthType as in, LevelFormat as it, Styles as j, createImageData$1 as jn, PageOrientation as jt, StyleLevel as k, createBodyProperties as kn, sectionPageSizeDefaults as kt, buildContentTypesFromRegistry as l, RelativeHorizontalPosition as ln, setTableParseChild as lt, DocPartBehavior as m, ProofErrorType as mn, drawingDesc as mt, frameXml as n, stringifyElement as nn, Numbering as nt, customPropertiesDesc as o, BorderStyle as on, parseTableCellPropertiesEl as ot, commentsDesc as p, VerticalMergeType as pn, stringifyRunInline as pt, LineNumberRestartFormat as q, checkboxSymbolRunInner as qt, framesetXml as r, objectDesc as rn, parseNumberingDefinitions as rt, corePropertiesDesc as s, TableLayoutType as sn, parseTablePropertiesEl as st, TargetScreenSize as t, subDocDesc as tn, DocumentAttributeNamespaces as tt, contentTypesDesc as u, RelativeVerticalPosition as un, tableDesc as ut, bibliographyDesc as v, RubyAlign as vn, stringifyBodyChild as vt, parseToc as w, TextBodyWrappingType as wn, FontWrapper as wt, EditGroupType as x, PositionalTabRelativeTo as xn, stringifyTableOfContents as xt, fontTableDesc as y, PositionalTabAlignment as yn, stringifyDocumentXml as yt, stringifyNumberingStyle as z, TextboxTightWrapType as zn, NumberFormat as zt };
|
|
13345
13566
|
|
|
13346
|
-
//# sourceMappingURL=parts-
|
|
13567
|
+
//# sourceMappingURL=parts-DgrmHznM.mjs.map
|