@forevka/wordcanvas 0.7.1 → 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.
Files changed (59) hide show
  1. package/dist-lib/assets/{worker-D8rUOKfg.js → worker-4HYrkNrG.js} +10873 -10730
  2. package/dist-lib/assets/worker-CJpwUzKh.js +2403 -0
  3. package/dist-lib/blockFactory-B_CLnkUh.js +106 -0
  4. package/dist-lib/browser-p_rkUcqE.js +1339 -0
  5. package/dist-lib/builder.js +14 -13
  6. package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
  7. package/dist-lib/export.js +4507 -4456
  8. package/dist-lib/generate-toc.js +5 -5
  9. package/dist-lib/import.js +2 -2
  10. package/dist-lib/measure.js +2 -2
  11. package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-B2aKX7lF.js} +1 -1
  12. package/dist-lib/metrics-BUMIC9Mv.js +164 -0
  13. package/dist-lib/pipeline-DD0nxAYM.js +1850 -0
  14. package/dist-lib/recalc-docx.js +2 -2
  15. package/dist-lib/recalcToc-CFCGCgij.js +3985 -0
  16. package/dist-lib/styleProps-DhqDEfvc.js +149 -0
  17. package/dist-lib/stylesheet-B6oczA-L.js +141 -0
  18. package/dist-lib/{toc-B6VpkJge.js → toc-Dj57zdz-.js} +5 -5
  19. package/dist-lib/{webmcp-6WxRNKCc.js → webmcp-CXghUon_.js} +2 -2
  20. package/dist-lib/{wordcanvas-CFqpDK0k.js → wordcanvas-D5DI9ZR1.js} +49 -23
  21. package/dist-lib/wordcanvas.js +1 -1
  22. package/dist-node/{chunk-22JHAERT.js → chunk-57L5XMCL.js} +235 -39
  23. package/dist-node/chunk-57L5XMCL.js.map +7 -0
  24. package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
  25. package/dist-node/chunk-EMY2P524.js.map +7 -0
  26. package/dist-node/{chunk-6AJJMHKY.js → chunk-KJV7GJ3H.js} +1 -1
  27. package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
  28. package/dist-node/{chunk-CDN6WU2P.js → chunk-PIMVQULL.js} +7 -1
  29. package/dist-node/chunk-PIMVQULL.js.map +7 -0
  30. package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
  31. package/dist-node/{chunk-RNB336F3.js → chunk-T3253N22.js} +92 -14
  32. package/dist-node/{chunk-RNB336F3.js.map → chunk-T3253N22.js.map} +2 -2
  33. package/dist-node/{chunk-4ICCHZX4.js → chunk-U27EBKBG.js} +37 -1
  34. package/dist-node/chunk-U27EBKBG.js.map +7 -0
  35. package/dist-node/{engine-5FGDJD2H.js → engine-5F7DUU4W.js} +4 -4
  36. package/dist-node/export.js +89 -24
  37. package/dist-node/export.js.map +2 -2
  38. package/dist-node/generate-toc.js +6 -6
  39. package/dist-node/import.js +3 -3
  40. package/dist-node/measure.js +2 -2
  41. package/dist-node/recalc-docx.js +4 -4
  42. package/package.json +1 -1
  43. package/types/model.d.ts +46 -0
  44. package/types/wordcanvas.d.ts +212 -157
  45. package/dist-lib/assets/worker-wXuuyshQ.js +0 -2258
  46. package/dist-lib/blockFactory-CUI4Rqiq.js +0 -186
  47. package/dist-lib/browser-DkKxreJM.js +0 -1305
  48. package/dist-lib/editorApp-DLXMmtu5.js +0 -8023
  49. package/dist-lib/metrics-CkAo4zh8.js +0 -143
  50. package/dist-lib/pipeline-CbxmCE84.js +0 -1705
  51. package/dist-lib/recalcToc-g1hFKSNs.js +0 -3935
  52. package/dist-lib/styleProps-Db5pEkG8.js +0 -127
  53. package/dist-node/chunk-22JHAERT.js.map +0 -7
  54. package/dist-node/chunk-4ICCHZX4.js.map +0 -7
  55. package/dist-node/chunk-4PDVRJF6.js.map +0 -7
  56. package/dist-node/chunk-6AJJMHKY.js.map +0 -7
  57. package/dist-node/chunk-CDN6WU2P.js.map +0 -7
  58. /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
  59. /package/dist-node/{engine-5FGDJD2H.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-6AJJMHKY.js";
22
+ } from "./chunk-KJV7GJ3H.js";
23
23
  import {
24
24
  strFromU8,
25
25
  unzipSync
@@ -30,7 +30,7 @@ import {
30
30
  normalizeRuns,
31
31
  parseFieldInstruction,
32
32
  parseFieldSpec
33
- } from "./chunk-CDN6WU2P.js";
33
+ } from "./chunk-PIMVQULL.js";
34
34
 
