@forevka/wordcanvas 0.7.0 → 0.7.2
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/README.md +48 -1
- package/dist-lib/assets/{worker-BsOsK39A.js → worker-4HYrkNrG.js} +12276 -11981
- package/dist-lib/assets/worker-CJpwUzKh.js +2403 -0
- package/dist-lib/blockFactory-B_CLnkUh.js +106 -0
- package/dist-lib/browser-p_rkUcqE.js +1339 -0
- package/dist-lib/builder.js +365 -109
- package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
- package/dist-lib/export.js +4670 -4567
- package/dist-lib/generate-toc.js +5 -5
- package/dist-lib/import.js +4 -1538
- package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
- package/dist-lib/measure.js +2 -2
- package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-B2aKX7lF.js} +1 -1
- package/dist-lib/metrics-BUMIC9Mv.js +164 -0
- package/dist-lib/pipeline-DD0nxAYM.js +1850 -0
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/recalcToc-CFCGCgij.js +3985 -0
- package/dist-lib/styleProps-DhqDEfvc.js +149 -0
- package/dist-lib/stylesheet-B6oczA-L.js +141 -0
- package/dist-lib/toc-Dj57zdz-.js +213 -0
- package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-CXghUon_.js} +2 -2
- package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-D5DI9ZR1.js} +49 -23
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-GXFDF7UY.js → chunk-57L5XMCL.js} +327 -59
- package/dist-node/chunk-57L5XMCL.js.map +7 -0
- package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
- package/dist-node/chunk-EGSAVPCC.js.map +7 -0
- package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
- package/dist-node/chunk-EMY2P524.js.map +7 -0
- package/dist-node/{chunk-2RCPB7UZ.js → chunk-KJV7GJ3H.js} +1 -1
- package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
- package/dist-node/{chunk-XDUDPPJW.js → chunk-PIMVQULL.js} +93 -24
- package/dist-node/chunk-PIMVQULL.js.map +7 -0
- package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
- package/dist-node/{chunk-IJLL6IFJ.js → chunk-T3253N22.js} +202 -13
- package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-T3253N22.js.map} +2 -2
- package/dist-node/{chunk-4ICCHZX4.js → chunk-U27EBKBG.js} +37 -1
- package/dist-node/chunk-U27EBKBG.js.map +7 -0
- package/dist-node/{engine-FRCX7PXF.js → engine-5F7DUU4W.js} +4 -4
- package/dist-node/export.js +178 -52
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +7 -7
- package/dist-node/import.js +3 -3
- package/dist-node/measure.js +2 -2
- package/dist-node/recalc-docx.js +5 -5
- package/dist-node/recalc-docx.js.map +1 -1
- package/package.json +1 -1
- package/types/model.d.ts +277 -225
- package/types/recalc-docx.d.ts +27 -27
- package/types/wordcanvas.d.ts +212 -157
- package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
- package/dist-lib/blockFactory-Bcy0U40y.js +0 -178
- package/dist-lib/browser-5Sv4CuNy.js +0 -1284
- package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
- package/dist-lib/metrics-CkAo4zh8.js +0 -143
- package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
- package/dist-lib/styleProps-Db5pEkG8.js +0 -127
- package/dist-lib/toc-CZel_Kk3.js +0 -127
- package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
- package/dist-node/chunk-4ICCHZX4.js.map +0 -7
- package/dist-node/chunk-4PDVRJF6.js.map +0 -7
- package/dist-node/chunk-GXFDF7UY.js.map +0 -7
- package/dist-node/chunk-TBSXA2I4.js.map +0 -7
- package/dist-node/chunk-XDUDPPJW.js.map +0 -7
- /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
- /package/dist-node/{engine-FRCX7PXF.js.map → engine-5F7DUU4W.js.map} +0 -0
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
rootEl,
|
|
20
20
|
textOf,
|
|
21
21
|
val
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KJV7GJ3H.js";
|
|
23
23
|
import {
|
|
24
24
|
strFromU8,
|
|
25
25
|
unzipSync
|
|
@@ -28,8 +28,9 @@ import {
|
|
|
28
28
|
isCustomFieldInstruction,
|
|
29
29
|
markImportedTocEntries,
|
|
30
30
|
normalizeRuns,
|
|
31
|
-
parseFieldInstruction
|
|
32
|
-
|
|
31
|
+
parseFieldInstruction,
|
|
32
|
+
parseFieldSpec
|
|
33
|
+
} from "./chunk-PIMVQULL.js";
|
|
33
34
|
|
|
34
35
|
// src/import/docx/units.ts
|
|
35
36
|
var twipsToPx = (tw) => tw / 15;
|
|
@@ -101,6 +102,19 @@ function resolveCellBorders(src, pos) {
|
|
|
101
102
|
if (right) out.right = right;
|
|
102
103
|
return out;
|
|
103
104
|
}
|
|
105
|
+
function cellBordersFromIR(b) {
|
|
106
|
+
if (!b) return void 0;
|
|
107
|
+
const out = {};
|
|
108
|
+
const t = toCellBorder(b.top);
|
|
109
|
+
if (t) out.top = t;
|
|
110
|
+
const r = toCellBorder(b.right);
|
|
111
|
+
if (r) out.right = r;
|
|
112
|
+
const bot = toCellBorder(b.bottom);
|
|
113
|
+
if (bot) out.bottom = bot;
|
|
114
|
+
const l = toCellBorder(b.left);
|
|
115
|
+
if (l) out.left = l;
|
|
116
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
117
|
+
}
|
|
104
118
|
function toCellBorder(raw) {
|
|
105
119
|
if (!raw || raw.val === "nil" || raw.val === "none") return void 0;
|
|
106
120
|
const widthPx = round2(Math.max(0.5, (raw.sizeEighthPt ?? 4) / 6));
|
|
@@ -245,13 +259,51 @@ function decodeParaProps(pPr, warnings) {
|
|
|
245
259
|
if (top !== void 0 && right !== void 0 && bottom !== void 0 && left !== void 0) {
|
|
246
260
|
props.sectionMarginTwips = { top, right, bottom, left };
|
|
247
261
|
}
|
|
262
|
+
const headerDist = numAttr(pgMar, "w:header");
|
|
263
|
+
if (headerDist !== void 0) props.sectionHeaderDistTwips = headerDist;
|
|
264
|
+
const footerDist = numAttr(pgMar, "w:footer");
|
|
265
|
+
if (footerDist !== void 0) props.sectionFooterDistTwips = footerDist;
|
|
248
266
|
}
|
|
249
267
|
const cols = el(sectPr, "w:cols");
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
268
|
+
if (cols) {
|
|
269
|
+
const colEls = els(cols, "w:col");
|
|
270
|
+
const colCount = numAttr(cols, "w:num") ?? (colEls.length > 1 ? colEls.length : 1);
|
|
271
|
+
if (colCount > 1) {
|
|
272
|
+
props.sectionColumns = { count: colCount };
|
|
273
|
+
const space = numAttr(cols, "w:space");
|
|
274
|
+
if (space !== void 0) props.sectionColumns.spaceTwips = space;
|
|
275
|
+
if (attr(cols, "w:sep") === "1" || attr(cols, "w:sep") === "true") props.sectionColumns.sep = true;
|
|
276
|
+
if (colEls.length === colCount) {
|
|
277
|
+
const list = colEls.map((cel) => ({
|
|
278
|
+
wTwips: numAttr(cel, "w:w") ?? 0,
|
|
279
|
+
spaceTwips: numAttr(cel, "w:space") ?? 0
|
|
280
|
+
}));
|
|
281
|
+
if (list.some((c) => c.wTwips > 0)) props.sectionColumns.cols = list;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const pgBorders = el(sectPr, "w:pgBorders");
|
|
286
|
+
if (pgBorders) {
|
|
287
|
+
const offsetFrom = attr(pgBorders, "w:offsetFrom");
|
|
288
|
+
const borders = { offsetFrom: offsetFrom === "text" ? "text" : "page" };
|
|
289
|
+
const edge = (name) => {
|
|
290
|
+
const e = el(pgBorders, "w:" + name);
|
|
291
|
+
if (!e) return;
|
|
292
|
+
const sz = numAttr(e, "w:sz");
|
|
293
|
+
const space = numAttr(e, "w:space");
|
|
294
|
+
const color = attr(e, "w:color");
|
|
295
|
+
borders[name] = {
|
|
296
|
+
style: attr(e, "w:val") ?? "single",
|
|
297
|
+
...sz !== void 0 ? { sz } : {},
|
|
298
|
+
...space !== void 0 ? { space } : {},
|
|
299
|
+
...color !== void 0 ? { color } : {}
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
edge("top");
|
|
303
|
+
edge("right");
|
|
304
|
+
edge("bottom");
|
|
305
|
+
edge("left");
|
|
306
|
+
if (borders.top || borders.right || borders.bottom || borders.left) props.sectionPgBorders = borders;
|
|
255
307
|
}
|
|
256
308
|
const pgNumStart = numAttr(el(sectPr, "w:pgNumType"), "w:start");
|
|
257
309
|
if (pgNumStart !== void 0) props.sectionPageNumberStart = pgNumStart;
|
|
@@ -292,8 +344,13 @@ function parseDocumentXml(xmlText, partName, warnings) {
|
|
|
292
344
|
walkBlocks(children(body), blocks, ctx);
|
|
293
345
|
const sectPr = el(body, "w:sectPr");
|
|
294
346
|
const section = sectPr ? parseSection(sectPr, warnings) : null;
|
|
347
|
+
const bgEl = doc ? el(doc, "w:background") : void 0;
|
|
348
|
+
const bgColor = bgEl ? attr(bgEl, "w:color") : void 0;
|
|
349
|
+
const pageColorHex = bgColor && bgColor !== "auto" ? bgColor : void 0;
|
|
295
350
|
const fields = ctx.fieldTrack.registry;
|
|
296
|
-
|
|
351
|
+
const out = Object.keys(fields).length > 0 ? { blocks, section, sdts, fields } : { blocks, section, sdts };
|
|
352
|
+
if (pageColorHex) out.pageColorHex = pageColorHex;
|
|
353
|
+
return out;
|
|
297
354
|
}
|
|
298
355
|
function parseHeaderFooterXml(xmlText, partName, warnings, sdts = {}) {
|
|
299
356
|
const nodes = parseXml(xmlText, partName);
|
|
@@ -383,8 +440,16 @@ function parseParagraph(p, ctx) {
|
|
|
383
440
|
const para = { kind: "paragraph", props, inlines };
|
|
384
441
|
if (bookmarks.length > 0) para.bookmarks = bookmarks;
|
|
385
442
|
if (markers.length > 0) para.bookmarkMarkers = markers;
|
|
443
|
+
if (field.tocInstr !== void 0) para.tocField = field.tocInstr;
|
|
386
444
|
return para;
|
|
387
445
|
}
|
|
446
|
+
var BUILTIN_INLINE = /* @__PURE__ */ new Set(["PAGE", "NUMPAGES", "DATE", "TIME", "IF"]);
|
|
447
|
+
var FIELD_SPEC_STYLE = { fontFamily: "", fontSizePx: 16, bold: false, italic: false, underline: false, strikethrough: false, color: "#000000" };
|
|
448
|
+
function pageTokenFor(spec) {
|
|
449
|
+
if (spec.type === "NUMPAGES") return "{pages}";
|
|
450
|
+
if (spec.type === "PAGE") return `{page${spec.numFmt && spec.numFmt !== "arabic" ? `:${spec.numFmt}` : ""}}`;
|
|
451
|
+
return "";
|
|
452
|
+
}
|
|
388
453
|
function fieldToken(instr) {
|
|
389
454
|
if (/\bNUMPAGES\b/.test(instr)) return "{pages}";
|
|
390
455
|
if (/\bPAGE\b/.test(instr)) return "{page}";
|
|
@@ -483,7 +548,7 @@ function parseRun(r, out, ctx, field) {
|
|
|
483
548
|
if (field.pagerefAnchor && props.linkAnchor === void 0 && props.linkRelId === void 0) {
|
|
484
549
|
props.linkAnchor = field.pagerefAnchor;
|
|
485
550
|
}
|
|
486
|
-
out.push({ kind: "run", text, props });
|
|
551
|
+
out.push({ kind: "run", text, props, ...field.resultFieldId ? { fieldId: field.resultFieldId } : {} });
|
|
487
552
|
}
|
|
488
553
|
text = "";
|
|
489
554
|
};
|
|
@@ -531,6 +596,8 @@ function parseRun(r, out, ctx, field) {
|
|
|
531
596
|
field.instr += textOf(node);
|
|
532
597
|
const anchor = anchorFromInstr(field.instr);
|
|
533
598
|
if (anchor) field.pagerefAnchor = anchor;
|
|
599
|
+
const t = textOf(node);
|
|
600
|
+
if (field.tocInstr === void 0 && /\bTOC\b/.test(t)) field.tocInstr = t;
|
|
534
601
|
}
|
|
535
602
|
if (ctx.trackFields && ctx.fieldTrack.depth === 1) ctx.fieldTrack.topInstr += textOf(node);
|
|
536
603
|
break;
|
|
@@ -570,6 +637,7 @@ function handleFldChar(node, runProps, out, ctx, field) {
|
|
|
570
637
|
field.instr = "";
|
|
571
638
|
field.suppressResult = false;
|
|
572
639
|
field.pagerefAnchor = void 0;
|
|
640
|
+
field.resultFieldId = void 0;
|
|
573
641
|
}
|
|
574
642
|
if (ctx.trackFields) {
|
|
575
643
|
ft.depth++;
|
|
@@ -582,6 +650,23 @@ function handleFldChar(node, runProps, out, ctx, field) {
|
|
|
582
650
|
case "separate": {
|
|
583
651
|
if (ctx.trackFields && ft.depth === 1) decideCustomField(ctx);
|
|
584
652
|
if (field.depth !== 1) break;
|
|
653
|
+
if (ctx.trackFields) {
|
|
654
|
+
const parsed = parseFieldInstruction(field.instr);
|
|
655
|
+
if (BUILTIN_INLINE.has(parsed.name)) {
|
|
656
|
+
const spec = parseFieldSpec(parsed, FIELD_SPEC_STYLE);
|
|
657
|
+
if (spec) {
|
|
658
|
+
const fid = `field${ft.next.n++}`;
|
|
659
|
+
ft.registry[fid] = { id: fid, instruction: field.instr, name: parsed.name, kind: "builtin", spec };
|
|
660
|
+
if (spec.type === "PAGE" || spec.type === "NUMPAGES") {
|
|
661
|
+
out.push({ kind: "run", text: pageTokenFor(spec), props: runProps, fieldId: fid });
|
|
662
|
+
field.suppressResult = true;
|
|
663
|
+
} else {
|
|
664
|
+
field.resultFieldId = fid;
|
|
665
|
+
}
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
585
670
|
const token = ctx.fieldTokens ? fieldToken(field.instr) : void 0;
|
|
586
671
|
if (token) {
|
|
587
672
|
out.push({ kind: "run", text: token, props: runProps });
|
|
@@ -607,6 +692,7 @@ function handleFldChar(node, runProps, out, ctx, field) {
|
|
|
607
692
|
field.instr = "";
|
|
608
693
|
field.suppressResult = false;
|
|
609
694
|
field.pagerefAnchor = void 0;
|
|
695
|
+
field.resultFieldId = void 0;
|
|
610
696
|
}
|
|
611
697
|
break;
|
|
612
698
|
}
|
|
@@ -629,20 +715,49 @@ function parseDrawing(drawing, ctx) {
|
|
|
629
715
|
if (cy !== void 0) image.heightEmu = cy;
|
|
630
716
|
if (anchor) {
|
|
631
717
|
const square = el(anchor, "wp:wrapSquare") ?? el(anchor, "wp:wrapTight") ?? el(anchor, "wp:wrapThrough");
|
|
718
|
+
const wrapNone = el(anchor, "wp:wrapNone");
|
|
632
719
|
image.anchorWrap = square ? "square" : "block";
|
|
633
|
-
|
|
720
|
+
const posH = el(anchor, "wp:positionH");
|
|
721
|
+
const posV = el(anchor, "wp:positionV");
|
|
722
|
+
const alignText = posH && el(posH, "wp:align");
|
|
723
|
+
const align = alignText && textOf(alignText);
|
|
724
|
+
if (align === "left" || align === "right" || align === "center") image.anchorAlign = align;
|
|
725
|
+
if (wrapNone) {
|
|
726
|
+
const dec = findDeep(anchor, "adec:decorative");
|
|
727
|
+
const z = numAttr(anchor, "relativeHeight");
|
|
728
|
+
image.anchorFloat = {
|
|
729
|
+
behind: attr(anchor, "behindDoc") === "1",
|
|
730
|
+
offsetXEmu: posOffsetEmu(posH),
|
|
731
|
+
offsetYEmu: posOffsetEmu(posV),
|
|
732
|
+
relFromH: relFromH(posH),
|
|
733
|
+
relFromV: relFromV(posV),
|
|
734
|
+
decorative: !!dec && attr(dec, "val") !== "0",
|
|
735
|
+
...z !== void 0 ? { z } : {}
|
|
736
|
+
};
|
|
737
|
+
} else if (!square) {
|
|
634
738
|
ctx.warnings.add(
|
|
635
739
|
"images-anchored",
|
|
636
740
|
"Some floating images (overlapping or top-and-bottom wrap) were placed in the text flow."
|
|
637
741
|
);
|
|
638
742
|
}
|
|
639
|
-
const posH = el(anchor, "wp:positionH");
|
|
640
|
-
const alignText = posH && el(posH, "wp:align");
|
|
641
|
-
const align = alignText && textOf(alignText);
|
|
642
|
-
if (align === "left" || align === "right" || align === "center") image.anchorAlign = align;
|
|
643
743
|
}
|
|
644
744
|
return image;
|
|
645
745
|
}
|
|
746
|
+
function posOffsetEmu(pos) {
|
|
747
|
+
const off = pos && el(pos, "wp:posOffset");
|
|
748
|
+
const n = off ? Number(textOf(off).trim()) : NaN;
|
|
749
|
+
return Number.isFinite(n) ? n : 0;
|
|
750
|
+
}
|
|
751
|
+
var REL_FROM_H = /* @__PURE__ */ new Set(["page", "margin", "column", "leftMargin", "rightMargin", "character"]);
|
|
752
|
+
var REL_FROM_V = /* @__PURE__ */ new Set(["page", "margin", "paragraph", "line", "topMargin", "bottomMargin"]);
|
|
753
|
+
function relFromH(pos) {
|
|
754
|
+
const v = pos && attr(pos, "relativeFrom");
|
|
755
|
+
return v && REL_FROM_H.has(v) ? v : "column";
|
|
756
|
+
}
|
|
757
|
+
function relFromV(pos) {
|
|
758
|
+
const v = pos && attr(pos, "relativeFrom");
|
|
759
|
+
return v && REL_FROM_V.has(v) ? v : "paragraph";
|
|
760
|
+
}
|
|
646
761
|
function parseVmlPict(pict, ctx) {
|
|
647
762
|
const imagedata = findDeep(pict, "v:imagedata");
|
|
648
763
|
const relId = imagedata && attr(imagedata, "r:id");
|
|
@@ -696,6 +811,21 @@ function parseTable(tbl, ctx) {
|
|
|
696
811
|
if (tblPr) {
|
|
697
812
|
const styleId = val(tblPr, "w:tblStyle");
|
|
698
813
|
if (styleId) table.styleId = styleId;
|
|
814
|
+
const look = el(tblPr, "w:tblLook");
|
|
815
|
+
if (look) {
|
|
816
|
+
const on = (a) => {
|
|
817
|
+
const v = attr(look, a);
|
|
818
|
+
return v === "1" || v === "true";
|
|
819
|
+
};
|
|
820
|
+
table.look = {
|
|
821
|
+
firstRow: on("w:firstRow"),
|
|
822
|
+
lastRow: on("w:lastRow"),
|
|
823
|
+
firstCol: on("w:firstColumn"),
|
|
824
|
+
lastCol: on("w:lastColumn"),
|
|
825
|
+
bandRows: !on("w:noHBand"),
|
|
826
|
+
bandCols: !on("w:noVBand")
|
|
827
|
+
};
|
|
828
|
+
}
|
|
699
829
|
if (el(tblPr, "w:tblBorders")) table.bordersSpecified = true;
|
|
700
830
|
const borders = decodeBorders(el(tblPr, "w:tblBorders"));
|
|
701
831
|
if (borders) table.borders = borders;
|
|
@@ -803,13 +933,47 @@ function parseSection(sectPr, warnings) {
|
|
|
803
933
|
if (el(sectPr, "w:titlePg")) section.titlePg = true;
|
|
804
934
|
const cols = el(sectPr, "w:cols");
|
|
805
935
|
if (cols) {
|
|
806
|
-
const
|
|
936
|
+
const colEls = els(cols, "w:col");
|
|
937
|
+
const count = numAttr(cols, "w:num") ?? (colEls.length > 1 ? colEls.length : 1);
|
|
807
938
|
if (count > 1) {
|
|
808
939
|
section.columns = { count };
|
|
809
940
|
const space = numAttr(cols, "w:space");
|
|
810
941
|
if (space !== void 0) section.columns.spaceTwips = space;
|
|
942
|
+
if (attr(cols, "w:sep") === "1" || attr(cols, "w:sep") === "true") section.columns.sep = true;
|
|
943
|
+
if (colEls.length === count) {
|
|
944
|
+
const list = colEls.map((cel) => ({
|
|
945
|
+
wTwips: numAttr(cel, "w:w") ?? 0,
|
|
946
|
+
spaceTwips: numAttr(cel, "w:space") ?? 0
|
|
947
|
+
}));
|
|
948
|
+
if (list.some((c) => c.wTwips > 0)) section.columns.cols = list;
|
|
949
|
+
}
|
|
811
950
|
}
|
|
812
951
|
}
|
|
952
|
+
const pgBorders = el(sectPr, "w:pgBorders");
|
|
953
|
+
if (pgBorders) {
|
|
954
|
+
const offsetFrom = attr(pgBorders, "w:offsetFrom");
|
|
955
|
+
const borders = {
|
|
956
|
+
offsetFrom: offsetFrom === "text" ? "text" : "page"
|
|
957
|
+
};
|
|
958
|
+
const edge = (name) => {
|
|
959
|
+
const e = el(pgBorders, "w:" + name);
|
|
960
|
+
if (!e) return;
|
|
961
|
+
const sz = numAttr(e, "w:sz");
|
|
962
|
+
const space = numAttr(e, "w:space");
|
|
963
|
+
const color = attr(e, "w:color");
|
|
964
|
+
borders[name] = {
|
|
965
|
+
style: attr(e, "w:val") ?? "single",
|
|
966
|
+
...sz !== void 0 ? { sz } : {},
|
|
967
|
+
...space !== void 0 ? { space } : {},
|
|
968
|
+
...color !== void 0 ? { color } : {}
|
|
969
|
+
};
|
|
970
|
+
};
|
|
971
|
+
edge("top");
|
|
972
|
+
edge("right");
|
|
973
|
+
edge("bottom");
|
|
974
|
+
edge("left");
|
|
975
|
+
if (borders.top || borders.right || borders.bottom || borders.left) section.pageBorders = borders;
|
|
976
|
+
}
|
|
813
977
|
const pgNumStart = numAttr(el(sectPr, "w:pgNumType"), "w:start");
|
|
814
978
|
if (pgNumStart !== void 0) section.pageNumberStart = pgNumStart;
|
|
815
979
|
return section;
|
|
@@ -856,6 +1020,42 @@ function parseFootnotesXml(xmlText, partName, warnings, sdts = {}) {
|
|
|
856
1020
|
}
|
|
857
1021
|
|
|
858
1022
|
// src/import/docx/mapToModel.ts
|
|
1023
|
+
var PAGE_BORDER_STYLES = /* @__PURE__ */ new Set(["single", "double", "dashed", "dotted", "thick", "none"]);
|
|
1024
|
+
function irColumnsToModel(c) {
|
|
1025
|
+
const out = { count: c.count, gapPx: round2(twipsToPx(c.spaceTwips ?? 720)) };
|
|
1026
|
+
if (c.sep) out.sep = true;
|
|
1027
|
+
if (c.cols && c.cols.length === c.count) {
|
|
1028
|
+
out.cols = c.cols.map((col) => ({
|
|
1029
|
+
widthPx: round2(twipsToPx(col.wTwips)),
|
|
1030
|
+
spaceAfterPx: round2(twipsToPx(col.spaceTwips))
|
|
1031
|
+
}));
|
|
1032
|
+
}
|
|
1033
|
+
return out;
|
|
1034
|
+
}
|
|
1035
|
+
function irPageBordersToModel(b) {
|
|
1036
|
+
const edge = (e) => {
|
|
1037
|
+
if (!e) return void 0;
|
|
1038
|
+
const style = PAGE_BORDER_STYLES.has(e.style) ? e.style : "single";
|
|
1039
|
+
const out2 = {
|
|
1040
|
+
style,
|
|
1041
|
+
widthPx: e.sz !== void 0 ? round2(e.sz / 6) : 1,
|
|
1042
|
+
// w:sz is eighth-points
|
|
1043
|
+
color: !e.color || e.color === "auto" ? "#000000" : `#${e.color}`
|
|
1044
|
+
};
|
|
1045
|
+
if (e.space !== void 0) out2.spacePx = round2(e.space * 96 / 72);
|
|
1046
|
+
return out2;
|
|
1047
|
+
};
|
|
1048
|
+
const out = { offsetFrom: b.offsetFrom ?? "page" };
|
|
1049
|
+
const top = edge(b.top);
|
|
1050
|
+
if (top) out.top = top;
|
|
1051
|
+
const right = edge(b.right);
|
|
1052
|
+
if (right) out.right = right;
|
|
1053
|
+
const bottom = edge(b.bottom);
|
|
1054
|
+
if (bottom) out.bottom = bottom;
|
|
1055
|
+
const left = edge(b.left);
|
|
1056
|
+
if (left) out.left = left;
|
|
1057
|
+
return out;
|
|
1058
|
+
}
|
|
859
1059
|
var NO_LINKS = () => void 0;
|
|
860
1060
|
var DEFAULT_CHAR = {
|
|
861
1061
|
fontFamily: "Times New Roman, serif",
|
|
@@ -934,7 +1134,7 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
934
1134
|
const sz = props.sectionPgSize;
|
|
935
1135
|
return !!sz && !!refPgSize && (sz.w !== refPgSize.w || sz.h !== refPgSize.h);
|
|
936
1136
|
};
|
|
937
|
-
const sectionIsDistinct = (props) => sectionChangesGeometry(props) || !!props.sectionColumns || props.sectionPageNumberStart !== void 0;
|
|
1137
|
+
const sectionIsDistinct = (props) => sectionChangesGeometry(props) || !!props.sectionColumns || props.sectionPageNumberStart !== void 0 || !!props.sectionPgBorders;
|
|
938
1138
|
const buildSectionPatch = (props) => {
|
|
939
1139
|
const patch = {};
|
|
940
1140
|
if (props.sectionPgSize) {
|
|
@@ -944,16 +1144,18 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
944
1144
|
if (props.sectionMarginTwips) {
|
|
945
1145
|
patch.marginPx = marginTwipsToPx(props.sectionMarginTwips);
|
|
946
1146
|
}
|
|
947
|
-
if (props.sectionColumns)
|
|
948
|
-
patch.columns = { count: props.sectionColumns.count, gapPx: round2(twipsToPx(props.sectionColumns.spaceTwips ?? 720)) };
|
|
949
|
-
}
|
|
1147
|
+
if (props.sectionColumns) patch.columns = irColumnsToModel(props.sectionColumns);
|
|
950
1148
|
if (props.sectionPageNumberStart !== void 0) patch.pageNumberStart = props.sectionPageNumberStart;
|
|
1149
|
+
if (props.sectionHeaderDistTwips !== void 0) patch.headerDistancePx = round2(twipsToPx(props.sectionHeaderDistTwips));
|
|
1150
|
+
if (props.sectionFooterDistTwips !== void 0) patch.footerDistancePx = round2(twipsToPx(props.sectionFooterDistTwips));
|
|
1151
|
+
if (props.sectionPgBorders) patch.pageBorders = irPageBordersToModel(props.sectionPgBorders);
|
|
951
1152
|
return patch;
|
|
952
1153
|
};
|
|
953
1154
|
const lastParagraphOf = (mapped) => {
|
|
954
1155
|
for (let i = mapped.length - 1; i >= 0; i--) if (mapped[i].kind === "paragraph") return mapped[i];
|
|
955
1156
|
return void 0;
|
|
956
1157
|
};
|
|
1158
|
+
let tocAnchor;
|
|
957
1159
|
const mapBlocks = (blocks, media, resolveLink = NO_LINKS) => {
|
|
958
1160
|
const out = [];
|
|
959
1161
|
let pending = false;
|
|
@@ -985,6 +1187,10 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
985
1187
|
const irBlock = blocks[bi];
|
|
986
1188
|
const mapped = irBlock.kind === "paragraph" ? mapParagraph(irBlock, media, resolveLink) : [mapTable(irBlock, media, resolveLink)];
|
|
987
1189
|
if (irBlock.fieldId) for (const b of mapped) b.fieldId = irBlock.fieldId;
|
|
1190
|
+
if (irBlock.kind === "paragraph" && irBlock.tocField !== void 0 && tocAnchor === void 0) {
|
|
1191
|
+
const p = mapped.find((b) => b.kind === "paragraph") ?? mapped[0];
|
|
1192
|
+
if (p) tocAnchor = { blockId: p.id, instruction: irBlock.tocField };
|
|
1193
|
+
}
|
|
988
1194
|
if (pending && mapped.length > 0) {
|
|
989
1195
|
const first = mapped[0];
|
|
990
1196
|
const empty = first.kind === "paragraph" && first.runs.every((r) => r.text.length === 0 || r.style.hidden);
|
|
@@ -1121,7 +1327,7 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
1121
1327
|
}
|
|
1122
1328
|
case "run": {
|
|
1123
1329
|
const effective = resolver.run(ir.props.styleId, inline.props);
|
|
1124
|
-
runs.push(mapRun(inline.text, effective, resolveLink, inline.sdtId));
|
|
1330
|
+
runs.push(mapRun(inline.text, effective, resolveLink, inline.sdtId, inline.fieldId));
|
|
1125
1331
|
trailingBreak = false;
|
|
1126
1332
|
break;
|
|
1127
1333
|
}
|
|
@@ -1166,9 +1372,21 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
1166
1372
|
align: inline.anchorAlign ?? (paraAlign === "justify" ? "left" : paraAlign)
|
|
1167
1373
|
};
|
|
1168
1374
|
if (inline.anchored && inline.anchorWrap === "square") image.wrap = "square";
|
|
1375
|
+
if (inline.anchorFloat) {
|
|
1376
|
+
const a = inline.anchorFloat;
|
|
1377
|
+
image.anchor = {
|
|
1378
|
+
behind: a.behind,
|
|
1379
|
+
offsetXPx: round2(emuToPx(a.offsetXEmu)),
|
|
1380
|
+
offsetYPx: round2(emuToPx(a.offsetYEmu)),
|
|
1381
|
+
relFromH: a.relFromH,
|
|
1382
|
+
relFromV: a.relFromV,
|
|
1383
|
+
...a.decorative ? { decorative: true } : {},
|
|
1384
|
+
...a.z !== void 0 ? { z: a.z } : {}
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1169
1387
|
return image;
|
|
1170
1388
|
}
|
|
1171
|
-
function mapRun(rawText, effective, resolveLink, sdtId) {
|
|
1389
|
+
function mapRun(rawText, effective, resolveLink, sdtId, fieldId) {
|
|
1172
1390
|
let text = rawText;
|
|
1173
1391
|
const style = mapCharStyle(effective);
|
|
1174
1392
|
if (effective.linkRelId) {
|
|
@@ -1191,6 +1409,8 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
1191
1409
|
style.fontFamily = DEFAULT_CHAR.fontFamily;
|
|
1192
1410
|
}
|
|
1193
1411
|
}
|
|
1412
|
+
if (fieldId) style.fieldId = fieldId;
|
|
1413
|
+
if (effective.styleId) style.charStyleId = effective.styleId;
|
|
1194
1414
|
return { text, style };
|
|
1195
1415
|
}
|
|
1196
1416
|
function styleCell(p, ir, styled, hasBorderInfo, width, rowCount) {
|
|
@@ -1254,6 +1474,8 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
1254
1474
|
for (const row of placedRows) for (const p of row) styleCell(p, ir, styled, hasBorderInfo, width, ir.rows.length);
|
|
1255
1475
|
const rows = placedRows.map((row) => ({ cells: row.map((p) => p.cell) }));
|
|
1256
1476
|
const table = { kind: "table", id: id(), revision: 0, rows };
|
|
1477
|
+
if (ir.styleId) table.styleId = ir.styleId;
|
|
1478
|
+
if (ir.look) table.condOverrides = { ...ir.look };
|
|
1257
1479
|
table.colFractions = columnFractions(ir.colWidthsTwips, width);
|
|
1258
1480
|
return table;
|
|
1259
1481
|
}
|
|
@@ -1264,19 +1486,23 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
1264
1486
|
pageHeightPx: ir.pageHeightTwips !== void 0 ? round2(twipsToPx(ir.pageHeightTwips)) : DEFAULT_SECTION.pageHeightPx,
|
|
1265
1487
|
marginPx: ir.marginTwips ? marginTwipsToPx(ir.marginTwips) : { ...DEFAULT_SECTION.marginPx }
|
|
1266
1488
|
};
|
|
1267
|
-
if (ir.columns)
|
|
1268
|
-
section.columns = { count: ir.columns.count, gapPx: round2(twipsToPx(ir.columns.spaceTwips ?? 720)) };
|
|
1269
|
-
}
|
|
1489
|
+
if (ir.columns) section.columns = irColumnsToModel(ir.columns);
|
|
1270
1490
|
if (ir.pageNumberStart !== void 0) section.pageNumberStart = ir.pageNumberStart;
|
|
1271
1491
|
if (ir.headerDistTwips !== void 0) section.headerDistancePx = round2(twipsToPx(ir.headerDistTwips));
|
|
1272
1492
|
if (ir.footerDistTwips !== void 0) section.footerDistancePx = round2(twipsToPx(ir.footerDistTwips));
|
|
1493
|
+
if (ir.pageBorders) section.pageBorders = irPageBordersToModel(ir.pageBorders);
|
|
1273
1494
|
return section;
|
|
1274
1495
|
}
|
|
1275
1496
|
return {
|
|
1276
1497
|
mapBlocks,
|
|
1277
1498
|
mapSection,
|
|
1278
1499
|
emptyParagraph,
|
|
1279
|
-
|
|
1500
|
+
// Realize EVERY defined numbering definition (not just referenced ones) so a
|
|
1501
|
+
// list style authored in the editor survives save→reopen before it's applied.
|
|
1502
|
+
lists: () => {
|
|
1503
|
+
for (const numId of numbering.keys()) listDefFor(numId);
|
|
1504
|
+
return Object.fromEntries(usedLists);
|
|
1505
|
+
},
|
|
1280
1506
|
bookmarks: () => {
|
|
1281
1507
|
const out = {};
|
|
1282
1508
|
for (const [id2, s] of bookmarkStarts) {
|
|
@@ -1284,7 +1510,8 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
|
|
|
1284
1510
|
}
|
|
1285
1511
|
return out;
|
|
1286
1512
|
},
|
|
1287
|
-
footnoteRefs: () => footnoteOrder.map((docxId) => ({ docxId, noteId: `fn${docxId}` }))
|
|
1513
|
+
footnoteRefs: () => footnoteOrder.map((docxId) => ({ docxId, noteId: `fn${docxId}` })),
|
|
1514
|
+
tocField: () => tocAnchor
|
|
1288
1515
|
};
|
|
1289
1516
|
}
|
|
1290
1517
|
var NUM_FORMAT_MAP = {
|
|
@@ -1437,16 +1664,6 @@ function mapSdts(ir) {
|
|
|
1437
1664
|
}
|
|
1438
1665
|
return out;
|
|
1439
1666
|
}
|
|
1440
|
-
function collectUsedStyleIds(blocks, into = /* @__PURE__ */ new Set()) {
|
|
1441
|
-
for (const b of blocks) {
|
|
1442
|
-
if (b.kind === "paragraph") {
|
|
1443
|
-
if (b.props.styleId) into.add(b.props.styleId);
|
|
1444
|
-
} else {
|
|
1445
|
-
for (const row of b.rows) for (const cell of row.cells) collectUsedStyleIds(cell.blocks, into);
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
return into;
|
|
1449
|
-
}
|
|
1450
1667
|
function mapCharPatch(props) {
|
|
1451
1668
|
const out = {};
|
|
1452
1669
|
applyRunProps(out, props);
|
|
@@ -1467,27 +1684,27 @@ function mapParaPatch(props) {
|
|
|
1467
1684
|
if (props.tabStops) out.tabStops = mapTabStops(props.tabStops);
|
|
1468
1685
|
return out;
|
|
1469
1686
|
}
|
|
1470
|
-
function buildStylesheet(data
|
|
1687
|
+
function buildStylesheet(data) {
|
|
1471
1688
|
if (data.styles.size === 0) return void 0;
|
|
1472
1689
|
const include = /* @__PURE__ */ new Set();
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1477
|
-
};
|
|
1478
|
-
for (const id of usedIds) addWithBases(id);
|
|
1479
|
-
if (data.defaultParaStyleId) addWithBases(data.defaultParaStyleId);
|
|
1690
|
+
for (const def of data.styles.values()) {
|
|
1691
|
+
if (def.type === "paragraph" || def.type === "character") include.add(def.id);
|
|
1692
|
+
}
|
|
1480
1693
|
if (include.size === 0) return void 0;
|
|
1481
1694
|
const styles = [];
|
|
1482
1695
|
for (const id of include) {
|
|
1483
1696
|
const def = data.styles.get(id);
|
|
1697
|
+
const isChar = def.type === "character";
|
|
1484
1698
|
const style = {
|
|
1485
1699
|
id,
|
|
1486
1700
|
name: def.name ?? id,
|
|
1701
|
+
type: isChar ? "character" : "paragraph",
|
|
1487
1702
|
char: mapCharPatch(def.rPr),
|
|
1488
|
-
para: mapParaPatch(def.pPr)
|
|
1703
|
+
para: isChar ? {} : mapParaPatch(def.pPr)
|
|
1489
1704
|
};
|
|
1490
|
-
if (def.basedOnId && include.has(def.basedOnId)
|
|
1705
|
+
if (def.basedOnId && include.has(def.basedOnId) && data.styles.get(def.basedOnId)?.type === def.type) {
|
|
1706
|
+
style.basedOn = def.basedOnId;
|
|
1707
|
+
}
|
|
1491
1708
|
styles.push(style);
|
|
1492
1709
|
}
|
|
1493
1710
|
styles.sort(
|
|
@@ -1495,6 +1712,38 @@ function buildStylesheet(data, usedIds) {
|
|
|
1495
1712
|
);
|
|
1496
1713
|
return { styles, defaultStyleId: data.defaultParaStyleId ?? styles[0].id };
|
|
1497
1714
|
}
|
|
1715
|
+
function buildTableStyles(data) {
|
|
1716
|
+
const include = /* @__PURE__ */ new Set();
|
|
1717
|
+
for (const def of data.styles.values()) if (def.type === "table") include.add(def.id);
|
|
1718
|
+
if (include.size === 0) return void 0;
|
|
1719
|
+
const condProps = (rPr, pPr, borders, shd) => {
|
|
1720
|
+
const cp = {};
|
|
1721
|
+
const char = mapCharPatch(rPr);
|
|
1722
|
+
if (Object.keys(char).length > 0) cp.char = char;
|
|
1723
|
+
const para = mapParaPatch(pPr);
|
|
1724
|
+
if (Object.keys(para).length > 0) cp.para = para;
|
|
1725
|
+
const cb = cellBordersFromIR(borders);
|
|
1726
|
+
if (cb) cp.borders = cb;
|
|
1727
|
+
if (shd !== void 0) cp.shading = shd;
|
|
1728
|
+
return cp;
|
|
1729
|
+
};
|
|
1730
|
+
const out = {};
|
|
1731
|
+
for (const id of include) {
|
|
1732
|
+
const def = data.styles.get(id);
|
|
1733
|
+
const conds = {
|
|
1734
|
+
wholeTable: condProps(def.rPr, def.pPr, def.tblBorders, def.tblShd)
|
|
1735
|
+
};
|
|
1736
|
+
for (const [cond, c] of Object.entries(def.tblStylePr ?? {})) {
|
|
1737
|
+
conds[cond] = condProps(c.rPr, c.pPr, c.borders, c.shd);
|
|
1738
|
+
}
|
|
1739
|
+
const style = { id, name: def.name ?? id, conds };
|
|
1740
|
+
if (def.basedOnId && include.has(def.basedOnId)) style.basedOn = def.basedOnId;
|
|
1741
|
+
if (def.rowBandSize !== void 0) style.rowBandSize = def.rowBandSize;
|
|
1742
|
+
if (def.colBandSize !== void 0) style.colBandSize = def.colBandSize;
|
|
1743
|
+
out[id] = style;
|
|
1744
|
+
}
|
|
1745
|
+
return out;
|
|
1746
|
+
}
|
|
1498
1747
|
function mapParaStyle(props) {
|
|
1499
1748
|
const style = { ...DEFAULT_PARA };
|
|
1500
1749
|
if (props.align) style.align = props.align;
|
|
@@ -1765,7 +2014,29 @@ function parseStylesXml(xmlText, warnings) {
|
|
|
1765
2014
|
if (borders) def.tblBorders = borders;
|
|
1766
2015
|
const shd = decodeShdFill(el(tblPr, "w:shd"));
|
|
1767
2016
|
if (shd) def.tblShd = shd;
|
|
2017
|
+
const rowBand = val(tblPr, "w:tblStyleRowBandSize");
|
|
2018
|
+
if (rowBand && Number.isFinite(Number(rowBand))) def.rowBandSize = Number(rowBand);
|
|
2019
|
+
const colBand = val(tblPr, "w:tblStyleColBandSize");
|
|
2020
|
+
if (colBand && Number.isFinite(Number(colBand))) def.colBandSize = Number(colBand);
|
|
2021
|
+
}
|
|
2022
|
+
const conds = {};
|
|
2023
|
+
for (const sp of els(style, "w:tblStylePr")) {
|
|
2024
|
+
const condType = attr(sp, "w:type");
|
|
2025
|
+
if (!condType) continue;
|
|
2026
|
+
const rPrEl2 = el(sp, "w:rPr");
|
|
2027
|
+
const pPrEl2 = el(sp, "w:pPr");
|
|
2028
|
+
const tcPr = el(sp, "w:tcPr");
|
|
2029
|
+
const cond = {
|
|
2030
|
+
rPr: rPrEl2 ? decodeRunProps(rPrEl2) : {},
|
|
2031
|
+
pPr: pPrEl2 ? decodeParaProps(pPrEl2, warnings) : {}
|
|
2032
|
+
};
|
|
2033
|
+
const cb = tcPr && decodeBorders(el(tcPr, "w:tcBorders"));
|
|
2034
|
+
if (cb) cond.borders = cb;
|
|
2035
|
+
const cs = tcPr && decodeShdFill(el(tcPr, "w:shd"));
|
|
2036
|
+
if (cs) cond.shd = cs;
|
|
2037
|
+
conds[condType] = cond;
|
|
1768
2038
|
}
|
|
2039
|
+
if (Object.keys(conds).length > 0) def.tblStylePr = conds;
|
|
1769
2040
|
}
|
|
1770
2041
|
data.styles.set(id, def);
|
|
1771
2042
|
const isDefault = attr(style, "w:default");
|
|
@@ -1994,6 +2265,7 @@ function runImport(bytes, onProgress, opts) {
|
|
|
1994
2265
|
const blocks = mapper.mapBlocks(ir.blocks, mediaFor(rels), linkResolverFor(rels));
|
|
1995
2266
|
if (blocks.length === 0) blocks.push(mapper.emptyParagraph());
|
|
1996
2267
|
const section = mapper.mapSection(ir.section);
|
|
2268
|
+
if (ir.pageColorHex) section.pageColorHex = `#${ir.pageColorHex}`;
|
|
1997
2269
|
const settingsXml = partByRelType(archive, rels, "settings") ?? archive.text("word/settings.xml");
|
|
1998
2270
|
const evenAndOdd = settingsXml !== void 0 && hasEvenAndOdd(settingsXml);
|
|
1999
2271
|
mapBands(section, "header", ir.section?.headerRefs, ir.section?.titlePg ?? false, evenAndOdd, archive, rels, mapper, mediaFor, warnings, ir.sdts);
|
|
@@ -2029,12 +2301,14 @@ function runImport(bytes, onProgress, opts) {
|
|
|
2029
2301
|
if (Object.keys(lists).length > 0) doc.lists = lists;
|
|
2030
2302
|
const bookmarks = mapper.bookmarks();
|
|
2031
2303
|
if (Object.keys(bookmarks).length > 0) doc.bookmarks = bookmarks;
|
|
2032
|
-
const stylesheet = buildStylesheet(styles
|
|
2304
|
+
const stylesheet = buildStylesheet(styles);
|
|
2033
2305
|
if (stylesheet) doc.stylesheet = stylesheet;
|
|
2034
|
-
const
|
|
2035
|
-
if (
|
|
2036
|
-
|
|
2037
|
-
|
|
2306
|
+
const tableStyles = buildTableStyles(styles);
|
|
2307
|
+
if (tableStyles) doc.tableStyles = tableStyles;
|
|
2308
|
+
const toc = mapper.tocField();
|
|
2309
|
+
if (toc) {
|
|
2310
|
+
doc.tocInstruction = toc.instruction;
|
|
2311
|
+
if (markImportedTocEntries(doc) === 0) doc.tocAnchorBlockId = toc.blockId;
|
|
2038
2312
|
}
|
|
2039
2313
|
if (ir.fields) doc.fields = ir.fields;
|
|
2040
2314
|
return {
|
|
@@ -2044,12 +2318,6 @@ function runImport(bytes, onProgress, opts) {
|
|
|
2044
2318
|
media: mediaRecords
|
|
2045
2319
|
};
|
|
2046
2320
|
}
|
|
2047
|
-
function captureTocInstruction(xml) {
|
|
2048
|
-
const re = /<w:instrText[^>]*>([\s\S]*?)<\/w:instrText>/g;
|
|
2049
|
-
let m;
|
|
2050
|
-
while ((m = re.exec(xml)) !== null) if (/\bTOC\b/.test(m[1])) return m[1];
|
|
2051
|
-
return void 0;
|
|
2052
|
-
}
|
|
2053
2321
|
function mapStory(archive, documentRels, relId, mapper, mediaFor, warnings, sdts) {
|
|
2054
2322
|
if (!relId) return void 0;
|
|
2055
2323
|
const rel = documentRels.get(relId);
|
|
@@ -2100,4 +2368,4 @@ function partNameByRelType(rels, kind) {
|
|
|
2100
2368
|
export {
|
|
2101
2369
|
runImport
|
|
2102
2370
|
};
|
|
2103
|
-
//# sourceMappingURL=chunk-
|
|
2371
|
+
//# sourceMappingURL=chunk-57L5XMCL.js.map
|