@json-to-office/core-docx 4.0.0 → 4.1.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +211 -40
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +210 -40
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/quality/facts.d.ts +2 -1
- package/dist/quality/facts.d.ts.map +1 -1
- package/dist/quality/text-inventory.d.ts +45 -0
- package/dist/quality/text-inventory.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { isNodeEnvironment, hasNodeBuiltins } from './utils/environment';
|
|
|
13
13
|
export { analyzeDocxQuality } from './quality/preflight';
|
|
14
14
|
export type { DocxQualityAnalysisOptions, DocxQualityOptions, } from './quality/preflight';
|
|
15
15
|
export { prepareDocxQualityDocument, type DocxHeadingFact, type DocxQualityFact, type DocxQualityModel, type DocxTableWidthFact, type PrepareDocxQualityOptions, } from './quality/facts';
|
|
16
|
+
export { collectDocxTextInventory, type DocxTextFact, type DocxTextRole, } from './quality/text-inventory';
|
|
16
17
|
export { DOCX_DEFAULT_QUALITY_PROFILE, DOCX_QUALITY_PROFILES, DOCX_QUALITY_RULES, docxQualityEngine, declaredDocxQualityProfile, resolveDocxQualityProfile, } from './quality/rules';
|
|
17
18
|
export { generateWarningsDocument, formatWarningsText, } from './utils/warningsDocument';
|
|
18
19
|
export { themes, minimalTheme, devportalTheme, vermilionTheme, consultingTheme, } from './styles/index';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAID,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,wB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3B,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12396,9 +12396,176 @@ async function expandBlocksWithPlugins(document, theme, plugins, render, preserv
|
|
|
12396
12396
|
init_styleHelpers();
|
|
12397
12397
|
init_defaults();
|
|
12398
12398
|
init_widthUtils();
|
|
12399
|
+
|
|
12400
|
+
// src/quality/text-inventory.ts
|
|
12399
12401
|
function asRecord(value) {
|
|
12400
12402
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
12401
12403
|
}
|
|
12404
|
+
function twipsToPt(value) {
|
|
12405
|
+
return typeof value === "number" && Number.isFinite(value) ? value / 20 : void 0;
|
|
12406
|
+
}
|
|
12407
|
+
function frameOf(props) {
|
|
12408
|
+
const widthPt = twipsToPt(asRecord(props.floating)?.width);
|
|
12409
|
+
return widthPt === void 0 ? void 0 : { widthPt };
|
|
12410
|
+
}
|
|
12411
|
+
function collectDocxTextInventory(children, basePath = "/children") {
|
|
12412
|
+
const entries = [];
|
|
12413
|
+
const add = (path4, text, role, extra = {}) => {
|
|
12414
|
+
if (typeof text !== "string" || text.trim() === "") return;
|
|
12415
|
+
entries.push({
|
|
12416
|
+
id: `docx:text:${path4}`,
|
|
12417
|
+
kind: "docx/text",
|
|
12418
|
+
path: path4,
|
|
12419
|
+
text,
|
|
12420
|
+
role,
|
|
12421
|
+
order: entries.length,
|
|
12422
|
+
...extra
|
|
12423
|
+
});
|
|
12424
|
+
};
|
|
12425
|
+
const visitCell = (cell, path4, role, inherited) => {
|
|
12426
|
+
const cellRole = inherited.repeats ? "chrome" : role;
|
|
12427
|
+
const extra = inherited.repeats ? { repeats: true } : {};
|
|
12428
|
+
if (typeof cell === "string") {
|
|
12429
|
+
add(path4, cell, cellRole, extra);
|
|
12430
|
+
return;
|
|
12431
|
+
}
|
|
12432
|
+
const rec = asRecord(cell);
|
|
12433
|
+
if (!rec) return;
|
|
12434
|
+
if ("content" in rec) {
|
|
12435
|
+
if (typeof rec.content === "string")
|
|
12436
|
+
add(`${path4}/content`, rec.content, cellRole, extra);
|
|
12437
|
+
else {
|
|
12438
|
+
const inner = asRecord(rec.content);
|
|
12439
|
+
if (inner) visitNode(inner, `${path4}/content`, inherited);
|
|
12440
|
+
}
|
|
12441
|
+
return;
|
|
12442
|
+
}
|
|
12443
|
+
if (typeof rec.name === "string") visitNode(rec, path4, inherited);
|
|
12444
|
+
};
|
|
12445
|
+
const visitNode = (node, path4, inherited) => {
|
|
12446
|
+
if (node.enabled === false) return;
|
|
12447
|
+
const props = asRecord(node.props) ?? {};
|
|
12448
|
+
const name = typeof node.name === "string" ? node.name : "";
|
|
12449
|
+
const extra = {
|
|
12450
|
+
...inherited.repeats && { repeats: true }
|
|
12451
|
+
};
|
|
12452
|
+
switch (name) {
|
|
12453
|
+
case "heading": {
|
|
12454
|
+
if (inherited.repeats) {
|
|
12455
|
+
add(`${path4}/props/text`, props.text, "chrome", extra);
|
|
12456
|
+
break;
|
|
12457
|
+
}
|
|
12458
|
+
const level = typeof props.level === "number" && Number.isFinite(props.level) ? props.level : 1;
|
|
12459
|
+
add(`${path4}/props/text`, props.text, "heading", { ...extra, level });
|
|
12460
|
+
break;
|
|
12461
|
+
}
|
|
12462
|
+
case "paragraph": {
|
|
12463
|
+
const frame = frameOf(props);
|
|
12464
|
+
add(
|
|
12465
|
+
`${path4}/props/text`,
|
|
12466
|
+
props.text,
|
|
12467
|
+
inherited.repeats ? "chrome" : "body",
|
|
12468
|
+
{
|
|
12469
|
+
...extra,
|
|
12470
|
+
...frame && { frame }
|
|
12471
|
+
}
|
|
12472
|
+
);
|
|
12473
|
+
break;
|
|
12474
|
+
}
|
|
12475
|
+
case "list": {
|
|
12476
|
+
if (Array.isArray(props.items)) {
|
|
12477
|
+
props.items.forEach((item, index) => {
|
|
12478
|
+
const itemPath = `${path4}/props/items/${index}`;
|
|
12479
|
+
if (typeof item === "string")
|
|
12480
|
+
add(itemPath, item, "list-item", extra);
|
|
12481
|
+
else {
|
|
12482
|
+
const rec = asRecord(item);
|
|
12483
|
+
if (rec) add(`${itemPath}/text`, rec.text, "list-item", extra);
|
|
12484
|
+
}
|
|
12485
|
+
});
|
|
12486
|
+
}
|
|
12487
|
+
break;
|
|
12488
|
+
}
|
|
12489
|
+
case "table": {
|
|
12490
|
+
const columns = Array.isArray(props.columns) ? props.columns.map(asRecord) : [];
|
|
12491
|
+
columns.forEach((column, columnIndex) => {
|
|
12492
|
+
if (!column) return;
|
|
12493
|
+
visitCell(
|
|
12494
|
+
column.header,
|
|
12495
|
+
`${path4}/props/columns/${columnIndex}/header`,
|
|
12496
|
+
"table-header",
|
|
12497
|
+
inherited
|
|
12498
|
+
);
|
|
12499
|
+
});
|
|
12500
|
+
const rows = Math.max(
|
|
12501
|
+
0,
|
|
12502
|
+
...columns.map(
|
|
12503
|
+
(column) => Array.isArray(column?.cells) ? column.cells.length : 0
|
|
12504
|
+
)
|
|
12505
|
+
);
|
|
12506
|
+
for (let row = 0; row < rows; row++) {
|
|
12507
|
+
columns.forEach((column, columnIndex) => {
|
|
12508
|
+
if (!column || !Array.isArray(column.cells)) return;
|
|
12509
|
+
if (row >= column.cells.length) return;
|
|
12510
|
+
visitCell(
|
|
12511
|
+
column.cells[row],
|
|
12512
|
+
`${path4}/props/columns/${columnIndex}/cells/${row}`,
|
|
12513
|
+
"table-cell",
|
|
12514
|
+
inherited
|
|
12515
|
+
);
|
|
12516
|
+
});
|
|
12517
|
+
}
|
|
12518
|
+
break;
|
|
12519
|
+
}
|
|
12520
|
+
case "statistic": {
|
|
12521
|
+
add(`${path4}/props/number`, props.number, "statistic", extra);
|
|
12522
|
+
add(`${path4}/props/description`, props.description, "statistic", extra);
|
|
12523
|
+
break;
|
|
12524
|
+
}
|
|
12525
|
+
case "image":
|
|
12526
|
+
case "chart":
|
|
12527
|
+
case "highcharts":
|
|
12528
|
+
case "visual":
|
|
12529
|
+
case "visual-native": {
|
|
12530
|
+
add(`${path4}/props/caption`, props.caption, "caption", extra);
|
|
12531
|
+
break;
|
|
12532
|
+
}
|
|
12533
|
+
case "section": {
|
|
12534
|
+
for (const part of ["header", "footer"]) {
|
|
12535
|
+
const components = props[part];
|
|
12536
|
+
if (!Array.isArray(components)) continue;
|
|
12537
|
+
components.forEach((component, index) => {
|
|
12538
|
+
const rec = asRecord(component);
|
|
12539
|
+
if (rec) {
|
|
12540
|
+
visitNode(rec, `${path4}/props/${part}/${index}`, {
|
|
12541
|
+
repeats: true
|
|
12542
|
+
});
|
|
12543
|
+
}
|
|
12544
|
+
});
|
|
12545
|
+
}
|
|
12546
|
+
break;
|
|
12547
|
+
}
|
|
12548
|
+
default:
|
|
12549
|
+
break;
|
|
12550
|
+
}
|
|
12551
|
+
if (Array.isArray(node.children)) {
|
|
12552
|
+
node.children.forEach((child, index) => {
|
|
12553
|
+
const rec = asRecord(child);
|
|
12554
|
+
if (rec) visitNode(rec, `${path4}/children/${index}`, inherited);
|
|
12555
|
+
});
|
|
12556
|
+
}
|
|
12557
|
+
};
|
|
12558
|
+
children.forEach((child, index) => {
|
|
12559
|
+
const rec = asRecord(child);
|
|
12560
|
+
if (rec) visitNode(rec, `${basePath}/${index}`, {});
|
|
12561
|
+
});
|
|
12562
|
+
return entries;
|
|
12563
|
+
}
|
|
12564
|
+
|
|
12565
|
+
// src/quality/facts.ts
|
|
12566
|
+
function asRecord2(value) {
|
|
12567
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
12568
|
+
}
|
|
12402
12569
|
function pageBox(theme, themeName, pageOverride) {
|
|
12403
12570
|
const page = createSectionProperties(
|
|
12404
12571
|
getColumnSettings("single"),
|
|
@@ -12424,7 +12591,7 @@ function tableFact(props, path4, availableWidthTwips) {
|
|
|
12424
12591
|
let percentSum = 0;
|
|
12425
12592
|
const explicitWidths = [];
|
|
12426
12593
|
columns.forEach((column, index) => {
|
|
12427
|
-
const width =
|
|
12594
|
+
const width = asRecord2(column)?.width;
|
|
12428
12595
|
if (typeof width === "number" && Number.isFinite(width)) {
|
|
12429
12596
|
hasExplicitWidth = true;
|
|
12430
12597
|
explicitWidths.push({ index, width });
|
|
@@ -12505,7 +12672,7 @@ function chartFact(node, props, path4, paletteTokens) {
|
|
|
12505
12672
|
const categoryCount = Math.max(
|
|
12506
12673
|
0,
|
|
12507
12674
|
...series.map((entry) => {
|
|
12508
|
-
const record =
|
|
12675
|
+
const record = asRecord2(entry);
|
|
12509
12676
|
const labels = Array.isArray(record?.labels) ? record.labels.length : 0;
|
|
12510
12677
|
const values = Array.isArray(record?.values) ? record.values.length : 0;
|
|
12511
12678
|
return Math.max(labels, values);
|
|
@@ -12547,8 +12714,8 @@ function statesOwnBorders(authored) {
|
|
|
12547
12714
|
return true;
|
|
12548
12715
|
}
|
|
12549
12716
|
const layers = [
|
|
12550
|
-
|
|
12551
|
-
|
|
12717
|
+
asRecord2(authored.cellDefaults),
|
|
12718
|
+
asRecord2(authored.headerCellDefaults)
|
|
12552
12719
|
];
|
|
12553
12720
|
if (layers.some(
|
|
12554
12721
|
(layer) => layer?.borderSize !== void 0 || layer?.borderColor !== void 0
|
|
@@ -12557,8 +12724,8 @@ function statesOwnBorders(authored) {
|
|
|
12557
12724
|
}
|
|
12558
12725
|
const columns = Array.isArray(authored.columns) ? authored.columns : [];
|
|
12559
12726
|
return columns.some((column) => {
|
|
12560
|
-
const record =
|
|
12561
|
-
const defaults =
|
|
12727
|
+
const record = asRecord2(column);
|
|
12728
|
+
const defaults = asRecord2(record?.cellDefaults);
|
|
12562
12729
|
return defaults?.borderSize !== void 0 || defaults?.borderColor !== void 0;
|
|
12563
12730
|
});
|
|
12564
12731
|
}
|
|
@@ -12582,7 +12749,7 @@ function tableDesignFact(props, path4, theme, themeName, authored) {
|
|
|
12582
12749
|
);
|
|
12583
12750
|
const columns = authoredColumns.map(
|
|
12584
12751
|
(column, index) => {
|
|
12585
|
-
const authoredColumn =
|
|
12752
|
+
const authoredColumn = asRecord2(column) ?? {};
|
|
12586
12753
|
const cells = Array.isArray(authoredColumn.cells) ? authoredColumn.cells : [];
|
|
12587
12754
|
const alignments = /* @__PURE__ */ new Set();
|
|
12588
12755
|
const values = [];
|
|
@@ -12601,11 +12768,11 @@ function tableDesignFact(props, path4, theme, themeName, authored) {
|
|
|
12601
12768
|
},
|
|
12602
12769
|
values,
|
|
12603
12770
|
alignment: alignments.size === 1 ? [...alignments][0] : alignments.size === 0 ? "left" : "mixed",
|
|
12604
|
-
hasCellDefaults:
|
|
12605
|
-
hasHeader:
|
|
12771
|
+
hasCellDefaults: asRecord2(authoredColumn.cellDefaults) !== void 0,
|
|
12772
|
+
hasHeader: asRecord2(authoredColumn.header) !== void 0,
|
|
12606
12773
|
generated: false,
|
|
12607
12774
|
cellsWithOwnAlignment: cells.flatMap((cell, cellIndex) => {
|
|
12608
|
-
const alignment2 =
|
|
12775
|
+
const alignment2 = asRecord2(cell)?.horizontalAlignment;
|
|
12609
12776
|
return typeof alignment2 === "string" && DOCX_ALIGNMENTS.has(alignment2) && alignment2 !== "right" ? [cellIndex] : [];
|
|
12610
12777
|
})
|
|
12611
12778
|
};
|
|
@@ -12626,7 +12793,7 @@ function finiteNumber(value) {
|
|
|
12626
12793
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
12627
12794
|
}
|
|
12628
12795
|
function lineHeightPt(fontSizePt, spacing) {
|
|
12629
|
-
const rule =
|
|
12796
|
+
const rule = asRecord2(spacing);
|
|
12630
12797
|
const value = finiteNumber(rule?.value);
|
|
12631
12798
|
switch (rule?.type) {
|
|
12632
12799
|
// `exactly` is an absolute line box, and display type routinely sets it
|
|
@@ -12643,7 +12810,7 @@ function lineHeightPt(fontSizePt, spacing) {
|
|
|
12643
12810
|
}
|
|
12644
12811
|
}
|
|
12645
12812
|
function characterSpacingPt(spacing) {
|
|
12646
|
-
const rule =
|
|
12813
|
+
const rule = asRecord2(spacing);
|
|
12647
12814
|
const value = finiteNumber(rule?.value);
|
|
12648
12815
|
if (rule === void 0 || value === void 0) return 0;
|
|
12649
12816
|
return rule.type === "condensed" ? -value / TWIPS_PER_POINT3 : value / TWIPS_PER_POINT3;
|
|
@@ -12657,7 +12824,7 @@ function nodeAtPointer(root, pointer) {
|
|
|
12657
12824
|
current = current[index];
|
|
12658
12825
|
continue;
|
|
12659
12826
|
}
|
|
12660
|
-
const record =
|
|
12827
|
+
const record = asRecord2(current);
|
|
12661
12828
|
if (!record) return void 0;
|
|
12662
12829
|
current = record[token];
|
|
12663
12830
|
}
|
|
@@ -12673,10 +12840,10 @@ function styleKey(node, props) {
|
|
|
12673
12840
|
return typeof props.themeStyle === "string" && props.themeStyle !== "" ? props.themeStyle : "normal";
|
|
12674
12841
|
}
|
|
12675
12842
|
function effectiveFontSize(node, props, typography) {
|
|
12676
|
-
const authored = finiteNumber(
|
|
12843
|
+
const authored = finiteNumber(asRecord2(props.font)?.size);
|
|
12677
12844
|
if (authored !== void 0) return { fontSizePt: authored, authored: true };
|
|
12678
12845
|
const { styles, theme } = typography;
|
|
12679
|
-
const style =
|
|
12846
|
+
const style = asRecord2(styles[styleKey(node, props)]) ?? asRecord2(styles.normal);
|
|
12680
12847
|
const stated = finiteNumber(style?.size);
|
|
12681
12848
|
if (stated !== void 0) return { fontSizePt: stated, authored: false };
|
|
12682
12849
|
const reference = style?.font === "heading" || style?.font === "body" || style?.font === "mono" || style?.font === "light" ? style.font : void 0;
|
|
@@ -12686,11 +12853,11 @@ function effectiveFontSize(node, props, typography) {
|
|
|
12686
12853
|
function pinnedLineBox(props, path4) {
|
|
12687
12854
|
const candidates = [
|
|
12688
12855
|
[props.lineSpacing, `${path4}/props/lineSpacing`],
|
|
12689
|
-
[
|
|
12856
|
+
[asRecord2(props.font)?.lineSpacing, `${path4}/props/font/lineSpacing`]
|
|
12690
12857
|
];
|
|
12691
12858
|
for (const [spacing, pointer] of candidates) {
|
|
12692
12859
|
if (spacing === void 0) continue;
|
|
12693
|
-
const rule =
|
|
12860
|
+
const rule = asRecord2(spacing);
|
|
12694
12861
|
if (rule?.type !== "exactly") return void 0;
|
|
12695
12862
|
const lineBoxPt = finiteNumber(rule.value);
|
|
12696
12863
|
return lineBoxPt === void 0 ? void 0 : { lineBoxPt, pointer };
|
|
@@ -12716,8 +12883,8 @@ function lineBoxFact(node, props, path4, typography, authored) {
|
|
|
12716
12883
|
};
|
|
12717
12884
|
}
|
|
12718
12885
|
function frameSignature(floating) {
|
|
12719
|
-
const horizontal =
|
|
12720
|
-
const vertical =
|
|
12886
|
+
const horizontal = asRecord2(floating.horizontalPosition);
|
|
12887
|
+
const vertical = asRecord2(floating.verticalPosition);
|
|
12721
12888
|
return JSON.stringify([
|
|
12722
12889
|
floating.width ?? null,
|
|
12723
12890
|
floating.height ?? null,
|
|
@@ -12727,24 +12894,24 @@ function frameSignature(floating) {
|
|
|
12727
12894
|
vertical?.offset ?? null,
|
|
12728
12895
|
vertical?.relative ?? null,
|
|
12729
12896
|
vertical?.align ?? null,
|
|
12730
|
-
|
|
12897
|
+
asRecord2(floating.wrap)?.type ?? null
|
|
12731
12898
|
]);
|
|
12732
12899
|
}
|
|
12733
12900
|
function frameTextFact(props, path4, page, frameChainId, flowIndex) {
|
|
12734
|
-
const floating =
|
|
12901
|
+
const floating = asRecord2(props.floating);
|
|
12735
12902
|
const frameWidthTwips = finiteNumber(floating?.width);
|
|
12736
12903
|
if (frameWidthTwips === void 0) return void 0;
|
|
12737
12904
|
const text = typeof props.text === "string" ? props.text : "";
|
|
12738
12905
|
if (text.trim() === "") return void 0;
|
|
12739
|
-
const font =
|
|
12906
|
+
const font = asRecord2(props.font);
|
|
12740
12907
|
const fontSizePt = finiteNumber(font?.size);
|
|
12741
12908
|
if (fontSizePt === void 0) return void 0;
|
|
12742
12909
|
const longestWord = text.split(/\s+/).reduce(
|
|
12743
12910
|
(longest, word) => word.length > longest.length ? word : longest,
|
|
12744
12911
|
""
|
|
12745
12912
|
);
|
|
12746
|
-
const horizontal =
|
|
12747
|
-
const vertical =
|
|
12913
|
+
const horizontal = asRecord2(floating?.horizontalPosition);
|
|
12914
|
+
const vertical = asRecord2(floating?.verticalPosition);
|
|
12748
12915
|
const offsetX = finiteNumber(horizontal?.offset);
|
|
12749
12916
|
const offsetY = finiteNumber(vertical?.offset);
|
|
12750
12917
|
const absolutelyPinned = horizontal?.offset !== void 0 || vertical?.offset !== void 0;
|
|
@@ -12815,7 +12982,7 @@ function svgTextFacts(props, path4) {
|
|
|
12815
12982
|
return facts;
|
|
12816
12983
|
}
|
|
12817
12984
|
function walkActive(node, path4, page, visit) {
|
|
12818
|
-
const rec =
|
|
12985
|
+
const rec = asRecord2(node);
|
|
12819
12986
|
if (!rec || rec.enabled === false) return;
|
|
12820
12987
|
visit(rec, path4, page);
|
|
12821
12988
|
const children = Array.isArray(rec.children) ? rec.children : [];
|
|
@@ -12838,7 +13005,7 @@ function textSizeFact(node, props, path4, typography, role) {
|
|
|
12838
13005
|
}
|
|
12839
13006
|
function tableTextSizeFacts(props, authored, path4, typography, page) {
|
|
12840
13007
|
const facts = [];
|
|
12841
|
-
const sizeOf = (holder) => finiteNumber(
|
|
13008
|
+
const sizeOf = (holder) => finiteNumber(asRecord2(asRecord2(holder)?.font)?.size);
|
|
12842
13009
|
const authoredSize = (holder, pointer, role) => {
|
|
12843
13010
|
const size = sizeOf(holder);
|
|
12844
13011
|
if (size === void 0) return;
|
|
@@ -12853,11 +13020,11 @@ function tableTextSizeFacts(props, authored, path4, typography, page) {
|
|
|
12853
13020
|
});
|
|
12854
13021
|
};
|
|
12855
13022
|
const cellContent = (holder, pointer, role) => {
|
|
12856
|
-
const content =
|
|
12857
|
-
if (
|
|
13023
|
+
const content = asRecord2(holder)?.content;
|
|
13024
|
+
if (asRecord2(content) === void 0) return;
|
|
12858
13025
|
walkActive(content, `${pointer}/content`, page, (node, nodePath) => {
|
|
12859
13026
|
if (node.name !== "paragraph" && node.name !== "heading") return;
|
|
12860
|
-
const nodeProps =
|
|
13027
|
+
const nodeProps = asRecord2(node.props) ?? {};
|
|
12861
13028
|
if (typeof nodeProps.text !== "string" || nodeProps.text.trim() === "")
|
|
12862
13029
|
return;
|
|
12863
13030
|
const fact = textSizeFact(node, nodeProps, nodePath, typography, role);
|
|
@@ -12877,7 +13044,7 @@ function tableTextSizeFacts(props, authored, path4, typography, page) {
|
|
|
12877
13044
|
);
|
|
12878
13045
|
const columns = Array.isArray(authored.columns) ? authored.columns : [];
|
|
12879
13046
|
columns.forEach((column, index) => {
|
|
12880
|
-
const record =
|
|
13047
|
+
const record = asRecord2(column) ?? {};
|
|
12881
13048
|
const columnPath = `${path4}/props/columns/${index}`;
|
|
12882
13049
|
authoredSize(
|
|
12883
13050
|
record.cellDefaults,
|
|
@@ -12974,7 +13141,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
12974
13141
|
let inherited = {};
|
|
12975
13142
|
topLevel.forEach((node, index) => {
|
|
12976
13143
|
if (node?.name !== "section") return;
|
|
12977
|
-
const props =
|
|
13144
|
+
const props = asRecord2(node.props) ?? {};
|
|
12978
13145
|
const part = (kind) => props[kind] === "linkToPrevious" ? inherited[kind] : props[kind];
|
|
12979
13146
|
const header = part("header");
|
|
12980
13147
|
const footer = part("footer");
|
|
@@ -12982,8 +13149,8 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
12982
13149
|
for (const kind of ["header", "footer"]) {
|
|
12983
13150
|
if (!Array.isArray(props[kind])) continue;
|
|
12984
13151
|
const drawnByBlock = !Array.isArray(
|
|
12985
|
-
|
|
12986
|
-
|
|
13152
|
+
asRecord2(
|
|
13153
|
+
asRecord2(
|
|
12987
13154
|
(Array.isArray(themed.document.children) ? themed.document.children : [])[index]
|
|
12988
13155
|
)?.props
|
|
12989
13156
|
)?.[kind]
|
|
@@ -12991,7 +13158,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
12991
13158
|
const part2 = props[kind];
|
|
12992
13159
|
const visitChrome = (child, childPath) => {
|
|
12993
13160
|
if (child.name !== "paragraph" && child.name !== "heading") return;
|
|
12994
|
-
const childProps =
|
|
13161
|
+
const childProps = asRecord2(child.props) ?? {};
|
|
12995
13162
|
if (typeof childProps.text !== "string" || childProps.text.trim() === "")
|
|
12996
13163
|
return;
|
|
12997
13164
|
const fact = textSizeFact(
|
|
@@ -13048,7 +13215,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13048
13215
|
const paletteTokens = resolved.theme.palette?.chart?.map(
|
|
13049
13216
|
(value) => `#${resolveDesignColor2(value, visualColors)}`
|
|
13050
13217
|
) ?? SERIES_COLOR_TOKENS.filter((token) => paletteHexes[token] !== void 0);
|
|
13051
|
-
const authoredPropsAt = (pointer) =>
|
|
13218
|
+
const authoredPropsAt = (pointer) => asRecord2(asRecord2(nodeAtPointer(context.document, pointer))?.props);
|
|
13052
13219
|
const roleSizesPt = {};
|
|
13053
13220
|
for (const key of Object.keys(typography.styles)) {
|
|
13054
13221
|
const size = effectiveFontSize(
|
|
@@ -13084,7 +13251,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13084
13251
|
fontFamilies: [
|
|
13085
13252
|
...new Set(
|
|
13086
13253
|
["heading", "body"].flatMap((role) => {
|
|
13087
|
-
const family =
|
|
13254
|
+
const family = asRecord2(
|
|
13088
13255
|
resolved.theme.fonts?.[role]
|
|
13089
13256
|
)?.family;
|
|
13090
13257
|
return typeof family === "string" && family.trim() !== "" ? [family] : [];
|
|
@@ -13120,12 +13287,15 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13120
13287
|
excerpt: occurrence.match.excerpt
|
|
13121
13288
|
});
|
|
13122
13289
|
});
|
|
13290
|
+
for (const entry of collectDocxTextInventory(resolved.children)) {
|
|
13291
|
+
addFact({ ...entry, generated: authoredPath(entry.path) !== entry.path });
|
|
13292
|
+
}
|
|
13123
13293
|
let previousVisitPath;
|
|
13124
13294
|
let lastFrame;
|
|
13125
13295
|
let flowIndex = 0;
|
|
13126
13296
|
const parentOf = (path4) => path4.slice(0, path4.lastIndexOf("/"));
|
|
13127
13297
|
const visit = (node, path4, page) => {
|
|
13128
|
-
const props =
|
|
13298
|
+
const props = asRecord2(node.props) ?? {};
|
|
13129
13299
|
if (node.name === "table") {
|
|
13130
13300
|
const fact = tableFact(props, path4, page.availableWidthTwips);
|
|
13131
13301
|
if (fact) addFact(fact);
|
|
@@ -13154,7 +13324,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13154
13324
|
return {
|
|
13155
13325
|
...column,
|
|
13156
13326
|
path: authored,
|
|
13157
|
-
generated: table2 === void 0 ||
|
|
13327
|
+
generated: table2 === void 0 || asRecord2(nodeAtPointer(themed.document, table2))?.name !== "table"
|
|
13158
13328
|
};
|
|
13159
13329
|
})
|
|
13160
13330
|
});
|
|
@@ -13170,7 +13340,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13170
13340
|
addFact({
|
|
13171
13341
|
...fact,
|
|
13172
13342
|
generated: !["chart", "highcharts"].includes(
|
|
13173
|
-
String(
|
|
13343
|
+
String(asRecord2(nodeAtPointer(themed.document, authored))?.name)
|
|
13174
13344
|
),
|
|
13175
13345
|
seriesColorsPath: authoredPath(fact.seriesColorsPath),
|
|
13176
13346
|
...fact.annotation && {
|
|
@@ -13184,7 +13354,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13184
13354
|
}
|
|
13185
13355
|
}
|
|
13186
13356
|
if (node.name === "paragraph" || node.name === "text-box") {
|
|
13187
|
-
const floating =
|
|
13357
|
+
const floating = asRecord2(props.floating);
|
|
13188
13358
|
if (floating) {
|
|
13189
13359
|
const signature = frameSignature(floating);
|
|
13190
13360
|
const chainId = lastFrame !== void 0 && previousVisitPath === lastFrame.path && parentOf(lastFrame.path) === parentOf(path4) && lastFrame.signature === signature ? lastFrame.chainId : `docx:frame-chain:${path4}`;
|
|
@@ -16324,6 +16494,7 @@ export {
|
|
|
16324
16494
|
analyzeDocxQuality,
|
|
16325
16495
|
blockSlotBudgets,
|
|
16326
16496
|
cleanComponentProps,
|
|
16497
|
+
collectDocxTextInventory,
|
|
16327
16498
|
consultingTheme,
|
|
16328
16499
|
createComponent,
|
|
16329
16500
|
createDocumentGenerator,
|