35
35
  // src/import/docx/units.ts
36
36
  var twipsToPx = (tw) => tw / 15;
@@ -102,6 +102,19 @@ function resolveCellBorders(src, pos) {
102
102
  if (right) out.right = right;
103
103
  return out;
104
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
+ }
105
118
  function toCellBorder(raw) {
106
119
  if (!raw || raw.val === "nil" || raw.val === "none") return void 0;
107
120
  const widthPx = round2(Math.max(0.5, (raw.sizeEighthPt ?? 4) / 6));
@@ -246,13 +259,51 @@ function decodeParaProps(pPr, warnings) {
246
259
  if (top !== void 0 && right !== void 0 && bottom !== void 0 && left !== void 0) {
247
260
  props.sectionMarginTwips = { top, right, bottom, left };
248
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;
249
266
  }
250
267
  const cols = el(sectPr, "w:cols");
251
- const colCount = numAttr(cols, "w:num");
252
- if (colCount !== void 0 && colCount > 1) {
253
- props.sectionColumns = { count: colCount };
254
- const space = numAttr(cols, "w:space");
255
- if (space !== void 0) props.sectionColumns.spaceTwips = space;
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;
256
307
  }
257
308
  const pgNumStart = numAttr(el(sectPr, "w:pgNumType"), "w:start");
258
309
  if (pgNumStart !== void 0) props.sectionPageNumberStart = pgNumStart;
@@ -293,8 +344,13 @@ function parseDocumentXml(xmlText, partName, warnings) {
293
344
  walkBlocks(children(body), blocks, ctx);
294
345
  const sectPr = el(body, "w:sectPr");
295
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;
296
350
  const fields = ctx.fieldTrack.registry;
297
- return Object.keys(fields).length > 0 ? { blocks, section, sdts, fields } : { blocks, section, sdts };
351
+ const out = Object.keys(fields).length > 0 ? { blocks, section, sdts, fields } : { blocks, section, sdts };
352
+ if (pageColorHex) out.pageColorHex = pageColorHex;
353
+ return out;
298
354
  }
299
355
  function parseHeaderFooterXml(xmlText, partName, warnings, sdts = {}) {
300
356
  const nodes = parseXml(xmlText, partName);
@@ -755,6 +811,21 @@ function parseTable(tbl, ctx) {
755
811
  if (tblPr) {
756
812
  const styleId = val(tblPr, "w:tblStyle");
757
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
+ }
758
829
  if (el(tblPr, "w:tblBorders")) table.bordersSpecified = true;
759
830
  const borders = decodeBorders(el(tblPr, "w:tblBorders"));
760
831
  if (borders) table.borders = borders;
@@ -862,13 +933,47 @@ function parseSection(sectPr, warnings) {
862
933
  if (el(sectPr, "w:titlePg")) section.titlePg = true;
863
934
  const cols = el(sectPr, "w:cols");
864
935
  if (cols) {
865
- const count = numAttr(cols, "w:num") ?? 1;
936
+ const colEls = els(cols, "w:col");
937
+ const count = numAttr(cols, "w:num") ?? (colEls.length > 1 ? colEls.length : 1);
866
938
  if (count > 1) {
867
939
  section.columns = { count };
868
940
  const space = numAttr(cols, "w:space");
869
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
+ }
870
950
  }
871
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
+ }
872
977
  const pgNumStart = numAttr(el(sectPr, "w:pgNumType"), "w:start");
873
978
  if (pgNumStart !== void 0) section.pageNumberStart = pgNumStart;
874
979
  return section;
@@ -915,6 +1020,42 @@ function parseFootnotesXml(xmlText, partName, warnings, sdts = {}) {
915
1020
  }
916
1021
 
917
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
+ }
918
1059
  var NO_LINKS = () => void 0;
919
1060
  var DEFAULT_CHAR = {
920
1061
  fontFamily: "Times New Roman, serif",
@@ -993,7 +1134,7 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
993
1134
  const sz = props.sectionPgSize;
994
1135
  return !!sz && !!refPgSize && (sz.w !== refPgSize.w || sz.h !== refPgSize.h);
995
1136
  };
996
- 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;
997
1138
  const buildSectionPatch = (props) => {
998
1139
  const patch = {};
999
1140
  if (props.sectionPgSize) {
@@ -1003,10 +1144,11 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
1003
1144
  if (props.sectionMarginTwips) {
1004
1145
  patch.marginPx = marginTwipsToPx(props.sectionMarginTwips);
1005
1146
  }
1006
- if (props.sectionColumns) {
1007
- patch.columns = { count: props.sectionColumns.count, gapPx: round2(twipsToPx(props.sectionColumns.spaceTwips ?? 720)) };
1008
- }
1147
+ if (props.sectionColumns) patch.columns = irColumnsToModel(props.sectionColumns);
1009
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);
1010
1152
  return patch;
1011
1153
  };
1012
1154
  const lastParagraphOf = (mapped) => {
@@ -1268,6 +1410,7 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
1268
1410
  }
1269
1411
  }
1270
1412
  if (fieldId) style.fieldId = fieldId;
1413
+ if (effective.styleId) style.charStyleId = effective.styleId;
1271
1414
  return { text, style };
1272
1415
  }
1273
1416
  function styleCell(p, ir, styled, hasBorderInfo, width, rowCount) {
@@ -1331,6 +1474,8 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
1331
1474
  for (const row of placedRows) for (const p of row) styleCell(p, ir, styled, hasBorderInfo, width, ir.rows.length);
1332
1475
  const rows = placedRows.map((row) => ({ cells: row.map((p) => p.cell) }));
1333
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 };
1334
1479
  table.colFractions = columnFractions(ir.colWidthsTwips, width);
1335
1480
  return table;
1336
1481
  }
