@json-to-office/core-docx 4.1.0 → 4.3.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.js +101 -8
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +101 -8
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/quality/text-inventory.d.ts +14 -1
- package/dist/quality/text-inventory.d.ts.map +1 -1
- package/dist/templates/themes/index.d.ts +125 -0
- package/dist/templates/themes/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -9921,6 +9921,11 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
|
|
|
9921
9921
|
const props = component.props ?? {};
|
|
9922
9922
|
const items = props.items ?? [];
|
|
9923
9923
|
if (items.length === 0) return [];
|
|
9924
|
+
const base = runFormatting3(
|
|
9925
|
+
props.font ?? {},
|
|
9926
|
+
props,
|
|
9927
|
+
ctx
|
|
9928
|
+
);
|
|
9924
9929
|
const notes = createNoteBinding(props.footnotes, props.endnotes, ctx);
|
|
9925
9930
|
const reference = declareNumbering(
|
|
9926
9931
|
props,
|
|
@@ -9956,17 +9961,21 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
|
|
|
9956
9961
|
paragraphNode(
|
|
9957
9962
|
{ ctx, path: itemPath, id: `${scope.id}:i${index}` },
|
|
9958
9963
|
revision === void 0 ? parseInline(text, {
|
|
9959
|
-
base
|
|
9964
|
+
base,
|
|
9960
9965
|
hyperlinks: true,
|
|
9961
9966
|
...notes ? { resolveNote: notes.resolve } : {},
|
|
9962
9967
|
resolvePlaceholder: placeholderResolver(ctx),
|
|
9963
9968
|
resolveCrossReference: crossReferenceResolver(ctx, itemPath)
|
|
9964
|
-
}) : compileRevision(revision,
|
|
9969
|
+
}) : compileRevision(revision, base, ctx),
|
|
9965
9970
|
{
|
|
9966
9971
|
styleId: "Normal",
|
|
9967
9972
|
formatting: {
|
|
9968
9973
|
alignment: compileAlignment(props.alignment) ?? "left",
|
|
9969
|
-
spacing: itemSpacing(props.spacing, index, items.length)
|
|
9974
|
+
spacing: itemSpacing(props.spacing, index, items.length),
|
|
9975
|
+
// Every item carries the flags, not just the first: keeping a list
|
|
9976
|
+
// with what introduces it means keeping it whole.
|
|
9977
|
+
...props.keepNext !== void 0 ? { keepNext: props.keepNext } : {},
|
|
9978
|
+
...props.keepLines !== void 0 ? { keepLines: props.keepLines } : {}
|
|
9970
9979
|
},
|
|
9971
9980
|
...commentIds && index === firstRendered ? { commentOpen: commentIds } : {},
|
|
9972
9981
|
...commentIds && index === lastRendered ? { commentClose: commentIds } : {},
|
|
@@ -12484,6 +12493,12 @@ init_defaults();
|
|
|
12484
12493
|
init_widthUtils();
|
|
12485
12494
|
|
|
12486
12495
|
// src/quality/text-inventory.ts
|
|
12496
|
+
function tocDepth(depth) {
|
|
12497
|
+
const range = asRecord(depth) ?? {};
|
|
12498
|
+
const from = typeof range.from === "number" ? range.from : 1;
|
|
12499
|
+
const to = typeof range.to === "number" ? range.to : 3;
|
|
12500
|
+
return { from, to };
|
|
12501
|
+
}
|
|
12487
12502
|
function asRecord(value) {
|
|
12488
12503
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
12489
12504
|
}
|
|
@@ -12504,10 +12519,14 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12504
12519
|
path: path3,
|
|
12505
12520
|
text,
|
|
12506
12521
|
role,
|
|
12507
|
-
|
|
12522
|
+
// Renumbered once the walk is done: contents entries are spliced in.
|
|
12523
|
+
order: -1,
|
|
12508
12524
|
...extra
|
|
12509
12525
|
});
|
|
12510
12526
|
};
|
|
12527
|
+
const headings = [];
|
|
12528
|
+
const tocs = [];
|
|
12529
|
+
let sectionCount = 0;
|
|
12511
12530
|
const visitCell = (cell, path3, role, inherited) => {
|
|
12512
12531
|
const cellRole = inherited.repeats ? "chrome" : role;
|
|
12513
12532
|
const extra = inherited.repeats ? { repeats: true } : {};
|
|
@@ -12522,11 +12541,13 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12522
12541
|
add(`${path3}/content`, rec.content, cellRole, extra);
|
|
12523
12542
|
else {
|
|
12524
12543
|
const inner = asRecord(rec.content);
|
|
12525
|
-
if (inner)
|
|
12544
|
+
if (inner)
|
|
12545
|
+
visitNode(inner, `${path3}/content`, { ...inherited, inCell: true });
|
|
12526
12546
|
}
|
|
12527
12547
|
return;
|
|
12528
12548
|
}
|
|
12529
|
-
if (typeof rec.name === "string")
|
|
12549
|
+
if (typeof rec.name === "string")
|
|
12550
|
+
visitNode(rec, path3, { ...inherited, inCell: true });
|
|
12530
12551
|
};
|
|
12531
12552
|
const visitNode = (node, path3, inherited) => {
|
|
12532
12553
|
if (node.enabled === false) return;
|
|
@@ -12535,6 +12556,7 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12535
12556
|
const extra = {
|
|
12536
12557
|
...inherited.repeats && { repeats: true }
|
|
12537
12558
|
};
|
|
12559
|
+
const scope = name === "section" ? { ...inherited, section: ++sectionCount } : inherited;
|
|
12538
12560
|
switch (name) {
|
|
12539
12561
|
case "heading": {
|
|
12540
12562
|
if (inherited.repeats) {
|
|
@@ -12543,6 +12565,27 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12543
12565
|
}
|
|
12544
12566
|
const level = typeof props.level === "number" && Number.isFinite(props.level) ? props.level : 1;
|
|
12545
12567
|
add(`${path3}/props/text`, props.text, "heading", { ...extra, level });
|
|
12568
|
+
if (typeof props.text === "string" && props.text.trim() !== "" && !scope.inCell) {
|
|
12569
|
+
headings.push({ text: props.text, level, section: scope.section });
|
|
12570
|
+
}
|
|
12571
|
+
break;
|
|
12572
|
+
}
|
|
12573
|
+
case "toc": {
|
|
12574
|
+
add(`${path3}/props/title`, props.title, "toc-entry", extra);
|
|
12575
|
+
const styles = /* @__PURE__ */ new Set();
|
|
12576
|
+
if (Array.isArray(props.styles)) {
|
|
12577
|
+
for (const mapping of props.styles) {
|
|
12578
|
+
const id = asRecord(mapping)?.styleId;
|
|
12579
|
+
if (typeof id === "string") styles.add(id);
|
|
12580
|
+
}
|
|
12581
|
+
}
|
|
12582
|
+
tocs.push({
|
|
12583
|
+
at: entries.length,
|
|
12584
|
+
path: path3,
|
|
12585
|
+
depth: tocDepth(props.depth),
|
|
12586
|
+
styles,
|
|
12587
|
+
section: props.scope === "document" ? void 0 : scope.section
|
|
12588
|
+
});
|
|
12546
12589
|
break;
|
|
12547
12590
|
}
|
|
12548
12591
|
case "paragraph": {
|
|
@@ -12556,6 +12599,13 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12556
12599
|
...frame && { frame }
|
|
12557
12600
|
}
|
|
12558
12601
|
);
|
|
12602
|
+
if (typeof props.themeStyle === "string" && typeof props.text === "string" && props.text.trim() !== "" && !scope.inCell) {
|
|
12603
|
+
headings.push({
|
|
12604
|
+
text: props.text,
|
|
12605
|
+
themeStyle: props.themeStyle,
|
|
12606
|
+
section: scope.section
|
|
12607
|
+
});
|
|
12608
|
+
}
|
|
12559
12609
|
break;
|
|
12560
12610
|
}
|
|
12561
12611
|
case "list": {
|
|
@@ -12608,8 +12658,28 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12608
12658
|
add(`${path3}/props/description`, props.description, "statistic", extra);
|
|
12609
12659
|
break;
|
|
12610
12660
|
}
|
|
12661
|
+
case "chart": {
|
|
12662
|
+
if (props.showTitle !== false) {
|
|
12663
|
+
add(`${path3}/props/title`, props.title, "caption", extra);
|
|
12664
|
+
}
|
|
12665
|
+
if (props.type !== "pie" && props.type !== "doughnut") {
|
|
12666
|
+
add(
|
|
12667
|
+
`${path3}/props/catAxisTitle`,
|
|
12668
|
+
props.catAxisTitle,
|
|
12669
|
+
"caption",
|
|
12670
|
+
extra
|
|
12671
|
+
);
|
|
12672
|
+
add(
|
|
12673
|
+
`${path3}/props/valAxisTitle`,
|
|
12674
|
+
props.valAxisTitle,
|
|
12675
|
+
"caption",
|
|
12676
|
+
extra
|
|
12677
|
+
);
|
|
12678
|
+
}
|
|
12679
|
+
add(`${path3}/props/caption`, props.caption, "caption", extra);
|
|
12680
|
+
break;
|
|
12681
|
+
}
|
|
12611
12682
|
case "image":
|
|
12612
|
-
case "chart":
|
|
12613
12683
|
case "highcharts":
|
|
12614
12684
|
case "visual":
|
|
12615
12685
|
case "visual-native": {
|
|
@@ -12637,7 +12707,7 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12637
12707
|
if (Array.isArray(node.children)) {
|
|
12638
12708
|
node.children.forEach((child, index) => {
|
|
12639
12709
|
const rec = asRecord(child);
|
|
12640
|
-
if (rec) visitNode(rec, `${path3}/children/${index}`,
|
|
12710
|
+
if (rec) visitNode(rec, `${path3}/children/${index}`, scope);
|
|
12641
12711
|
});
|
|
12642
12712
|
}
|
|
12643
12713
|
};
|
|
@@ -12645,6 +12715,29 @@ function collectDocxTextInventory(children, basePath = "/children") {
|
|
|
12645
12715
|
const rec = asRecord(child);
|
|
12646
12716
|
if (rec) visitNode(rec, `${basePath}/${index}`, {});
|
|
12647
12717
|
});
|
|
12718
|
+
for (const toc of [...tocs].reverse()) {
|
|
12719
|
+
const collected = headings.filter(
|
|
12720
|
+
(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))
|
|
12721
|
+
);
|
|
12722
|
+
entries.splice(
|
|
12723
|
+
toc.at,
|
|
12724
|
+
0,
|
|
12725
|
+
...collected.map(
|
|
12726
|
+
(heading, index) => ({
|
|
12727
|
+
id: `docx:text:${toc.path}:entry:${index}`,
|
|
12728
|
+
kind: "docx/text",
|
|
12729
|
+
path: toc.path,
|
|
12730
|
+
text: heading.text,
|
|
12731
|
+
role: "toc-entry",
|
|
12732
|
+
order: 0,
|
|
12733
|
+
optional: true
|
|
12734
|
+
})
|
|
12735
|
+
)
|
|
12736
|
+
);
|
|
12737
|
+
}
|
|
12738
|
+
entries.forEach((entry, index) => {
|
|
12739
|
+
entry.order = index;
|
|
12740
|
+
});
|
|
12648
12741
|
return entries;
|
|
12649
12742
|
}
|
|
12650
12743
|
|