@json-to-office/core-docx 4.0.0 → 4.2.0

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.
@@ -12482,9 +12482,260 @@ async function expandBlocksWithPlugins(document, theme, plugins, render, preserv
12482
12482
  init_styleHelpers();
12483
12483
  init_defaults();
12484
12484
  init_widthUtils();
12485
+
12486
+ // src/quality/text-inventory.ts
12487
+ function tocDepth(depth) {
12488
+ const range = asRecord(depth) ?? {};
12489
+ const from = typeof range.from === "number" ? range.from : 1;
12490
+ const to = typeof range.to === "number" ? range.to : 3;
12491
+ return { from, to };
12492
+ }
12485
12493
  function asRecord(value) {
12486
12494
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
12487
12495
  }
12496
+ function twipsToPt(value) {
12497
+ return typeof value === "number" && Number.isFinite(value) ? value / 20 : void 0;
12498
+ }
12499
+ function frameOf(props) {
12500
+ const widthPt = twipsToPt(asRecord(props.floating)?.width);
12501
+ return widthPt === void 0 ? void 0 : { widthPt };
12502
+ }
12503
+ function collectDocxTextInventory(children, basePath = "/children") {
12504
+ const entries = [];
12505
+ const add = (path3, text, role, extra = {}) => {
12506
+ if (typeof text !== "string" || text.trim() === "") return;
12507
+ entries.push({
12508
+ id: `docx:text:${path3}`,
12509
+ kind: "docx/text",
12510
+ path: path3,
12511
+ text,
12512
+ role,
12513
+ // Renumbered once the walk is done: contents entries are spliced in.
12514
+ order: -1,
12515
+ ...extra
12516
+ });
12517
+ };
12518
+ const headings = [];
12519
+ const tocs = [];
12520
+ let sectionCount = 0;
12521
+ const visitCell = (cell, path3, role, inherited) => {
12522
+ const cellRole = inherited.repeats ? "chrome" : role;
12523
+ const extra = inherited.repeats ? { repeats: true } : {};
12524
+ if (typeof cell === "string") {
12525
+ add(path3, cell, cellRole, extra);
12526
+ return;
12527
+ }
12528
+ const rec = asRecord(cell);
12529
+ if (!rec) return;
12530
+ if ("content" in rec) {
12531
+ if (typeof rec.content === "string")
12532
+ add(`${path3}/content`, rec.content, cellRole, extra);
12533
+ else {
12534
+ const inner = asRecord(rec.content);
12535
+ if (inner)
12536
+ visitNode(inner, `${path3}/content`, { ...inherited, inCell: true });
12537
+ }
12538
+ return;
12539
+ }
12540
+ if (typeof rec.name === "string")
12541
+ visitNode(rec, path3, { ...inherited, inCell: true });
12542
+ };
12543
+ const visitNode = (node, path3, inherited) => {
12544
+ if (node.enabled === false) return;
12545
+ const props = asRecord(node.props) ?? {};
12546
+ const name = typeof node.name === "string" ? node.name : "";
12547
+ const extra = {
12548
+ ...inherited.repeats && { repeats: true }
12549
+ };
12550
+ const scope = name === "section" ? { ...inherited, section: ++sectionCount } : inherited;
12551
+ switch (name) {
12552
+ case "heading": {
12553
+ if (inherited.repeats) {
12554
+ add(`${path3}/props/text`, props.text, "chrome", extra);
12555
+ break;
12556
+ }
12557
+ const level = typeof props.level === "number" && Number.isFinite(props.level) ? props.level : 1;
12558
+ add(`${path3}/props/text`, props.text, "heading", { ...extra, level });
12559
+ if (typeof props.text === "string" && props.text.trim() !== "" && !scope.inCell) {
12560
+ headings.push({ text: props.text, level, section: scope.section });
12561
+ }
12562
+ break;
12563
+ }
12564
+ case "toc": {
12565
+ add(`${path3}/props/title`, props.title, "toc-entry", extra);
12566
+ const styles = /* @__PURE__ */ new Set();
12567
+ if (Array.isArray(props.styles)) {
12568
+ for (const mapping of props.styles) {
12569
+ const id = asRecord(mapping)?.styleId;
12570
+ if (typeof id === "string") styles.add(id);
12571
+ }
12572
+ }
12573
+ tocs.push({
12574
+ at: entries.length,
12575
+ path: path3,
12576
+ depth: tocDepth(props.depth),
12577
+ styles,
12578
+ section: props.scope === "document" ? void 0 : scope.section
12579
+ });
12580
+ break;
12581
+ }
12582
+ case "paragraph": {
12583
+ const frame = frameOf(props);
12584
+ add(
12585
+ `${path3}/props/text`,
12586
+ props.text,
12587
+ inherited.repeats ? "chrome" : "body",
12588
+ {
12589
+ ...extra,
12590
+ ...frame && { frame }
12591
+ }
12592
+ );
12593
+ if (typeof props.themeStyle === "string" && typeof props.text === "string" && props.text.trim() !== "" && !scope.inCell) {
12594
+ headings.push({
12595
+ text: props.text,
12596
+ themeStyle: props.themeStyle,
12597
+ section: scope.section
12598
+ });
12599
+ }
12600
+ break;
12601
+ }
12602
+ case "list": {
12603
+ if (Array.isArray(props.items)) {
12604
+ props.items.forEach((item, index) => {
12605
+ const itemPath = `${path3}/props/items/${index}`;
12606
+ if (typeof item === "string")
12607
+ add(itemPath, item, "list-item", extra);
12608
+ else {
12609
+ const rec = asRecord(item);
12610
+ if (rec) add(`${itemPath}/text`, rec.text, "list-item", extra);
12611
+ }
12612
+ });
12613
+ }
12614
+ break;
12615
+ }
12616
+ case "table": {
12617
+ const columns = Array.isArray(props.columns) ? props.columns.map(asRecord) : [];
12618
+ columns.forEach((column, columnIndex) => {
12619
+ if (!column) return;
12620
+ visitCell(
12621
+ column.header,
12622
+ `${path3}/props/columns/${columnIndex}/header`,
12623
+ "table-header",
12624
+ inherited
12625
+ );
12626
+ });
12627
+ const rows = Math.max(
12628
+ 0,
12629
+ ...columns.map(
12630
+ (column) => Array.isArray(column?.cells) ? column.cells.length : 0
12631
+ )
12632
+ );
12633
+ for (let row = 0; row < rows; row++) {
12634
+ columns.forEach((column, columnIndex) => {
12635
+ if (!column || !Array.isArray(column.cells)) return;
12636
+ if (row >= column.cells.length) return;
12637
+ visitCell(
12638
+ column.cells[row],
12639
+ `${path3}/props/columns/${columnIndex}/cells/${row}`,
12640
+ "table-cell",
12641
+ inherited
12642
+ );
12643
+ });
12644
+ }
12645
+ break;
12646
+ }
12647
+ case "statistic": {
12648
+ add(`${path3}/props/number`, props.number, "statistic", extra);
12649
+ add(`${path3}/props/description`, props.description, "statistic", extra);
12650
+ break;
12651
+ }
12652
+ case "chart": {
12653
+ if (props.showTitle !== false) {
12654
+ add(`${path3}/props/title`, props.title, "caption", extra);
12655
+ }
12656
+ if (props.type !== "pie" && props.type !== "doughnut") {
12657
+ add(
12658
+ `${path3}/props/catAxisTitle`,
12659
+ props.catAxisTitle,
12660
+ "caption",
12661
+ extra
12662
+ );
12663
+ add(
12664
+ `${path3}/props/valAxisTitle`,
12665
+ props.valAxisTitle,
12666
+ "caption",
12667
+ extra
12668
+ );
12669
+ }
12670
+ add(`${path3}/props/caption`, props.caption, "caption", extra);
12671
+ break;
12672
+ }
12673
+ case "image":
12674
+ case "highcharts":
12675
+ case "visual":
12676
+ case "visual-native": {
12677
+ add(`${path3}/props/caption`, props.caption, "caption", extra);
12678
+ break;
12679
+ }
12680
+ case "section": {
12681
+ for (const part of ["header", "footer"]) {
12682
+ const components = props[part];
12683
+ if (!Array.isArray(components)) continue;
12684
+ components.forEach((component, index) => {
12685
+ const rec = asRecord(component);
12686
+ if (rec) {
12687
+ visitNode(rec, `${path3}/props/${part}/${index}`, {
12688
+ repeats: true
12689
+ });
12690
+ }
12691
+ });
12692
+ }
12693
+ break;
12694
+ }
12695
+ default:
12696
+ break;
12697
+ }
12698
+ if (Array.isArray(node.children)) {
12699
+ node.children.forEach((child, index) => {
12700
+ const rec = asRecord(child);
12701
+ if (rec) visitNode(rec, `${path3}/children/${index}`, scope);
12702
+ });
12703
+ }
12704
+ };
12705
+ children.forEach((child, index) => {
12706
+ const rec = asRecord(child);
12707
+ if (rec) visitNode(rec, `${basePath}/${index}`, {});
12708
+ });
12709
+ for (const toc of [...tocs].reverse()) {
12710
+ const collected = headings.filter(
12711
+ (heading) => (toc.section === void 0 || heading.section === toc.section) && (heading.level !== void 0 ? heading.level >= toc.depth.from && heading.level <= toc.depth.to : heading.themeStyle !== void 0 && toc.styles.has(heading.themeStyle))
12712
+ );
12713
+ entries.splice(
12714
+ toc.at,
12715
+ 0,
12716
+ ...collected.map(
12717
+ (heading, index) => ({
12718
+ id: `docx:text:${toc.path}:entry:${index}`,
12719
+ kind: "docx/text",
12720
+ path: toc.path,
12721
+ text: heading.text,
12722
+ role: "toc-entry",
12723
+ order: 0,
12724
+ optional: true
12725
+ })
12726
+ )
12727
+ );
12728
+ }
12729
+ entries.forEach((entry, index) => {
12730
+ entry.order = index;
12731
+ });
12732
+ return entries;
12733
+ }
12734
+
12735
+ // src/quality/facts.ts
12736
+ function asRecord2(value) {
12737
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
12738
+ }
12488
12739
  function pageBox(theme, themeName, pageOverride) {
12489
12740
  const page = createSectionProperties(
12490
12741
  getColumnSettings("single"),
@@ -12510,7 +12761,7 @@ function tableFact(props, path3, availableWidthTwips) {
12510
12761
  let percentSum = 0;
12511
12762
  const explicitWidths = [];
12512
12763
  columns.forEach((column, index) => {
12513
- const width = asRecord(column)?.width;
12764
+ const width = asRecord2(column)?.width;
12514
12765
  if (typeof width === "number" && Number.isFinite(width)) {
12515
12766
  hasExplicitWidth = true;
12516
12767
  explicitWidths.push({ index, width });
@@ -12591,7 +12842,7 @@ function chartFact(node, props, path3, paletteTokens) {
12591
12842
  const categoryCount = Math.max(
12592
12843
  0,
12593
12844
  ...series.map((entry) => {
12594
- const record = asRecord(entry);
12845
+ const record = asRecord2(entry);
12595
12846
  const labels = Array.isArray(record?.labels) ? record.labels.length : 0;
12596
12847
  const values = Array.isArray(record?.values) ? record.values.length : 0;
12597
12848
  return Math.max(labels, values);
@@ -12633,8 +12884,8 @@ function statesOwnBorders(authored) {
12633
12884
  return true;
12634
12885
  }
12635
12886
  const layers = [
12636
- asRecord(authored.cellDefaults),
12637
- asRecord(authored.headerCellDefaults)
12887
+ asRecord2(authored.cellDefaults),
12888
+ asRecord2(authored.headerCellDefaults)
12638
12889
  ];
12639
12890
  if (layers.some(
12640
12891
  (layer) => layer?.borderSize !== void 0 || layer?.borderColor !== void 0
@@ -12643,8 +12894,8 @@ function statesOwnBorders(authored) {
12643
12894
  }
12644
12895
  const columns = Array.isArray(authored.columns) ? authored.columns : [];
12645
12896
  return columns.some((column) => {
12646
- const record = asRecord(column);
12647
- const defaults = asRecord(record?.cellDefaults);
12897
+ const record = asRecord2(column);
12898
+ const defaults = asRecord2(record?.cellDefaults);
12648
12899
  return defaults?.borderSize !== void 0 || defaults?.borderColor !== void 0;
12649
12900
  });
12650
12901
  }
@@ -12668,7 +12919,7 @@ function tableDesignFact(props, path3, theme, themeName, authored) {
12668
12919
  );
12669
12920
  const columns = authoredColumns.map(
12670
12921
  (column, index) => {
12671
- const authoredColumn = asRecord(column) ?? {};
12922
+ const authoredColumn = asRecord2(column) ?? {};
12672
12923
  const cells = Array.isArray(authoredColumn.cells) ? authoredColumn.cells : [];
12673
12924
  const alignments = /* @__PURE__ */ new Set();
12674
12925
  const values = [];
@@ -12687,11 +12938,11 @@ function tableDesignFact(props, path3, theme, themeName, authored) {
12687
12938
  },
12688
12939
  values,
12689
12940
  alignment: alignments.size === 1 ? [...alignments][0] : alignments.size === 0 ? "left" : "mixed",
12690
- hasCellDefaults: asRecord(authoredColumn.cellDefaults) !== void 0,
12691
- hasHeader: asRecord(authoredColumn.header) !== void 0,
12941
+ hasCellDefaults: asRecord2(authoredColumn.cellDefaults) !== void 0,
12942
+ hasHeader: asRecord2(authoredColumn.header) !== void 0,
12692
12943
  generated: false,
12693
12944
  cellsWithOwnAlignment: cells.flatMap((cell, cellIndex) => {
12694
- const alignment2 = asRecord(cell)?.horizontalAlignment;
12945
+ const alignment2 = asRecord2(cell)?.horizontalAlignment;
12695
12946
  return typeof alignment2 === "string" && DOCX_ALIGNMENTS.has(alignment2) && alignment2 !== "right" ? [cellIndex] : [];
12696
12947
  })
12697
12948
  };
@@ -12712,7 +12963,7 @@ function finiteNumber(value) {
12712
12963
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
12713
12964
  }
12714
12965
  function lineHeightPt(fontSizePt, spacing) {
12715
- const rule = asRecord(spacing);
12966
+ const rule = asRecord2(spacing);
12716
12967
  const value = finiteNumber(rule?.value);
12717
12968
  switch (rule?.type) {
12718
12969
  // `exactly` is an absolute line box, and display type routinely sets it
@@ -12729,7 +12980,7 @@ function lineHeightPt(fontSizePt, spacing) {
12729
12980
  }
12730
12981
  }
12731
12982
  function characterSpacingPt(spacing) {
12732
- const rule = asRecord(spacing);
12983
+ const rule = asRecord2(spacing);
12733
12984
  const value = finiteNumber(rule?.value);
12734
12985
  if (rule === void 0 || value === void 0) return 0;
12735
12986
  return rule.type === "condensed" ? -value / TWIPS_PER_POINT3 : value / TWIPS_PER_POINT3;
@@ -12743,7 +12994,7 @@ function nodeAtPointer(root, pointer) {
12743
12994
  current = current[index];
12744
12995
  continue;
12745
12996
  }
12746
- const record = asRecord(current);
12997
+ const record = asRecord2(current);
12747
12998
  if (!record) return void 0;
12748
12999
  current = record[token];
12749
13000
  }
@@ -12759,10 +13010,10 @@ function styleKey(node, props) {
12759
13010
  return typeof props.themeStyle === "string" && props.themeStyle !== "" ? props.themeStyle : "normal";
12760
13011
  }
12761
13012
  function effectiveFontSize(node, props, typography) {
12762
- const authored = finiteNumber(asRecord(props.font)?.size);
13013
+ const authored = finiteNumber(asRecord2(props.font)?.size);
12763
13014
  if (authored !== void 0) return { fontSizePt: authored, authored: true };
12764
13015
  const { styles, theme } = typography;
12765
- const style = asRecord(styles[styleKey(node, props)]) ?? asRecord(styles.normal);
13016
+ const style = asRecord2(styles[styleKey(node, props)]) ?? asRecord2(styles.normal);
12766
13017
  const stated = finiteNumber(style?.size);
12767
13018
  if (stated !== void 0) return { fontSizePt: stated, authored: false };
12768
13019
  const reference = style?.font === "heading" || style?.font === "body" || style?.font === "mono" || style?.font === "light" ? style.font : void 0;
@@ -12772,11 +13023,11 @@ function effectiveFontSize(node, props, typography) {
12772
13023
  function pinnedLineBox(props, path3) {
12773
13024
  const candidates = [
12774
13025
  [props.lineSpacing, `${path3}/props/lineSpacing`],
12775
- [asRecord(props.font)?.lineSpacing, `${path3}/props/font/lineSpacing`]
13026
+ [asRecord2(props.font)?.lineSpacing, `${path3}/props/font/lineSpacing`]
12776
13027
  ];
12777
13028
  for (const [spacing, pointer] of candidates) {
12778
13029
  if (spacing === void 0) continue;
12779
- const rule = asRecord(spacing);
13030
+ const rule = asRecord2(spacing);
12780
13031
  if (rule?.type !== "exactly") return void 0;
12781
13032
  const lineBoxPt = finiteNumber(rule.value);
12782
13033
  return lineBoxPt === void 0 ? void 0 : { lineBoxPt, pointer };
@@ -12802,8 +13053,8 @@ function lineBoxFact(node, props, path3, typography, authored) {
12802
13053
  };
12803
13054
  }
12804
13055
  function frameSignature(floating) {
12805
- const horizontal = asRecord(floating.horizontalPosition);
12806
- const vertical = asRecord(floating.verticalPosition);
13056
+ const horizontal = asRecord2(floating.horizontalPosition);
13057
+ const vertical = asRecord2(floating.verticalPosition);
12807
13058
  return JSON.stringify([
12808
13059
  floating.width ?? null,
12809
13060
  floating.height ?? null,
@@ -12813,24 +13064,24 @@ function frameSignature(floating) {
12813
13064
  vertical?.offset ?? null,
12814
13065
  vertical?.relative ?? null,
12815
13066
  vertical?.align ?? null,
12816
- asRecord(floating.wrap)?.type ?? null
13067
+ asRecord2(floating.wrap)?.type ?? null
12817
13068
  ]);
12818
13069
  }
12819
13070
  function frameTextFact(props, path3, page, frameChainId, flowIndex) {
12820
- const floating = asRecord(props.floating);
13071
+ const floating = asRecord2(props.floating);
12821
13072
  const frameWidthTwips = finiteNumber(floating?.width);
12822
13073
  if (frameWidthTwips === void 0) return void 0;
12823
13074
  const text = typeof props.text === "string" ? props.text : "";
12824
13075
  if (text.trim() === "") return void 0;
12825
- const font = asRecord(props.font);
13076
+ const font = asRecord2(props.font);
12826
13077
  const fontSizePt = finiteNumber(font?.size);
12827
13078
  if (fontSizePt === void 0) return void 0;
12828
13079
  const longestWord = text.split(/\s+/).reduce(
12829
13080
  (longest, word) => word.length > longest.length ? word : longest,
12830
13081
  ""
12831
13082
  );
12832
- const horizontal = asRecord(floating?.horizontalPosition);
12833
- const vertical = asRecord(floating?.verticalPosition);
13083
+ const horizontal = asRecord2(floating?.horizontalPosition);
13084
+ const vertical = asRecord2(floating?.verticalPosition);
12834
13085
  const offsetX = finiteNumber(horizontal?.offset);
12835
13086
  const offsetY = finiteNumber(vertical?.offset);
12836
13087
  const absolutelyPinned = horizontal?.offset !== void 0 || vertical?.offset !== void 0;
@@ -12901,7 +13152,7 @@ function svgTextFacts(props, path3) {
12901
13152
  return facts;
12902
13153
  }
12903
13154
  function walkActive(node, path3, page, visit) {
12904
- const rec = asRecord(node);
13155
+ const rec = asRecord2(node);
12905
13156
  if (!rec || rec.enabled === false) return;
12906
13157
  visit(rec, path3, page);
12907
13158
  const children = Array.isArray(rec.children) ? rec.children : [];
@@ -12924,7 +13175,7 @@ function textSizeFact(node, props, path3, typography, role) {
12924
13175
  }
12925
13176
  function tableTextSizeFacts(props, authored, path3, typography, page) {
12926
13177
  const facts = [];
12927
- const sizeOf = (holder) => finiteNumber(asRecord(asRecord(holder)?.font)?.size);
13178
+ const sizeOf = (holder) => finiteNumber(asRecord2(asRecord2(holder)?.font)?.size);
12928
13179
  const authoredSize = (holder, pointer, role) => {
12929
13180
  const size = sizeOf(holder);
12930
13181
  if (size === void 0) return;
@@ -12939,11 +13190,11 @@ function tableTextSizeFacts(props, authored, path3, typography, page) {
12939
13190
  });
12940
13191
  };
12941
13192
  const cellContent = (holder, pointer, role) => {
12942
- const content = asRecord(holder)?.content;
12943
- if (asRecord(content) === void 0) return;
13193
+ const content = asRecord2(holder)?.content;
13194
+ if (asRecord2(content) === void 0) return;
12944
13195
  walkActive(content, `${pointer}/content`, page, (node, nodePath) => {
12945
13196
  if (node.name !== "paragraph" && node.name !== "heading") return;
12946
- const nodeProps = asRecord(node.props) ?? {};
13197
+ const nodeProps = asRecord2(node.props) ?? {};
12947
13198
  if (typeof nodeProps.text !== "string" || nodeProps.text.trim() === "")
12948
13199
  return;
12949
13200
  const fact = textSizeFact(node, nodeProps, nodePath, typography, role);
@@ -12963,7 +13214,7 @@ function tableTextSizeFacts(props, authored, path3, typography, page) {
12963
13214
  );
12964
13215
  const columns = Array.isArray(authored.columns) ? authored.columns : [];
12965
13216
  columns.forEach((column, index) => {
12966
- const record = asRecord(column) ?? {};
13217
+ const record = asRecord2(column) ?? {};
12967
13218
  const columnPath = `${path3}/props/columns/${index}`;
12968
13219
  authoredSize(
12969
13220
  record.cellDefaults,
@@ -13060,7 +13311,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13060
13311
  let inherited = {};
13061
13312
  topLevel.forEach((node, index) => {
13062
13313
  if (node?.name !== "section") return;
13063
- const props = asRecord(node.props) ?? {};
13314
+ const props = asRecord2(node.props) ?? {};
13064
13315
  const part = (kind) => props[kind] === "linkToPrevious" ? inherited[kind] : props[kind];
13065
13316
  const header = part("header");
13066
13317
  const footer = part("footer");
@@ -13068,8 +13319,8 @@ function prepareDocxQualityDocument(document, options = {}) {
13068
13319
  for (const kind of ["header", "footer"]) {
13069
13320
  if (!Array.isArray(props[kind])) continue;
13070
13321
  const drawnByBlock = !Array.isArray(
13071
- asRecord(
13072
- asRecord(
13322
+ asRecord2(
13323
+ asRecord2(
13073
13324
  (Array.isArray(themed.document.children) ? themed.document.children : [])[index]
13074
13325
  )?.props
13075
13326
  )?.[kind]
@@ -13077,7 +13328,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13077
13328
  const part2 = props[kind];
13078
13329
  const visitChrome = (child, childPath) => {
13079
13330
  if (child.name !== "paragraph" && child.name !== "heading") return;
13080
- const childProps = asRecord(child.props) ?? {};
13331
+ const childProps = asRecord2(child.props) ?? {};
13081
13332
  if (typeof childProps.text !== "string" || childProps.text.trim() === "")
13082
13333
  return;
13083
13334
  const fact = textSizeFact(
@@ -13134,7 +13385,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13134
13385
  const paletteTokens = resolved.theme.palette?.chart?.map(
13135
13386
  (value) => `#${resolveDesignColor2(value, visualColors)}`
13136
13387
  ) ?? SERIES_COLOR_TOKENS.filter((token) => paletteHexes[token] !== void 0);
13137
- const authoredPropsAt = (pointer) => asRecord(asRecord(nodeAtPointer(context.document, pointer))?.props);
13388
+ const authoredPropsAt = (pointer) => asRecord2(asRecord2(nodeAtPointer(context.document, pointer))?.props);
13138
13389
  const roleSizesPt = {};
13139
13390
  for (const key of Object.keys(typography.styles)) {
13140
13391
  const size = effectiveFontSize(
@@ -13170,7 +13421,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13170
13421
  fontFamilies: [
13171
13422
  ...new Set(
13172
13423
  ["heading", "body"].flatMap((role) => {
13173
- const family = asRecord(
13424
+ const family = asRecord2(
13174
13425
  resolved.theme.fonts?.[role]
13175
13426
  )?.family;
13176
13427
  return typeof family === "string" && family.trim() !== "" ? [family] : [];
@@ -13206,12 +13457,15 @@ function prepareDocxQualityDocument(document, options = {}) {
13206
13457
  excerpt: occurrence.match.excerpt
13207
13458
  });
13208
13459
  });
13460
+ for (const entry of collectDocxTextInventory(resolved.children)) {
13461
+ addFact({ ...entry, generated: authoredPath(entry.path) !== entry.path });
13462
+ }
13209
13463
  let previousVisitPath;
13210
13464
  let lastFrame;
13211
13465
  let flowIndex = 0;
13212
13466
  const parentOf = (path3) => path3.slice(0, path3.lastIndexOf("/"));
13213
13467
  const visit = (node, path3, page) => {
13214
- const props = asRecord(node.props) ?? {};
13468
+ const props = asRecord2(node.props) ?? {};
13215
13469
  if (node.name === "table") {
13216
13470
  const fact = tableFact(props, path3, page.availableWidthTwips);
13217
13471
  if (fact) addFact(fact);
@@ -13240,7 +13494,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13240
13494
  return {
13241
13495
  ...column,
13242
13496
  path: authored,
13243
- generated: table2 === void 0 || asRecord(nodeAtPointer(themed.document, table2))?.name !== "table"
13497
+ generated: table2 === void 0 || asRecord2(nodeAtPointer(themed.document, table2))?.name !== "table"
13244
13498
  };
13245
13499
  })
13246
13500
  });
@@ -13256,7 +13510,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13256
13510
  addFact({
13257
13511
  ...fact,
13258
13512
  generated: !["chart", "highcharts"].includes(
13259
- String(asRecord(nodeAtPointer(themed.document, authored))?.name)
13513
+ String(asRecord2(nodeAtPointer(themed.document, authored))?.name)
13260
13514
  ),
13261
13515
  seriesColorsPath: authoredPath(fact.seriesColorsPath),
13262
13516
  ...fact.annotation && {
@@ -13270,7 +13524,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13270
13524
  }
13271
13525
  }
13272
13526
  if (node.name === "paragraph" || node.name === "text-box") {
13273
- const floating = asRecord(props.floating);
13527
+ const floating = asRecord2(props.floating);
13274
13528
  if (floating) {
13275
13529
  const signature = frameSignature(floating);
13276
13530
  const chainId = lastFrame !== void 0 && previousVisitPath === lastFrame.path && parentOf(lastFrame.path) === parentOf(path3) && lastFrame.signature === signature ? lastFrame.chainId : `docx:frame-chain:${path3}`;