@@ -1341,19 +1486,23 @@ function createMapper(warnings, resolver, sdts = {}, numbering = /* @__PURE__ */
1341
1486
  pageHeightPx: ir.pageHeightTwips !== void 0 ? round2(twipsToPx(ir.pageHeightTwips)) : DEFAULT_SECTION.pageHeightPx,
1342
1487
  marginPx: ir.marginTwips ? marginTwipsToPx(ir.marginTwips) : { ...DEFAULT_SECTION.marginPx }
1343
1488
  };
1344
- if (ir.columns) {
1345
- section.columns = { count: ir.columns.count, gapPx: round2(twipsToPx(ir.columns.spaceTwips ?? 720)) };
1346
- }
1489
+ if (ir.columns) section.columns = irColumnsToModel(ir.columns);
1347
1490
  if (ir.pageNumberStart !== void 0) section.pageNumberStart = ir.pageNumberStart;
1348
1491
  if (ir.headerDistTwips !== void 0) section.headerDistancePx = round2(twipsToPx(ir.headerDistTwips));
1349
1492
  if (ir.footerDistTwips !== void 0) section.footerDistancePx = round2(twipsToPx(ir.footerDistTwips));
1493
+ if (ir.pageBorders) section.pageBorders = irPageBordersToModel(ir.pageBorders);
1350
1494
  return section;
1351
1495
  }
