bun-docx 0.17.0 → 0.18.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/README.md +11 -0
- package/dist/index.js +1854 -623
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4710,12 +4710,15 @@ var init_jsx = __esm(() => {
|
|
|
4710
4710
|
"type",
|
|
4711
4711
|
"tbl",
|
|
4712
4712
|
"tblPr",
|
|
4713
|
+
"tblStyle",
|
|
4713
4714
|
"tblPrChange",
|
|
4714
4715
|
"tblGrid",
|
|
4715
4716
|
"tblGridChange",
|
|
4716
4717
|
"gridCol",
|
|
4717
4718
|
"tr",
|
|
4718
4719
|
"trPr",
|
|
4720
|
+
"trHeight",
|
|
4721
|
+
"tblHeader",
|
|
4719
4722
|
"tc",
|
|
4720
4723
|
"tcPr",
|
|
4721
4724
|
"tcPrChange",
|
|
@@ -4761,6 +4764,7 @@ var init_jsx = __esm(() => {
|
|
|
4761
4764
|
"tcW",
|
|
4762
4765
|
"tblLayout",
|
|
4763
4766
|
"vMerge",
|
|
4767
|
+
"vAlign",
|
|
4764
4768
|
"gridSpan",
|
|
4765
4769
|
"numbering",
|
|
4766
4770
|
"num",
|
|
@@ -21607,6 +21611,481 @@ var init_body = __esm(() => {
|
|
|
21607
21611
|
};
|
|
21608
21612
|
});
|
|
21609
21613
|
|
|
21614
|
+
// src/core/ast/document/numbering.tsx
|
|
21615
|
+
function numFmtToFormat(numFmt) {
|
|
21616
|
+
return NUMFMT_TO_FORMAT[numFmt] ?? numFmt;
|
|
21617
|
+
}
|
|
21618
|
+
|
|
21619
|
+
class NumberingView {
|
|
21620
|
+
tree;
|
|
21621
|
+
constructor(tree = XmlNode2.parse(EMPTY_NUMBERING_XML)) {
|
|
21622
|
+
this.tree = tree;
|
|
21623
|
+
}
|
|
21624
|
+
static async fromPackage(pkg) {
|
|
21625
|
+
const tree = await pkg.readPart(NUMBERING_PART_NAME);
|
|
21626
|
+
return tree ? new NumberingView(tree) : undefined;
|
|
21627
|
+
}
|
|
21628
|
+
static fromXml(xml) {
|
|
21629
|
+
return xml ? new NumberingView(XmlNode2.parse(xml)) : undefined;
|
|
21630
|
+
}
|
|
21631
|
+
writeTo(pkg) {
|
|
21632
|
+
pkg.writeText(NUMBERING_PART_NAME, XmlNode2.serialize(this.tree));
|
|
21633
|
+
}
|
|
21634
|
+
static register(deps) {
|
|
21635
|
+
if (!deps.relationships.hasTarget("numbering.xml")) {
|
|
21636
|
+
deps.relationships.add(NUMBERING_RELATIONSHIP_TYPE, "numbering.xml");
|
|
21637
|
+
}
|
|
21638
|
+
deps.contentTypes.registerPart(NUMBERING_PART_NAME, NUMBERING_CONTENT_TYPE);
|
|
21639
|
+
return new NumberingView;
|
|
21640
|
+
}
|
|
21641
|
+
listNumIds() {
|
|
21642
|
+
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
21643
|
+
if (!root)
|
|
21644
|
+
return [];
|
|
21645
|
+
const out = [];
|
|
21646
|
+
for (const child2 of root.findChildren("w:num")) {
|
|
21647
|
+
const id = child2.getAttribute("w:numId");
|
|
21648
|
+
if (id)
|
|
21649
|
+
out.push(id);
|
|
21650
|
+
}
|
|
21651
|
+
return out;
|
|
21652
|
+
}
|
|
21653
|
+
listAbstractNumIds() {
|
|
21654
|
+
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
21655
|
+
if (!root)
|
|
21656
|
+
return [];
|
|
21657
|
+
const out = [];
|
|
21658
|
+
for (const child2 of root.findChildren("w:abstractNum")) {
|
|
21659
|
+
const id = child2.getAttribute("w:abstractNumId");
|
|
21660
|
+
if (id)
|
|
21661
|
+
out.push(id);
|
|
21662
|
+
}
|
|
21663
|
+
return out;
|
|
21664
|
+
}
|
|
21665
|
+
allocate(kind, start = 1) {
|
|
21666
|
+
const root = this.ensureNumberingRoot();
|
|
21667
|
+
const abstractNumId = this.ensureAbstractNum(root, kind);
|
|
21668
|
+
const numId = nextNumId(root);
|
|
21669
|
+
root.children.push(/* @__PURE__ */ jsxDEV(NumElement, {
|
|
21670
|
+
numId,
|
|
21671
|
+
abstractNumId,
|
|
21672
|
+
start
|
|
21673
|
+
}, undefined, false, undefined, this));
|
|
21674
|
+
return numId;
|
|
21675
|
+
}
|
|
21676
|
+
getLevelInfo(numId, level) {
|
|
21677
|
+
const num = this.findNum(numId);
|
|
21678
|
+
const lvlOverride = num ? this.findLvlOverride(num, level) : undefined;
|
|
21679
|
+
const override = lvlOverride?.findChild("w:lvl")?.findChild("w:numFmt")?.getAttribute("w:val");
|
|
21680
|
+
const abstractNum = this.resolveAbstractNum(numId);
|
|
21681
|
+
const abstractLvl = abstractNum ? findLevel(abstractNum, level) ?? findLevel(abstractNum, 0) : undefined;
|
|
21682
|
+
const format = override ?? abstractLvl?.findChild("w:numFmt")?.getAttribute("w:val");
|
|
21683
|
+
const startRaw = lvlOverride?.findChild("w:startOverride")?.getAttribute("w:val") ?? abstractLvl?.findChild("w:start")?.getAttribute("w:val");
|
|
21684
|
+
const startNum = Number(startRaw);
|
|
21685
|
+
const start = startRaw !== undefined && Number.isFinite(startNum) ? startNum : 1;
|
|
21686
|
+
return { format, override, start };
|
|
21687
|
+
}
|
|
21688
|
+
getFormat(numId, level) {
|
|
21689
|
+
return this.getLevelInfo(numId, level).format;
|
|
21690
|
+
}
|
|
21691
|
+
getBulletText(numId, level) {
|
|
21692
|
+
const fromOverride = this.overrideLevel(numId, level)?.findChild("w:lvlText")?.getAttribute("w:val");
|
|
21693
|
+
if (fromOverride !== undefined)
|
|
21694
|
+
return fromOverride;
|
|
21695
|
+
const abstractNum = this.resolveAbstractNum(numId);
|
|
21696
|
+
if (!abstractNum)
|
|
21697
|
+
return;
|
|
21698
|
+
const lvl = findLevel(abstractNum, level) ?? findLevel(abstractNum, 0);
|
|
21699
|
+
return lvl?.findChild("w:lvlText")?.getAttribute("w:val") ?? undefined;
|
|
21700
|
+
}
|
|
21701
|
+
getStart(numId, level) {
|
|
21702
|
+
return this.getLevelInfo(numId, level).start;
|
|
21703
|
+
}
|
|
21704
|
+
setStart(numId, level, start) {
|
|
21705
|
+
const num = this.findNum(numId);
|
|
21706
|
+
if (!num)
|
|
21707
|
+
return false;
|
|
21708
|
+
const lvlOverride = this.ensureLvlOverride(num, level);
|
|
21709
|
+
const existing = lvlOverride.findChild("w:startOverride");
|
|
21710
|
+
if (existing)
|
|
21711
|
+
existing.setAttribute("w:val", String(start));
|
|
21712
|
+
else
|
|
21713
|
+
insertLvlOverrideChildInOrder(lvlOverride, /* @__PURE__ */ jsxDEV(w.startOverride, {
|
|
21714
|
+
"w-val": String(start)
|
|
21715
|
+
}, undefined, false, undefined, this));
|
|
21716
|
+
return true;
|
|
21717
|
+
}
|
|
21718
|
+
setFormat(numId, level, numFmt) {
|
|
21719
|
+
const num = this.findNum(numId);
|
|
21720
|
+
if (!num)
|
|
21721
|
+
return false;
|
|
21722
|
+
const lvl = this.buildOverrideLevel(numId, level, numFmt);
|
|
21723
|
+
const lvlOverride = this.ensureLvlOverride(num, level);
|
|
21724
|
+
const existing = lvlOverride.findChild("w:lvl");
|
|
21725
|
+
if (existing) {
|
|
21726
|
+
lvlOverride.children.splice(lvlOverride.children.indexOf(existing), 1, lvl);
|
|
21727
|
+
} else {
|
|
21728
|
+
insertLvlOverrideChildInOrder(lvlOverride, lvl);
|
|
21729
|
+
}
|
|
21730
|
+
return true;
|
|
21731
|
+
}
|
|
21732
|
+
cloneListDefinition(srcNumId, start) {
|
|
21733
|
+
const root = this.ensureNumberingRoot();
|
|
21734
|
+
const src = this.findNum(srcNumId);
|
|
21735
|
+
const abstractNumId = src?.findChild("w:abstractNumId")?.getAttribute("w:val") ?? "0";
|
|
21736
|
+
const numId = nextNumId(root);
|
|
21737
|
+
const num = /* @__PURE__ */ jsxDEV(w.num, {
|
|
21738
|
+
"w-numId": String(numId)
|
|
21739
|
+
}, undefined, false, undefined, this);
|
|
21740
|
+
num.children.push(/* @__PURE__ */ jsxDEV(w.abstractNumId, {
|
|
21741
|
+
"w-val": abstractNumId
|
|
21742
|
+
}, undefined, false, undefined, this));
|
|
21743
|
+
if (src) {
|
|
21744
|
+
for (const lvlOverride of src.findChildren("w:lvlOverride")) {
|
|
21745
|
+
const lvl = lvlOverride.findChild("w:lvl");
|
|
21746
|
+
if (!lvl)
|
|
21747
|
+
continue;
|
|
21748
|
+
const carried = /* @__PURE__ */ jsxDEV(w.lvlOverride, {
|
|
21749
|
+
"w-ilvl": lvlOverride.getAttribute("w:ilvl") ?? "0"
|
|
21750
|
+
}, undefined, false, undefined, this);
|
|
21751
|
+
carried.children.push(lvl.clone());
|
|
21752
|
+
num.children.push(carried);
|
|
21753
|
+
}
|
|
21754
|
+
}
|
|
21755
|
+
root.children.push(num);
|
|
21756
|
+
this.setStart(String(numId), 0, start);
|
|
21757
|
+
return numId;
|
|
21758
|
+
}
|
|
21759
|
+
findNum(numId) {
|
|
21760
|
+
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
21761
|
+
return root?.findChildren("w:num").find((node) => node.getAttribute("w:numId") === numId);
|
|
21762
|
+
}
|
|
21763
|
+
findLvlOverride(num, level) {
|
|
21764
|
+
const target = String(level);
|
|
21765
|
+
return num.findChildren("w:lvlOverride").find((node) => node.getAttribute("w:ilvl") === target);
|
|
21766
|
+
}
|
|
21767
|
+
ensureLvlOverride(num, level) {
|
|
21768
|
+
const existing = this.findLvlOverride(num, level);
|
|
21769
|
+
if (existing)
|
|
21770
|
+
return existing;
|
|
21771
|
+
const created = /* @__PURE__ */ jsxDEV(w.lvlOverride, {
|
|
21772
|
+
"w-ilvl": String(level)
|
|
21773
|
+
}, undefined, false, undefined, this);
|
|
21774
|
+
const abstractIdx = num.children.findIndex((child2) => child2.tag === "w:abstractNumId");
|
|
21775
|
+
num.children.splice(abstractIdx + 1, 0, created);
|
|
21776
|
+
return created;
|
|
21777
|
+
}
|
|
21778
|
+
overrideLevel(numId, level) {
|
|
21779
|
+
const num = this.findNum(numId);
|
|
21780
|
+
const lvlOverride = num ? this.findLvlOverride(num, level) : undefined;
|
|
21781
|
+
return lvlOverride?.findChild("w:lvl");
|
|
21782
|
+
}
|
|
21783
|
+
buildOverrideLevel(numId, level, numFmt) {
|
|
21784
|
+
const abstractNum = this.resolveAbstractNum(numId);
|
|
21785
|
+
const base = abstractNum && (findLevel(abstractNum, level) ?? findLevel(abstractNum, 0));
|
|
21786
|
+
const lvl = base ? base.clone() : /* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
21787
|
+
ilvl: level,
|
|
21788
|
+
text: `%${level + 1}.`,
|
|
21789
|
+
fmt: numFmt
|
|
21790
|
+
}, undefined, false, undefined, this);
|
|
21791
|
+
lvl.setAttribute("w:ilvl", String(level));
|
|
21792
|
+
lvl.findChild("w:numFmt")?.setAttribute("w:val", numFmt);
|
|
21793
|
+
lvl.children = lvl.children.filter((child2) => child2.tag !== "w:start");
|
|
21794
|
+
return lvl;
|
|
21795
|
+
}
|
|
21796
|
+
resolveAbstractNum(numId) {
|
|
21797
|
+
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
21798
|
+
if (!root)
|
|
21799
|
+
return;
|
|
21800
|
+
const num = root.findChildren("w:num").find((node) => node.getAttribute("w:numId") === numId);
|
|
21801
|
+
if (!num)
|
|
21802
|
+
return;
|
|
21803
|
+
const abstractNumId = num.findChild("w:abstractNumId")?.getAttribute("w:val");
|
|
21804
|
+
if (!abstractNumId)
|
|
21805
|
+
return;
|
|
21806
|
+
return root.findChildren("w:abstractNum").find((node) => node.getAttribute("w:abstractNumId") === abstractNumId);
|
|
21807
|
+
}
|
|
21808
|
+
ensureNumberingRoot() {
|
|
21809
|
+
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
21810
|
+
if (!root) {
|
|
21811
|
+
throw new Error("expected <w:numbering> root in numbering tree");
|
|
21812
|
+
}
|
|
21813
|
+
return root;
|
|
21814
|
+
}
|
|
21815
|
+
ensureAbstractNum(root, kind) {
|
|
21816
|
+
const targetFormat = kind === "bullet" ? "bullet" : "decimal";
|
|
21817
|
+
for (const child2 of root.findChildren("w:abstractNum")) {
|
|
21818
|
+
const lvl0 = findLevel(child2, 0);
|
|
21819
|
+
const numFmt = lvl0?.findChild("w:numFmt");
|
|
21820
|
+
if (numFmt?.getAttribute("w:val") === targetFormat) {
|
|
21821
|
+
const id = child2.getAttribute("w:abstractNumId");
|
|
21822
|
+
if (id)
|
|
21823
|
+
return Number(id);
|
|
21824
|
+
}
|
|
21825
|
+
}
|
|
21826
|
+
const newId = nextAbstractNumId(root);
|
|
21827
|
+
const def = /* @__PURE__ */ jsxDEV(AbstractNum, {
|
|
21828
|
+
kind,
|
|
21829
|
+
id: newId
|
|
21830
|
+
}, undefined, false, undefined, this);
|
|
21831
|
+
const firstNumIdx = root.children.findIndex((child2) => child2.tag === "w:num");
|
|
21832
|
+
if (firstNumIdx === -1)
|
|
21833
|
+
root.children.push(def);
|
|
21834
|
+
else
|
|
21835
|
+
root.children.splice(firstNumIdx, 0, def);
|
|
21836
|
+
return newId;
|
|
21837
|
+
}
|
|
21838
|
+
}
|
|
21839
|
+
function nextAbstractNumId(root) {
|
|
21840
|
+
let max = -1;
|
|
21841
|
+
for (const child2 of root.findChildren("w:abstractNum")) {
|
|
21842
|
+
const id = child2.getAttribute("w:abstractNumId");
|
|
21843
|
+
if (id) {
|
|
21844
|
+
const numeric = Number(id);
|
|
21845
|
+
if (Number.isFinite(numeric) && numeric > max)
|
|
21846
|
+
max = numeric;
|
|
21847
|
+
}
|
|
21848
|
+
}
|
|
21849
|
+
return max + 1;
|
|
21850
|
+
}
|
|
21851
|
+
function nextNumId(root) {
|
|
21852
|
+
let max = 0;
|
|
21853
|
+
for (const child2 of root.findChildren("w:num")) {
|
|
21854
|
+
const id = child2.getAttribute("w:numId");
|
|
21855
|
+
if (id) {
|
|
21856
|
+
const numeric = Number(id);
|
|
21857
|
+
if (Number.isFinite(numeric) && numeric > max)
|
|
21858
|
+
max = numeric;
|
|
21859
|
+
}
|
|
21860
|
+
}
|
|
21861
|
+
return max + 1;
|
|
21862
|
+
}
|
|
21863
|
+
function insertLvlOverrideChildInOrder(lvlOverride, child2) {
|
|
21864
|
+
const order = ["w:startOverride", "w:lvl"];
|
|
21865
|
+
const rank = order.indexOf(child2.tag);
|
|
21866
|
+
const at = lvlOverride.children.findIndex((existing) => !existing.isText && order.indexOf(existing.tag) > rank);
|
|
21867
|
+
if (at < 0)
|
|
21868
|
+
lvlOverride.children.push(child2);
|
|
21869
|
+
else
|
|
21870
|
+
lvlOverride.children.splice(at, 0, child2);
|
|
21871
|
+
}
|
|
21872
|
+
function findLevel(abstractNum, ilvl) {
|
|
21873
|
+
const target = String(ilvl);
|
|
21874
|
+
return abstractNum.findChildren("w:lvl").find((lvl) => lvl.getAttribute("w:ilvl") === target);
|
|
21875
|
+
}
|
|
21876
|
+
function NumElement({
|
|
21877
|
+
numId,
|
|
21878
|
+
abstractNumId,
|
|
21879
|
+
start
|
|
21880
|
+
}) {
|
|
21881
|
+
return /* @__PURE__ */ jsxDEV(w.num, {
|
|
21882
|
+
"w-numId": String(numId),
|
|
21883
|
+
children: [
|
|
21884
|
+
/* @__PURE__ */ jsxDEV(w.abstractNumId, {
|
|
21885
|
+
"w-val": String(abstractNumId)
|
|
21886
|
+
}, undefined, false, undefined, this),
|
|
21887
|
+
/* @__PURE__ */ jsxDEV(w.lvlOverride, {
|
|
21888
|
+
"w-ilvl": "0",
|
|
21889
|
+
children: /* @__PURE__ */ jsxDEV(w.startOverride, {
|
|
21890
|
+
"w-val": String(start)
|
|
21891
|
+
}, undefined, false, undefined, this)
|
|
21892
|
+
}, undefined, false, undefined, this)
|
|
21893
|
+
]
|
|
21894
|
+
}, undefined, true, undefined, this);
|
|
21895
|
+
}
|
|
21896
|
+
function AbstractNum({
|
|
21897
|
+
kind,
|
|
21898
|
+
id
|
|
21899
|
+
}) {
|
|
21900
|
+
return kind === "bullet" ? /* @__PURE__ */ jsxDEV(BulletAbstractNum, {
|
|
21901
|
+
id
|
|
21902
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV(OrderedAbstractNum, {
|
|
21903
|
+
id
|
|
21904
|
+
}, undefined, false, undefined, this);
|
|
21905
|
+
}
|
|
21906
|
+
function BulletAbstractNum({ id }) {
|
|
21907
|
+
return /* @__PURE__ */ jsxDEV(w.abstractNum, {
|
|
21908
|
+
"w-abstractNumId": String(id),
|
|
21909
|
+
children: [
|
|
21910
|
+
/* @__PURE__ */ jsxDEV(w.multiLevelType, {
|
|
21911
|
+
"w-val": "hybridMultilevel"
|
|
21912
|
+
}, undefined, false, undefined, this),
|
|
21913
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21914
|
+
ilvl: 0,
|
|
21915
|
+
glyph: "\u2022"
|
|
21916
|
+
}, undefined, false, undefined, this),
|
|
21917
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21918
|
+
ilvl: 1,
|
|
21919
|
+
glyph: "\u25E6"
|
|
21920
|
+
}, undefined, false, undefined, this),
|
|
21921
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21922
|
+
ilvl: 2,
|
|
21923
|
+
glyph: "\u25AA"
|
|
21924
|
+
}, undefined, false, undefined, this),
|
|
21925
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21926
|
+
ilvl: 3,
|
|
21927
|
+
glyph: "\u2022"
|
|
21928
|
+
}, undefined, false, undefined, this),
|
|
21929
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21930
|
+
ilvl: 4,
|
|
21931
|
+
glyph: "\u25E6"
|
|
21932
|
+
}, undefined, false, undefined, this),
|
|
21933
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21934
|
+
ilvl: 5,
|
|
21935
|
+
glyph: "\u25AA"
|
|
21936
|
+
}, undefined, false, undefined, this),
|
|
21937
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21938
|
+
ilvl: 6,
|
|
21939
|
+
glyph: "\u2022"
|
|
21940
|
+
}, undefined, false, undefined, this),
|
|
21941
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21942
|
+
ilvl: 7,
|
|
21943
|
+
glyph: "\u25E6"
|
|
21944
|
+
}, undefined, false, undefined, this),
|
|
21945
|
+
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
21946
|
+
ilvl: 8,
|
|
21947
|
+
glyph: "\u25AA"
|
|
21948
|
+
}, undefined, false, undefined, this)
|
|
21949
|
+
]
|
|
21950
|
+
}, undefined, true, undefined, this);
|
|
21951
|
+
}
|
|
21952
|
+
function BulletLevel({
|
|
21953
|
+
ilvl,
|
|
21954
|
+
glyph
|
|
21955
|
+
}) {
|
|
21956
|
+
return /* @__PURE__ */ jsxDEV(w.lvl, {
|
|
21957
|
+
"w-ilvl": String(ilvl),
|
|
21958
|
+
children: [
|
|
21959
|
+
/* @__PURE__ */ jsxDEV(w.start, {
|
|
21960
|
+
"w-val": "1"
|
|
21961
|
+
}, undefined, false, undefined, this),
|
|
21962
|
+
/* @__PURE__ */ jsxDEV(w.numFmt, {
|
|
21963
|
+
"w-val": "bullet"
|
|
21964
|
+
}, undefined, false, undefined, this),
|
|
21965
|
+
/* @__PURE__ */ jsxDEV(w.lvlText, {
|
|
21966
|
+
"w-val": glyph
|
|
21967
|
+
}, undefined, false, undefined, this),
|
|
21968
|
+
/* @__PURE__ */ jsxDEV(w.lvlJc, {
|
|
21969
|
+
"w-val": "left"
|
|
21970
|
+
}, undefined, false, undefined, this),
|
|
21971
|
+
/* @__PURE__ */ jsxDEV(w.pPr, {
|
|
21972
|
+
children: /* @__PURE__ */ jsxDEV(w.ind, {
|
|
21973
|
+
"w-left": String(levelIndent(ilvl)),
|
|
21974
|
+
"w-hanging": HANGING
|
|
21975
|
+
}, undefined, false, undefined, this)
|
|
21976
|
+
}, undefined, false, undefined, this)
|
|
21977
|
+
]
|
|
21978
|
+
}, undefined, true, undefined, this);
|
|
21979
|
+
}
|
|
21980
|
+
function OrderedAbstractNum({ id }) {
|
|
21981
|
+
return /* @__PURE__ */ jsxDEV(w.abstractNum, {
|
|
21982
|
+
"w-abstractNumId": String(id),
|
|
21983
|
+
children: [
|
|
21984
|
+
/* @__PURE__ */ jsxDEV(w.multiLevelType, {
|
|
21985
|
+
"w-val": "hybridMultilevel"
|
|
21986
|
+
}, undefined, false, undefined, this),
|
|
21987
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
21988
|
+
ilvl: 0,
|
|
21989
|
+
text: "%1.",
|
|
21990
|
+
fmt: "decimal"
|
|
21991
|
+
}, undefined, false, undefined, this),
|
|
21992
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
21993
|
+
ilvl: 1,
|
|
21994
|
+
text: "%2.",
|
|
21995
|
+
fmt: "lowerLetter"
|
|
21996
|
+
}, undefined, false, undefined, this),
|
|
21997
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
21998
|
+
ilvl: 2,
|
|
21999
|
+
text: "%3.",
|
|
22000
|
+
fmt: "lowerRoman"
|
|
22001
|
+
}, undefined, false, undefined, this),
|
|
22002
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
22003
|
+
ilvl: 3,
|
|
22004
|
+
text: "%4.",
|
|
22005
|
+
fmt: "decimal"
|
|
22006
|
+
}, undefined, false, undefined, this),
|
|
22007
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
22008
|
+
ilvl: 4,
|
|
22009
|
+
text: "%5.",
|
|
22010
|
+
fmt: "lowerLetter"
|
|
22011
|
+
}, undefined, false, undefined, this),
|
|
22012
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
22013
|
+
ilvl: 5,
|
|
22014
|
+
text: "%6.",
|
|
22015
|
+
fmt: "lowerRoman"
|
|
22016
|
+
}, undefined, false, undefined, this),
|
|
22017
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
22018
|
+
ilvl: 6,
|
|
22019
|
+
text: "%7.",
|
|
22020
|
+
fmt: "decimal"
|
|
22021
|
+
}, undefined, false, undefined, this),
|
|
22022
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
22023
|
+
ilvl: 7,
|
|
22024
|
+
text: "%8.",
|
|
22025
|
+
fmt: "lowerLetter"
|
|
22026
|
+
}, undefined, false, undefined, this),
|
|
22027
|
+
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
22028
|
+
ilvl: 8,
|
|
22029
|
+
text: "%9.",
|
|
22030
|
+
fmt: "lowerRoman"
|
|
22031
|
+
}, undefined, false, undefined, this)
|
|
22032
|
+
]
|
|
22033
|
+
}, undefined, true, undefined, this);
|
|
22034
|
+
}
|
|
22035
|
+
function OrderedLevel({
|
|
22036
|
+
ilvl,
|
|
22037
|
+
text: text2,
|
|
22038
|
+
fmt
|
|
22039
|
+
}) {
|
|
22040
|
+
return /* @__PURE__ */ jsxDEV(w.lvl, {
|
|
22041
|
+
"w-ilvl": String(ilvl),
|
|
22042
|
+
children: [
|
|
22043
|
+
/* @__PURE__ */ jsxDEV(w.start, {
|
|
22044
|
+
"w-val": "1"
|
|
22045
|
+
}, undefined, false, undefined, this),
|
|
22046
|
+
/* @__PURE__ */ jsxDEV(w.numFmt, {
|
|
22047
|
+
"w-val": fmt
|
|
22048
|
+
}, undefined, false, undefined, this),
|
|
22049
|
+
/* @__PURE__ */ jsxDEV(w.lvlText, {
|
|
22050
|
+
"w-val": text2
|
|
22051
|
+
}, undefined, false, undefined, this),
|
|
22052
|
+
/* @__PURE__ */ jsxDEV(w.lvlJc, {
|
|
22053
|
+
"w-val": "left"
|
|
22054
|
+
}, undefined, false, undefined, this),
|
|
22055
|
+
/* @__PURE__ */ jsxDEV(w.pPr, {
|
|
22056
|
+
children: /* @__PURE__ */ jsxDEV(w.ind, {
|
|
22057
|
+
"w-left": String(levelIndent(ilvl)),
|
|
22058
|
+
"w-hanging": HANGING
|
|
22059
|
+
}, undefined, false, undefined, this)
|
|
22060
|
+
}, undefined, false, undefined, this)
|
|
22061
|
+
]
|
|
22062
|
+
}, undefined, true, undefined, this);
|
|
22063
|
+
}
|
|
22064
|
+
function levelIndent(ilvl) {
|
|
22065
|
+
return (ilvl + 1) * 300;
|
|
22066
|
+
}
|
|
22067
|
+
var FORMAT_TO_NUMFMT, NUMFMT_TO_FORMAT, NUMBERING_PART_NAME = "word/numbering.xml", NUMBERING_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", EMPTY_NUMBERING_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
22068
|
+
<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>`, HANGING = "240";
|
|
22069
|
+
var init_numbering = __esm(() => {
|
|
22070
|
+
init_jsx();
|
|
22071
|
+
init_parser();
|
|
22072
|
+
init_jsx_dev_runtime();
|
|
22073
|
+
FORMAT_TO_NUMFMT = {
|
|
22074
|
+
decimal: "decimal",
|
|
22075
|
+
"lower-alpha": "lowerLetter",
|
|
22076
|
+
"upper-alpha": "upperLetter",
|
|
22077
|
+
"lower-roman": "lowerRoman",
|
|
22078
|
+
"upper-roman": "upperRoman"
|
|
22079
|
+
};
|
|
22080
|
+
NUMFMT_TO_FORMAT = {
|
|
22081
|
+
decimal: "decimal",
|
|
22082
|
+
lowerLetter: "lower-alpha",
|
|
22083
|
+
upperLetter: "upper-alpha",
|
|
22084
|
+
lowerRoman: "lower-roman",
|
|
22085
|
+
upperRoman: "upper-roman"
|
|
22086
|
+
};
|
|
22087
|
+
});
|
|
22088
|
+
|
|
21610
22089
|
// src/core/ast/sym.ts
|
|
21611
22090
|
function decodeSym(font, charHex) {
|
|
21612
22091
|
const codepoint = Number.parseInt(charHex, 16);
|
|
@@ -22380,9 +22859,13 @@ function applyParagraphProperties(document2, paragraph, paragraphProperties) {
|
|
|
22380
22859
|
level,
|
|
22381
22860
|
numId: id
|
|
22382
22861
|
};
|
|
22383
|
-
const
|
|
22384
|
-
if (format !== undefined && format !== "bullet" && format !== "none") {
|
|
22862
|
+
const info = id ? document2.numbering?.getLevelInfo(id, level) : undefined;
|
|
22863
|
+
if (info?.format !== undefined && info.format !== "bullet" && info.format !== "none") {
|
|
22385
22864
|
list.ordered = true;
|
|
22865
|
+
if (info.override !== undefined)
|
|
22866
|
+
list.format = numFmtToFormat(info.override);
|
|
22867
|
+
if (info.start !== 1)
|
|
22868
|
+
list.start = info.start;
|
|
22386
22869
|
}
|
|
22387
22870
|
paragraph.list = list;
|
|
22388
22871
|
}
|
|
@@ -22692,6 +23175,7 @@ function readTable(document2, node, id, state) {
|
|
|
22692
23175
|
const width = readTableWidth(node);
|
|
22693
23176
|
const borders = readTableBorders(node);
|
|
22694
23177
|
const style = readTableStyle(node);
|
|
23178
|
+
const align = readTableAlign(node);
|
|
22695
23179
|
readTablePropertyRevision(document2, node, id, state);
|
|
22696
23180
|
readGridRevision(document2, node, id, state);
|
|
22697
23181
|
const rows = [];
|
|
@@ -22711,6 +23195,11 @@ function readTable(document2, node, id, state) {
|
|
|
22711
23195
|
const row = { cells };
|
|
22712
23196
|
if (rowChange)
|
|
22713
23197
|
row.trackedChange = rowChange;
|
|
23198
|
+
const height = readRowHeight(child2);
|
|
23199
|
+
if (height)
|
|
23200
|
+
row.height = height;
|
|
23201
|
+
if (readRepeatHeader(child2))
|
|
23202
|
+
row.repeatHeader = true;
|
|
22714
23203
|
rows.push(row);
|
|
22715
23204
|
rowIndex++;
|
|
22716
23205
|
}
|
|
@@ -22721,8 +23210,35 @@ function readTable(document2, node, id, state) {
|
|
|
22721
23210
|
table.borders = borders;
|
|
22722
23211
|
if (style)
|
|
22723
23212
|
table.style = style;
|
|
23213
|
+
if (align)
|
|
23214
|
+
table.align = align;
|
|
22724
23215
|
return table;
|
|
22725
23216
|
}
|
|
23217
|
+
function readTableAlign(table) {
|
|
23218
|
+
const val = table.findChild("w:tblPr")?.findChild("w:jc")?.getAttribute("w:val");
|
|
23219
|
+
return val === "center" || val === "right" ? val : undefined;
|
|
23220
|
+
}
|
|
23221
|
+
function readRowHeight(row) {
|
|
23222
|
+
const trHeight = row.findChild("w:trPr")?.findChild("w:trHeight");
|
|
23223
|
+
if (!trHeight)
|
|
23224
|
+
return;
|
|
23225
|
+
const raw = trHeight.getAttribute("w:val");
|
|
23226
|
+
const value = raw ? Number(raw) : NaN;
|
|
23227
|
+
if (!Number.isFinite(value))
|
|
23228
|
+
return;
|
|
23229
|
+
const rule = trHeight.getAttribute("w:hRule");
|
|
23230
|
+
return {
|
|
23231
|
+
value,
|
|
23232
|
+
rule: rule === "exact" || rule === "auto" ? rule : "atLeast"
|
|
23233
|
+
};
|
|
23234
|
+
}
|
|
23235
|
+
function readRepeatHeader(row) {
|
|
23236
|
+
const marker = row.findChild("w:trPr")?.findChild("w:tblHeader");
|
|
23237
|
+
if (!marker)
|
|
23238
|
+
return false;
|
|
23239
|
+
const val = marker.getAttribute("w:val");
|
|
23240
|
+
return val !== "false" && val !== "0" && val !== "off";
|
|
23241
|
+
}
|
|
22726
23242
|
function readTableStyle(table) {
|
|
22727
23243
|
return table.findChild("w:tblPr")?.findChild("w:tblStyle")?.getAttribute("w:val") ?? undefined;
|
|
22728
23244
|
}
|
|
@@ -22854,8 +23370,39 @@ function readTableCell(document2, cellNode, rowChildren, tableId, rowIndex, colu
|
|
|
22854
23370
|
if (fill && fill.toLowerCase() !== "auto")
|
|
22855
23371
|
cell.shading = fill.toUpperCase();
|
|
22856
23372
|
}
|
|
23373
|
+
const vAlignNode = tcPr.findChild("w:vAlign");
|
|
23374
|
+
if (vAlignNode) {
|
|
23375
|
+
const raw = vAlignNode.getAttribute("w:val");
|
|
23376
|
+
if (raw === "center" || raw === "bottom")
|
|
23377
|
+
cell.vAlign = raw;
|
|
23378
|
+
}
|
|
23379
|
+
const cellBorders = readCellBorders(tcPr);
|
|
23380
|
+
if (cellBorders)
|
|
23381
|
+
cell.borders = cellBorders;
|
|
22857
23382
|
return cell;
|
|
22858
23383
|
}
|
|
23384
|
+
function readCellBorders(tcPr) {
|
|
23385
|
+
const tcBorders = tcPr.findChild("w:tcBorders");
|
|
23386
|
+
if (!tcBorders)
|
|
23387
|
+
return;
|
|
23388
|
+
const byStyle = new Map;
|
|
23389
|
+
for (const edge of CELL_BORDER_EDGES) {
|
|
23390
|
+
const val = tcBorders.findChild(`w:${edge}`)?.getAttribute("w:val");
|
|
23391
|
+
if (!val || val === "nil" || val === "none")
|
|
23392
|
+
continue;
|
|
23393
|
+
const sides = byStyle.get(val) ?? [];
|
|
23394
|
+
sides.push(edge);
|
|
23395
|
+
byStyle.set(val, sides);
|
|
23396
|
+
}
|
|
23397
|
+
if (byStyle.size === 0)
|
|
23398
|
+
return;
|
|
23399
|
+
const parts = [];
|
|
23400
|
+
for (const [style, sides] of byStyle) {
|
|
23401
|
+
const label = sides.length === CELL_BORDER_EDGES.length ? "all" : sides.join(",");
|
|
23402
|
+
parts.push(`${label}:${style}`);
|
|
23403
|
+
}
|
|
23404
|
+
return parts.join(" ");
|
|
23405
|
+
}
|
|
22859
23406
|
function readCellPropertyRevision(document2, cell, tableId, state) {
|
|
22860
23407
|
const tcPr = cell.findChild("w:tcPr");
|
|
22861
23408
|
const change = tcPr?.findChild("w:tcPrChange");
|
|
@@ -22891,7 +23438,7 @@ function readCellBlocks(document2, cell, tableId, rowIndex, columnIndex, state)
|
|
|
22891
23438
|
}
|
|
22892
23439
|
return blocks;
|
|
22893
23440
|
}
|
|
22894
|
-
var TRACKED_CHANGE_KIND_BY_TAG, WRAP_TAGS, TABLE_BORDER_EDGES;
|
|
23441
|
+
var TRACKED_CHANGE_KIND_BY_TAG, WRAP_TAGS, TABLE_BORDER_EDGES, CELL_BORDER_EDGES;
|
|
22895
23442
|
var init_read2 = __esm(() => {
|
|
22896
23443
|
init_blocks();
|
|
22897
23444
|
init_equation();
|
|
@@ -22902,6 +23449,7 @@ var init_read2 = __esm(() => {
|
|
|
22902
23449
|
init_sections();
|
|
22903
23450
|
init_task_list();
|
|
22904
23451
|
init_body();
|
|
23452
|
+
init_numbering();
|
|
22905
23453
|
init_sym();
|
|
22906
23454
|
TRACKED_CHANGE_KIND_BY_TAG = {
|
|
22907
23455
|
"w:ins": "ins",
|
|
@@ -22924,6 +23472,14 @@ var init_read2 = __esm(() => {
|
|
|
22924
23472
|
"w:insideH",
|
|
22925
23473
|
"w:insideV"
|
|
22926
23474
|
];
|
|
23475
|
+
CELL_BORDER_EDGES = [
|
|
23476
|
+
"top",
|
|
23477
|
+
"left",
|
|
23478
|
+
"bottom",
|
|
23479
|
+
"right",
|
|
23480
|
+
"insideH",
|
|
23481
|
+
"insideV"
|
|
23482
|
+
];
|
|
22927
23483
|
});
|
|
22928
23484
|
|
|
22929
23485
|
// src/core/ast/document/comments.tsx
|
|
@@ -23731,348 +24287,6 @@ var init_notes2 = __esm(() => {
|
|
|
23731
24287
|
init_relationships();
|
|
23732
24288
|
});
|
|
23733
24289
|
|
|
23734
|
-
// src/core/ast/document/numbering.tsx
|
|
23735
|
-
class NumberingView {
|
|
23736
|
-
tree;
|
|
23737
|
-
constructor(tree = XmlNode2.parse(EMPTY_NUMBERING_XML)) {
|
|
23738
|
-
this.tree = tree;
|
|
23739
|
-
}
|
|
23740
|
-
static async fromPackage(pkg) {
|
|
23741
|
-
const tree = await pkg.readPart(NUMBERING_PART_NAME);
|
|
23742
|
-
return tree ? new NumberingView(tree) : undefined;
|
|
23743
|
-
}
|
|
23744
|
-
static fromXml(xml) {
|
|
23745
|
-
return xml ? new NumberingView(XmlNode2.parse(xml)) : undefined;
|
|
23746
|
-
}
|
|
23747
|
-
writeTo(pkg) {
|
|
23748
|
-
pkg.writeText(NUMBERING_PART_NAME, XmlNode2.serialize(this.tree));
|
|
23749
|
-
}
|
|
23750
|
-
static register(deps) {
|
|
23751
|
-
if (!deps.relationships.hasTarget("numbering.xml")) {
|
|
23752
|
-
deps.relationships.add(NUMBERING_RELATIONSHIP_TYPE, "numbering.xml");
|
|
23753
|
-
}
|
|
23754
|
-
deps.contentTypes.registerPart(NUMBERING_PART_NAME, NUMBERING_CONTENT_TYPE);
|
|
23755
|
-
return new NumberingView;
|
|
23756
|
-
}
|
|
23757
|
-
listNumIds() {
|
|
23758
|
-
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
23759
|
-
if (!root)
|
|
23760
|
-
return [];
|
|
23761
|
-
const out = [];
|
|
23762
|
-
for (const child2 of root.findChildren("w:num")) {
|
|
23763
|
-
const id = child2.getAttribute("w:numId");
|
|
23764
|
-
if (id)
|
|
23765
|
-
out.push(id);
|
|
23766
|
-
}
|
|
23767
|
-
return out;
|
|
23768
|
-
}
|
|
23769
|
-
listAbstractNumIds() {
|
|
23770
|
-
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
23771
|
-
if (!root)
|
|
23772
|
-
return [];
|
|
23773
|
-
const out = [];
|
|
23774
|
-
for (const child2 of root.findChildren("w:abstractNum")) {
|
|
23775
|
-
const id = child2.getAttribute("w:abstractNumId");
|
|
23776
|
-
if (id)
|
|
23777
|
-
out.push(id);
|
|
23778
|
-
}
|
|
23779
|
-
return out;
|
|
23780
|
-
}
|
|
23781
|
-
allocate(kind, start = 1) {
|
|
23782
|
-
const root = this.ensureNumberingRoot();
|
|
23783
|
-
const abstractNumId = this.ensureAbstractNum(root, kind);
|
|
23784
|
-
const numId = nextNumId(root);
|
|
23785
|
-
root.children.push(/* @__PURE__ */ jsxDEV(NumElement, {
|
|
23786
|
-
numId,
|
|
23787
|
-
abstractNumId,
|
|
23788
|
-
start
|
|
23789
|
-
}, undefined, false, undefined, this));
|
|
23790
|
-
return numId;
|
|
23791
|
-
}
|
|
23792
|
-
getFormat(numId, level) {
|
|
23793
|
-
const abstractNum = this.resolveAbstractNum(numId);
|
|
23794
|
-
if (!abstractNum)
|
|
23795
|
-
return;
|
|
23796
|
-
const lvl = findLevel(abstractNum, level) ?? findLevel(abstractNum, 0);
|
|
23797
|
-
return lvl?.findChild("w:numFmt")?.getAttribute("w:val") ?? undefined;
|
|
23798
|
-
}
|
|
23799
|
-
getBulletText(numId, level) {
|
|
23800
|
-
const abstractNum = this.resolveAbstractNum(numId);
|
|
23801
|
-
if (!abstractNum)
|
|
23802
|
-
return;
|
|
23803
|
-
const lvl = findLevel(abstractNum, level) ?? findLevel(abstractNum, 0);
|
|
23804
|
-
return lvl?.findChild("w:lvlText")?.getAttribute("w:val") ?? undefined;
|
|
23805
|
-
}
|
|
23806
|
-
resolveAbstractNum(numId) {
|
|
23807
|
-
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
23808
|
-
if (!root)
|
|
23809
|
-
return;
|
|
23810
|
-
const num = root.findChildren("w:num").find((node) => node.getAttribute("w:numId") === numId);
|
|
23811
|
-
if (!num)
|
|
23812
|
-
return;
|
|
23813
|
-
const abstractNumId = num.findChild("w:abstractNumId")?.getAttribute("w:val");
|
|
23814
|
-
if (!abstractNumId)
|
|
23815
|
-
return;
|
|
23816
|
-
return root.findChildren("w:abstractNum").find((node) => node.getAttribute("w:abstractNumId") === abstractNumId);
|
|
23817
|
-
}
|
|
23818
|
-
ensureNumberingRoot() {
|
|
23819
|
-
const root = XmlNode2.findRoot(this.tree, "w:numbering");
|
|
23820
|
-
if (!root) {
|
|
23821
|
-
throw new Error("expected <w:numbering> root in numbering tree");
|
|
23822
|
-
}
|
|
23823
|
-
return root;
|
|
23824
|
-
}
|
|
23825
|
-
ensureAbstractNum(root, kind) {
|
|
23826
|
-
const targetFormat = kind === "bullet" ? "bullet" : "decimal";
|
|
23827
|
-
for (const child2 of root.findChildren("w:abstractNum")) {
|
|
23828
|
-
const lvl0 = findLevel(child2, 0);
|
|
23829
|
-
const numFmt = lvl0?.findChild("w:numFmt");
|
|
23830
|
-
if (numFmt?.getAttribute("w:val") === targetFormat) {
|
|
23831
|
-
const id = child2.getAttribute("w:abstractNumId");
|
|
23832
|
-
if (id)
|
|
23833
|
-
return Number(id);
|
|
23834
|
-
}
|
|
23835
|
-
}
|
|
23836
|
-
const newId = nextAbstractNumId(root);
|
|
23837
|
-
const def = /* @__PURE__ */ jsxDEV(AbstractNum, {
|
|
23838
|
-
kind,
|
|
23839
|
-
id: newId
|
|
23840
|
-
}, undefined, false, undefined, this);
|
|
23841
|
-
const firstNumIdx = root.children.findIndex((child2) => child2.tag === "w:num");
|
|
23842
|
-
if (firstNumIdx === -1)
|
|
23843
|
-
root.children.push(def);
|
|
23844
|
-
else
|
|
23845
|
-
root.children.splice(firstNumIdx, 0, def);
|
|
23846
|
-
return newId;
|
|
23847
|
-
}
|
|
23848
|
-
}
|
|
23849
|
-
function nextAbstractNumId(root) {
|
|
23850
|
-
let max = -1;
|
|
23851
|
-
for (const child2 of root.findChildren("w:abstractNum")) {
|
|
23852
|
-
const id = child2.getAttribute("w:abstractNumId");
|
|
23853
|
-
if (id) {
|
|
23854
|
-
const numeric = Number(id);
|
|
23855
|
-
if (Number.isFinite(numeric) && numeric > max)
|
|
23856
|
-
max = numeric;
|
|
23857
|
-
}
|
|
23858
|
-
}
|
|
23859
|
-
return max + 1;
|
|
23860
|
-
}
|
|
23861
|
-
function nextNumId(root) {
|
|
23862
|
-
let max = 0;
|
|
23863
|
-
for (const child2 of root.findChildren("w:num")) {
|
|
23864
|
-
const id = child2.getAttribute("w:numId");
|
|
23865
|
-
if (id) {
|
|
23866
|
-
const numeric = Number(id);
|
|
23867
|
-
if (Number.isFinite(numeric) && numeric > max)
|
|
23868
|
-
max = numeric;
|
|
23869
|
-
}
|
|
23870
|
-
}
|
|
23871
|
-
return max + 1;
|
|
23872
|
-
}
|
|
23873
|
-
function findLevel(abstractNum, ilvl) {
|
|
23874
|
-
const target = String(ilvl);
|
|
23875
|
-
return abstractNum.findChildren("w:lvl").find((lvl) => lvl.getAttribute("w:ilvl") === target);
|
|
23876
|
-
}
|
|
23877
|
-
function NumElement({
|
|
23878
|
-
numId,
|
|
23879
|
-
abstractNumId,
|
|
23880
|
-
start
|
|
23881
|
-
}) {
|
|
23882
|
-
return /* @__PURE__ */ jsxDEV(w.num, {
|
|
23883
|
-
"w-numId": String(numId),
|
|
23884
|
-
children: [
|
|
23885
|
-
/* @__PURE__ */ jsxDEV(w.abstractNumId, {
|
|
23886
|
-
"w-val": String(abstractNumId)
|
|
23887
|
-
}, undefined, false, undefined, this),
|
|
23888
|
-
/* @__PURE__ */ jsxDEV(w.lvlOverride, {
|
|
23889
|
-
"w-ilvl": "0",
|
|
23890
|
-
children: /* @__PURE__ */ jsxDEV(w.startOverride, {
|
|
23891
|
-
"w-val": String(start)
|
|
23892
|
-
}, undefined, false, undefined, this)
|
|
23893
|
-
}, undefined, false, undefined, this)
|
|
23894
|
-
]
|
|
23895
|
-
}, undefined, true, undefined, this);
|
|
23896
|
-
}
|
|
23897
|
-
function AbstractNum({
|
|
23898
|
-
kind,
|
|
23899
|
-
id
|
|
23900
|
-
}) {
|
|
23901
|
-
return kind === "bullet" ? /* @__PURE__ */ jsxDEV(BulletAbstractNum, {
|
|
23902
|
-
id
|
|
23903
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV(OrderedAbstractNum, {
|
|
23904
|
-
id
|
|
23905
|
-
}, undefined, false, undefined, this);
|
|
23906
|
-
}
|
|
23907
|
-
function BulletAbstractNum({ id }) {
|
|
23908
|
-
return /* @__PURE__ */ jsxDEV(w.abstractNum, {
|
|
23909
|
-
"w-abstractNumId": String(id),
|
|
23910
|
-
children: [
|
|
23911
|
-
/* @__PURE__ */ jsxDEV(w.multiLevelType, {
|
|
23912
|
-
"w-val": "hybridMultilevel"
|
|
23913
|
-
}, undefined, false, undefined, this),
|
|
23914
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23915
|
-
ilvl: 0,
|
|
23916
|
-
glyph: "\u2022"
|
|
23917
|
-
}, undefined, false, undefined, this),
|
|
23918
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23919
|
-
ilvl: 1,
|
|
23920
|
-
glyph: "\u25E6"
|
|
23921
|
-
}, undefined, false, undefined, this),
|
|
23922
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23923
|
-
ilvl: 2,
|
|
23924
|
-
glyph: "\u25AA"
|
|
23925
|
-
}, undefined, false, undefined, this),
|
|
23926
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23927
|
-
ilvl: 3,
|
|
23928
|
-
glyph: "\u2022"
|
|
23929
|
-
}, undefined, false, undefined, this),
|
|
23930
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23931
|
-
ilvl: 4,
|
|
23932
|
-
glyph: "\u25E6"
|
|
23933
|
-
}, undefined, false, undefined, this),
|
|
23934
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23935
|
-
ilvl: 5,
|
|
23936
|
-
glyph: "\u25AA"
|
|
23937
|
-
}, undefined, false, undefined, this),
|
|
23938
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23939
|
-
ilvl: 6,
|
|
23940
|
-
glyph: "\u2022"
|
|
23941
|
-
}, undefined, false, undefined, this),
|
|
23942
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23943
|
-
ilvl: 7,
|
|
23944
|
-
glyph: "\u25E6"
|
|
23945
|
-
}, undefined, false, undefined, this),
|
|
23946
|
-
/* @__PURE__ */ jsxDEV(BulletLevel, {
|
|
23947
|
-
ilvl: 8,
|
|
23948
|
-
glyph: "\u25AA"
|
|
23949
|
-
}, undefined, false, undefined, this)
|
|
23950
|
-
]
|
|
23951
|
-
}, undefined, true, undefined, this);
|
|
23952
|
-
}
|
|
23953
|
-
function BulletLevel({
|
|
23954
|
-
ilvl,
|
|
23955
|
-
glyph
|
|
23956
|
-
}) {
|
|
23957
|
-
return /* @__PURE__ */ jsxDEV(w.lvl, {
|
|
23958
|
-
"w-ilvl": String(ilvl),
|
|
23959
|
-
children: [
|
|
23960
|
-
/* @__PURE__ */ jsxDEV(w.start, {
|
|
23961
|
-
"w-val": "1"
|
|
23962
|
-
}, undefined, false, undefined, this),
|
|
23963
|
-
/* @__PURE__ */ jsxDEV(w.numFmt, {
|
|
23964
|
-
"w-val": "bullet"
|
|
23965
|
-
}, undefined, false, undefined, this),
|
|
23966
|
-
/* @__PURE__ */ jsxDEV(w.lvlText, {
|
|
23967
|
-
"w-val": glyph
|
|
23968
|
-
}, undefined, false, undefined, this),
|
|
23969
|
-
/* @__PURE__ */ jsxDEV(w.lvlJc, {
|
|
23970
|
-
"w-val": "left"
|
|
23971
|
-
}, undefined, false, undefined, this),
|
|
23972
|
-
/* @__PURE__ */ jsxDEV(w.pPr, {
|
|
23973
|
-
children: /* @__PURE__ */ jsxDEV(w.ind, {
|
|
23974
|
-
"w-left": String(levelIndent(ilvl)),
|
|
23975
|
-
"w-hanging": HANGING
|
|
23976
|
-
}, undefined, false, undefined, this)
|
|
23977
|
-
}, undefined, false, undefined, this)
|
|
23978
|
-
]
|
|
23979
|
-
}, undefined, true, undefined, this);
|
|
23980
|
-
}
|
|
23981
|
-
function OrderedAbstractNum({ id }) {
|
|
23982
|
-
return /* @__PURE__ */ jsxDEV(w.abstractNum, {
|
|
23983
|
-
"w-abstractNumId": String(id),
|
|
23984
|
-
children: [
|
|
23985
|
-
/* @__PURE__ */ jsxDEV(w.multiLevelType, {
|
|
23986
|
-
"w-val": "hybridMultilevel"
|
|
23987
|
-
}, undefined, false, undefined, this),
|
|
23988
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
23989
|
-
ilvl: 0,
|
|
23990
|
-
text: "%1.",
|
|
23991
|
-
fmt: "decimal"
|
|
23992
|
-
}, undefined, false, undefined, this),
|
|
23993
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
23994
|
-
ilvl: 1,
|
|
23995
|
-
text: "%2.",
|
|
23996
|
-
fmt: "lowerLetter"
|
|
23997
|
-
}, undefined, false, undefined, this),
|
|
23998
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
23999
|
-
ilvl: 2,
|
|
24000
|
-
text: "%3.",
|
|
24001
|
-
fmt: "lowerRoman"
|
|
24002
|
-
}, undefined, false, undefined, this),
|
|
24003
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
24004
|
-
ilvl: 3,
|
|
24005
|
-
text: "%4.",
|
|
24006
|
-
fmt: "decimal"
|
|
24007
|
-
}, undefined, false, undefined, this),
|
|
24008
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
24009
|
-
ilvl: 4,
|
|
24010
|
-
text: "%5.",
|
|
24011
|
-
fmt: "lowerLetter"
|
|
24012
|
-
}, undefined, false, undefined, this),
|
|
24013
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
24014
|
-
ilvl: 5,
|
|
24015
|
-
text: "%6.",
|
|
24016
|
-
fmt: "lowerRoman"
|
|
24017
|
-
}, undefined, false, undefined, this),
|
|
24018
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
24019
|
-
ilvl: 6,
|
|
24020
|
-
text: "%7.",
|
|
24021
|
-
fmt: "decimal"
|
|
24022
|
-
}, undefined, false, undefined, this),
|
|
24023
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
24024
|
-
ilvl: 7,
|
|
24025
|
-
text: "%8.",
|
|
24026
|
-
fmt: "lowerLetter"
|
|
24027
|
-
}, undefined, false, undefined, this),
|
|
24028
|
-
/* @__PURE__ */ jsxDEV(OrderedLevel, {
|
|
24029
|
-
ilvl: 8,
|
|
24030
|
-
text: "%9.",
|
|
24031
|
-
fmt: "lowerRoman"
|
|
24032
|
-
}, undefined, false, undefined, this)
|
|
24033
|
-
]
|
|
24034
|
-
}, undefined, true, undefined, this);
|
|
24035
|
-
}
|
|
24036
|
-
function OrderedLevel({
|
|
24037
|
-
ilvl,
|
|
24038
|
-
text: text2,
|
|
24039
|
-
fmt
|
|
24040
|
-
}) {
|
|
24041
|
-
return /* @__PURE__ */ jsxDEV(w.lvl, {
|
|
24042
|
-
"w-ilvl": String(ilvl),
|
|
24043
|
-
children: [
|
|
24044
|
-
/* @__PURE__ */ jsxDEV(w.start, {
|
|
24045
|
-
"w-val": "1"
|
|
24046
|
-
}, undefined, false, undefined, this),
|
|
24047
|
-
/* @__PURE__ */ jsxDEV(w.numFmt, {
|
|
24048
|
-
"w-val": fmt
|
|
24049
|
-
}, undefined, false, undefined, this),
|
|
24050
|
-
/* @__PURE__ */ jsxDEV(w.lvlText, {
|
|
24051
|
-
"w-val": text2
|
|
24052
|
-
}, undefined, false, undefined, this),
|
|
24053
|
-
/* @__PURE__ */ jsxDEV(w.lvlJc, {
|
|
24054
|
-
"w-val": "left"
|
|
24055
|
-
}, undefined, false, undefined, this),
|
|
24056
|
-
/* @__PURE__ */ jsxDEV(w.pPr, {
|
|
24057
|
-
children: /* @__PURE__ */ jsxDEV(w.ind, {
|
|
24058
|
-
"w-left": String(levelIndent(ilvl)),
|
|
24059
|
-
"w-hanging": HANGING
|
|
24060
|
-
}, undefined, false, undefined, this)
|
|
24061
|
-
}, undefined, false, undefined, this)
|
|
24062
|
-
]
|
|
24063
|
-
}, undefined, true, undefined, this);
|
|
24064
|
-
}
|
|
24065
|
-
function levelIndent(ilvl) {
|
|
24066
|
-
return (ilvl + 1) * 300;
|
|
24067
|
-
}
|
|
24068
|
-
var NUMBERING_PART_NAME = "word/numbering.xml", NUMBERING_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", NUMBERING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", EMPTY_NUMBERING_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
24069
|
-
<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>`, HANGING = "240";
|
|
24070
|
-
var init_numbering = __esm(() => {
|
|
24071
|
-
init_jsx();
|
|
24072
|
-
init_parser();
|
|
24073
|
-
init_jsx_dev_runtime();
|
|
24074
|
-
});
|
|
24075
|
-
|
|
24076
24290
|
// node_modules/process-nextick-args/index.js
|
|
24077
24291
|
var require_process_nextick_args = __commonJS((exports, module) => {
|
|
24078
24292
|
if (typeof process === "undefined" || !process.version || process.version.indexOf("v0.") === 0 || process.version.indexOf("v1.") === 0 && process.version.indexOf("v1.8.") !== 0) {
|
|
@@ -72485,6 +72699,69 @@ function setCellWidth(cell, width) {
|
|
|
72485
72699
|
}, undefined, false, undefined, this) : null);
|
|
72486
72700
|
pruneEmptyTcPr(cell, tcPr);
|
|
72487
72701
|
}
|
|
72702
|
+
function setCellShading(cell, hex) {
|
|
72703
|
+
const tcPr = ensureTcPr(cell);
|
|
72704
|
+
setTcPrChild(tcPr, "w:shd", hex ? /* @__PURE__ */ jsxDEV(w.shd, {
|
|
72705
|
+
"w-val": "clear",
|
|
72706
|
+
"w-color": "auto",
|
|
72707
|
+
"w-fill": hex
|
|
72708
|
+
}, undefined, false, undefined, this) : null);
|
|
72709
|
+
pruneEmptyTcPr(cell, tcPr);
|
|
72710
|
+
}
|
|
72711
|
+
function setCellVAlign(cell, value) {
|
|
72712
|
+
const tcPr = ensureTcPr(cell);
|
|
72713
|
+
setTcPrChild(tcPr, "w:vAlign", value && value !== "top" ? /* @__PURE__ */ jsxDEV(w.vAlign, {
|
|
72714
|
+
"w-val": value
|
|
72715
|
+
}, undefined, false, undefined, this) : null);
|
|
72716
|
+
pruneEmptyTcPr(cell, tcPr);
|
|
72717
|
+
}
|
|
72718
|
+
function setCellBorders(cell, updates, clearAll = false) {
|
|
72719
|
+
const tcPr = ensureTcPr(cell);
|
|
72720
|
+
if (clearAll) {
|
|
72721
|
+
setTcPrChild(tcPr, "w:tcBorders", null);
|
|
72722
|
+
pruneEmptyTcPr(cell, tcPr);
|
|
72723
|
+
return;
|
|
72724
|
+
}
|
|
72725
|
+
let tcBorders = tcPr.findChild("w:tcBorders");
|
|
72726
|
+
if (!tcBorders) {
|
|
72727
|
+
if (updates.every((update) => update.edge === null)) {
|
|
72728
|
+
pruneEmptyTcPr(cell, tcPr);
|
|
72729
|
+
return;
|
|
72730
|
+
}
|
|
72731
|
+
tcBorders = /* @__PURE__ */ jsxDEV(w.tcBorders, {}, undefined, false, undefined, this);
|
|
72732
|
+
setTcPrChild(tcPr, "w:tcBorders", tcBorders);
|
|
72733
|
+
}
|
|
72734
|
+
for (const { side, edge } of updates) {
|
|
72735
|
+
const tag = `w:${side}`;
|
|
72736
|
+
tcBorders.children = tcBorders.children.filter((child2) => child2.tag !== tag);
|
|
72737
|
+
if (edge)
|
|
72738
|
+
insertEdgeInOrder(tcBorders, tag, borderEdge(tag, edge));
|
|
72739
|
+
}
|
|
72740
|
+
if (tcBorders.children.length === 0)
|
|
72741
|
+
setTcPrChild(tcPr, "w:tcBorders", null);
|
|
72742
|
+
pruneEmptyTcPr(cell, tcPr);
|
|
72743
|
+
}
|
|
72744
|
+
function borderEdge(tag, edge) {
|
|
72745
|
+
const attributes = edge.style === "none" ? { "w:val": "none" } : {
|
|
72746
|
+
"w:val": edge.style,
|
|
72747
|
+
"w:sz": String(edge.sizeEighths),
|
|
72748
|
+
"w:space": "0",
|
|
72749
|
+
"w:color": edge.color
|
|
72750
|
+
};
|
|
72751
|
+
return XmlNode2.element(tag, attributes);
|
|
72752
|
+
}
|
|
72753
|
+
function insertEdgeInOrder(parent, tag, node2) {
|
|
72754
|
+
const target = orderIndex(CELL_BORDER_ORDER, tag);
|
|
72755
|
+
let insertAt = parent.children.length;
|
|
72756
|
+
for (let index2 = 0;index2 < parent.children.length; index2++) {
|
|
72757
|
+
const child2 = parent.children[index2];
|
|
72758
|
+
if (child2 && orderIndex(CELL_BORDER_ORDER, child2.tag) > target) {
|
|
72759
|
+
insertAt = index2;
|
|
72760
|
+
break;
|
|
72761
|
+
}
|
|
72762
|
+
}
|
|
72763
|
+
parent.children.splice(insertAt, 0, node2);
|
|
72764
|
+
}
|
|
72488
72765
|
function markRowTracked(row, kind, meta) {
|
|
72489
72766
|
const trPr = ensureTrPr(row);
|
|
72490
72767
|
trPr.children = trPr.children.filter((child2) => child2.tag !== "w:ins" && child2.tag !== "w:del");
|
|
@@ -72515,6 +72792,24 @@ function ensureTrPr(row) {
|
|
|
72515
72792
|
row.children.unshift(trPr);
|
|
72516
72793
|
return trPr;
|
|
72517
72794
|
}
|
|
72795
|
+
function setRowHeight(row, height) {
|
|
72796
|
+
const trPr = ensureTrPr(row);
|
|
72797
|
+
setTrPrChild(trPr, "w:trHeight", height ? /* @__PURE__ */ jsxDEV(w.trHeight, {
|
|
72798
|
+
"w-val": String(height.value),
|
|
72799
|
+
"w-hRule": height.rule
|
|
72800
|
+
}, undefined, false, undefined, this) : null);
|
|
72801
|
+
pruneEmptyTrPr(row, trPr);
|
|
72802
|
+
}
|
|
72803
|
+
function setRepeatHeader(row, on) {
|
|
72804
|
+
const trPr = ensureTrPr(row);
|
|
72805
|
+
setTrPrChild(trPr, "w:tblHeader", on ? /* @__PURE__ */ jsxDEV(w.tblHeader, {}, undefined, false, undefined, this) : null);
|
|
72806
|
+
pruneEmptyTrPr(row, trPr);
|
|
72807
|
+
}
|
|
72808
|
+
function pruneEmptyTrPr(row, trPr) {
|
|
72809
|
+
if (trPr.children.length === 0) {
|
|
72810
|
+
row.children = row.children.filter((child2) => child2 !== trPr);
|
|
72811
|
+
}
|
|
72812
|
+
}
|
|
72518
72813
|
function appendTblGridChange(tblGrid, priorCols, meta) {
|
|
72519
72814
|
tblGrid.children = tblGrid.children.filter((child2) => child2.tag !== "w:tblGridChange");
|
|
72520
72815
|
tblGrid.children.push(/* @__PURE__ */ jsxDEV(w.tblGridChange, {
|
|
@@ -72566,6 +72861,16 @@ function setTableLayout(table, layout) {
|
|
|
72566
72861
|
function setTablePropertiesChild(table, tag, node2) {
|
|
72567
72862
|
setTblPrChild(ensureTblPr(table), tag, node2);
|
|
72568
72863
|
}
|
|
72864
|
+
function setTableJustification(table, value) {
|
|
72865
|
+
setTablePropertiesChild(table, "w:jc", value && value !== "left" ? /* @__PURE__ */ jsxDEV(w.jc, {
|
|
72866
|
+
"w-val": value
|
|
72867
|
+
}, undefined, false, undefined, this) : null);
|
|
72868
|
+
}
|
|
72869
|
+
function setTableStyle(table, styleId) {
|
|
72870
|
+
setTablePropertiesChild(table, "w:tblStyle", styleId ? /* @__PURE__ */ jsxDEV(w.tblStyle, {
|
|
72871
|
+
"w-val": styleId
|
|
72872
|
+
}, undefined, false, undefined, this) : null);
|
|
72873
|
+
}
|
|
72569
72874
|
function setTblPrChild(tblPr, tag, node2) {
|
|
72570
72875
|
tblPr.children = tblPr.children.filter((child2) => child2.tag !== tag);
|
|
72571
72876
|
if (!node2)
|
|
@@ -72600,13 +72905,37 @@ function setTcPrChild(tcPr, tag, node2) {
|
|
|
72600
72905
|
}
|
|
72601
72906
|
tcPr.children.splice(insertAt, 0, node2);
|
|
72602
72907
|
}
|
|
72603
|
-
|
|
72908
|
+
function setTrPrChild(trPr, tag, node2) {
|
|
72909
|
+
trPr.children = trPr.children.filter((child2) => child2.tag !== tag);
|
|
72910
|
+
if (!node2)
|
|
72911
|
+
return;
|
|
72912
|
+
const target = orderIndex(TR_PR_ORDER, tag);
|
|
72913
|
+
let insertAt = trPr.children.length;
|
|
72914
|
+
for (let index2 = 0;index2 < trPr.children.length; index2++) {
|
|
72915
|
+
const child2 = trPr.children[index2];
|
|
72916
|
+
if (child2 && orderIndex(TR_PR_ORDER, child2.tag) > target) {
|
|
72917
|
+
insertAt = index2;
|
|
72918
|
+
break;
|
|
72919
|
+
}
|
|
72920
|
+
}
|
|
72921
|
+
trPr.children.splice(insertAt, 0, node2);
|
|
72922
|
+
}
|
|
72923
|
+
var CELL_BORDER_ORDER, TBL_PR_ORDER, TC_PR_ORDER, TR_PR_ORDER;
|
|
72604
72924
|
var init_mutate = __esm(() => {
|
|
72605
72925
|
init_blocks();
|
|
72606
72926
|
init_jsx();
|
|
72927
|
+
init_parser();
|
|
72607
72928
|
init_emit2();
|
|
72608
72929
|
init_table();
|
|
72609
72930
|
init_jsx_dev_runtime();
|
|
72931
|
+
CELL_BORDER_ORDER = [
|
|
72932
|
+
"w:top",
|
|
72933
|
+
"w:left",
|
|
72934
|
+
"w:bottom",
|
|
72935
|
+
"w:right",
|
|
72936
|
+
"w:insideH",
|
|
72937
|
+
"w:insideV"
|
|
72938
|
+
];
|
|
72610
72939
|
TBL_PR_ORDER = [
|
|
72611
72940
|
"w:tblStyle",
|
|
72612
72941
|
"w:tblpPr",
|
|
@@ -72644,6 +72973,23 @@ var init_mutate = __esm(() => {
|
|
|
72644
72973
|
"w:cellMerge",
|
|
72645
72974
|
"w:tcPrChange"
|
|
72646
72975
|
];
|
|
72976
|
+
TR_PR_ORDER = [
|
|
72977
|
+
"w:cnfStyle",
|
|
72978
|
+
"w:divId",
|
|
72979
|
+
"w:gridBefore",
|
|
72980
|
+
"w:gridAfter",
|
|
72981
|
+
"w:wBefore",
|
|
72982
|
+
"w:wAfter",
|
|
72983
|
+
"w:cantSplit",
|
|
72984
|
+
"w:trHeight",
|
|
72985
|
+
"w:tblHeader",
|
|
72986
|
+
"w:tblCellSpacing",
|
|
72987
|
+
"w:jc",
|
|
72988
|
+
"w:hidden",
|
|
72989
|
+
"w:ins",
|
|
72990
|
+
"w:del",
|
|
72991
|
+
"w:trPrChange"
|
|
72992
|
+
];
|
|
72647
72993
|
});
|
|
72648
72994
|
|
|
72649
72995
|
// src/core/table/index.tsx
|
|
@@ -73741,6 +74087,99 @@ var init_insert = __esm(() => {
|
|
|
73741
74087
|
};
|
|
73742
74088
|
});
|
|
73743
74089
|
|
|
74090
|
+
// src/core/lists/index.ts
|
|
74091
|
+
class Lists {
|
|
74092
|
+
document;
|
|
74093
|
+
constructor(document4) {
|
|
74094
|
+
this.document = document4;
|
|
74095
|
+
}
|
|
74096
|
+
setStart(blockRef, start) {
|
|
74097
|
+
const list3 = this.requireList(blockRef.node);
|
|
74098
|
+
this.numbering().setStart(list3.numId, list3.level, start);
|
|
74099
|
+
}
|
|
74100
|
+
setFormat(blockRef, format) {
|
|
74101
|
+
const list3 = this.requireList(blockRef.node);
|
|
74102
|
+
this.numbering().setFormat(list3.numId, list3.level, FORMAT_TO_NUMFMT[format]);
|
|
74103
|
+
}
|
|
74104
|
+
restart(blockRef, start) {
|
|
74105
|
+
const list3 = this.requireList(blockRef.node);
|
|
74106
|
+
const newNumId = String(this.numbering().cloneListDefinition(list3.numId, start));
|
|
74107
|
+
const startIdx = blockRef.parent.indexOf(blockRef.node);
|
|
74108
|
+
this.repointFrom(blockRef.parent, startIdx, list3.numId, newNumId);
|
|
74109
|
+
}
|
|
74110
|
+
continue(blockRef) {
|
|
74111
|
+
const list3 = this.requireList(blockRef.node);
|
|
74112
|
+
const siblings = blockRef.parent;
|
|
74113
|
+
const startIdx = siblings.indexOf(blockRef.node);
|
|
74114
|
+
let precedingNumId;
|
|
74115
|
+
for (let i = startIdx - 1;i >= 0; i--) {
|
|
74116
|
+
const sibling = siblings[i];
|
|
74117
|
+
if (!sibling)
|
|
74118
|
+
continue;
|
|
74119
|
+
const numbered = readNumPr(sibling);
|
|
74120
|
+
if (!numbered)
|
|
74121
|
+
continue;
|
|
74122
|
+
if (numbered.numId !== list3.numId && this.isOrdered(numbered)) {
|
|
74123
|
+
precedingNumId = numbered.numId;
|
|
74124
|
+
break;
|
|
74125
|
+
}
|
|
74126
|
+
}
|
|
74127
|
+
if (!precedingNumId) {
|
|
74128
|
+
throw new ListOperationError("no preceding list to continue from");
|
|
74129
|
+
}
|
|
74130
|
+
this.repointFrom(siblings, startIdx, list3.numId, precedingNumId);
|
|
74131
|
+
}
|
|
74132
|
+
repointFrom(siblings, startIdx, oldNumId, newNumId) {
|
|
74133
|
+
for (let i = startIdx;i < siblings.length; i++) {
|
|
74134
|
+
const sibling = siblings[i];
|
|
74135
|
+
if (!sibling)
|
|
74136
|
+
continue;
|
|
74137
|
+
if (readNumPr(sibling)?.numId === oldNumId)
|
|
74138
|
+
setNumId(sibling, newNumId);
|
|
74139
|
+
}
|
|
74140
|
+
}
|
|
74141
|
+
isOrdered(numbered) {
|
|
74142
|
+
const format = this.numbering().getFormat(numbered.numId, numbered.level);
|
|
74143
|
+
return format !== undefined && format !== "bullet" && format !== "none";
|
|
74144
|
+
}
|
|
74145
|
+
requireList(paragraph2) {
|
|
74146
|
+
const numbered = readNumPr(paragraph2);
|
|
74147
|
+
if (!numbered) {
|
|
74148
|
+
throw new ListOperationError("paragraph is not a list item");
|
|
74149
|
+
}
|
|
74150
|
+
return numbered;
|
|
74151
|
+
}
|
|
74152
|
+
numbering() {
|
|
74153
|
+
if (!this.document.numbering) {
|
|
74154
|
+
throw new ListOperationError("document has no numbering definitions");
|
|
74155
|
+
}
|
|
74156
|
+
return this.document.numbering;
|
|
74157
|
+
}
|
|
74158
|
+
}
|
|
74159
|
+
function readNumPr(paragraph2) {
|
|
74160
|
+
const numPr = paragraph2.findChild("w:pPr")?.findChild("w:numPr");
|
|
74161
|
+
if (!numPr)
|
|
74162
|
+
return;
|
|
74163
|
+
const numId = numPr.findChild("w:numId")?.getAttribute("w:val");
|
|
74164
|
+
if (numId === undefined)
|
|
74165
|
+
return;
|
|
74166
|
+
const level = Number(numPr.findChild("w:ilvl")?.getAttribute("w:val") ?? "0");
|
|
74167
|
+
return { numId, level };
|
|
74168
|
+
}
|
|
74169
|
+
function setNumId(paragraph2, numId) {
|
|
74170
|
+
paragraph2.findChild("w:pPr")?.findChild("w:numPr")?.findChild("w:numId")?.setAttribute("w:val", numId);
|
|
74171
|
+
}
|
|
74172
|
+
var ListOperationError;
|
|
74173
|
+
var init_lists = __esm(() => {
|
|
74174
|
+
init_numbering();
|
|
74175
|
+
ListOperationError = class ListOperationError extends Error {
|
|
74176
|
+
constructor(message) {
|
|
74177
|
+
super(message);
|
|
74178
|
+
this.name = "ListOperationError";
|
|
74179
|
+
}
|
|
74180
|
+
};
|
|
74181
|
+
});
|
|
74182
|
+
|
|
73744
74183
|
// src/core/marginals/index.tsx
|
|
73745
74184
|
class Marginals {
|
|
73746
74185
|
document;
|
|
@@ -82082,11 +82521,13 @@ var init_render = __esm(() => {
|
|
|
82082
82521
|
// src/core/index.ts
|
|
82083
82522
|
var init_core2 = __esm(() => {
|
|
82084
82523
|
init_ast();
|
|
82524
|
+
init_numbering();
|
|
82085
82525
|
init_package();
|
|
82086
82526
|
init_comments2();
|
|
82087
82527
|
init_edit();
|
|
82088
82528
|
init_fonts();
|
|
82089
82529
|
init_insert();
|
|
82530
|
+
init_lists();
|
|
82090
82531
|
init_literal_text();
|
|
82091
82532
|
init_locators();
|
|
82092
82533
|
init_marginals2();
|
|
@@ -89569,7 +90010,19 @@ export type Paragraph = {
|
|
|
89569
90010
|
type: "paragraph";
|
|
89570
90011
|
style?: string;
|
|
89571
90012
|
alignment?: "left" | "center" | "right" | "justify";
|
|
89572
|
-
|
|
90013
|
+
/** List membership from \`<w:pPr><w:numPr>\`. \`start\`/\`format\` are the
|
|
90014
|
+
* numbering-control properties \`docx lists set\` authors: \`start\` is the
|
|
90015
|
+
* effective level-start (omitted when 1), \`format\` the friendly
|
|
90016
|
+
* \`--format\` glyph vocabulary (decimal/lower-alpha/upper-roman/\u2026, omitted
|
|
90017
|
+
* when the default \`decimal\`). Two paragraphs sharing a \`numId\` are the same
|
|
90018
|
+
* (or continued) list, so a \`--continue\` link needs no field of its own. */
|
|
90019
|
+
list?: {
|
|
90020
|
+
level: number;
|
|
90021
|
+
numId: string;
|
|
90022
|
+
ordered?: boolean;
|
|
90023
|
+
start?: number;
|
|
90024
|
+
format?: string;
|
|
90025
|
+
};
|
|
89573
90026
|
/** GFM task-list marker. Set when the paragraph's first content is a Word
|
|
89574
90027
|
* checkbox content control (\`<w:sdt><w14:checkbox/></w:sdt>\`); the SDT itself
|
|
89575
90028
|
* plus the leading whitespace run after it are stripped from \`runs\` so the
|
|
@@ -89642,6 +90095,10 @@ export type Table = {
|
|
|
89642
90095
|
* \`borders\` summary. Surfaced so \`styles --used\` can report the table styles
|
|
89643
90096
|
* a document actually applies. Present only when the table references one. */
|
|
89644
90097
|
style?: string;
|
|
90098
|
+
/** Justification of the whole table on the page, from \`<w:tblPr><w:jc w:val="\u2026"/>\`
|
|
90099
|
+
* (\`"center"\` / \`"right"\`). Absent \u21D2 the default \`"left"\`. Authorable via
|
|
90100
|
+
* \`docx tables format --at tN --align\`. */
|
|
90101
|
+
align?: "left" | "center" | "right";
|
|
89645
90102
|
rows: TableRow[];
|
|
89646
90103
|
};
|
|
89647
90104
|
|
|
@@ -89650,6 +90107,15 @@ export type TableRow = {
|
|
|
89650
90107
|
/** Tracked row insertion/deletion from <w:trPr><w:ins/> or <w:del/>
|
|
89651
90108
|
* (kind "rowIns" / "rowDel"). Present only under track-changes. */
|
|
89652
90109
|
trackedChange?: TrackedChange;
|
|
90110
|
+
/** Row height from \`<w:trPr><w:trHeight w:val="\u2026" w:hRule="\u2026"/>\`. \`value\` is
|
|
90111
|
+
* in twips; \`rule\` is \`atLeast\` (minimum, the default), \`exact\` (fixed), or
|
|
90112
|
+
* \`auto\` (fit content). Present only when the row declares an explicit height.
|
|
90113
|
+
* Authorable via \`docx tables format --at tN:rR --row-height\`. */
|
|
90114
|
+
height?: { value: number; rule: "atLeast" | "exact" | "auto" };
|
|
90115
|
+
/** Whether the row repeats as a header at the top of each page that the table
|
|
90116
|
+
* spans, from \`<w:trPr><w:tblHeader/>\`. Present (true) only when the marker is
|
|
90117
|
+
* set. Authorable via \`docx tables format --at tN:rR --repeat-header\`. */
|
|
90118
|
+
repeatHeader?: boolean;
|
|
89653
90119
|
};
|
|
89654
90120
|
|
|
89655
90121
|
export type TableCell = {
|
|
@@ -89674,6 +90140,17 @@ export type TableCell = {
|
|
|
89674
90140
|
* hint \u2014 GFM can't show cell shading; the fill survives edits via in-place
|
|
89675
90141
|
* mutation. */
|
|
89676
90142
|
shading?: string;
|
|
90143
|
+
/** Vertical alignment of the cell's content from \`<w:tcPr><w:vAlign w:val="\u2026"/>\`
|
|
90144
|
+
* (\`"center"\` / \`"bottom"\`). Absent \u21D2 the default \`"top"\`. Authorable via
|
|
90145
|
+
* \`docx tables format --at \u2026 --valign\`. (Horizontal alignment is NOT a cell
|
|
90146
|
+
* property \u2014 it lives on each paragraph's \`<w:jc>\`, surfaced as \`docx:p align\`.) */
|
|
90147
|
+
vAlign?: "top" | "center" | "bottom";
|
|
90148
|
+
/** Summary of \`<w:tcPr><w:tcBorders>\` \u2014 the set edges and their dominant style,
|
|
90149
|
+
* as a compact \`side:style\` string (e.g. \`"bottom:double"\`, \`"all:single"\`).
|
|
90150
|
+
* A read-time hint mirroring \`Table.borders\`; full per-edge fidelity stays in
|
|
90151
|
+
* the XML via in-place mutation. Authorable via \`docx tables format --at \u2026
|
|
90152
|
+
* --cell-borders\`. Present only when the cell declares explicit borders. */
|
|
90153
|
+
borders?: string;
|
|
89677
90154
|
};
|
|
89678
90155
|
|
|
89679
90156
|
export type TableWidth = {
|
|
@@ -90042,7 +90519,10 @@ var init_schema = __esm(() => {
|
|
|
90042
90519
|
required: ["level", "numId"],
|
|
90043
90520
|
properties: {
|
|
90044
90521
|
level: { type: "number" },
|
|
90045
|
-
numId: { type: "string" }
|
|
90522
|
+
numId: { type: "string" },
|
|
90523
|
+
ordered: { type: "boolean" },
|
|
90524
|
+
start: { type: "number" },
|
|
90525
|
+
format: { type: "string" }
|
|
90046
90526
|
}
|
|
90047
90527
|
},
|
|
90048
90528
|
taskState: { enum: ["checked", "unchecked"] },
|
|
@@ -90236,6 +90716,7 @@ var init_schema = __esm(() => {
|
|
|
90236
90716
|
width: { $ref: "#/$defs/TableWidth" },
|
|
90237
90717
|
borders: { type: "string" },
|
|
90238
90718
|
style: { type: "string" },
|
|
90719
|
+
align: { enum: ["left", "center", "right"] },
|
|
90239
90720
|
rows: {
|
|
90240
90721
|
type: "array",
|
|
90241
90722
|
items: {
|
|
@@ -90254,6 +90735,8 @@ var init_schema = __esm(() => {
|
|
|
90254
90735
|
vMerge: { enum: ["restart", "continue"] },
|
|
90255
90736
|
width: { $ref: "#/$defs/TableWidth" },
|
|
90256
90737
|
shading: { type: "string" },
|
|
90738
|
+
vAlign: { enum: ["top", "center", "bottom"] },
|
|
90739
|
+
borders: { type: "string" },
|
|
90257
90740
|
trackedChange: {
|
|
90258
90741
|
$ref: "#/$defs/TableRevision",
|
|
90259
90742
|
description: "cellIns / cellDel (tracked column change)"
|
|
@@ -90264,7 +90747,15 @@ var init_schema = __esm(() => {
|
|
|
90264
90747
|
trackedChange: {
|
|
90265
90748
|
$ref: "#/$defs/TableRevision",
|
|
90266
90749
|
description: "rowIns / rowDel (tracked row change)"
|
|
90267
|
-
}
|
|
90750
|
+
},
|
|
90751
|
+
height: {
|
|
90752
|
+
type: "object",
|
|
90753
|
+
properties: {
|
|
90754
|
+
value: { type: "number" },
|
|
90755
|
+
rule: { enum: ["atLeast", "exact", "auto"] }
|
|
90756
|
+
}
|
|
90757
|
+
},
|
|
90758
|
+
repeatHeader: { type: "boolean" }
|
|
90268
90759
|
}
|
|
90269
90760
|
}
|
|
90270
90761
|
}
|
|
@@ -90576,6 +91067,216 @@ var init_info = __esm(() => {
|
|
|
90576
91067
|
};
|
|
90577
91068
|
});
|
|
90578
91069
|
|
|
91070
|
+
// src/cli/lists/set.ts
|
|
91071
|
+
var exports_set = {};
|
|
91072
|
+
__export(exports_set, {
|
|
91073
|
+
run: () => run34
|
|
91074
|
+
});
|
|
91075
|
+
async function run34(args) {
|
|
91076
|
+
const parsed = await tryParseArgs(args, {
|
|
91077
|
+
at: { type: "string" },
|
|
91078
|
+
start: { type: "string" },
|
|
91079
|
+
format: { type: "string" },
|
|
91080
|
+
restart: { type: "boolean" },
|
|
91081
|
+
continue: { type: "boolean" },
|
|
91082
|
+
...SAVE_FLAGS
|
|
91083
|
+
}, HELP30);
|
|
91084
|
+
if (typeof parsed === "number")
|
|
91085
|
+
return parsed;
|
|
91086
|
+
if (parsed.values.help) {
|
|
91087
|
+
await writeStdout(HELP30);
|
|
91088
|
+
return EXIT2.OK;
|
|
91089
|
+
}
|
|
91090
|
+
setVerboseAck(Boolean(parsed.values.verbose));
|
|
91091
|
+
const path2 = parsed.positionals[0];
|
|
91092
|
+
if (!path2)
|
|
91093
|
+
return fail("USAGE", "Missing FILE argument", HELP30);
|
|
91094
|
+
const at = parsed.values.at;
|
|
91095
|
+
if (!at) {
|
|
91096
|
+
return fail("USAGE", "Missing --at LOCATOR (a list item, e.g. p5)", HELP30);
|
|
91097
|
+
}
|
|
91098
|
+
const plan = buildPlan(parsed.values);
|
|
91099
|
+
if (typeof plan === "string")
|
|
91100
|
+
return fail("USAGE", plan);
|
|
91101
|
+
const document4 = await openOrFail(path2);
|
|
91102
|
+
if (typeof document4 === "number")
|
|
91103
|
+
return document4;
|
|
91104
|
+
const blockRef = await resolveBlockOrFail(document4, at);
|
|
91105
|
+
if (typeof blockRef === "number")
|
|
91106
|
+
return blockRef;
|
|
91107
|
+
const orderedError = validateOrderedList(document4, at);
|
|
91108
|
+
if (orderedError)
|
|
91109
|
+
return fail("USAGE", orderedError);
|
|
91110
|
+
const outputPath = parsed.values.output;
|
|
91111
|
+
if (parsed.values["dry-run"]) {
|
|
91112
|
+
await respond({
|
|
91113
|
+
operation: "lists.set",
|
|
91114
|
+
dryRun: true,
|
|
91115
|
+
path: path2,
|
|
91116
|
+
at,
|
|
91117
|
+
applied: appliedList(plan),
|
|
91118
|
+
...outputPath ? { output: outputPath } : {}
|
|
91119
|
+
});
|
|
91120
|
+
return EXIT2.OK;
|
|
91121
|
+
}
|
|
91122
|
+
const lists = new Lists(document4);
|
|
91123
|
+
try {
|
|
91124
|
+
if (plan.continue) {
|
|
91125
|
+
lists.continue(blockRef);
|
|
91126
|
+
} else if (plan.restart) {
|
|
91127
|
+
lists.restart(blockRef, plan.start ?? 1);
|
|
91128
|
+
if (plan.format)
|
|
91129
|
+
lists.setFormat(blockRef, plan.format);
|
|
91130
|
+
} else {
|
|
91131
|
+
if (plan.start !== undefined)
|
|
91132
|
+
lists.setStart(blockRef, plan.start);
|
|
91133
|
+
if (plan.format)
|
|
91134
|
+
lists.setFormat(blockRef, plan.format);
|
|
91135
|
+
}
|
|
91136
|
+
} catch (error) {
|
|
91137
|
+
if (error instanceof ListOperationError) {
|
|
91138
|
+
return fail("BLOCK_NOT_FOUND", error.message);
|
|
91139
|
+
}
|
|
91140
|
+
throw error;
|
|
91141
|
+
}
|
|
91142
|
+
await document4.save(outputPath);
|
|
91143
|
+
const destination = outputPath ?? path2;
|
|
91144
|
+
await respondAck({
|
|
91145
|
+
ok: true,
|
|
91146
|
+
operation: "lists.set",
|
|
91147
|
+
path: destination,
|
|
91148
|
+
locator: at,
|
|
91149
|
+
applied: appliedList(plan)
|
|
91150
|
+
});
|
|
91151
|
+
return EXIT2.OK;
|
|
91152
|
+
}
|
|
91153
|
+
function buildPlan(values2) {
|
|
91154
|
+
const restart = Boolean(values2.restart);
|
|
91155
|
+
const continueFlag = Boolean(values2.continue);
|
|
91156
|
+
if (restart && continueFlag) {
|
|
91157
|
+
return "Pass only one of --restart / --continue";
|
|
91158
|
+
}
|
|
91159
|
+
let start;
|
|
91160
|
+
if (values2.start !== undefined) {
|
|
91161
|
+
const parsedStart = Number(values2.start);
|
|
91162
|
+
if (!Number.isInteger(parsedStart) || parsedStart < 1) {
|
|
91163
|
+
return `--start must be a positive integer (got ${values2.start})`;
|
|
91164
|
+
}
|
|
91165
|
+
start = parsedStart;
|
|
91166
|
+
}
|
|
91167
|
+
let format;
|
|
91168
|
+
if (values2.format !== undefined) {
|
|
91169
|
+
const candidate = String(values2.format);
|
|
91170
|
+
if (!Object.hasOwn(FORMAT_TO_NUMFMT, candidate)) {
|
|
91171
|
+
return `--format must be one of ${Object.keys(FORMAT_TO_NUMFMT).join(", ")} (got ${candidate})`;
|
|
91172
|
+
}
|
|
91173
|
+
format = candidate;
|
|
91174
|
+
}
|
|
91175
|
+
if (continueFlag && (start !== undefined || format !== undefined)) {
|
|
91176
|
+
return "--continue adopts the previous list's numbering \u2014 it can't combine with --start/--format";
|
|
91177
|
+
}
|
|
91178
|
+
if (!restart && !continueFlag && start === undefined && format === undefined) {
|
|
91179
|
+
return "Nothing to do \u2014 pass --start, --format, --restart, or --continue";
|
|
91180
|
+
}
|
|
91181
|
+
return { start, format, restart, continue: continueFlag };
|
|
91182
|
+
}
|
|
91183
|
+
function validateOrderedList(document4, at) {
|
|
91184
|
+
const block = document4.body.findBlockById(at);
|
|
91185
|
+
if (!block || block.type !== "paragraph" || !block.list) {
|
|
91186
|
+
return `${at} is not a list item \u2014 list numbering controls only apply to numbered lists`;
|
|
91187
|
+
}
|
|
91188
|
+
if (!block.list.ordered) {
|
|
91189
|
+
return `${at} is a bulleted list \u2014 numbering controls (start/format/restart/continue) apply to numbered (ordered) lists`;
|
|
91190
|
+
}
|
|
91191
|
+
return null;
|
|
91192
|
+
}
|
|
91193
|
+
function appliedList(plan) {
|
|
91194
|
+
const applied = [];
|
|
91195
|
+
if (plan.continue)
|
|
91196
|
+
applied.push("continue");
|
|
91197
|
+
if (plan.restart)
|
|
91198
|
+
applied.push("restart");
|
|
91199
|
+
if (plan.start !== undefined)
|
|
91200
|
+
applied.push(`start=${plan.start}`);
|
|
91201
|
+
if (plan.format)
|
|
91202
|
+
applied.push(`format=${plan.format}`);
|
|
91203
|
+
return applied;
|
|
91204
|
+
}
|
|
91205
|
+
var HELP30 = `docx lists set \u2014 renumber a numbered list (start value, glyph format, restart/continue)
|
|
91206
|
+
|
|
91207
|
+
Usage:
|
|
91208
|
+
docx lists set FILE --at pN [options]
|
|
91209
|
+
|
|
91210
|
+
--at names any item of a NUMBERED (ordered) list. --start/--format change the whole
|
|
91211
|
+
list (every paragraph sharing its numbering); --restart/--continue act from the
|
|
91212
|
+
addressed item onward. Bulleted lists aren't numbered, so they're rejected.
|
|
91213
|
+
|
|
91214
|
+
Options:
|
|
91215
|
+
--start N Start the list's numbering at N (a positive integer)
|
|
91216
|
+
--format FMT Glyph style: decimal | lower-alpha | upper-alpha | lower-roman | upper-roman
|
|
91217
|
+
(decimal = 1.2.3., lower-alpha = a.b.c., upper-roman = I.II.III., \u2026)
|
|
91218
|
+
--restart Begin a FRESH list at this item: split it off with its own numbering
|
|
91219
|
+
(combine with --start/--format to set the new list's first number/style)
|
|
91220
|
+
--continue Continue the PREVIOUS list's numbering here instead of restarting at 1
|
|
91221
|
+
-o, --output PATH / --dry-run / -v, --verbose / -h, --help
|
|
91222
|
+
|
|
91223
|
+
--restart and --continue are mutually exclusive; --continue can't combine with
|
|
91224
|
+
--start/--format (it adopts the previous list's numbering). List numbering edits
|
|
91225
|
+
are applied directly (untracked) \u2014 Word records no revision for them.
|
|
91226
|
+
|
|
91227
|
+
Examples:
|
|
91228
|
+
docx lists set report.docx --at p12 --start 5
|
|
91229
|
+
docx lists set report.docx --at p12 --format upper-roman
|
|
91230
|
+
docx lists set report.docx --at p20 --restart --start 1
|
|
91231
|
+
docx lists set report.docx --at p20 --continue
|
|
91232
|
+
`;
|
|
91233
|
+
var init_set2 = __esm(() => {
|
|
91234
|
+
init_core2();
|
|
91235
|
+
init_respond();
|
|
91236
|
+
});
|
|
91237
|
+
|
|
91238
|
+
// src/cli/lists/index.ts
|
|
91239
|
+
var exports_lists = {};
|
|
91240
|
+
__export(exports_lists, {
|
|
91241
|
+
run: () => run35
|
|
91242
|
+
});
|
|
91243
|
+
async function run35(args) {
|
|
91244
|
+
const verb = args[0];
|
|
91245
|
+
if (!verb || verb === "--help" || verb === "-h" || verb === "help") {
|
|
91246
|
+
await writeStdout(HELP31);
|
|
91247
|
+
return verb ? 0 : 2;
|
|
91248
|
+
}
|
|
91249
|
+
const loader = SUBCOMMANDS9[verb];
|
|
91250
|
+
if (!loader) {
|
|
91251
|
+
return fail("USAGE", `Unknown lists subcommand: ${verb}`, 'Run "docx lists --help".');
|
|
91252
|
+
}
|
|
91253
|
+
const module_ = await loader();
|
|
91254
|
+
return module_.run(args.slice(1));
|
|
91255
|
+
}
|
|
91256
|
+
var SUBCOMMANDS9, HELP31 = `docx lists \u2014 control list numbering (start value, glyph format, restart/continue)
|
|
91257
|
+
|
|
91258
|
+
Usage:
|
|
91259
|
+
docx lists set FILE --at pN [options]
|
|
91260
|
+
|
|
91261
|
+
Verbs:
|
|
91262
|
+
set Renumber a numbered list \u2014 set its start value or glyph format, or make it
|
|
91263
|
+
restart vs. continue the previous list
|
|
91264
|
+
(--at pN [--start N] [--format FMT] [--restart] [--continue])
|
|
91265
|
+
|
|
91266
|
+
Lists are otherwise handled by the standard verbs:
|
|
91267
|
+
create a list docx insert FILE --after pN --list "first,second" (or markdown "1. \u2026")
|
|
91268
|
+
edit an item docx edit FILE --at pN --text "..."
|
|
91269
|
+
inspect docx read FILE --ast (list.numId / level / ordered / start / format)
|
|
91270
|
+
|
|
91271
|
+
Run "docx lists set --help" for option detail.
|
|
91272
|
+
`;
|
|
91273
|
+
var init_lists2 = __esm(() => {
|
|
91274
|
+
init_respond();
|
|
91275
|
+
SUBCOMMANDS9 = {
|
|
91276
|
+
set: () => Promise.resolve().then(() => (init_set2(), exports_set))
|
|
91277
|
+
};
|
|
91278
|
+
});
|
|
91279
|
+
|
|
90579
91280
|
// src/cli/outline/build.ts
|
|
90580
91281
|
function buildOutline(doc, options = {}) {
|
|
90581
91282
|
const stylePrefix = options.stylePrefix ?? "Heading";
|
|
@@ -90637,23 +91338,23 @@ var init_build = __esm(() => {
|
|
|
90637
91338
|
// src/cli/outline/index.ts
|
|
90638
91339
|
var exports_outline = {};
|
|
90639
91340
|
__export(exports_outline, {
|
|
90640
|
-
run: () =>
|
|
91341
|
+
run: () => run36
|
|
90641
91342
|
});
|
|
90642
|
-
async function
|
|
91343
|
+
async function run36(args) {
|
|
90643
91344
|
const parsed = await tryParseArgs(args, {
|
|
90644
91345
|
"style-prefix": { type: "string" },
|
|
90645
91346
|
json: { type: "boolean" },
|
|
90646
91347
|
help: { type: "boolean", short: "h" }
|
|
90647
|
-
},
|
|
91348
|
+
}, HELP32);
|
|
90648
91349
|
if (typeof parsed === "number")
|
|
90649
91350
|
return parsed;
|
|
90650
91351
|
if (parsed.values.help) {
|
|
90651
|
-
await writeStdout(
|
|
91352
|
+
await writeStdout(HELP32);
|
|
90652
91353
|
return EXIT2.OK;
|
|
90653
91354
|
}
|
|
90654
91355
|
const path2 = parsed.positionals[0];
|
|
90655
91356
|
if (!path2)
|
|
90656
|
-
return fail("USAGE", "Missing FILE argument",
|
|
91357
|
+
return fail("USAGE", "Missing FILE argument", HELP32);
|
|
90657
91358
|
const stylePrefix = parsed.values["style-prefix"] ?? "Heading";
|
|
90658
91359
|
if (stylePrefix.length === 0) {
|
|
90659
91360
|
return fail("USAGE", "--style-prefix cannot be empty");
|
|
@@ -90681,7 +91382,7 @@ function renderOutlineText(entries, depth = 0) {
|
|
|
90681
91382
|
}
|
|
90682
91383
|
return lines;
|
|
90683
91384
|
}
|
|
90684
|
-
var
|
|
91385
|
+
var HELP32 = `docx outline \u2014 list headings as a hierarchical tree
|
|
90685
91386
|
|
|
90686
91387
|
Usage:
|
|
90687
91388
|
docx outline FILE [options]
|
|
@@ -90761,6 +91462,8 @@ function renderMarkdown(doc, options = {}) {
|
|
|
90761
91462
|
referencedEndnoteIds: new Set,
|
|
90762
91463
|
referencedTrackedChanges: new Map,
|
|
90763
91464
|
orderedCounters: new Map,
|
|
91465
|
+
prevListNumId: null,
|
|
91466
|
+
seenListNumIds: new Set,
|
|
90764
91467
|
contentWidthEmu: contentWidthEmu(documentGeometry(blocks)?.geometry),
|
|
90765
91468
|
governingColumns: computeGoverningColumns(blocks),
|
|
90766
91469
|
wrappingTabLines: [],
|
|
@@ -90847,17 +91550,17 @@ function detectFormatBaseline(blocks) {
|
|
|
90847
91550
|
const sizeChars = new Map;
|
|
90848
91551
|
let total = 0;
|
|
90849
91552
|
for (const paragraph2 of flattenParagraphs(blocks)) {
|
|
90850
|
-
for (const
|
|
90851
|
-
if (
|
|
91553
|
+
for (const run37 of paragraph2.runs) {
|
|
91554
|
+
if (run37.type !== "text")
|
|
90852
91555
|
continue;
|
|
90853
|
-
const length =
|
|
91556
|
+
const length = run37.text.length;
|
|
90854
91557
|
if (length === 0)
|
|
90855
91558
|
continue;
|
|
90856
91559
|
total += length;
|
|
90857
|
-
if (
|
|
90858
|
-
fontChars.set(
|
|
90859
|
-
if (
|
|
90860
|
-
sizeChars.set(
|
|
91560
|
+
if (run37.font)
|
|
91561
|
+
fontChars.set(run37.font, (fontChars.get(run37.font) ?? 0) + length);
|
|
91562
|
+
if (run37.sizeHalfPoints !== undefined) {
|
|
91563
|
+
sizeChars.set(run37.sizeHalfPoints, (sizeChars.get(run37.sizeHalfPoints) ?? 0) + length);
|
|
90861
91564
|
}
|
|
90862
91565
|
}
|
|
90863
91566
|
}
|
|
@@ -90891,8 +91594,8 @@ function emptyCommentIndex() {
|
|
|
90891
91594
|
orderedIds: []
|
|
90892
91595
|
};
|
|
90893
91596
|
}
|
|
90894
|
-
function isRunVisible(
|
|
90895
|
-
const kind =
|
|
91597
|
+
function isRunVisible(run37, view) {
|
|
91598
|
+
const kind = run37.trackedChange?.kind;
|
|
90896
91599
|
if (!kind)
|
|
90897
91600
|
return true;
|
|
90898
91601
|
if (view === "accepted" && (kind === "del" || kind === "moveFrom"))
|
|
@@ -90907,13 +91610,13 @@ function buildCommentIndex(blocks, options) {
|
|
|
90907
91610
|
const spanText = new Map;
|
|
90908
91611
|
const orderedIds = [];
|
|
90909
91612
|
for (const paragraph2 of flattenParagraphs(blocks)) {
|
|
90910
|
-
paragraph2.runs.forEach((
|
|
90911
|
-
const comments = runComments(
|
|
91613
|
+
paragraph2.runs.forEach((run37, index2) => {
|
|
91614
|
+
const comments = runComments(run37);
|
|
90912
91615
|
if (!comments)
|
|
90913
91616
|
return;
|
|
90914
|
-
if (
|
|
91617
|
+
if (run37.type === "text" && !isRunVisible(run37, view))
|
|
90915
91618
|
return;
|
|
90916
|
-
const spanContribution =
|
|
91619
|
+
const spanContribution = run37.type === "text" ? run37.text : run37.type === "equation" ? run37.text : "";
|
|
90917
91620
|
for (const commentId of comments) {
|
|
90918
91621
|
if (!spanText.has(commentId))
|
|
90919
91622
|
orderedIds.push(commentId);
|
|
@@ -90933,11 +91636,11 @@ function buildCommentIndex(blocks, options) {
|
|
|
90933
91636
|
}
|
|
90934
91637
|
return { endingsByRun, spanText, orderedIds };
|
|
90935
91638
|
}
|
|
90936
|
-
function runComments(
|
|
90937
|
-
if (
|
|
90938
|
-
return
|
|
90939
|
-
if (
|
|
90940
|
-
return
|
|
91639
|
+
function runComments(run37) {
|
|
91640
|
+
if (run37.type === "text")
|
|
91641
|
+
return run37.comments;
|
|
91642
|
+
if (run37.type === "equation")
|
|
91643
|
+
return run37.comments;
|
|
90941
91644
|
return;
|
|
90942
91645
|
}
|
|
90943
91646
|
function slotKey(paragraphId, runIndex) {
|
|
@@ -90946,6 +91649,7 @@ function slotKey(paragraphId, runIndex) {
|
|
|
90946
91649
|
function renderBlock(block, ctx) {
|
|
90947
91650
|
if (block.type === "paragraph")
|
|
90948
91651
|
return renderParagraph(block, ctx);
|
|
91652
|
+
ctx.prevListNumId = null;
|
|
90949
91653
|
if (block.type === "table")
|
|
90950
91654
|
return renderTable(block, ctx);
|
|
90951
91655
|
return null;
|
|
@@ -91009,7 +91713,7 @@ function tabCureRange(ids) {
|
|
|
91009
91713
|
return min === max ? `p${min}` : `p${min}-p${max}`;
|
|
91010
91714
|
}
|
|
91011
91715
|
function layoutHazardNote(paragraph2, ctx) {
|
|
91012
|
-
if (!paragraph2.runs.some((
|
|
91716
|
+
if (!paragraph2.runs.some((run37) => run37.type === "tab"))
|
|
91013
91717
|
return "";
|
|
91014
91718
|
const cols = ctx.governingColumns.get(paragraph2.id) ?? 1;
|
|
91015
91719
|
if (cols > 1) {
|
|
@@ -91082,25 +91786,25 @@ function contentWidthEmu(geometry) {
|
|
|
91082
91786
|
const fallback = (DEFAULT_PAGE.width - 2 * DEFAULT_PAGE.margin) * EMU_PER_TWIP2;
|
|
91083
91787
|
return contentTwips > 0 ? contentTwips * EMU_PER_TWIP2 : fallback;
|
|
91084
91788
|
}
|
|
91085
|
-
function formatImageNote(
|
|
91789
|
+
function formatImageNote(run37, contentEmu) {
|
|
91086
91790
|
const pairs = [];
|
|
91087
|
-
if (
|
|
91791
|
+
if (run37.widthEmu && run37.heightEmu) {
|
|
91088
91792
|
pairs.push([
|
|
91089
91793
|
"size",
|
|
91090
|
-
`${emuToInches(
|
|
91794
|
+
`${emuToInches(run37.widthEmu)}x${emuToInches(run37.heightEmu)}in`
|
|
91091
91795
|
]);
|
|
91092
91796
|
}
|
|
91093
|
-
if (
|
|
91797
|
+
if (run37.floating)
|
|
91094
91798
|
pairs.push(["float", "yes"]);
|
|
91095
|
-
if (
|
|
91096
|
-
pairs.push(["wrap",
|
|
91097
|
-
if (
|
|
91098
|
-
pairs.push(["align",
|
|
91099
|
-
if (
|
|
91799
|
+
if (run37.wrap)
|
|
91800
|
+
pairs.push(["wrap", run37.wrap]);
|
|
91801
|
+
if (run37.align)
|
|
91802
|
+
pairs.push(["align", run37.align]);
|
|
91803
|
+
if (run37.widthEmu && run37.widthEmu > contentEmu)
|
|
91100
91804
|
pairs.push(["overflow", "yes"]);
|
|
91101
91805
|
if (pairs.length === 0)
|
|
91102
91806
|
return "";
|
|
91103
|
-
return ` ${formatNote("image", pairs, [
|
|
91807
|
+
return ` ${formatNote("image", pairs, [run37.id])}`;
|
|
91104
91808
|
}
|
|
91105
91809
|
function documentGeometry(blocks) {
|
|
91106
91810
|
const geometric = blocks.filter((block) => block.type === "sectionBreak" && hasGeometry(block));
|
|
@@ -91206,14 +91910,14 @@ function isCodeBlockParagraph(block) {
|
|
|
91206
91910
|
function renderCodeBlockGroup(paragraphs, ctx) {
|
|
91207
91911
|
if (ctx.options.view !== "baseline" && ctx.options.view !== "accepted") {
|
|
91208
91912
|
for (const paragraph2 of paragraphs) {
|
|
91209
|
-
for (const
|
|
91210
|
-
if (
|
|
91211
|
-
ctx.referencedTrackedChanges.set(
|
|
91913
|
+
for (const run37 of paragraph2.runs) {
|
|
91914
|
+
if (run37.type === "text" && run37.trackedChange) {
|
|
91915
|
+
ctx.referencedTrackedChanges.set(run37.trackedChange.id, run37.trackedChange);
|
|
91212
91916
|
}
|
|
91213
91917
|
}
|
|
91214
91918
|
}
|
|
91215
91919
|
}
|
|
91216
|
-
const lines = paragraphs.map((paragraph2) => paragraph2.runs.filter((
|
|
91920
|
+
const lines = paragraphs.map((paragraph2) => paragraph2.runs.filter((run37) => run37.type === "text" && typeof run37.text === "string").map((run37) => run37.text).join(""));
|
|
91217
91921
|
const firstId = paragraphs[0]?.id ?? "";
|
|
91218
91922
|
const lastId = paragraphs[paragraphs.length - 1]?.id ?? firstId;
|
|
91219
91923
|
const language = codeBlockLanguageFromStyleId(paragraphs[0]?.style) ?? "";
|
|
@@ -91227,11 +91931,14 @@ function renderParagraph(paragraph2, ctx) {
|
|
|
91227
91931
|
const view = ctx.options.view ?? "accepted";
|
|
91228
91932
|
const mask = inlineEscapeMask(paragraphContent(paragraph2.runs, view), hasEquationRun(paragraph2.runs));
|
|
91229
91933
|
const rendered = renderRuns(paragraph2.id, paragraph2.runs, ctx, mask, 0);
|
|
91230
|
-
if (rendered.length === 0)
|
|
91934
|
+
if (rendered.length === 0) {
|
|
91935
|
+
ctx.prevListNumId = paragraph2.list?.numId ?? null;
|
|
91231
91936
|
return null;
|
|
91937
|
+
}
|
|
91232
91938
|
const prefix = paragraphPrefix(paragraph2, orderedOrdinal(paragraph2, ctx));
|
|
91233
91939
|
const body = rendered.replace(/[ \t]+$/, "");
|
|
91234
|
-
const
|
|
91940
|
+
const listNote = listAnnotation(paragraph2, ctx);
|
|
91941
|
+
const note = listNote !== "" ? listNote : formatParagraphNote(paragraph2);
|
|
91235
91942
|
const locatorOrNote = note !== "" ? note : ` <!-- ${paragraph2.id} -->`;
|
|
91236
91943
|
const trailing = `${locatorOrNote}${layoutHazardNote(paragraph2, ctx)}`;
|
|
91237
91944
|
if (isDisplayEquationOnly(body)) {
|
|
@@ -91296,7 +92003,8 @@ function orderedOrdinal(paragraph2, ctx) {
|
|
|
91296
92003
|
return 1;
|
|
91297
92004
|
const { numId, level } = paragraph2.list;
|
|
91298
92005
|
const key = `${numId}:${level}`;
|
|
91299
|
-
const
|
|
92006
|
+
const base = ctx.orderedCounters.get(key) ?? (paragraph2.list.start ?? 1) - 1;
|
|
92007
|
+
const next = base + 1;
|
|
91300
92008
|
ctx.orderedCounters.set(key, next);
|
|
91301
92009
|
for (const existing of ctx.orderedCounters.keys()) {
|
|
91302
92010
|
const [keyNumId, keyLevel] = existing.split(":");
|
|
@@ -91306,6 +92014,32 @@ function orderedOrdinal(paragraph2, ctx) {
|
|
|
91306
92014
|
}
|
|
91307
92015
|
return next;
|
|
91308
92016
|
}
|
|
92017
|
+
function listAnnotation(paragraph2, ctx) {
|
|
92018
|
+
const list3 = paragraph2.list;
|
|
92019
|
+
if (!list3) {
|
|
92020
|
+
ctx.prevListNumId = null;
|
|
92021
|
+
return "";
|
|
92022
|
+
}
|
|
92023
|
+
const isRunStart = ctx.prevListNumId !== list3.numId;
|
|
92024
|
+
ctx.prevListNumId = list3.numId;
|
|
92025
|
+
if (!isRunStart)
|
|
92026
|
+
return "";
|
|
92027
|
+
const isContinuation = ctx.seenListNumIds.has(list3.numId);
|
|
92028
|
+
ctx.seenListNumIds.add(list3.numId);
|
|
92029
|
+
if (!list3.ordered)
|
|
92030
|
+
return "";
|
|
92031
|
+
if (isContinuation) {
|
|
92032
|
+
return ` ${formatNote("list", [], [paragraph2.id, "continues"])}`;
|
|
92033
|
+
}
|
|
92034
|
+
const pairs = [];
|
|
92035
|
+
if (list3.start !== undefined && list3.start !== 1)
|
|
92036
|
+
pairs.push(["start", list3.start]);
|
|
92037
|
+
if (list3.format)
|
|
92038
|
+
pairs.push(["format", list3.format]);
|
|
92039
|
+
if (pairs.length === 0)
|
|
92040
|
+
return "";
|
|
92041
|
+
return ` ${formatNote("list", pairs, [paragraph2.id])}`;
|
|
92042
|
+
}
|
|
91309
92043
|
function paragraphPrefix(paragraph2, ordinal) {
|
|
91310
92044
|
const quotePrefix = paragraph2.quoteDepth ? "> ".repeat(paragraph2.quoteDepth) : "";
|
|
91311
92045
|
const headingLevel2 = headingLevelFor(paragraph2.style);
|
|
@@ -91336,10 +92070,10 @@ function headingLevelFor(style) {
|
|
|
91336
92070
|
function renderRuns(paragraphId, runs, ctx, mask, baseOffset) {
|
|
91337
92071
|
const view = ctx.options.view ?? "accepted";
|
|
91338
92072
|
const visibleEntries = [];
|
|
91339
|
-
runs.forEach((
|
|
91340
|
-
if (
|
|
92073
|
+
runs.forEach((run37, index2) => {
|
|
92074
|
+
if (run37.type === "text" && !isRunVisible(run37, view))
|
|
91341
92075
|
return;
|
|
91342
|
-
visibleEntries.push({ run:
|
|
92076
|
+
visibleEntries.push({ run: run37, originalIndex: index2 });
|
|
91343
92077
|
});
|
|
91344
92078
|
let out = "";
|
|
91345
92079
|
let cursor = 0;
|
|
@@ -91350,14 +92084,14 @@ function renderRuns(paragraphId, runs, ctx, mask, baseOffset) {
|
|
|
91350
92084
|
cursor++;
|
|
91351
92085
|
continue;
|
|
91352
92086
|
}
|
|
91353
|
-
const { run:
|
|
91354
|
-
if (
|
|
92087
|
+
const { run: run37 } = entry;
|
|
92088
|
+
if (run37.type === "text") {
|
|
91355
92089
|
let lookahead2 = cursor + 1;
|
|
91356
92090
|
while (lookahead2 < visibleEntries.length) {
|
|
91357
92091
|
const next = visibleEntries[lookahead2];
|
|
91358
92092
|
if (!next || next.run.type !== "text")
|
|
91359
92093
|
break;
|
|
91360
|
-
if (!sameDecoration(
|
|
92094
|
+
if (!sameDecoration(run37, next.run))
|
|
91361
92095
|
break;
|
|
91362
92096
|
lookahead2++;
|
|
91363
92097
|
}
|
|
@@ -91378,29 +92112,29 @@ function renderRuns(paragraphId, runs, ctx, mask, baseOffset) {
|
|
|
91378
92112
|
cursor = lookahead2;
|
|
91379
92113
|
continue;
|
|
91380
92114
|
}
|
|
91381
|
-
if (
|
|
91382
|
-
const alt = sanitizeAltText(
|
|
91383
|
-
const extension2 = extensionForImageMime(
|
|
91384
|
-
out += ` {
|
|
92116
|
+
const alt = sanitizeAltText(run37.alt ?? run37.id);
|
|
92117
|
+
const extension2 = extensionForImageMime(run37.contentType) ?? "bin";
|
|
92118
|
+
out += ``;
|
|
92119
|
+
out += formatImageNote(run37, ctx.contentWidthEmu);
|
|
92120
|
+
} else if (run37.type === "break") {
|
|
92121
|
+
if (run37.kind === "line")
|
|
91388
92122
|
out += `
|
|
91389
92123
|
`;
|
|
91390
|
-
} else if (
|
|
92124
|
+
} else if (run37.type === "tab") {
|
|
91391
92125
|
out += "\t";
|
|
91392
|
-
} else if (
|
|
91393
|
-
const body =
|
|
91394
|
-
out +=
|
|
92126
|
+
} else if (run37.type === "equation") {
|
|
92127
|
+
const body = run37.latex.length > 0 ? run37.latex : run37.text;
|
|
92128
|
+
out += run37.display ? `$$${body}$$` : `$${body}$`;
|
|
91395
92129
|
out += commentEndingsFor(paragraphId, [{ originalIndex: cursor }], ctx.commentIndex);
|
|
91396
|
-
} else if (
|
|
91397
|
-
if (
|
|
91398
|
-
ctx.referencedFootnoteIds.add(
|
|
92130
|
+
} else if (run37.type === "noteRef") {
|
|
92131
|
+
if (run37.kind === "footnote")
|
|
92132
|
+
ctx.referencedFootnoteIds.add(run37.id);
|
|
91399
92133
|
else
|
|
91400
|
-
ctx.referencedEndnoteIds.add(
|
|
91401
|
-
out += `[^${
|
|
91402
|
-
} else if (
|
|
91403
|
-
out += `\`[${
|
|
92134
|
+
ctx.referencedEndnoteIds.add(run37.id);
|
|
92135
|
+
out += `[^${run37.id}]`;
|
|
92136
|
+
} else if (run37.type === "chart") {
|
|
92137
|
+
out += `\`[${run37.kind}]\``;
|
|
91404
92138
|
}
|
|
91405
92139
|
cursor++;
|
|
91406
92140
|
}
|
|
@@ -91434,7 +92168,7 @@ function sameCommentSet(left, right) {
|
|
|
91434
92168
|
return true;
|
|
91435
92169
|
}
|
|
91436
92170
|
function renderTextSegment(runs, view, baseline, mask, offset2) {
|
|
91437
|
-
const text6 = runs.map((
|
|
92171
|
+
const text6 = runs.map((run37) => run37.text).join("");
|
|
91438
92172
|
if (text6.length === 0)
|
|
91439
92173
|
return "";
|
|
91440
92174
|
const first = runs[0];
|
|
@@ -91478,33 +92212,33 @@ function criticMarkerFor(kind) {
|
|
|
91478
92212
|
return "++";
|
|
91479
92213
|
return "--";
|
|
91480
92214
|
}
|
|
91481
|
-
function needsHtmlWrap(
|
|
91482
|
-
return Boolean(
|
|
92215
|
+
function needsHtmlWrap(run37, baseline) {
|
|
92216
|
+
return Boolean(run37.color && !isDefaultColor(run37.color) || run37.colorTheme && !isDefaultThemeColor(run37) || run37.shade || run37.font && run37.font !== baseline.font || run37.sizeHalfPoints !== undefined && run37.sizeHalfPoints !== baseline.sizeHalfPoints || run37.smallCaps || run37.allCaps || run37.underline || run37.vertAlign === "superscript" || run37.vertAlign === "subscript" || run37.highlight);
|
|
91483
92217
|
}
|
|
91484
|
-
function wrapRunFormatting(body,
|
|
92218
|
+
function wrapRunFormatting(body, run37, baseline) {
|
|
91485
92219
|
const styles = [];
|
|
91486
92220
|
const attrs = [];
|
|
91487
|
-
if (
|
|
91488
|
-
styles.push(`color:#${
|
|
91489
|
-
if (
|
|
91490
|
-
styles.push(`background-color:#${
|
|
91491
|
-
if (
|
|
91492
|
-
styles.push(`font-family:${cssFontFamily(
|
|
92221
|
+
if (run37.color && !isDefaultColor(run37.color))
|
|
92222
|
+
styles.push(`color:#${run37.color}`);
|
|
92223
|
+
if (run37.shade)
|
|
92224
|
+
styles.push(`background-color:#${run37.shade}`);
|
|
92225
|
+
if (run37.font && run37.font !== baseline.font) {
|
|
92226
|
+
styles.push(`font-family:${cssFontFamily(run37.font)}`);
|
|
91493
92227
|
}
|
|
91494
|
-
if (
|
|
91495
|
-
styles.push(`font-size:${
|
|
92228
|
+
if (run37.sizeHalfPoints !== undefined && run37.sizeHalfPoints !== baseline.sizeHalfPoints) {
|
|
92229
|
+
styles.push(`font-size:${run37.sizeHalfPoints / 2}pt`);
|
|
91496
92230
|
}
|
|
91497
|
-
if (
|
|
92231
|
+
if (run37.smallCaps)
|
|
91498
92232
|
styles.push("font-variant:small-caps");
|
|
91499
|
-
if (
|
|
92233
|
+
if (run37.allCaps)
|
|
91500
92234
|
styles.push("text-transform:uppercase");
|
|
91501
|
-
if (
|
|
91502
|
-
attrs.push(htmlAttr("data-color-theme",
|
|
91503
|
-
if (
|
|
91504
|
-
attrs.push(htmlAttr("data-color-theme-tint",
|
|
92235
|
+
if (run37.colorTheme && !isDefaultThemeColor(run37)) {
|
|
92236
|
+
attrs.push(htmlAttr("data-color-theme", run37.colorTheme));
|
|
92237
|
+
if (run37.colorThemeTint) {
|
|
92238
|
+
attrs.push(htmlAttr("data-color-theme-tint", run37.colorThemeTint));
|
|
91505
92239
|
}
|
|
91506
|
-
if (
|
|
91507
|
-
attrs.push(htmlAttr("data-color-theme-shade",
|
|
92240
|
+
if (run37.colorThemeShade) {
|
|
92241
|
+
attrs.push(htmlAttr("data-color-theme-shade", run37.colorThemeShade));
|
|
91508
92242
|
}
|
|
91509
92243
|
}
|
|
91510
92244
|
let out = body;
|
|
@@ -91513,18 +92247,18 @@ function wrapRunFormatting(body, run35, baseline) {
|
|
|
91513
92247
|
const attrPart = attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
91514
92248
|
out = `<span${stylePart}${attrPart}>${out}</span>`;
|
|
91515
92249
|
}
|
|
91516
|
-
if (
|
|
92250
|
+
if (run37.underline === "single") {
|
|
91517
92251
|
out = `<u>${out}</u>`;
|
|
91518
|
-
} else if (
|
|
91519
|
-
const color2 =
|
|
91520
|
-
out = `<u ${htmlAttr("data-underline",
|
|
92252
|
+
} else if (run37.underline) {
|
|
92253
|
+
const color2 = run37.underlineColor ? ` ${htmlAttr("data-underline-color", run37.underlineColor)}` : "";
|
|
92254
|
+
out = `<u ${htmlAttr("data-underline", run37.underline)}${color2}>${out}</u>`;
|
|
91521
92255
|
}
|
|
91522
|
-
if (
|
|
92256
|
+
if (run37.vertAlign === "superscript")
|
|
91523
92257
|
out = `<sup>${out}</sup>`;
|
|
91524
|
-
else if (
|
|
92258
|
+
else if (run37.vertAlign === "subscript")
|
|
91525
92259
|
out = `<sub>${out}</sub>`;
|
|
91526
|
-
if (
|
|
91527
|
-
const named =
|
|
92260
|
+
if (run37.highlight) {
|
|
92261
|
+
const named = run37.highlight === "yellow" ? "" : ` ${htmlAttr("data-highlight", run37.highlight)}`;
|
|
91528
92262
|
out = `<mark${named}>${out}</mark>`;
|
|
91529
92263
|
}
|
|
91530
92264
|
return out;
|
|
@@ -91533,8 +92267,8 @@ function isDefaultColor(color2) {
|
|
|
91533
92267
|
const normalized = color2.toLowerCase();
|
|
91534
92268
|
return normalized === "000000" || normalized === "auto";
|
|
91535
92269
|
}
|
|
91536
|
-
function isDefaultThemeColor(
|
|
91537
|
-
return (
|
|
92270
|
+
function isDefaultThemeColor(run37) {
|
|
92271
|
+
return (run37.colorTheme === "text1" || run37.colorTheme === "dark1") && !run37.colorThemeTint && !run37.colorThemeShade;
|
|
91538
92272
|
}
|
|
91539
92273
|
function cssFontFamily(font) {
|
|
91540
92274
|
return /\s/.test(font) ? `'${font}'` : font;
|
|
@@ -91551,19 +92285,19 @@ function applyEscapeMask(text6, mask, offset2) {
|
|
|
91551
92285
|
}
|
|
91552
92286
|
function paragraphContent(runs, view) {
|
|
91553
92287
|
let content3 = "";
|
|
91554
|
-
for (const
|
|
91555
|
-
if (
|
|
92288
|
+
for (const run37 of runs) {
|
|
92289
|
+
if (run37.type !== "text")
|
|
91556
92290
|
continue;
|
|
91557
|
-
if (
|
|
92291
|
+
if (run37.runStyle === "Code")
|
|
91558
92292
|
continue;
|
|
91559
|
-
if (!isRunVisible(
|
|
92293
|
+
if (!isRunVisible(run37, view))
|
|
91560
92294
|
continue;
|
|
91561
|
-
content3 +=
|
|
92295
|
+
content3 += run37.text;
|
|
91562
92296
|
}
|
|
91563
92297
|
return content3;
|
|
91564
92298
|
}
|
|
91565
92299
|
function hasEquationRun(runs) {
|
|
91566
|
-
return runs.some((
|
|
92300
|
+
return runs.some((run37) => run37.type === "equation");
|
|
91567
92301
|
}
|
|
91568
92302
|
function renderTable(table, ctx) {
|
|
91569
92303
|
const view = ctx.options.view ?? "accepted";
|
|
@@ -91607,10 +92341,24 @@ function formatTableNote(table) {
|
|
|
91607
92341
|
if (table.borders && table.borders !== "single") {
|
|
91608
92342
|
pairs.push(["borders", table.borders]);
|
|
91609
92343
|
}
|
|
92344
|
+
if (table.align && table.align !== "left")
|
|
92345
|
+
pairs.push(["align", table.align]);
|
|
92346
|
+
if (table.style)
|
|
92347
|
+
pairs.push(["style", table.style]);
|
|
92348
|
+
const repeatHeaderRows = table.rows.map((row, index2) => row.repeatHeader ? `r${index2}` : null).filter((value) => value !== null);
|
|
92349
|
+
if (repeatHeaderRows.length > 0)
|
|
92350
|
+
pairs.push(["repeat-header", repeatHeaderRows.join(",")]);
|
|
92351
|
+
const rowHeights = table.rows.map((row, index2) => row.height ? `r${index2}:${formatRowHeight(row.height)}` : null).filter((value) => value !== null);
|
|
92352
|
+
if (rowHeights.length > 0)
|
|
92353
|
+
pairs.push(["row-heights", rowHeights.join(",")]);
|
|
91610
92354
|
if (pairs.length === 0)
|
|
91611
92355
|
return "";
|
|
91612
92356
|
return formatNote("table", pairs, [table.id]);
|
|
91613
92357
|
}
|
|
92358
|
+
function formatRowHeight(height) {
|
|
92359
|
+
const inches = `${twipsToInches(height.value)}in`;
|
|
92360
|
+
return height.rule === "atLeast" ? inches : `${inches}(${height.rule})`;
|
|
92361
|
+
}
|
|
91614
92362
|
function unevenWidths(grid) {
|
|
91615
92363
|
if (grid.length < 2)
|
|
91616
92364
|
return;
|
|
@@ -91667,11 +92415,27 @@ function cellNote(cell) {
|
|
|
91667
92415
|
pairs.push(["vMerge", cell.vMerge]);
|
|
91668
92416
|
if (cell.shading)
|
|
91669
92417
|
pairs.push(["shading", cell.shading]);
|
|
92418
|
+
if (cell.vAlign)
|
|
92419
|
+
pairs.push(["vAlign", cell.vAlign]);
|
|
92420
|
+
if (cell.borders)
|
|
92421
|
+
pairs.push(["borders", cell.borders]);
|
|
92422
|
+
const halign = uniformCellAlignment(cell);
|
|
92423
|
+
if (halign)
|
|
92424
|
+
pairs.push(["halign", halign]);
|
|
91670
92425
|
if (pairs.length === 0)
|
|
91671
92426
|
return "";
|
|
91672
92427
|
const address = cellAddress(cell);
|
|
91673
92428
|
return formatNote("cell", pairs, address ? [address] : []);
|
|
91674
92429
|
}
|
|
92430
|
+
function uniformCellAlignment(cell) {
|
|
92431
|
+
const aligns = cell.blocks.filter((block) => block.type === "paragraph").map((paragraph2) => paragraph2.alignment ?? "left");
|
|
92432
|
+
if (aligns.length === 0)
|
|
92433
|
+
return;
|
|
92434
|
+
const first = aligns[0];
|
|
92435
|
+
if (!first || first === "left")
|
|
92436
|
+
return;
|
|
92437
|
+
return aligns.every((align) => align === first) ? first : undefined;
|
|
92438
|
+
}
|
|
91675
92439
|
function cellAddress(cell) {
|
|
91676
92440
|
return cell.blocks[0]?.id.replace(/:(?:p|t)\d+$/, "");
|
|
91677
92441
|
}
|
|
@@ -91849,9 +92613,9 @@ var init_markdown3 = __esm(() => {
|
|
|
91849
92613
|
// src/cli/read/index.ts
|
|
91850
92614
|
var exports_read = {};
|
|
91851
92615
|
__export(exports_read, {
|
|
91852
|
-
run: () =>
|
|
92616
|
+
run: () => run37
|
|
91853
92617
|
});
|
|
91854
|
-
async function
|
|
92618
|
+
async function run37(args) {
|
|
91855
92619
|
const parsed = await tryParseArgs(args, {
|
|
91856
92620
|
ast: { type: "boolean" },
|
|
91857
92621
|
from: { type: "string" },
|
|
@@ -91861,16 +92625,16 @@ async function run35(args) {
|
|
|
91861
92625
|
current: { type: "boolean" },
|
|
91862
92626
|
comments: { type: "boolean" },
|
|
91863
92627
|
help: { type: "boolean", short: "h" }
|
|
91864
|
-
},
|
|
92628
|
+
}, HELP33);
|
|
91865
92629
|
if (typeof parsed === "number")
|
|
91866
92630
|
return parsed;
|
|
91867
92631
|
if (parsed.values.help) {
|
|
91868
|
-
await writeStdout(
|
|
92632
|
+
await writeStdout(HELP33);
|
|
91869
92633
|
return EXIT2.OK;
|
|
91870
92634
|
}
|
|
91871
92635
|
const path2 = parsed.positionals[0];
|
|
91872
92636
|
if (!path2)
|
|
91873
|
-
return fail("USAGE", "Missing FILE argument",
|
|
92637
|
+
return fail("USAGE", "Missing FILE argument", HELP33);
|
|
91874
92638
|
const ast = Boolean(parsed.values.ast);
|
|
91875
92639
|
const from = parsed.values.from;
|
|
91876
92640
|
const to = parsed.values.to;
|
|
@@ -91879,11 +92643,11 @@ async function run35(args) {
|
|
|
91879
92643
|
const current = Boolean(parsed.values.current);
|
|
91880
92644
|
const showComments = Boolean(parsed.values.comments);
|
|
91881
92645
|
if (ast && (from || to || accepted || baseline || current || showComments)) {
|
|
91882
|
-
return fail("USAGE", "--from, --to, --accepted, --baseline, --current, and --comments are Markdown-only and cannot be combined with --ast",
|
|
92646
|
+
return fail("USAGE", "--from, --to, --accepted, --baseline, --current, and --comments are Markdown-only and cannot be combined with --ast", HELP33);
|
|
91883
92647
|
}
|
|
91884
92648
|
const view = resolveView({ accepted, baseline, current });
|
|
91885
92649
|
if (!view) {
|
|
91886
|
-
return fail("USAGE", "--accepted, --baseline, and --current are mutually exclusive",
|
|
92650
|
+
return fail("USAGE", "--accepted, --baseline, and --current are mutually exclusive", HELP33);
|
|
91887
92651
|
}
|
|
91888
92652
|
const docView = await openOrFail(path2);
|
|
91889
92653
|
if (typeof docView === "number")
|
|
@@ -91912,7 +92676,7 @@ async function run35(args) {
|
|
|
91912
92676
|
throw err;
|
|
91913
92677
|
}
|
|
91914
92678
|
}
|
|
91915
|
-
var
|
|
92679
|
+
var HELP33 = `docx read \u2014 render document body as Markdown, or print AST as JSON
|
|
91916
92680
|
|
|
91917
92681
|
Usage:
|
|
91918
92682
|
docx read FILE [options]
|
|
@@ -92002,20 +92766,20 @@ function parsePagesSpec(spec) {
|
|
|
92002
92766
|
// src/cli/render/index.ts
|
|
92003
92767
|
var exports_render = {};
|
|
92004
92768
|
__export(exports_render, {
|
|
92005
|
-
run: () =>
|
|
92769
|
+
run: () => run38
|
|
92006
92770
|
});
|
|
92007
92771
|
import { basename as basename2, extname as extname2, resolve as resolve2 } from "path";
|
|
92008
|
-
async function
|
|
92009
|
-
const parsed = await tryParseArgs(args, OPTION_SPEC6,
|
|
92772
|
+
async function run38(args) {
|
|
92773
|
+
const parsed = await tryParseArgs(args, OPTION_SPEC6, HELP34);
|
|
92010
92774
|
if (typeof parsed === "number")
|
|
92011
92775
|
return parsed;
|
|
92012
92776
|
if (parsed.values.help) {
|
|
92013
|
-
await writeStdout(
|
|
92777
|
+
await writeStdout(HELP34);
|
|
92014
92778
|
return EXIT2.OK;
|
|
92015
92779
|
}
|
|
92016
92780
|
const filePath = parsed.positionals[0];
|
|
92017
92781
|
if (!filePath)
|
|
92018
|
-
return fail("USAGE", "Missing FILE argument",
|
|
92782
|
+
return fail("USAGE", "Missing FILE argument", HELP34);
|
|
92019
92783
|
if (!await Bun.file(filePath).exists()) {
|
|
92020
92784
|
return fail("FILE_NOT_FOUND", `File not found: ${filePath}`);
|
|
92021
92785
|
}
|
|
@@ -92095,7 +92859,7 @@ function availabilityHint(installed) {
|
|
|
92095
92859
|
}
|
|
92096
92860
|
return `Detected engines: ${installed.join(", ")} \u2014 but none chose auto-select; pass --engine explicitly.`;
|
|
92097
92861
|
}
|
|
92098
|
-
var
|
|
92862
|
+
var HELP34 = `docx render \u2014 render each page of a .docx as a PNG/JPG image
|
|
92099
92863
|
|
|
92100
92864
|
Usage:
|
|
92101
92865
|
docx render FILE [options]
|
|
@@ -92384,9 +93148,9 @@ var init_batch4 = __esm(() => {
|
|
|
92384
93148
|
// src/cli/replace/index.ts
|
|
92385
93149
|
var exports_replace3 = {};
|
|
92386
93150
|
__export(exports_replace3, {
|
|
92387
|
-
run: () =>
|
|
93151
|
+
run: () => run39
|
|
92388
93152
|
});
|
|
92389
|
-
async function
|
|
93153
|
+
async function run39(args) {
|
|
92390
93154
|
const parsed = await tryParseArgs(args, {
|
|
92391
93155
|
batch: { type: "string" },
|
|
92392
93156
|
at: { type: "string" },
|
|
@@ -92400,33 +93164,33 @@ async function run37(args) {
|
|
|
92400
93164
|
baseline: { type: "boolean" },
|
|
92401
93165
|
exact: { type: "boolean" },
|
|
92402
93166
|
...SAVE_FLAGS
|
|
92403
|
-
},
|
|
93167
|
+
}, HELP35);
|
|
92404
93168
|
if (typeof parsed === "number")
|
|
92405
93169
|
return parsed;
|
|
92406
93170
|
if (parsed.values.help) {
|
|
92407
|
-
await writeStdout(
|
|
93171
|
+
await writeStdout(HELP35);
|
|
92408
93172
|
return EXIT2.OK;
|
|
92409
93173
|
}
|
|
92410
93174
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
92411
93175
|
const path2 = parsed.positionals[0];
|
|
92412
93176
|
if (!path2)
|
|
92413
|
-
return fail("USAGE", "Missing FILE argument",
|
|
93177
|
+
return fail("USAGE", "Missing FILE argument", HELP35);
|
|
92414
93178
|
const batchInput = parsed.values.batch;
|
|
92415
93179
|
if (batchInput !== undefined) {
|
|
92416
93180
|
if (parsed.positionals.length > 1) {
|
|
92417
|
-
return fail("USAGE", "--batch reads pattern/replacement from the JSONL file; don't also pass them as positionals",
|
|
93181
|
+
return fail("USAGE", "--batch reads pattern/replacement from the JSONL file; don't also pass them as positionals", HELP35);
|
|
92418
93182
|
}
|
|
92419
93183
|
if (parsed.values.at !== undefined) {
|
|
92420
|
-
return fail("USAGE", '--at is per-entry in batch mode: put "at" on each JSONL line, not on the command',
|
|
93184
|
+
return fail("USAGE", '--at is per-entry in batch mode: put "at" on each JSONL line, not on the command', HELP35);
|
|
92421
93185
|
}
|
|
92422
93186
|
return runReplaceBatch(path2, batchInput, parsed.values);
|
|
92423
93187
|
}
|
|
92424
93188
|
const pattern = parsed.positionals[1];
|
|
92425
93189
|
const replacement = parsed.positionals[2];
|
|
92426
93190
|
if (pattern == null)
|
|
92427
|
-
return fail("USAGE", "Missing PATTERN argument",
|
|
93191
|
+
return fail("USAGE", "Missing PATTERN argument", HELP35);
|
|
92428
93192
|
if (replacement == null) {
|
|
92429
|
-
return fail("USAGE", "Missing REPLACEMENT argument",
|
|
93193
|
+
return fail("USAGE", "Missing REPLACEMENT argument", HELP35);
|
|
92430
93194
|
}
|
|
92431
93195
|
const ignoreCase = Boolean(parsed.values["ignore-case"]);
|
|
92432
93196
|
const useRegex = Boolean(parsed.values.regex);
|
|
@@ -92563,7 +93327,7 @@ async function run37(args) {
|
|
|
92563
93327
|
}, partialHint);
|
|
92564
93328
|
return EXIT2.OK;
|
|
92565
93329
|
}
|
|
92566
|
-
var
|
|
93330
|
+
var HELP35 = `docx replace \u2014 substitute text spans (sed for docx)
|
|
92567
93331
|
|
|
92568
93332
|
Usage:
|
|
92569
93333
|
docx replace FILE PATTERN REPLACEMENT [options]
|
|
@@ -92657,23 +93421,23 @@ var init_replace4 = __esm(() => {
|
|
|
92657
93421
|
// src/cli/sections/index.tsx
|
|
92658
93422
|
var exports_sections = {};
|
|
92659
93423
|
__export(exports_sections, {
|
|
92660
|
-
run: () =>
|
|
93424
|
+
run: () => run40
|
|
92661
93425
|
});
|
|
92662
93426
|
function hasPageGeometry(flags) {
|
|
92663
93427
|
return flags.pageSize !== undefined || flags.orientation !== undefined || flags.margins !== undefined;
|
|
92664
93428
|
}
|
|
92665
|
-
async function
|
|
92666
|
-
const parsed = await tryParseArgs(args, OPTION_SPEC7,
|
|
93429
|
+
async function run40(args) {
|
|
93430
|
+
const parsed = await tryParseArgs(args, OPTION_SPEC7, HELP36);
|
|
92667
93431
|
if (typeof parsed === "number")
|
|
92668
93432
|
return parsed;
|
|
92669
93433
|
if (parsed.values.help) {
|
|
92670
|
-
await writeStdout(
|
|
93434
|
+
await writeStdout(HELP36);
|
|
92671
93435
|
return EXIT2.OK;
|
|
92672
93436
|
}
|
|
92673
93437
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
92674
93438
|
const filePath = parsed.positionals[0];
|
|
92675
93439
|
if (!filePath)
|
|
92676
|
-
return fail("USAGE", "Missing FILE argument",
|
|
93440
|
+
return fail("USAGE", "Missing FILE argument", HELP36);
|
|
92677
93441
|
const at = parsed.values.at;
|
|
92678
93442
|
const flags = await parseSectionFlags(parsed.values);
|
|
92679
93443
|
if (typeof flags === "number")
|
|
@@ -92693,22 +93457,22 @@ async function run38(args) {
|
|
|
92693
93457
|
if (hasPageGeometry(flags) && flags.columns === undefined && flags.sectionType === undefined) {
|
|
92694
93458
|
return editAllSections(document4, opts);
|
|
92695
93459
|
}
|
|
92696
|
-
return fail("USAGE", "Missing --at LOCATOR (a section sN, or a range pN-pM to wrap in columns). To set PAGE GEOMETRY for the whole document, omit --at and pass only --margins/--orientation/--size.",
|
|
93460
|
+
return fail("USAGE", "Missing --at LOCATOR (a section sN, or a range pN-pM to wrap in columns). To set PAGE GEOMETRY for the whole document, omit --at and pass only --margins/--orientation/--size.", HELP36);
|
|
92697
93461
|
}
|
|
92698
93462
|
let locator;
|
|
92699
93463
|
try {
|
|
92700
93464
|
locator = parseLocator(at);
|
|
92701
93465
|
} catch (error) {
|
|
92702
93466
|
if (error instanceof LocatorParseError) {
|
|
92703
|
-
return fail("INVALID_LOCATOR", error.message,
|
|
93467
|
+
return fail("INVALID_LOCATOR", error.message, HELP36);
|
|
92704
93468
|
}
|
|
92705
93469
|
throw error;
|
|
92706
93470
|
}
|
|
92707
93471
|
if (locator.kind === "blockRange") {
|
|
92708
93472
|
if (hasPageGeometry(flags))
|
|
92709
|
-
return fail("USAGE", WRAP_REJECTS_GEOMETRY,
|
|
93473
|
+
return fail("USAGE", WRAP_REJECTS_GEOMETRY, HELP36);
|
|
92710
93474
|
if (flags.columns === undefined) {
|
|
92711
|
-
return fail("USAGE", "Wrapping a range in a section needs --columns N",
|
|
93475
|
+
return fail("USAGE", "Wrapping a range in a section needs --columns N", HELP36);
|
|
92712
93476
|
}
|
|
92713
93477
|
const range = await resolveBlockRangeOrFail(document4, at);
|
|
92714
93478
|
if (typeof range === "number")
|
|
@@ -92720,20 +93484,20 @@ async function run38(args) {
|
|
|
92720
93484
|
return blockRef;
|
|
92721
93485
|
if (blockRef.node.tag === "w:sectPr") {
|
|
92722
93486
|
if (flags.columns === undefined && flags.sectionType === undefined && !hasPageGeometry(flags)) {
|
|
92723
|
-
return fail("USAGE", "Section edit needs --columns, --type, --orientation, --size, or --margins",
|
|
93487
|
+
return fail("USAGE", "Section edit needs --columns, --type, --orientation, --size, or --margins", HELP36);
|
|
92724
93488
|
}
|
|
92725
93489
|
return editSection(document4, blockRef, at, opts);
|
|
92726
93490
|
}
|
|
92727
93491
|
if (blockRef.node.tag === "w:p") {
|
|
92728
93492
|
if (hasPageGeometry(flags))
|
|
92729
|
-
return fail("USAGE", WRAP_REJECTS_GEOMETRY,
|
|
93493
|
+
return fail("USAGE", WRAP_REJECTS_GEOMETRY, HELP36);
|
|
92730
93494
|
if (flags.columns === undefined) {
|
|
92731
|
-
return fail("USAGE", "Wrapping a paragraph in a section needs --columns N",
|
|
93495
|
+
return fail("USAGE", "Wrapping a paragraph in a section needs --columns N", HELP36);
|
|
92732
93496
|
}
|
|
92733
93497
|
const index2 = blockRef.parent.indexOf(blockRef.node);
|
|
92734
93498
|
return wrapRange(document4, blockRef.parent, index2, index2, at, opts);
|
|
92735
93499
|
}
|
|
92736
|
-
return fail("INVALID_LOCATOR", `--at needs a section (sN) or a paragraph range (pN-pM); ${at} is neither`,
|
|
93500
|
+
return fail("INVALID_LOCATOR", `--at needs a section (sN) or a paragraph range (pN-pM); ${at} is neither`, HELP36);
|
|
92737
93501
|
}
|
|
92738
93502
|
async function editSection(document4, blockRef, at, opts) {
|
|
92739
93503
|
const track = resolveTracked(document4, opts.trackFlag);
|
|
@@ -92986,7 +93750,7 @@ async function commit(document4, opts, meta) {
|
|
|
92986
93750
|
}, realignedNote + renderVerifyHint(destination));
|
|
92987
93751
|
return EXIT2.OK;
|
|
92988
93752
|
}
|
|
92989
|
-
var
|
|
93753
|
+
var HELP36 = `docx sections \u2014 multi-column layout, section breaks & page setup
|
|
92990
93754
|
|
|
92991
93755
|
Usage:
|
|
92992
93756
|
docx sections FILE --at LOCATOR (--columns N | page setup) [options]
|
|
@@ -93479,9 +94243,9 @@ function appliedStyleIds(document4) {
|
|
|
93479
94243
|
continue;
|
|
93480
94244
|
if (block.style)
|
|
93481
94245
|
used.add(block.style);
|
|
93482
|
-
for (const
|
|
93483
|
-
if (
|
|
93484
|
-
used.add(
|
|
94246
|
+
for (const run41 of block.runs) {
|
|
94247
|
+
if (run41.type === "text" && run41.runStyle)
|
|
94248
|
+
used.add(run41.runStyle);
|
|
93485
94249
|
}
|
|
93486
94250
|
}
|
|
93487
94251
|
return used;
|
|
@@ -93637,8 +94401,8 @@ function countStyleUsage(document4, styleId) {
|
|
|
93637
94401
|
continue;
|
|
93638
94402
|
if (block.style === styleId)
|
|
93639
94403
|
count++;
|
|
93640
|
-
for (const
|
|
93641
|
-
if (
|
|
94404
|
+
for (const run41 of block.runs) {
|
|
94405
|
+
if (run41.type === "text" && run41.runStyle === styleId)
|
|
93642
94406
|
count++;
|
|
93643
94407
|
}
|
|
93644
94408
|
}
|
|
@@ -93690,7 +94454,7 @@ Examples:
|
|
|
93690
94454
|
docx styles set report.docx --at Normal --font "Times New Roman" --size 12
|
|
93691
94455
|
docx styles set report.docx --at Quote --italic --indent-left 0.5 --space-after 6
|
|
93692
94456
|
`;
|
|
93693
|
-
var
|
|
94457
|
+
var init_set3 = __esm(() => {
|
|
93694
94458
|
init_core2();
|
|
93695
94459
|
init_respond();
|
|
93696
94460
|
init_shared2();
|
|
@@ -93804,18 +94568,18 @@ var init_set_default_font = __esm(() => {
|
|
|
93804
94568
|
// src/cli/styles/index.ts
|
|
93805
94569
|
var exports_styles = {};
|
|
93806
94570
|
__export(exports_styles, {
|
|
93807
|
-
run: () =>
|
|
94571
|
+
run: () => run41
|
|
93808
94572
|
});
|
|
93809
|
-
async function
|
|
94573
|
+
async function run41(args) {
|
|
93810
94574
|
if (args[0] === "set-default-font")
|
|
93811
94575
|
return runSetDefaultFont(args.slice(1));
|
|
93812
94576
|
if (args[0] === "set")
|
|
93813
94577
|
return runStylesSet(args.slice(1));
|
|
93814
94578
|
if (args[0] === "create")
|
|
93815
94579
|
return runStylesCreate(args.slice(1));
|
|
93816
|
-
return runStylesRead(args,
|
|
94580
|
+
return runStylesRead(args, HELP37);
|
|
93817
94581
|
}
|
|
93818
|
-
var
|
|
94582
|
+
var HELP37 = `docx styles \u2014 inspect, edit, and create the styles a document can apply
|
|
93819
94583
|
|
|
93820
94584
|
Usage:
|
|
93821
94585
|
docx styles FILE [--used] [--at STYLEID] [--json] # list / describe (read)
|
|
@@ -93858,16 +94622,16 @@ See \`docx styles set --help\`, \`docx styles create --help\`, and
|
|
|
93858
94622
|
var init_styles2 = __esm(() => {
|
|
93859
94623
|
init_create3();
|
|
93860
94624
|
init_read4();
|
|
93861
|
-
|
|
94625
|
+
init_set3();
|
|
93862
94626
|
init_set_default_font();
|
|
93863
94627
|
});
|
|
93864
94628
|
|
|
93865
94629
|
// src/cli/tables/insert-row.tsx
|
|
93866
94630
|
var exports_insert_row = {};
|
|
93867
94631
|
__export(exports_insert_row, {
|
|
93868
|
-
run: () =>
|
|
94632
|
+
run: () => run42
|
|
93869
94633
|
});
|
|
93870
|
-
async function
|
|
94634
|
+
async function run42(args) {
|
|
93871
94635
|
const parsed = await tryParseArgs(args, {
|
|
93872
94636
|
at: { type: "string" },
|
|
93873
94637
|
position: { type: "string" },
|
|
@@ -93875,20 +94639,20 @@ async function run40(args) {
|
|
|
93875
94639
|
author: { type: "string" },
|
|
93876
94640
|
track: { type: "boolean" },
|
|
93877
94641
|
...SAVE_FLAGS
|
|
93878
|
-
},
|
|
94642
|
+
}, HELP38);
|
|
93879
94643
|
if (typeof parsed === "number")
|
|
93880
94644
|
return parsed;
|
|
93881
94645
|
if (parsed.values.help) {
|
|
93882
|
-
await writeStdout(
|
|
94646
|
+
await writeStdout(HELP38);
|
|
93883
94647
|
return EXIT2.OK;
|
|
93884
94648
|
}
|
|
93885
94649
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
93886
94650
|
const path2 = parsed.positionals[0];
|
|
93887
94651
|
if (!path2)
|
|
93888
|
-
return fail("USAGE", "Missing FILE argument",
|
|
94652
|
+
return fail("USAGE", "Missing FILE argument", HELP38);
|
|
93889
94653
|
const at = parsed.values.at;
|
|
93890
94654
|
if (!at)
|
|
93891
|
-
return fail("USAGE", "Missing --at tN",
|
|
94655
|
+
return fail("USAGE", "Missing --at tN", HELP38);
|
|
93892
94656
|
const tableId = parseTableAt(at);
|
|
93893
94657
|
if (!tableId) {
|
|
93894
94658
|
return fail("INVALID_LOCATOR", `--at must be a table id like t0 (got ${at})`);
|
|
@@ -93909,7 +94673,7 @@ async function run40(args) {
|
|
|
93909
94673
|
}
|
|
93910
94674
|
const cellTexts = parsed.values.cells ? parsed.values.cells.split(",") : [];
|
|
93911
94675
|
for (const cell of cellTexts) {
|
|
93912
|
-
const mangled = await rejectShellMangledValue(cell,
|
|
94676
|
+
const mangled = await rejectShellMangledValue(cell, HELP38, "--cells");
|
|
93913
94677
|
if (typeof mangled === "number")
|
|
93914
94678
|
return mangled;
|
|
93915
94679
|
}
|
|
@@ -94010,7 +94774,7 @@ function rowChildIndex(table, grid, position2) {
|
|
|
94010
94774
|
const lastRow = grid.rows[grid.rows.length - 1]?.node;
|
|
94011
94775
|
return lastRow ? table.children.indexOf(lastRow) + 1 : table.children.length;
|
|
94012
94776
|
}
|
|
94013
|
-
var AT_FORMS6,
|
|
94777
|
+
var AT_FORMS6, HELP38;
|
|
94014
94778
|
var init_insert_row = __esm(() => {
|
|
94015
94779
|
init_core2();
|
|
94016
94780
|
init_blocks();
|
|
@@ -94021,7 +94785,7 @@ var init_insert_row = __esm(() => {
|
|
|
94021
94785
|
init_respond();
|
|
94022
94786
|
init_jsx_dev_runtime();
|
|
94023
94787
|
AT_FORMS6 = describeForms(["table"], " ");
|
|
94024
|
-
|
|
94788
|
+
HELP38 = `docx tables insert-row \u2014 insert a table row
|
|
94025
94789
|
|
|
94026
94790
|
Usage:
|
|
94027
94791
|
docx tables insert-row FILE --at tN [options]
|
|
@@ -94070,28 +94834,28 @@ Examples:
|
|
|
94070
94834
|
// src/cli/tables/delete-row.ts
|
|
94071
94835
|
var exports_delete_row = {};
|
|
94072
94836
|
__export(exports_delete_row, {
|
|
94073
|
-
run: () =>
|
|
94837
|
+
run: () => run43
|
|
94074
94838
|
});
|
|
94075
|
-
async function
|
|
94839
|
+
async function run43(args) {
|
|
94076
94840
|
const parsed = await tryParseArgs(args, {
|
|
94077
94841
|
at: { type: "string" },
|
|
94078
94842
|
author: { type: "string" },
|
|
94079
94843
|
track: { type: "boolean" },
|
|
94080
94844
|
...SAVE_FLAGS
|
|
94081
|
-
},
|
|
94845
|
+
}, HELP39);
|
|
94082
94846
|
if (typeof parsed === "number")
|
|
94083
94847
|
return parsed;
|
|
94084
94848
|
if (parsed.values.help) {
|
|
94085
|
-
await writeStdout(
|
|
94849
|
+
await writeStdout(HELP39);
|
|
94086
94850
|
return EXIT2.OK;
|
|
94087
94851
|
}
|
|
94088
94852
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
94089
94853
|
const path2 = parsed.positionals[0];
|
|
94090
94854
|
if (!path2)
|
|
94091
|
-
return fail("USAGE", "Missing FILE argument",
|
|
94855
|
+
return fail("USAGE", "Missing FILE argument", HELP39);
|
|
94092
94856
|
const at = parsed.values.at;
|
|
94093
94857
|
if (!at)
|
|
94094
|
-
return fail("USAGE", "Missing --at tN:rR",
|
|
94858
|
+
return fail("USAGE", "Missing --at tN:rR", HELP39);
|
|
94095
94859
|
const target = parseRowAt(at);
|
|
94096
94860
|
if (!target) {
|
|
94097
94861
|
return fail("INVALID_LOCATOR", `--at must be a row locator like t0:r1 (got ${at})`);
|
|
@@ -94158,14 +94922,14 @@ function findVMergeOrphan(grid, rowIndex) {
|
|
|
94158
94922
|
}
|
|
94159
94923
|
return null;
|
|
94160
94924
|
}
|
|
94161
|
-
var AT_FORMS7,
|
|
94925
|
+
var AT_FORMS7, HELP39;
|
|
94162
94926
|
var init_delete_row = __esm(() => {
|
|
94163
94927
|
init_core2();
|
|
94164
94928
|
init_locators();
|
|
94165
94929
|
init_table();
|
|
94166
94930
|
init_respond();
|
|
94167
94931
|
AT_FORMS7 = describeForms(["tableRow"], " ");
|
|
94168
|
-
|
|
94932
|
+
HELP39 = `docx tables delete-row \u2014 delete a table row
|
|
94169
94933
|
|
|
94170
94934
|
Usage:
|
|
94171
94935
|
docx tables delete-row FILE --at tN:rR [options]
|
|
@@ -94201,9 +94965,9 @@ Examples:
|
|
|
94201
94965
|
// src/cli/tables/insert-column.tsx
|
|
94202
94966
|
var exports_insert_column = {};
|
|
94203
94967
|
__export(exports_insert_column, {
|
|
94204
|
-
run: () =>
|
|
94968
|
+
run: () => run44
|
|
94205
94969
|
});
|
|
94206
|
-
async function
|
|
94970
|
+
async function run44(args) {
|
|
94207
94971
|
const parsed = await tryParseArgs(args, {
|
|
94208
94972
|
at: { type: "string" },
|
|
94209
94973
|
position: { type: "string" },
|
|
@@ -94211,20 +94975,20 @@ async function run42(args) {
|
|
|
94211
94975
|
author: { type: "string" },
|
|
94212
94976
|
track: { type: "boolean" },
|
|
94213
94977
|
...SAVE_FLAGS
|
|
94214
|
-
},
|
|
94978
|
+
}, HELP40);
|
|
94215
94979
|
if (typeof parsed === "number")
|
|
94216
94980
|
return parsed;
|
|
94217
94981
|
if (parsed.values.help) {
|
|
94218
|
-
await writeStdout(
|
|
94982
|
+
await writeStdout(HELP40);
|
|
94219
94983
|
return EXIT2.OK;
|
|
94220
94984
|
}
|
|
94221
94985
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
94222
94986
|
const path2 = parsed.positionals[0];
|
|
94223
94987
|
if (!path2)
|
|
94224
|
-
return fail("USAGE", "Missing FILE argument",
|
|
94988
|
+
return fail("USAGE", "Missing FILE argument", HELP40);
|
|
94225
94989
|
const at = parsed.values.at;
|
|
94226
94990
|
if (!at)
|
|
94227
|
-
return fail("USAGE", "Missing --at tN",
|
|
94991
|
+
return fail("USAGE", "Missing --at tN", HELP40);
|
|
94228
94992
|
const tableId = parseTableAt(at);
|
|
94229
94993
|
if (!tableId) {
|
|
94230
94994
|
return fail("INVALID_LOCATOR", `--at must be a table id like t0 (got ${at})`);
|
|
@@ -94339,14 +95103,14 @@ function insertCellAtColumn(row, position2, cell) {
|
|
|
94339
95103
|
const at = lastCell ? row.node.children.indexOf(lastCell.node) + 1 : row.node.children.length;
|
|
94340
95104
|
row.node.children.splice(at, 0, cell);
|
|
94341
95105
|
}
|
|
94342
|
-
var AT_FORMS8,
|
|
95106
|
+
var AT_FORMS8, HELP40;
|
|
94343
95107
|
var init_insert_column = __esm(() => {
|
|
94344
95108
|
init_core2();
|
|
94345
95109
|
init_locators();
|
|
94346
95110
|
init_table();
|
|
94347
95111
|
init_respond();
|
|
94348
95112
|
AT_FORMS8 = describeForms(["table"], " ");
|
|
94349
|
-
|
|
95113
|
+
HELP40 = `docx tables insert-column \u2014 insert a table column
|
|
94350
95114
|
|
|
94351
95115
|
Usage:
|
|
94352
95116
|
docx tables insert-column FILE --at tN [options]
|
|
@@ -94384,28 +95148,28 @@ Examples:
|
|
|
94384
95148
|
// src/cli/tables/delete-column.ts
|
|
94385
95149
|
var exports_delete_column = {};
|
|
94386
95150
|
__export(exports_delete_column, {
|
|
94387
|
-
run: () =>
|
|
95151
|
+
run: () => run45
|
|
94388
95152
|
});
|
|
94389
|
-
async function
|
|
95153
|
+
async function run45(args) {
|
|
94390
95154
|
const parsed = await tryParseArgs(args, {
|
|
94391
95155
|
at: { type: "string" },
|
|
94392
95156
|
author: { type: "string" },
|
|
94393
95157
|
track: { type: "boolean" },
|
|
94394
95158
|
...SAVE_FLAGS
|
|
94395
|
-
},
|
|
95159
|
+
}, HELP41);
|
|
94396
95160
|
if (typeof parsed === "number")
|
|
94397
95161
|
return parsed;
|
|
94398
95162
|
if (parsed.values.help) {
|
|
94399
|
-
await writeStdout(
|
|
95163
|
+
await writeStdout(HELP41);
|
|
94400
95164
|
return EXIT2.OK;
|
|
94401
95165
|
}
|
|
94402
95166
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
94403
95167
|
const path2 = parsed.positionals[0];
|
|
94404
95168
|
if (!path2)
|
|
94405
|
-
return fail("USAGE", "Missing FILE argument",
|
|
95169
|
+
return fail("USAGE", "Missing FILE argument", HELP41);
|
|
94406
95170
|
const at = parsed.values.at;
|
|
94407
95171
|
if (!at)
|
|
94408
|
-
return fail("USAGE", "Missing --at tN:cC",
|
|
95172
|
+
return fail("USAGE", "Missing --at tN:cC", HELP41);
|
|
94409
95173
|
const target = parseColumnAt(at);
|
|
94410
95174
|
if (!target) {
|
|
94411
95175
|
return fail("INVALID_LOCATOR", `--at must be a column locator like t0:c2 (got ${at})`);
|
|
@@ -94489,14 +95253,14 @@ function removeGridColumn(tblGrid, col) {
|
|
|
94489
95253
|
if (index2 !== -1)
|
|
94490
95254
|
tblGrid.children.splice(index2, 1);
|
|
94491
95255
|
}
|
|
94492
|
-
var AT_FORMS9,
|
|
95256
|
+
var AT_FORMS9, HELP41;
|
|
94493
95257
|
var init_delete_column = __esm(() => {
|
|
94494
95258
|
init_core2();
|
|
94495
95259
|
init_locators();
|
|
94496
95260
|
init_table();
|
|
94497
95261
|
init_respond();
|
|
94498
95262
|
AT_FORMS9 = describeForms(["tableColumn"], " ");
|
|
94499
|
-
|
|
95263
|
+
HELP41 = `docx tables delete-column \u2014 delete a table column
|
|
94500
95264
|
|
|
94501
95265
|
Usage:
|
|
94502
95266
|
docx tables delete-column FILE --at tN:cC [options]
|
|
@@ -94531,36 +95295,36 @@ Examples:
|
|
|
94531
95295
|
// src/cli/tables/set-widths.ts
|
|
94532
95296
|
var exports_set_widths = {};
|
|
94533
95297
|
__export(exports_set_widths, {
|
|
94534
|
-
run: () =>
|
|
95298
|
+
run: () => run46
|
|
94535
95299
|
});
|
|
94536
|
-
async function
|
|
95300
|
+
async function run46(args) {
|
|
94537
95301
|
const parsed = await tryParseArgs(args, {
|
|
94538
95302
|
at: { type: "string" },
|
|
94539
95303
|
widths: { type: "string" },
|
|
94540
95304
|
author: { type: "string" },
|
|
94541
95305
|
track: { type: "boolean" },
|
|
94542
95306
|
...SAVE_FLAGS
|
|
94543
|
-
},
|
|
95307
|
+
}, HELP42);
|
|
94544
95308
|
if (typeof parsed === "number")
|
|
94545
95309
|
return parsed;
|
|
94546
95310
|
if (parsed.values.help) {
|
|
94547
|
-
await writeStdout(
|
|
95311
|
+
await writeStdout(HELP42);
|
|
94548
95312
|
return EXIT2.OK;
|
|
94549
95313
|
}
|
|
94550
95314
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
94551
95315
|
const path2 = parsed.positionals[0];
|
|
94552
95316
|
if (!path2)
|
|
94553
|
-
return fail("USAGE", "Missing FILE argument",
|
|
95317
|
+
return fail("USAGE", "Missing FILE argument", HELP42);
|
|
94554
95318
|
const at = parsed.values.at;
|
|
94555
95319
|
if (!at)
|
|
94556
|
-
return fail("USAGE", "Missing --at tN",
|
|
95320
|
+
return fail("USAGE", "Missing --at tN", HELP42);
|
|
94557
95321
|
const tableId = parseTableAt(at);
|
|
94558
95322
|
if (!tableId) {
|
|
94559
95323
|
return fail("INVALID_LOCATOR", `--at must be a table id like t0 (got ${at})`);
|
|
94560
95324
|
}
|
|
94561
95325
|
const widthsSpec = parsed.values.widths;
|
|
94562
95326
|
if (!widthsSpec)
|
|
94563
|
-
return fail("USAGE", "Missing --widths",
|
|
95327
|
+
return fail("USAGE", "Missing --widths", HELP42);
|
|
94564
95328
|
const document4 = await openOrFail(path2);
|
|
94565
95329
|
if (typeof document4 === "number")
|
|
94566
95330
|
return document4;
|
|
@@ -94709,14 +95473,14 @@ function describeColumnWidths(twips) {
|
|
|
94709
95473
|
const cells = twips.map((value, index2) => `g${index2}=${twipsToInches(value)}in`);
|
|
94710
95474
|
return `widths: ${cells.join(" ")}`;
|
|
94711
95475
|
}
|
|
94712
|
-
var AT_FORMS10,
|
|
95476
|
+
var AT_FORMS10, HELP42, MIN_COL_TWIPS = 288;
|
|
94713
95477
|
var init_set_widths = __esm(() => {
|
|
94714
95478
|
init_core2();
|
|
94715
95479
|
init_locators();
|
|
94716
95480
|
init_table();
|
|
94717
95481
|
init_respond();
|
|
94718
95482
|
AT_FORMS10 = describeForms(["table"], " ");
|
|
94719
|
-
|
|
95483
|
+
HELP42 = `docx tables set-widths \u2014 set column widths
|
|
94720
95484
|
|
|
94721
95485
|
Usage:
|
|
94722
95486
|
docx tables set-widths FILE --at tN --widths SPEC [options]
|
|
@@ -94785,28 +95549,28 @@ var init_common2 = __esm(() => {
|
|
|
94785
95549
|
// src/cli/tables/merge.tsx
|
|
94786
95550
|
var exports_merge = {};
|
|
94787
95551
|
__export(exports_merge, {
|
|
94788
|
-
run: () =>
|
|
95552
|
+
run: () => run47
|
|
94789
95553
|
});
|
|
94790
|
-
async function
|
|
95554
|
+
async function run47(args) {
|
|
94791
95555
|
const parsed = await tryParseArgs(args, {
|
|
94792
95556
|
at: { type: "string" },
|
|
94793
95557
|
author: { type: "string" },
|
|
94794
95558
|
track: { type: "boolean" },
|
|
94795
95559
|
...SAVE_FLAGS
|
|
94796
|
-
},
|
|
95560
|
+
}, HELP43);
|
|
94797
95561
|
if (typeof parsed === "number")
|
|
94798
95562
|
return parsed;
|
|
94799
95563
|
if (parsed.values.help) {
|
|
94800
|
-
await writeStdout(
|
|
95564
|
+
await writeStdout(HELP43);
|
|
94801
95565
|
return EXIT2.OK;
|
|
94802
95566
|
}
|
|
94803
95567
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
94804
95568
|
const path2 = parsed.positionals[0];
|
|
94805
95569
|
if (!path2)
|
|
94806
|
-
return fail("USAGE", "Missing FILE argument",
|
|
95570
|
+
return fail("USAGE", "Missing FILE argument", HELP43);
|
|
94807
95571
|
const at = parsed.values.at;
|
|
94808
95572
|
if (!at)
|
|
94809
|
-
return fail("USAGE", "Missing --at tN:rR1cC1-rR2cC2",
|
|
95573
|
+
return fail("USAGE", "Missing --at tN:rR1cC1-rR2cC2", HELP43);
|
|
94810
95574
|
const region = parseCellRangeAt(at);
|
|
94811
95575
|
if (!region) {
|
|
94812
95576
|
return fail("INVALID_LOCATOR", `--at must be a cell-range locator like t0:r0c0-r1c1 (got ${at})`);
|
|
@@ -94899,7 +95663,7 @@ function mergeRow(row, c1, c2, width, isTop, vertical) {
|
|
|
94899
95663
|
if (vertical && !isTop)
|
|
94900
95664
|
clearCellContent(anchor.node);
|
|
94901
95665
|
}
|
|
94902
|
-
var AT_FORMS11,
|
|
95666
|
+
var AT_FORMS11, HELP43;
|
|
94903
95667
|
var init_merge = __esm(() => {
|
|
94904
95668
|
init_core2();
|
|
94905
95669
|
init_locators();
|
|
@@ -94907,7 +95671,7 @@ var init_merge = __esm(() => {
|
|
|
94907
95671
|
init_respond();
|
|
94908
95672
|
init_common2();
|
|
94909
95673
|
AT_FORMS11 = describeForms(["cellRange"], " ");
|
|
94910
|
-
|
|
95674
|
+
HELP43 = `docx tables merge \u2014 merge a rectangular cell region
|
|
94911
95675
|
|
|
94912
95676
|
Usage:
|
|
94913
95677
|
docx tables merge FILE --at tN:rR1cC1-rR2cC2 [options]
|
|
@@ -94946,28 +95710,28 @@ Examples:
|
|
|
94946
95710
|
// src/cli/tables/unmerge.tsx
|
|
94947
95711
|
var exports_unmerge = {};
|
|
94948
95712
|
__export(exports_unmerge, {
|
|
94949
|
-
run: () =>
|
|
95713
|
+
run: () => run48
|
|
94950
95714
|
});
|
|
94951
|
-
async function
|
|
95715
|
+
async function run48(args) {
|
|
94952
95716
|
const parsed = await tryParseArgs(args, {
|
|
94953
95717
|
at: { type: "string" },
|
|
94954
95718
|
author: { type: "string" },
|
|
94955
95719
|
track: { type: "boolean" },
|
|
94956
95720
|
...SAVE_FLAGS
|
|
94957
|
-
},
|
|
95721
|
+
}, HELP44);
|
|
94958
95722
|
if (typeof parsed === "number")
|
|
94959
95723
|
return parsed;
|
|
94960
95724
|
if (parsed.values.help) {
|
|
94961
|
-
await writeStdout(
|
|
95725
|
+
await writeStdout(HELP44);
|
|
94962
95726
|
return EXIT2.OK;
|
|
94963
95727
|
}
|
|
94964
95728
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
94965
95729
|
const path2 = parsed.positionals[0];
|
|
94966
95730
|
if (!path2)
|
|
94967
|
-
return fail("USAGE", "Missing FILE argument",
|
|
95731
|
+
return fail("USAGE", "Missing FILE argument", HELP44);
|
|
94968
95732
|
const at = parsed.values.at;
|
|
94969
95733
|
if (!at)
|
|
94970
|
-
return fail("USAGE", "Missing --at tN:rRcC",
|
|
95734
|
+
return fail("USAGE", "Missing --at tN:rRcC", HELP44);
|
|
94971
95735
|
const target = parseCellAt(at);
|
|
94972
95736
|
if (!target) {
|
|
94973
95737
|
return fail("INVALID_LOCATOR", `--at must be a cell locator like t0:r0c0 (got ${at})`);
|
|
@@ -95042,7 +95806,7 @@ function verticalSpanRows(grid, row, col, vertical) {
|
|
|
95042
95806
|
}
|
|
95043
95807
|
return rows;
|
|
95044
95808
|
}
|
|
95045
|
-
var AT_FORMS12,
|
|
95809
|
+
var AT_FORMS12, HELP44;
|
|
95046
95810
|
var init_unmerge = __esm(() => {
|
|
95047
95811
|
init_core2();
|
|
95048
95812
|
init_locators();
|
|
@@ -95050,7 +95814,7 @@ var init_unmerge = __esm(() => {
|
|
|
95050
95814
|
init_respond();
|
|
95051
95815
|
init_common2();
|
|
95052
95816
|
AT_FORMS12 = describeForms(["cell"], " ");
|
|
95053
|
-
|
|
95817
|
+
HELP44 = `docx tables unmerge \u2014 split a merged cell back into individual cells
|
|
95054
95818
|
|
|
95055
95819
|
Usage:
|
|
95056
95820
|
docx tables unmerge FILE --at tN:rRcC [options]
|
|
@@ -95087,9 +95851,9 @@ Examples:
|
|
|
95087
95851
|
// src/cli/tables/borders.tsx
|
|
95088
95852
|
var exports_borders = {};
|
|
95089
95853
|
__export(exports_borders, {
|
|
95090
|
-
run: () =>
|
|
95854
|
+
run: () => run49
|
|
95091
95855
|
});
|
|
95092
|
-
async function
|
|
95856
|
+
async function run49(args) {
|
|
95093
95857
|
const parsed = await tryParseArgs(args, {
|
|
95094
95858
|
at: { type: "string" },
|
|
95095
95859
|
style: { type: "string" },
|
|
@@ -95098,20 +95862,20 @@ async function run47(args) {
|
|
|
95098
95862
|
author: { type: "string" },
|
|
95099
95863
|
track: { type: "boolean" },
|
|
95100
95864
|
...SAVE_FLAGS
|
|
95101
|
-
},
|
|
95865
|
+
}, HELP45);
|
|
95102
95866
|
if (typeof parsed === "number")
|
|
95103
95867
|
return parsed;
|
|
95104
95868
|
if (parsed.values.help) {
|
|
95105
|
-
await writeStdout(
|
|
95869
|
+
await writeStdout(HELP45);
|
|
95106
95870
|
return EXIT2.OK;
|
|
95107
95871
|
}
|
|
95108
95872
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
95109
95873
|
const path2 = parsed.positionals[0];
|
|
95110
95874
|
if (!path2)
|
|
95111
|
-
return fail("USAGE", "Missing FILE argument",
|
|
95875
|
+
return fail("USAGE", "Missing FILE argument", HELP45);
|
|
95112
95876
|
const at = parsed.values.at;
|
|
95113
95877
|
if (!at)
|
|
95114
|
-
return fail("USAGE", "Missing --at tN",
|
|
95878
|
+
return fail("USAGE", "Missing --at tN", HELP45);
|
|
95115
95879
|
const tableId = parseTableAt(at);
|
|
95116
95880
|
if (!tableId) {
|
|
95117
95881
|
return fail("INVALID_LOCATOR", `--at must be a table id like t0 (got ${at})`);
|
|
@@ -95188,7 +95952,7 @@ function buildBorders(style, sizeEighths, color2) {
|
|
|
95188
95952
|
]
|
|
95189
95953
|
}, undefined, true, undefined, this);
|
|
95190
95954
|
}
|
|
95191
|
-
var STYLES, AT_FORMS13,
|
|
95955
|
+
var STYLES, AT_FORMS13, HELP45;
|
|
95192
95956
|
var init_borders = __esm(() => {
|
|
95193
95957
|
init_core2();
|
|
95194
95958
|
init_jsx();
|
|
@@ -95199,7 +95963,7 @@ var init_borders = __esm(() => {
|
|
|
95199
95963
|
init_jsx_dev_runtime();
|
|
95200
95964
|
STYLES = new Set(["single", "double", "none"]);
|
|
95201
95965
|
AT_FORMS13 = describeForms(["table"], " ");
|
|
95202
|
-
|
|
95966
|
+
HELP45 = `docx tables borders \u2014 set table borders
|
|
95203
95967
|
|
|
95204
95968
|
Usage:
|
|
95205
95969
|
docx tables borders FILE --at tN [options]
|
|
@@ -95236,25 +96000,486 @@ Examples:
|
|
|
95236
96000
|
`;
|
|
95237
96001
|
});
|
|
95238
96002
|
|
|
96003
|
+
// src/cli/tables/format.tsx
|
|
96004
|
+
var exports_format = {};
|
|
96005
|
+
__export(exports_format, {
|
|
96006
|
+
run: () => run50
|
|
96007
|
+
});
|
|
96008
|
+
async function run50(args) {
|
|
96009
|
+
const parsed = await tryParseArgs(args, {
|
|
96010
|
+
at: { type: "string" },
|
|
96011
|
+
shade: { type: "string" },
|
|
96012
|
+
valign: { type: "string" },
|
|
96013
|
+
halign: { type: "string" },
|
|
96014
|
+
"cell-borders": { type: "string" },
|
|
96015
|
+
"border-style": { type: "string" },
|
|
96016
|
+
"border-size": { type: "string" },
|
|
96017
|
+
"border-color": { type: "string" },
|
|
96018
|
+
align: { type: "string" },
|
|
96019
|
+
style: { type: "string" },
|
|
96020
|
+
"row-height": { type: "string" },
|
|
96021
|
+
"height-rule": { type: "string" },
|
|
96022
|
+
"repeat-header": { type: "boolean" },
|
|
96023
|
+
"no-repeat-header": { type: "boolean" },
|
|
96024
|
+
author: { type: "string" },
|
|
96025
|
+
track: { type: "boolean" },
|
|
96026
|
+
...SAVE_FLAGS
|
|
96027
|
+
}, HELP46);
|
|
96028
|
+
if (typeof parsed === "number")
|
|
96029
|
+
return parsed;
|
|
96030
|
+
if (parsed.values.help) {
|
|
96031
|
+
await writeStdout(HELP46);
|
|
96032
|
+
return EXIT2.OK;
|
|
96033
|
+
}
|
|
96034
|
+
setVerboseAck(Boolean(parsed.values.verbose));
|
|
96035
|
+
const path2 = parsed.positionals[0];
|
|
96036
|
+
if (!path2)
|
|
96037
|
+
return fail("USAGE", "Missing FILE argument", HELP46);
|
|
96038
|
+
const at = parsed.values.at;
|
|
96039
|
+
if (!at)
|
|
96040
|
+
return fail("USAGE", "Missing --at LOCATOR", HELP46);
|
|
96041
|
+
const scope = resolveScope(at);
|
|
96042
|
+
if (!scope) {
|
|
96043
|
+
return fail("INVALID_LOCATOR", `--at must address a table, row, column, cell, or cell range (got ${at})`, "e.g. t0 (table), t0:r0 (row), t0:c1 (column), t0:r0c0 (cell), t0:r0c0-r1c2 (range).");
|
|
96044
|
+
}
|
|
96045
|
+
const plan = buildPlan2(parsed.values);
|
|
96046
|
+
if (typeof plan === "string")
|
|
96047
|
+
return fail("USAGE", plan);
|
|
96048
|
+
if (planIsEmpty(plan)) {
|
|
96049
|
+
return fail("USAGE", "Nothing to format \u2014 pass at least one of --shade/--valign/--halign/--cell-borders/--align/--style/--row-height/--repeat-header");
|
|
96050
|
+
}
|
|
96051
|
+
const scopeError = validateScope(scope, plan);
|
|
96052
|
+
if (scopeError)
|
|
96053
|
+
return fail("USAGE", scopeError);
|
|
96054
|
+
const document4 = await openOrFail(path2);
|
|
96055
|
+
if (typeof document4 === "number")
|
|
96056
|
+
return document4;
|
|
96057
|
+
const tableNode = resolveTableNode(document4, scope.tableId);
|
|
96058
|
+
if (!tableNode)
|
|
96059
|
+
return fail("BLOCK_NOT_FOUND", `Table not found: ${scope.tableId}`);
|
|
96060
|
+
const grid = buildGrid(tableNode);
|
|
96061
|
+
const cells = selectCells(grid, scope);
|
|
96062
|
+
const rows = selectRows(grid, scope);
|
|
96063
|
+
const targetError = validateTargets(scope, plan, cells, rows);
|
|
96064
|
+
if (targetError)
|
|
96065
|
+
return fail("BLOCK_NOT_FOUND", targetError);
|
|
96066
|
+
const outputPath = parsed.values.output;
|
|
96067
|
+
if (parsed.values["dry-run"]) {
|
|
96068
|
+
await respond({
|
|
96069
|
+
operation: "tables.format",
|
|
96070
|
+
dryRun: true,
|
|
96071
|
+
path: path2,
|
|
96072
|
+
at,
|
|
96073
|
+
applied: appliedList2(plan),
|
|
96074
|
+
...outputPath ? { output: outputPath } : {}
|
|
96075
|
+
});
|
|
96076
|
+
return EXIT2.OK;
|
|
96077
|
+
}
|
|
96078
|
+
const tracking = resolveTracked(document4, parsed.values.track);
|
|
96079
|
+
const author = parsed.values.author;
|
|
96080
|
+
applyCellProps(document4, cells, plan, tracking, author);
|
|
96081
|
+
if (plan.halign !== undefined)
|
|
96082
|
+
applyHalign(document4, cells, plan.halign, tracking, author);
|
|
96083
|
+
applyTableProps(tableNode, plan);
|
|
96084
|
+
applyRowProps(rows, plan);
|
|
96085
|
+
const untracked = untrackedSummary(plan);
|
|
96086
|
+
if (untracked)
|
|
96087
|
+
noteStructuralChange(document4, cells[0]?.node, untracked, author, parsed.values.track);
|
|
96088
|
+
await document4.save(outputPath);
|
|
96089
|
+
const destination = outputPath ?? path2;
|
|
96090
|
+
await respondAck({
|
|
96091
|
+
ok: true,
|
|
96092
|
+
operation: "tables.format",
|
|
96093
|
+
path: destination,
|
|
96094
|
+
table: at,
|
|
96095
|
+
applied: appliedList2(plan)
|
|
96096
|
+
}, renderVerifyHint(destination));
|
|
96097
|
+
return EXIT2.OK;
|
|
96098
|
+
}
|
|
96099
|
+
function resolveScope(at) {
|
|
96100
|
+
const cell = parseCellAt(at);
|
|
96101
|
+
if (cell)
|
|
96102
|
+
return { kind: "cell", ...cell };
|
|
96103
|
+
const range = parseCellRangeAt(at);
|
|
96104
|
+
if (range)
|
|
96105
|
+
return { kind: "range", ...range };
|
|
96106
|
+
const row = parseRowAt(at);
|
|
96107
|
+
if (row)
|
|
96108
|
+
return { kind: "row", ...row };
|
|
96109
|
+
const column = parseColumnAt(at);
|
|
96110
|
+
if (column)
|
|
96111
|
+
return { kind: "column", ...column };
|
|
96112
|
+
const tableId = parseTableAt(at);
|
|
96113
|
+
if (tableId)
|
|
96114
|
+
return { kind: "table", tableId };
|
|
96115
|
+
return null;
|
|
96116
|
+
}
|
|
96117
|
+
function buildPlan2(values2) {
|
|
96118
|
+
const plan = {};
|
|
96119
|
+
const shade = values2.shade;
|
|
96120
|
+
if (shade !== undefined) {
|
|
96121
|
+
if (isClear(shade))
|
|
96122
|
+
plan.shade = null;
|
|
96123
|
+
else {
|
|
96124
|
+
const hex = resolveColor(shade);
|
|
96125
|
+
if (!hex)
|
|
96126
|
+
return colorError("--shade", shade);
|
|
96127
|
+
plan.shade = hex;
|
|
96128
|
+
}
|
|
96129
|
+
}
|
|
96130
|
+
const valign = values2.valign;
|
|
96131
|
+
if (valign !== undefined) {
|
|
96132
|
+
if (!VALIGNS.has(valign))
|
|
96133
|
+
return "--valign must be top, center, or bottom";
|
|
96134
|
+
plan.valign = valign;
|
|
96135
|
+
}
|
|
96136
|
+
const halign = values2.halign;
|
|
96137
|
+
if (halign !== undefined) {
|
|
96138
|
+
if (!HALIGNS.has(halign))
|
|
96139
|
+
return "--halign must be left, center, right, or justify";
|
|
96140
|
+
plan.halign = halign;
|
|
96141
|
+
}
|
|
96142
|
+
const cellBorders = values2["cell-borders"];
|
|
96143
|
+
if (cellBorders !== undefined) {
|
|
96144
|
+
const built = buildCellBorders(values2, cellBorders);
|
|
96145
|
+
if (typeof built === "string")
|
|
96146
|
+
return built;
|
|
96147
|
+
plan.cellBorders = built;
|
|
96148
|
+
}
|
|
96149
|
+
const align = values2.align;
|
|
96150
|
+
if (align !== undefined) {
|
|
96151
|
+
if (!TABLE_ALIGNS.has(align))
|
|
96152
|
+
return "--align must be left, center, or right";
|
|
96153
|
+
plan.align = align;
|
|
96154
|
+
}
|
|
96155
|
+
const style = values2.style;
|
|
96156
|
+
if (style !== undefined)
|
|
96157
|
+
plan.style = isClear(style) ? null : style;
|
|
96158
|
+
const rowHeight = values2["row-height"];
|
|
96159
|
+
const heightRule = values2["height-rule"];
|
|
96160
|
+
if (heightRule !== undefined && !HEIGHT_RULES.has(heightRule))
|
|
96161
|
+
return "--height-rule must be atLeast, exact, or auto";
|
|
96162
|
+
if (heightRule !== undefined && rowHeight === undefined)
|
|
96163
|
+
return "--height-rule has no effect without --row-height";
|
|
96164
|
+
if (rowHeight !== undefined) {
|
|
96165
|
+
const twips = parseMeasureToTwips(rowHeight);
|
|
96166
|
+
if (twips === null)
|
|
96167
|
+
return `--row-height must be a positive measure WITH a unit, e.g. 0.4in or 28pt (got ${rowHeight})`;
|
|
96168
|
+
plan.rowHeight = {
|
|
96169
|
+
value: twips,
|
|
96170
|
+
rule: heightRule ?? "atLeast"
|
|
96171
|
+
};
|
|
96172
|
+
}
|
|
96173
|
+
if (values2["repeat-header"] && values2["no-repeat-header"])
|
|
96174
|
+
return "--repeat-header and --no-repeat-header are mutually exclusive";
|
|
96175
|
+
if (values2["repeat-header"])
|
|
96176
|
+
plan.repeatHeader = true;
|
|
96177
|
+
if (values2["no-repeat-header"])
|
|
96178
|
+
plan.repeatHeader = false;
|
|
96179
|
+
return plan;
|
|
96180
|
+
}
|
|
96181
|
+
function buildCellBorders(values2, sidesRaw) {
|
|
96182
|
+
if (isClear(sidesRaw))
|
|
96183
|
+
return { updates: [], clearAll: true };
|
|
96184
|
+
const style = values2["border-style"] ?? "single";
|
|
96185
|
+
if (!BORDER_STYLES.has(style))
|
|
96186
|
+
return "--border-style must be single, double, or none";
|
|
96187
|
+
const sizeRaw = values2["border-size"];
|
|
96188
|
+
if (sizeRaw !== undefined && (!Number.isInteger(Number(sizeRaw)) || Number(sizeRaw) <= 0))
|
|
96189
|
+
return "--border-size must be a positive integer (eighths of a point)";
|
|
96190
|
+
const sizeEighths = sizeRaw ? Number(sizeRaw) : 4;
|
|
96191
|
+
const colorRaw = values2["border-color"] ?? "auto";
|
|
96192
|
+
const color2 = colorRaw === "auto" ? "auto" : resolveColor(colorRaw);
|
|
96193
|
+
if (!color2)
|
|
96194
|
+
return colorError("--border-color", colorRaw);
|
|
96195
|
+
const edge = { style, sizeEighths, color: color2 };
|
|
96196
|
+
const sides = new Set;
|
|
96197
|
+
for (const token of sidesRaw.split(",").map((value) => value.trim())) {
|
|
96198
|
+
if (token === "all") {
|
|
96199
|
+
for (const side of ALL_SIDES)
|
|
96200
|
+
sides.add(side);
|
|
96201
|
+
continue;
|
|
96202
|
+
}
|
|
96203
|
+
if (!ALL_SIDES.includes(token))
|
|
96204
|
+
return `--cell-borders side "${token}" must be one of ${ALL_SIDES.join(", ")}, all, or none`;
|
|
96205
|
+
sides.add(token);
|
|
96206
|
+
}
|
|
96207
|
+
return {
|
|
96208
|
+
updates: [...sides].map((side) => ({ side, edge })),
|
|
96209
|
+
clearAll: false
|
|
96210
|
+
};
|
|
96211
|
+
}
|
|
96212
|
+
function selectCells(grid, scope) {
|
|
96213
|
+
if (scope.kind === "table")
|
|
96214
|
+
return grid.rows.flatMap((row) => row.cells);
|
|
96215
|
+
if (scope.kind === "row")
|
|
96216
|
+
return grid.rows[scope.row]?.cells ?? [];
|
|
96217
|
+
if (scope.kind === "cell") {
|
|
96218
|
+
const cell = cellAt(grid.rows[scope.row], scope.col);
|
|
96219
|
+
return cell ? [cell] : [];
|
|
96220
|
+
}
|
|
96221
|
+
if (scope.kind === "column") {
|
|
96222
|
+
const out2 = [];
|
|
96223
|
+
for (const row of grid.rows) {
|
|
96224
|
+
const cell = cellAt(row, scope.col);
|
|
96225
|
+
if (cell && !out2.includes(cell))
|
|
96226
|
+
out2.push(cell);
|
|
96227
|
+
}
|
|
96228
|
+
return out2;
|
|
96229
|
+
}
|
|
96230
|
+
const r1 = Math.min(scope.start.row, scope.end.row);
|
|
96231
|
+
const r2 = Math.max(scope.start.row, scope.end.row);
|
|
96232
|
+
const c1 = Math.min(scope.start.col, scope.end.col);
|
|
96233
|
+
const c2 = Math.max(scope.start.col, scope.end.col);
|
|
96234
|
+
const out = [];
|
|
96235
|
+
for (let row = r1;row <= r2; row++) {
|
|
96236
|
+
for (const cell of grid.rows[row]?.cells ?? []) {
|
|
96237
|
+
if (cell.colStart <= c2 && cell.colStart + cell.colSpan - 1 >= c1)
|
|
96238
|
+
out.push(cell);
|
|
96239
|
+
}
|
|
96240
|
+
}
|
|
96241
|
+
return out;
|
|
96242
|
+
}
|
|
96243
|
+
function selectRows(grid, scope) {
|
|
96244
|
+
if (scope.kind === "table")
|
|
96245
|
+
return grid.rows;
|
|
96246
|
+
if (scope.kind === "row") {
|
|
96247
|
+
const row = grid.rows[scope.row];
|
|
96248
|
+
return row ? [row] : [];
|
|
96249
|
+
}
|
|
96250
|
+
return [];
|
|
96251
|
+
}
|
|
96252
|
+
function applyCellProps(document4, cells, plan, tracking, author) {
|
|
96253
|
+
if (plan.shade === undefined && plan.valign === undefined && plan.cellBorders === undefined)
|
|
96254
|
+
return;
|
|
96255
|
+
for (const cell of cells) {
|
|
96256
|
+
const prior = tracking ? (cell.node.findChild("w:tcPr")?.children ?? []).map((child2) => child2.clone()) : [];
|
|
96257
|
+
if (plan.shade !== undefined)
|
|
96258
|
+
setCellShading(cell.node, plan.shade);
|
|
96259
|
+
if (plan.valign !== undefined)
|
|
96260
|
+
setCellVAlign(cell.node, plan.valign);
|
|
96261
|
+
if (plan.cellBorders !== undefined)
|
|
96262
|
+
setCellBorders(cell.node, plan.cellBorders.updates, plan.cellBorders.clearAll);
|
|
96263
|
+
if (tracking)
|
|
96264
|
+
appendTcPrChange(cell.node, prior, new TrackChanges(document4).mintMeta(author));
|
|
96265
|
+
}
|
|
96266
|
+
}
|
|
96267
|
+
function applyHalign(document4, cells, alignment, tracking, author) {
|
|
96268
|
+
const edit = new Edit(document4);
|
|
96269
|
+
for (const cell of cells) {
|
|
96270
|
+
for (const paragraph2 of cell.node.findChildren("w:p")) {
|
|
96271
|
+
edit.paragraphProperties({ node: paragraph2, parent: cell.node.children }, { alignment }, { authorFlag: author, track: tracking });
|
|
96272
|
+
}
|
|
96273
|
+
}
|
|
96274
|
+
}
|
|
96275
|
+
function applyTableProps(tableNode, plan) {
|
|
96276
|
+
if (plan.align !== undefined)
|
|
96277
|
+
setTableJustification(tableNode, plan.align);
|
|
96278
|
+
if (plan.style !== undefined)
|
|
96279
|
+
setTableStyle(tableNode, plan.style);
|
|
96280
|
+
}
|
|
96281
|
+
function applyRowProps(rows, plan) {
|
|
96282
|
+
if (plan.rowHeight === undefined && plan.repeatHeader === undefined)
|
|
96283
|
+
return;
|
|
96284
|
+
for (const row of rows) {
|
|
96285
|
+
if (plan.rowHeight !== undefined)
|
|
96286
|
+
setRowHeight(row.node, plan.rowHeight);
|
|
96287
|
+
if (plan.repeatHeader !== undefined)
|
|
96288
|
+
setRepeatHeader(row.node, plan.repeatHeader);
|
|
96289
|
+
}
|
|
96290
|
+
}
|
|
96291
|
+
function validateScope(scope, plan) {
|
|
96292
|
+
const hasTableFlag = plan.align !== undefined || plan.style !== undefined;
|
|
96293
|
+
if (hasTableFlag && scope.kind !== "table")
|
|
96294
|
+
return "--align/--style position or restyle the whole table \u2014 use --at tN";
|
|
96295
|
+
const hasRowFlag = plan.rowHeight !== undefined || plan.repeatHeader !== undefined;
|
|
96296
|
+
if (hasRowFlag && scope.kind !== "table" && scope.kind !== "row")
|
|
96297
|
+
return "--row-height/--repeat-header apply to a row \u2014 use --at tN:rR (or --at tN for every row)";
|
|
96298
|
+
return null;
|
|
96299
|
+
}
|
|
96300
|
+
function validateTargets(scope, plan, cells, rows) {
|
|
96301
|
+
const hasCellFlag = plan.shade !== undefined || plan.valign !== undefined || plan.halign !== undefined || plan.cellBorders !== undefined;
|
|
96302
|
+
if (hasCellFlag && cells.length === 0)
|
|
96303
|
+
return `No cells matched ${describeScope(scope)}`;
|
|
96304
|
+
const hasRowFlag = plan.rowHeight !== undefined || plan.repeatHeader !== undefined;
|
|
96305
|
+
if (hasRowFlag && rows.length === 0)
|
|
96306
|
+
return `No rows matched ${describeScope(scope)}`;
|
|
96307
|
+
return null;
|
|
96308
|
+
}
|
|
96309
|
+
function describeScope(scope) {
|
|
96310
|
+
if (scope.kind === "table")
|
|
96311
|
+
return scope.tableId;
|
|
96312
|
+
if (scope.kind === "row")
|
|
96313
|
+
return `${scope.tableId}:r${scope.row}`;
|
|
96314
|
+
if (scope.kind === "column")
|
|
96315
|
+
return `${scope.tableId}:c${scope.col}`;
|
|
96316
|
+
if (scope.kind === "cell")
|
|
96317
|
+
return `${scope.tableId}:r${scope.row}c${scope.col}`;
|
|
96318
|
+
return `${scope.tableId}:r${scope.start.row}c${scope.start.col}-r${scope.end.row}c${scope.end.col}`;
|
|
96319
|
+
}
|
|
96320
|
+
function appliedList2(plan) {
|
|
96321
|
+
const out = [];
|
|
96322
|
+
if (plan.shade !== undefined)
|
|
96323
|
+
out.push("shade");
|
|
96324
|
+
if (plan.valign !== undefined)
|
|
96325
|
+
out.push("valign");
|
|
96326
|
+
if (plan.halign !== undefined)
|
|
96327
|
+
out.push("halign");
|
|
96328
|
+
if (plan.cellBorders !== undefined)
|
|
96329
|
+
out.push("cell-borders");
|
|
96330
|
+
if (plan.align !== undefined)
|
|
96331
|
+
out.push("align");
|
|
96332
|
+
if (plan.style !== undefined)
|
|
96333
|
+
out.push("style");
|
|
96334
|
+
if (plan.rowHeight !== undefined)
|
|
96335
|
+
out.push("row-height");
|
|
96336
|
+
if (plan.repeatHeader !== undefined)
|
|
96337
|
+
out.push("repeat-header");
|
|
96338
|
+
return out;
|
|
96339
|
+
}
|
|
96340
|
+
function untrackedSummary(plan) {
|
|
96341
|
+
const parts = [];
|
|
96342
|
+
if (plan.align !== undefined)
|
|
96343
|
+
parts.push(`table align ${plan.align ?? "left"}`);
|
|
96344
|
+
if (plan.style !== undefined)
|
|
96345
|
+
parts.push(plan.style ? `table style ${plan.style}` : "table style cleared");
|
|
96346
|
+
if (plan.rowHeight !== undefined)
|
|
96347
|
+
parts.push("row height set");
|
|
96348
|
+
if (plan.repeatHeader !== undefined)
|
|
96349
|
+
parts.push(plan.repeatHeader ? "repeat-header on" : "repeat-header off");
|
|
96350
|
+
return parts.length > 0 ? `set ${parts.join("; ")}` : "";
|
|
96351
|
+
}
|
|
96352
|
+
function planIsEmpty(plan) {
|
|
96353
|
+
return appliedList2(plan).length === 0;
|
|
96354
|
+
}
|
|
96355
|
+
function isClear(value) {
|
|
96356
|
+
const lower = value.toLowerCase();
|
|
96357
|
+
return lower === "none" || lower === "auto";
|
|
96358
|
+
}
|
|
96359
|
+
function resolveColor(value) {
|
|
96360
|
+
const named = COLOR_NAMES[value.toLowerCase()];
|
|
96361
|
+
if (named)
|
|
96362
|
+
return named;
|
|
96363
|
+
const hex = normalizeHexColor(value).toUpperCase();
|
|
96364
|
+
return /^[0-9A-F]{6}$/.test(hex) ? hex : null;
|
|
96365
|
+
}
|
|
96366
|
+
function colorError(flag, value) {
|
|
96367
|
+
return `${flag} must be a 6-digit hex (e.g. D9D9D9) or a name (${Object.keys(COLOR_NAMES).slice(0, 6).join(", ")}, \u2026) \u2014 got ${value}`;
|
|
96368
|
+
}
|
|
96369
|
+
function parseMeasureToTwips(raw) {
|
|
96370
|
+
const match = raw.trim().match(/^(\d*\.?\d+)\s*(in|pt)$/i);
|
|
96371
|
+
if (!match)
|
|
96372
|
+
return null;
|
|
96373
|
+
const value = Number.parseFloat(match[1]);
|
|
96374
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
96375
|
+
return null;
|
|
96376
|
+
const unit = match[2].toLowerCase();
|
|
96377
|
+
return Math.round(unit === "pt" ? value * 20 : value * 1440);
|
|
96378
|
+
}
|
|
96379
|
+
var HELP46 = `docx tables format \u2014 shade, align, border, and size table cells/rows/tables
|
|
96380
|
+
|
|
96381
|
+
Usage:
|
|
96382
|
+
docx tables format FILE --at LOCATOR [formatting options]
|
|
96383
|
+
|
|
96384
|
+
The --at locator picks WHAT to format; its granularity picks which options apply.
|
|
96385
|
+
--at t0 whole table
|
|
96386
|
+
--at t0:r2 a row --at t0:c1 a column
|
|
96387
|
+
--at t0:r1c2 a single cell --at t0:r1c0-r3c2 a rectangle of cells
|
|
96388
|
+
|
|
96389
|
+
Cell options (any locator \u2014 broadcast to every cell it covers):
|
|
96390
|
+
--shade HEX|NAME|none Cell background fill (e.g. D9D9D9, "grey", or none to clear)
|
|
96391
|
+
--valign top|center|bottom Vertical alignment of cell content
|
|
96392
|
+
--halign left|center|right|justify
|
|
96393
|
+
Horizontal alignment of cell TEXT (a paragraph property \u2014
|
|
96394
|
+
not the same as --align, which moves the whole table)
|
|
96395
|
+
--cell-borders SIDES Comma list of top,bottom,left,right,all,insideH,insideV
|
|
96396
|
+
(or none to clear). Styled by the --border-* options:
|
|
96397
|
+
--border-style single|double|none (default: single)
|
|
96398
|
+
--border-size EIGHTHS Thickness in eighths of a point (default: 4 = 0.5pt)
|
|
96399
|
+
--border-color HEX|NAME (default: auto)
|
|
96400
|
+
|
|
96401
|
+
Row options (--at t0:rR, or --at t0 for every row):
|
|
96402
|
+
--row-height MEASURE a unit is required: 0.4in or 28pt (a bare number is rejected)
|
|
96403
|
+
--height-rule atLeast|exact|auto (default: atLeast)
|
|
96404
|
+
--repeat-header / --no-repeat-header
|
|
96405
|
+
Repeat the row as a header atop each page the table spans
|
|
96406
|
+
|
|
96407
|
+
Table options (--at t0 only):
|
|
96408
|
+
--align left|center|right Position the whole table on the page
|
|
96409
|
+
--style STYLEID|none Apply (or clear) a table style from styles.xml
|
|
96410
|
+
|
|
96411
|
+
Common:
|
|
96412
|
+
--author NAME Author for tracked changes / audit comments (default: $DOCX_AUTHOR)
|
|
96413
|
+
--track Record as a tracked change even if the doc toggle is off
|
|
96414
|
+
-o, --output PATH / --dry-run / -v, --verbose / -h, --help
|
|
96415
|
+
|
|
96416
|
+
Tracking: cell shading/vAlign/borders record as a real <w:tcPrChange> and --halign
|
|
96417
|
+
as a <w:pPrChange> (both round-trip in Word). Table align/style and row height/
|
|
96418
|
+
repeat-header have no tracked-change construct Word will revert, so under tracking
|
|
96419
|
+
they apply in place with a [docx-cli] audit comment (same policy as tables borders).
|
|
96420
|
+
|
|
96421
|
+
Examples:
|
|
96422
|
+
docx tables format invoice.docx --at t0:r0 --shade D9D9D9 --valign center
|
|
96423
|
+
docx tables format invoice.docx --at t0:c2 --halign right
|
|
96424
|
+
docx tables format invoice.docx --at t0:r1c0-r3c2 --cell-borders bottom
|
|
96425
|
+
docx tables format invoice.docx --at t0 --align center --style LightGrid
|
|
96426
|
+
docx tables format invoice.docx --at t0:r0 --repeat-header --row-height 0.4in
|
|
96427
|
+
`, VALIGNS, HALIGNS, TABLE_ALIGNS, BORDER_STYLES, HEIGHT_RULES, ALL_SIDES, COLOR_NAMES;
|
|
96428
|
+
var init_format = __esm(() => {
|
|
96429
|
+
init_core2();
|
|
96430
|
+
init_locators();
|
|
96431
|
+
init_table();
|
|
96432
|
+
init_parse_helpers();
|
|
96433
|
+
init_respond();
|
|
96434
|
+
init_common2();
|
|
96435
|
+
VALIGNS = new Set(["top", "center", "bottom"]);
|
|
96436
|
+
HALIGNS = new Set(["left", "center", "right", "justify"]);
|
|
96437
|
+
TABLE_ALIGNS = new Set(["left", "center", "right"]);
|
|
96438
|
+
BORDER_STYLES = new Set(["single", "double", "none"]);
|
|
96439
|
+
HEIGHT_RULES = new Set(["atLeast", "exact", "auto"]);
|
|
96440
|
+
ALL_SIDES = [
|
|
96441
|
+
"top",
|
|
96442
|
+
"left",
|
|
96443
|
+
"bottom",
|
|
96444
|
+
"right",
|
|
96445
|
+
"insideH",
|
|
96446
|
+
"insideV"
|
|
96447
|
+
];
|
|
96448
|
+
COLOR_NAMES = {
|
|
96449
|
+
white: "FFFFFF",
|
|
96450
|
+
black: "000000",
|
|
96451
|
+
gray: "808080",
|
|
96452
|
+
grey: "808080",
|
|
96453
|
+
lightgray: "D9D9D9",
|
|
96454
|
+
lightgrey: "D9D9D9",
|
|
96455
|
+
darkgray: "A6A6A6",
|
|
96456
|
+
darkgrey: "A6A6A6",
|
|
96457
|
+
red: "FF0000",
|
|
96458
|
+
green: "00B050",
|
|
96459
|
+
blue: "0070C0",
|
|
96460
|
+
yellow: "FFFF00"
|
|
96461
|
+
};
|
|
96462
|
+
});
|
|
96463
|
+
|
|
95239
96464
|
// src/cli/tables/index.ts
|
|
95240
96465
|
var exports_tables = {};
|
|
95241
96466
|
__export(exports_tables, {
|
|
95242
|
-
run: () =>
|
|
96467
|
+
run: () => run51
|
|
95243
96468
|
});
|
|
95244
|
-
async function
|
|
96469
|
+
async function run51(args) {
|
|
95245
96470
|
const verb = args[0];
|
|
95246
96471
|
if (!verb || verb === "--help" || verb === "-h" || verb === "help") {
|
|
95247
|
-
await writeStdout(
|
|
96472
|
+
await writeStdout(HELP47);
|
|
95248
96473
|
return verb ? 0 : 2;
|
|
95249
96474
|
}
|
|
95250
|
-
const loader =
|
|
96475
|
+
const loader = SUBCOMMANDS10[verb];
|
|
95251
96476
|
if (!loader) {
|
|
95252
96477
|
return fail("USAGE", `Unknown tables subcommand: ${verb}`, 'Run "docx tables --help".');
|
|
95253
96478
|
}
|
|
95254
96479
|
const module_ = await loader();
|
|
95255
96480
|
return module_.run(args.slice(1));
|
|
95256
96481
|
}
|
|
95257
|
-
var
|
|
96482
|
+
var SUBCOMMANDS10, HELP47 = `docx tables \u2014 restructure & format tables (rows, columns, merges, widths, shading)
|
|
95258
96483
|
|
|
95259
96484
|
Usage:
|
|
95260
96485
|
docx tables <verb> FILE [options]
|
|
@@ -95268,6 +96493,9 @@ Verbs:
|
|
|
95268
96493
|
merge Merge a cell region (--at tN:rR1cC1-rR2cC2)
|
|
95269
96494
|
unmerge Split a merge anchor (--at tN:rRcC)
|
|
95270
96495
|
borders Set table borders (--at tN [--style] [--size] [--color])
|
|
96496
|
+
format Shade/align/border/size cells, rows, or the table
|
|
96497
|
+
(--at LOCATOR [--shade] [--valign] [--halign] [--cell-borders]
|
|
96498
|
+
[--align] [--style] [--row-height] [--repeat-header])
|
|
95271
96499
|
|
|
95272
96500
|
These verbs restructure an existing table. The rest of the table lifecycle uses
|
|
95273
96501
|
the standard verbs:
|
|
@@ -95280,7 +96508,7 @@ Run "docx tables <verb> --help" for verb-specific help.
|
|
|
95280
96508
|
`;
|
|
95281
96509
|
var init_tables = __esm(() => {
|
|
95282
96510
|
init_respond();
|
|
95283
|
-
|
|
96511
|
+
SUBCOMMANDS10 = {
|
|
95284
96512
|
"insert-row": () => Promise.resolve().then(() => (init_insert_row(), exports_insert_row)),
|
|
95285
96513
|
"delete-row": () => Promise.resolve().then(() => (init_delete_row(), exports_delete_row)),
|
|
95286
96514
|
"insert-column": () => Promise.resolve().then(() => (init_insert_column(), exports_insert_column)),
|
|
@@ -95288,7 +96516,8 @@ var init_tables = __esm(() => {
|
|
|
95288
96516
|
"set-widths": () => Promise.resolve().then(() => (init_set_widths(), exports_set_widths)),
|
|
95289
96517
|
merge: () => Promise.resolve().then(() => (init_merge(), exports_merge)),
|
|
95290
96518
|
unmerge: () => Promise.resolve().then(() => (init_unmerge(), exports_unmerge)),
|
|
95291
|
-
borders: () => Promise.resolve().then(() => (init_borders(), exports_borders))
|
|
96519
|
+
borders: () => Promise.resolve().then(() => (init_borders(), exports_borders)),
|
|
96520
|
+
format: () => Promise.resolve().then(() => (init_format(), exports_format))
|
|
95292
96521
|
};
|
|
95293
96522
|
});
|
|
95294
96523
|
|
|
@@ -95354,19 +96583,19 @@ var init_groups = __esm(() => {
|
|
|
95354
96583
|
function collectTrackedChangeRecords(document4) {
|
|
95355
96584
|
const byId = new Map;
|
|
95356
96585
|
for (const paragraph2 of flattenParagraphs(document4.body.blocks)) {
|
|
95357
|
-
for (const
|
|
95358
|
-
if (
|
|
96586
|
+
for (const run52 of paragraph2.runs) {
|
|
96587
|
+
if (run52.type !== "text" || !run52.trackedChange)
|
|
95359
96588
|
continue;
|
|
95360
|
-
const change =
|
|
96589
|
+
const change = run52.trackedChange;
|
|
95361
96590
|
const existing = byId.get(change.id);
|
|
95362
96591
|
if (existing) {
|
|
95363
|
-
existing.text +=
|
|
96592
|
+
existing.text += run52.text;
|
|
95364
96593
|
continue;
|
|
95365
96594
|
}
|
|
95366
96595
|
byId.set(change.id, {
|
|
95367
96596
|
...change,
|
|
95368
96597
|
blockId: paragraph2.id,
|
|
95369
|
-
text:
|
|
96598
|
+
text: run52.text
|
|
95370
96599
|
});
|
|
95371
96600
|
}
|
|
95372
96601
|
}
|
|
@@ -95609,22 +96838,22 @@ var init_list_view = __esm(() => {
|
|
|
95609
96838
|
// src/cli/track-changes/list.ts
|
|
95610
96839
|
var exports_list5 = {};
|
|
95611
96840
|
__export(exports_list5, {
|
|
95612
|
-
run: () =>
|
|
96841
|
+
run: () => run52
|
|
95613
96842
|
});
|
|
95614
|
-
async function
|
|
96843
|
+
async function run52(args) {
|
|
95615
96844
|
const parsed = await tryParseArgs(args, {
|
|
95616
96845
|
help: { type: "boolean", short: "h" },
|
|
95617
96846
|
json: { type: "boolean" }
|
|
95618
|
-
},
|
|
96847
|
+
}, HELP48);
|
|
95619
96848
|
if (typeof parsed === "number")
|
|
95620
96849
|
return parsed;
|
|
95621
96850
|
if (parsed.values.help) {
|
|
95622
|
-
await writeStdout(
|
|
96851
|
+
await writeStdout(HELP48);
|
|
95623
96852
|
return EXIT2.OK;
|
|
95624
96853
|
}
|
|
95625
96854
|
const path2 = parsed.positionals[0];
|
|
95626
96855
|
if (!path2)
|
|
95627
|
-
return fail("USAGE", "Missing FILE argument",
|
|
96856
|
+
return fail("USAGE", "Missing FILE argument", HELP48);
|
|
95628
96857
|
const document4 = await openOrFail(path2);
|
|
95629
96858
|
if (typeof document4 === "number")
|
|
95630
96859
|
return document4;
|
|
@@ -95636,7 +96865,7 @@ async function run49(args) {
|
|
|
95636
96865
|
await writeStdout(renderTrackedChangeTable(records));
|
|
95637
96866
|
return EXIT2.OK;
|
|
95638
96867
|
}
|
|
95639
|
-
var
|
|
96868
|
+
var HELP48 = `docx track-changes list \u2014 inventory every revision wrapper
|
|
95640
96869
|
|
|
95641
96870
|
Usage:
|
|
95642
96871
|
docx track-changes list FILE [options]
|
|
@@ -95786,17 +97015,17 @@ var init_run_apply = __esm(() => {
|
|
|
95786
97015
|
// src/cli/track-changes/accept.ts
|
|
95787
97016
|
var exports_accept = {};
|
|
95788
97017
|
__export(exports_accept, {
|
|
95789
|
-
run: () =>
|
|
97018
|
+
run: () => run53
|
|
95790
97019
|
});
|
|
95791
|
-
async function
|
|
95792
|
-
return runApply(args, "accept",
|
|
97020
|
+
async function run53(args) {
|
|
97021
|
+
return runApply(args, "accept", HELP49);
|
|
95793
97022
|
}
|
|
95794
|
-
var AT_FORMS14,
|
|
97023
|
+
var AT_FORMS14, HELP49;
|
|
95795
97024
|
var init_accept = __esm(() => {
|
|
95796
97025
|
init_core2();
|
|
95797
97026
|
init_run_apply();
|
|
95798
97027
|
AT_FORMS14 = describeForms(["trackedChange"], " ");
|
|
95799
|
-
|
|
97028
|
+
HELP49 = `docx track-changes accept \u2014 accept tracked changes (incorporate into the doc)
|
|
95800
97029
|
|
|
95801
97030
|
Usage:
|
|
95802
97031
|
docx track-changes accept FILE --at tcN [options]
|
|
@@ -95857,17 +97086,17 @@ Examples:
|
|
|
95857
97086
|
// src/cli/track-changes/reject.ts
|
|
95858
97087
|
var exports_reject = {};
|
|
95859
97088
|
__export(exports_reject, {
|
|
95860
|
-
run: () =>
|
|
97089
|
+
run: () => run54
|
|
95861
97090
|
});
|
|
95862
|
-
async function
|
|
95863
|
-
return runApply(args, "reject",
|
|
97091
|
+
async function run54(args) {
|
|
97092
|
+
return runApply(args, "reject", HELP50);
|
|
95864
97093
|
}
|
|
95865
|
-
var AT_FORMS15,
|
|
97094
|
+
var AT_FORMS15, HELP50;
|
|
95866
97095
|
var init_reject = __esm(() => {
|
|
95867
97096
|
init_core2();
|
|
95868
97097
|
init_run_apply();
|
|
95869
97098
|
AT_FORMS15 = describeForms(["trackedChange"], " ");
|
|
95870
|
-
|
|
97099
|
+
HELP50 = `docx track-changes reject \u2014 reject tracked changes (revert to pre-change state)
|
|
95871
97100
|
|
|
95872
97101
|
Usage:
|
|
95873
97102
|
docx track-changes reject FILE --at tcN [options]
|
|
@@ -95936,28 +97165,28 @@ Examples:
|
|
|
95936
97165
|
// src/cli/track-changes/apply.ts
|
|
95937
97166
|
var exports_apply = {};
|
|
95938
97167
|
__export(exports_apply, {
|
|
95939
|
-
run: () =>
|
|
97168
|
+
run: () => run55
|
|
95940
97169
|
});
|
|
95941
|
-
async function
|
|
97170
|
+
async function run55(args) {
|
|
95942
97171
|
const parsed = await tryParseArgs(args, {
|
|
95943
97172
|
accept: { type: "string", multiple: true },
|
|
95944
97173
|
reject: { type: "string", multiple: true },
|
|
95945
97174
|
...SAVE_FLAGS
|
|
95946
|
-
},
|
|
97175
|
+
}, HELP51);
|
|
95947
97176
|
if (typeof parsed === "number")
|
|
95948
97177
|
return parsed;
|
|
95949
97178
|
if (parsed.values.help) {
|
|
95950
|
-
await writeStdout(
|
|
97179
|
+
await writeStdout(HELP51);
|
|
95951
97180
|
return EXIT2.OK;
|
|
95952
97181
|
}
|
|
95953
97182
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
95954
97183
|
const path2 = parsed.positionals[0];
|
|
95955
97184
|
if (!path2)
|
|
95956
|
-
return fail("USAGE", "Missing FILE argument",
|
|
97185
|
+
return fail("USAGE", "Missing FILE argument", HELP51);
|
|
95957
97186
|
const acceptRaw = parsed.values.accept ?? [];
|
|
95958
97187
|
const rejectRaw = parsed.values.reject ?? [];
|
|
95959
97188
|
if (acceptRaw.length === 0 && rejectRaw.length === 0) {
|
|
95960
|
-
return fail("USAGE", "Specify --accept and/or --reject (handle)",
|
|
97189
|
+
return fail("USAGE", "Specify --accept and/or --reject (handle)", HELP51);
|
|
95961
97190
|
}
|
|
95962
97191
|
const document4 = await openOrFail(path2);
|
|
95963
97192
|
if (typeof document4 === "number")
|
|
@@ -95978,7 +97207,7 @@ async function run52(args) {
|
|
|
95978
97207
|
const rejectSet = new Set(rejects);
|
|
95979
97208
|
const conflict = accepts.find((id) => rejectSet.has(id));
|
|
95980
97209
|
if (conflict) {
|
|
95981
|
-
return fail("USAGE", `${conflict} is named in both --accept and --reject`,
|
|
97210
|
+
return fail("USAGE", `${conflict} is named in both --accept and --reject`, HELP51);
|
|
95982
97211
|
}
|
|
95983
97212
|
const outputPath = parsed.values.output;
|
|
95984
97213
|
try {
|
|
@@ -96021,7 +97250,7 @@ function trackedChangeIndex2(id) {
|
|
|
96021
97250
|
const match = id.match(/^tc(\d+)$/);
|
|
96022
97251
|
return match?.[1] ? Number(match[1]) : 0;
|
|
96023
97252
|
}
|
|
96024
|
-
var
|
|
97253
|
+
var HELP51 = `docx track-changes apply \u2014 finalize: accept AND reject in one atomic call
|
|
96025
97254
|
|
|
96026
97255
|
Usage:
|
|
96027
97256
|
docx track-changes apply FILE (--accept H ... | --reject H ...) [options]
|
|
@@ -96074,16 +97303,16 @@ var init_apply2 = __esm(() => {
|
|
|
96074
97303
|
// src/cli/track-changes/toggle.tsx
|
|
96075
97304
|
var exports_toggle = {};
|
|
96076
97305
|
__export(exports_toggle, {
|
|
96077
|
-
run: () =>
|
|
97306
|
+
run: () => run56
|
|
96078
97307
|
});
|
|
96079
|
-
async function
|
|
97308
|
+
async function run56(args) {
|
|
96080
97309
|
const parsed = await tryParseArgs(args, {
|
|
96081
97310
|
...SAVE_FLAGS
|
|
96082
|
-
},
|
|
97311
|
+
}, HELP52);
|
|
96083
97312
|
if (typeof parsed === "number")
|
|
96084
97313
|
return parsed;
|
|
96085
97314
|
if (parsed.values.help) {
|
|
96086
|
-
await writeStdout(
|
|
97315
|
+
await writeStdout(HELP52);
|
|
96087
97316
|
return EXIT2.OK;
|
|
96088
97317
|
}
|
|
96089
97318
|
setVerboseAck(Boolean(parsed.values.verbose));
|
|
@@ -96092,10 +97321,10 @@ async function run53(args) {
|
|
|
96092
97321
|
const mode = modeFirst ? first : second;
|
|
96093
97322
|
const path2 = modeFirst ? second : first;
|
|
96094
97323
|
if (mode !== "on" && mode !== "off") {
|
|
96095
|
-
return fail("USAGE", `Expected "on" or "off" (e.g. \`docx track-changes on FILE\`), got: ${parsed.positionals.join(" ") || "<nothing>"}`,
|
|
97324
|
+
return fail("USAGE", `Expected "on" or "off" (e.g. \`docx track-changes on FILE\`), got: ${parsed.positionals.join(" ") || "<nothing>"}`, HELP52);
|
|
96096
97325
|
}
|
|
96097
97326
|
if (!path2)
|
|
96098
|
-
return fail("USAGE", "Missing FILE argument",
|
|
97327
|
+
return fail("USAGE", "Missing FILE argument", HELP52);
|
|
96099
97328
|
const document4 = await openOrFail(path2);
|
|
96100
97329
|
if (typeof document4 === "number")
|
|
96101
97330
|
return document4;
|
|
@@ -96125,7 +97354,7 @@ async function run53(args) {
|
|
|
96125
97354
|
});
|
|
96126
97355
|
return EXIT2.OK;
|
|
96127
97356
|
}
|
|
96128
|
-
var
|
|
97357
|
+
var HELP52 = `docx track-changes \u2014 toggle the document's tracked-changes mode
|
|
96129
97358
|
|
|
96130
97359
|
Usage:
|
|
96131
97360
|
docx track-changes on|off FILE [options]
|
|
@@ -96163,16 +97392,16 @@ var init_toggle2 = __esm(() => {
|
|
|
96163
97392
|
// src/cli/track-changes/index.ts
|
|
96164
97393
|
var exports_track_changes = {};
|
|
96165
97394
|
__export(exports_track_changes, {
|
|
96166
|
-
run: () =>
|
|
97395
|
+
run: () => run57
|
|
96167
97396
|
});
|
|
96168
|
-
async function
|
|
97397
|
+
async function run57(args) {
|
|
96169
97398
|
const first = args[0];
|
|
96170
97399
|
if (first === "--help" || first === "-h" || first === "help") {
|
|
96171
|
-
await writeStdout(
|
|
97400
|
+
await writeStdout(HELP53);
|
|
96172
97401
|
return 0;
|
|
96173
97402
|
}
|
|
96174
97403
|
if (!first) {
|
|
96175
|
-
return fail("USAGE", "Missing arguments",
|
|
97404
|
+
return fail("USAGE", "Missing arguments", HELP53);
|
|
96176
97405
|
}
|
|
96177
97406
|
if (first === "list") {
|
|
96178
97407
|
const module_2 = await Promise.resolve().then(() => (init_list8(), exports_list5));
|
|
@@ -96193,7 +97422,7 @@ async function run54(args) {
|
|
|
96193
97422
|
const module_ = await Promise.resolve().then(() => (init_toggle2(), exports_toggle));
|
|
96194
97423
|
return module_.run(args);
|
|
96195
97424
|
}
|
|
96196
|
-
var
|
|
97425
|
+
var HELP53 = `docx track-changes \u2014 manage tracked-changes
|
|
96197
97426
|
|
|
96198
97427
|
Usage:
|
|
96199
97428
|
docx track-changes on|off FILE [options]
|
|
@@ -96339,29 +97568,29 @@ var init_count = __esm(() => {
|
|
|
96339
97568
|
// src/cli/wc/index.ts
|
|
96340
97569
|
var exports_wc = {};
|
|
96341
97570
|
__export(exports_wc, {
|
|
96342
|
-
run: () =>
|
|
97571
|
+
run: () => run58
|
|
96343
97572
|
});
|
|
96344
|
-
async function
|
|
97573
|
+
async function run58(args) {
|
|
96345
97574
|
const parsed = await tryParseArgs(args, {
|
|
96346
97575
|
accepted: { type: "boolean" },
|
|
96347
97576
|
baseline: { type: "boolean" },
|
|
96348
97577
|
current: { type: "boolean" },
|
|
96349
97578
|
json: { type: "boolean" },
|
|
96350
97579
|
help: { type: "boolean", short: "h" }
|
|
96351
|
-
},
|
|
97580
|
+
}, HELP54);
|
|
96352
97581
|
if (typeof parsed === "number")
|
|
96353
97582
|
return parsed;
|
|
96354
97583
|
if (parsed.values.help) {
|
|
96355
|
-
await writeStdout(
|
|
97584
|
+
await writeStdout(HELP54);
|
|
96356
97585
|
return EXIT2.OK;
|
|
96357
97586
|
}
|
|
96358
97587
|
const path2 = parsed.positionals[0];
|
|
96359
97588
|
const locatorInput = parsed.positionals[1];
|
|
96360
97589
|
if (!path2)
|
|
96361
|
-
return fail("USAGE", "Missing FILE argument",
|
|
97590
|
+
return fail("USAGE", "Missing FILE argument", HELP54);
|
|
96362
97591
|
const view = resolveView(parsed.values);
|
|
96363
97592
|
if (!view) {
|
|
96364
|
-
return fail("USAGE", "--accepted, --baseline, and --current are mutually exclusive",
|
|
97593
|
+
return fail("USAGE", "--accepted, --baseline, and --current are mutually exclusive", HELP54);
|
|
96365
97594
|
}
|
|
96366
97595
|
const json2 = Boolean(parsed.values.json);
|
|
96367
97596
|
const pickText = paragraphTextFor(view);
|
|
@@ -96539,13 +97768,13 @@ function paragraphTextFor(view) {
|
|
|
96539
97768
|
return paragraphTextBaseline;
|
|
96540
97769
|
return paragraphText2;
|
|
96541
97770
|
}
|
|
96542
|
-
var
|
|
97771
|
+
var HELP54;
|
|
96543
97772
|
var init_wc = __esm(() => {
|
|
96544
97773
|
init_core2();
|
|
96545
97774
|
init_parse_helpers();
|
|
96546
97775
|
init_respond();
|
|
96547
97776
|
init_count();
|
|
96548
|
-
|
|
97777
|
+
HELP54 = `docx wc \u2014 count words in a document or a locator-addressed slice
|
|
96549
97778
|
|
|
96550
97779
|
Usage:
|
|
96551
97780
|
docx wc FILE [LOCATOR] [options]
|
|
@@ -96609,7 +97838,7 @@ Examples:
|
|
|
96609
97838
|
// package.json
|
|
96610
97839
|
var package_default = {
|
|
96611
97840
|
name: "bun-docx",
|
|
96612
|
-
version: "0.
|
|
97841
|
+
version: "0.18.0",
|
|
96613
97842
|
description: "CLI for AI agents (Claude, Codex) to read, edit, and comment on .docx files with full format fidelity.",
|
|
96614
97843
|
keywords: [
|
|
96615
97844
|
"docx",
|
|
@@ -96717,6 +97946,7 @@ Commands (each one-liner names capabilities you'd otherwise miss; see <command>
|
|
|
96717
97946
|
images \u2026 Add (--caption "Figure 1: \u2026" for a captioned figure), extract, replace, delete, list images
|
|
96718
97947
|
hyperlinks \u2026 Add, list, replace, delete hyperlinks (add uses --url; replace uses --with)
|
|
96719
97948
|
tables \u2026 Restructure tables \u2014 insert/delete rows & columns, merge/unmerge, set widths, borders
|
|
97949
|
+
lists FILE Renumber a numbered list \u2014 "lists set --at pN --start 5" / "--format upper-roman" / "--restart" / "--continue"
|
|
96720
97950
|
track-changes \u2026 Toggle (on|off FILE); list / accept / reject revisions; "read" shows them as CriticMarkup
|
|
96721
97951
|
info \u2026 Reference material, no FILE needed (schema for read --ast, locator grammar)
|
|
96722
97952
|
|
|
@@ -96777,6 +98007,7 @@ var COMMANDS = {
|
|
|
96777
98007
|
images: () => Promise.resolve().then(() => (init_images(), exports_images)),
|
|
96778
98008
|
info: () => Promise.resolve().then(() => (init_info(), exports_info)),
|
|
96779
98009
|
insert: () => Promise.resolve().then(() => (init_insert2(), exports_insert)),
|
|
98010
|
+
lists: () => Promise.resolve().then(() => (init_lists2(), exports_lists)),
|
|
96780
98011
|
outline: () => Promise.resolve().then(() => (init_outline(), exports_outline)),
|
|
96781
98012
|
read: () => Promise.resolve().then(() => (init_read3(), exports_read)),
|
|
96782
98013
|
render: () => Promise.resolve().then(() => (init_render2(), exports_render)),
|