1352
1496
  return {
1353
1497
  mapBlocks,
1354
1498
  mapSection,
1355
1499
  emptyParagraph,
1356
- lists: () => Object.fromEntries(usedLists),
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
+ },
1357
1506
  bookmarks: () => {
1358
1507
  const out = {};
1359
1508
  for (const [id2, s] of bookmarkStarts) {
@@ -1515,16 +1664,6 @@ function mapSdts(ir) {
1515
1664
  }
1516
1665
  return out;
1517
1666
  }
1518
- function collectUsedStyleIds(blocks, into = /* @__PURE__ */ new Set()) {
1519
- for (const b of blocks) {
1520
- if (b.kind === "paragraph") {
1521
- if (b.props.styleId) into.add(b.props.styleId);
1522
- } else {
1523
- for (const row of b.rows) for (const cell of row.cells) collectUsedStyleIds(cell.blocks, into);
1524
- }
1525
- }
1526
- return into;
1527
- }
1528
1667
  function mapCharPatch(props) {
1529
1668
  const out = {};
1530
1669
  applyRunProps(out, props);
@@ -1545,27 +1684,27 @@ function mapParaPatch(props) {
1545
1684
  if (props.tabStops) out.tabStops = mapTabStops(props.tabStops);
1546
1685
  return out;
1547
1686
  }
1548
- function buildStylesheet(data, usedIds) {
1687
+ function buildStylesheet(data) {
1549
1688
  if (data.styles.size === 0) return void 0;
1550
1689
  const include = /* @__PURE__ */ new Set();
1551
- const addWithBases = (id) => {
1552
- for (let cur = data.styles.get(id); cur && !include.has(cur.id); cur = cur.basedOnId ? data.styles.get(cur.basedOnId) : void 0) {
1553
- if (cur.type === "paragraph") include.add(cur.id);
1554
- }
1555
- };
1556
- for (const id of usedIds) addWithBases(id);
1557
- 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
+ }
1558
1693
  if (include.size === 0) return void 0;
1559
1694
  const styles = [];
1560
1695
  for (const id of include) {
1561
1696
  const def = data.styles.get(id);
1697
+ const isChar = def.type === "character";
1562
1698
  const style = {
1563
1699
  id,
1564
1700
  name: def.name ?? id,
1701
+ type: isChar ? "character" : "paragraph",
1565
1702
  char: mapCharPatch(def.rPr),
1566
- para: mapParaPatch(def.pPr)
1703
+ para: isChar ? {} : mapParaPatch(def.pPr)
1567
1704
  };
1568
- if (def.basedOnId && include.has(def.basedOnId)) style.basedOn = def.basedOnId;
1705
+ if (def.basedOnId && include.has(def.basedOnId) && data.styles.get(def.basedOnId)?.type === def.type) {
1706
+ style.basedOn = def.basedOnId;
1707
+ }
1569
1708
  styles.push(style);
1570
1709
  }
1571
1710
  styles.sort(
@@ -1573,6 +1712,38 @@ function buildStylesheet(data, usedIds) {
1573
1712
  );
1574
1713
  return { styles, defaultStyleId: data.defaultParaStyleId ?? styles[0].id };
1575
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
+ }
1576
1747
  function mapParaStyle(props) {
1577
1748
  const style = { ...DEFAULT_PARA };
1578
1749
  if (props.align) style.align = props.align;
@@ -1843,7 +2014,29 @@ function parseStylesXml(xmlText, warnings) {
1843
2014
  if (borders) def.tblBorders = borders;
1844
2015
  const shd = decodeShdFill(el(tblPr, "w:shd"));
1845
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;
1846
2038
  }
2039
+ if (Object.keys(conds).length > 0) def.tblStylePr = conds;
1847
2040
  }
1848
2041
  data.styles.set(id, def);
1849
2042
  const isDefault = attr(style, "w:default");
@@ -2072,6 +2265,7 @@ function runImport(bytes, onProgress, opts) {
2072
2265
  const blocks = mapper.mapBlocks(ir.blocks, mediaFor(rels), linkResolverFor(rels));
2073
2266
  if (blocks.length === 0) blocks.push(mapper.emptyParagraph());
2074
2267
  const section = mapper.mapSection(ir.section);
2268
+ if (ir.pageColorHex) section.pageColorHex = `#${ir.pageColorHex}`;
2075
2269
  const settingsXml = partByRelType(archive, rels, "settings") ?? archive.text("word/settings.xml");
2076
2270
  const evenAndOdd = settingsXml !== void 0 && hasEvenAndOdd(settingsXml);
2077
2271
  mapBands(section, "header", ir.section?.headerRefs, ir.section?.titlePg ?? false, evenAndOdd, archive, rels, mapper, mediaFor, warnings, ir.sdts);
@@ -2107,8 +2301,10 @@ function runImport(bytes, onProgress, opts) {
2107
2301
  if (Object.keys(lists).length > 0) doc.lists = lists;
2108
2302
  const bookmarks = mapper.bookmarks();
2109
2303
  if (Object.keys(bookmarks).length > 0) doc.bookmarks = bookmarks;
2110
- const stylesheet = buildStylesheet(styles, collectUsedStyleIds(ir.blocks));
2304
+ const stylesheet = buildStylesheet(styles);
2111
2305
  if (stylesheet) doc.stylesheet = stylesheet;
2306
+ const tableStyles = buildTableStyles(styles);
2307
+ if (tableStyles) doc.tableStyles = tableStyles;
2112
2308
  const toc = mapper.tocField();
2113
2309
  if (toc) {
2114
2310
  doc.tocInstruction = toc.instruction;
@@ -2172,4 +2368,4 @@ function partNameByRelType(rels, kind) {
2172
2368
  export {
2173
2369
  runImport
2174
2370
  };
2175
- //# sourceMappingURL=chunk-22JHAERT.js.map
2371
+ //# sourceMappingURL=chunk-57L5XMCL.js.map