bun-docx 0.14.1 → 0.15.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.
Files changed (3) hide show
  1. package/README.md +11 -2
  2. package/dist/index.js +904 -318
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32530,10 +32530,349 @@ var init_settings = __esm(() => {
32530
32530
  ]);
32531
32531
  });
32532
32532
 
32533
+ // src/core/blocks.tsx
32534
+ function Paragraph({
32535
+ style,
32536
+ alignment,
32537
+ list,
32538
+ taskState,
32539
+ tabs,
32540
+ text: text2,
32541
+ runs,
32542
+ ...formatting
32543
+ }) {
32544
+ const resolvedRuns = runs ?? textToRuns(text2 ?? "", formatting);
32545
+ return /* @__PURE__ */ jsxDEV(w.p, {
32546
+ children: [
32547
+ /* @__PURE__ */ jsxDEV(ParagraphProperties, {
32548
+ options: { style, alignment, list, tabs }
32549
+ }, undefined, false, undefined, this),
32550
+ taskState && /* @__PURE__ */ jsxDEV(TaskCheckbox, {
32551
+ checked: taskState === "checked"
32552
+ }, undefined, false, undefined, this),
32553
+ taskState && /* @__PURE__ */ jsxDEV(w.r, {
32554
+ children: /* @__PURE__ */ jsxDEV(w.t, {
32555
+ "xml:space": "preserve",
32556
+ children: " "
32557
+ }, undefined, false, undefined, this)
32558
+ }, undefined, false, undefined, this),
32559
+ resolvedRuns.map((run) => /* @__PURE__ */ jsxDEV(RunElement, {
32560
+ run
32561
+ }, undefined, false, undefined, this))
32562
+ ]
32563
+ }, undefined, true, undefined, this);
32564
+ }
32565
+ function textToRuns(text2, formatting) {
32566
+ if (!text2.includes(`
32567
+ `) && !text2.includes("\t")) {
32568
+ return [{ type: "text", text: text2, ...formatting }];
32569
+ }
32570
+ const runs = [];
32571
+ for (const segment of text2.split(/(\n|\t)/)) {
32572
+ if (segment === "")
32573
+ continue;
32574
+ if (segment === `
32575
+ `)
32576
+ runs.push({ type: "break", kind: "line" });
32577
+ else if (segment === "\t")
32578
+ runs.push({ type: "tab" });
32579
+ else
32580
+ runs.push({ type: "text", text: segment, ...formatting });
32581
+ }
32582
+ return runs;
32583
+ }
32584
+ function RunElement({ run }) {
32585
+ if (run.type === "text")
32586
+ return /* @__PURE__ */ jsxDEV(TextRunElement, {
32587
+ run
32588
+ }, undefined, false, undefined, this);
32589
+ if (run.type === "break") {
32590
+ return /* @__PURE__ */ jsxDEV(w.r, {
32591
+ children: /* @__PURE__ */ jsxDEV(w.br, {
32592
+ "w-type": run.kind === "line" ? undefined : run.kind
32593
+ }, undefined, false, undefined, this)
32594
+ }, undefined, false, undefined, this);
32595
+ }
32596
+ if (run.type === "tab") {
32597
+ return /* @__PURE__ */ jsxDEV(w.r, {
32598
+ children: /* @__PURE__ */ jsxDEV(w.tab, {}, undefined, false, undefined, this)
32599
+ }, undefined, false, undefined, this);
32600
+ }
32601
+ return null;
32602
+ }
32603
+ function applyParagraphOptionsInPlace(rebuilt, options) {
32604
+ if (!options.style && !options.alignment && !options.tabs)
32605
+ return;
32606
+ let pPr = rebuilt.find((child2) => child2.tag === "w:pPr");
32607
+ if (!pPr) {
32608
+ pPr = new XmlNode2("w:pPr");
32609
+ rebuilt.unshift(pPr);
32610
+ }
32611
+ if (options.tabs) {
32612
+ pPr.children = pPr.children.filter((child2) => child2.tag !== "w:tabs");
32613
+ if (options.tabs.length > 0) {
32614
+ const tabsNode = new XmlNode2("w:tabs");
32615
+ for (const stop of options.tabs) {
32616
+ tabsNode.children.push(new XmlNode2("w:tab", {
32617
+ "w:val": stop.align,
32618
+ "w:pos": String(Math.round(stop.pos))
32619
+ }));
32620
+ }
32621
+ insertPprChildInOrder(pPr, tabsNode);
32622
+ }
32623
+ }
32624
+ if (options.style) {
32625
+ const existingStyle = pPr.findChild("w:pStyle");
32626
+ if (existingStyle) {
32627
+ existingStyle.setAttribute("w:val", options.style);
32628
+ } else {
32629
+ insertPprChildInOrder(pPr, new XmlNode2("w:pStyle", { "w:val": options.style }));
32630
+ }
32631
+ }
32632
+ if (options.alignment) {
32633
+ const existingJc = pPr.findChild("w:jc");
32634
+ if (existingJc) {
32635
+ existingJc.setAttribute("w:val", options.alignment);
32636
+ } else {
32637
+ insertPprChildInOrder(pPr, new XmlNode2("w:jc", { "w:val": options.alignment }));
32638
+ }
32639
+ }
32640
+ }
32641
+ function pprChildRank(tag) {
32642
+ const index = PPR_CHILD_ORDER.indexOf(tag);
32643
+ if (index >= 0)
32644
+ return index;
32645
+ return PPR_CHILD_ORDER.indexOf("w:rPr") - 0.5;
32646
+ }
32647
+ function insertPprChildInOrder(pPr, child2) {
32648
+ const rank = pprChildRank(child2.tag);
32649
+ const at = pPr.children.findIndex((existing) => pprChildRank(existing.tag) > rank);
32650
+ if (at < 0)
32651
+ pPr.children.push(child2);
32652
+ else
32653
+ pPr.children.splice(at, 0, child2);
32654
+ }
32655
+ function rprChildRank(tag) {
32656
+ const index = RPR_CHILD_ORDER.indexOf(tag);
32657
+ return index >= 0 ? index : RPR_CHILD_ORDER.length;
32658
+ }
32659
+ function insertRprChildInOrder(rPr, child2) {
32660
+ const rank = rprChildRank(child2.tag);
32661
+ const at = rPr.children.findIndex((existing) => rprChildRank(existing.tag) > rank);
32662
+ if (at < 0)
32663
+ rPr.children.push(child2);
32664
+ else
32665
+ rPr.children.splice(at, 0, child2);
32666
+ }
32667
+ function HorizontalRule() {
32668
+ return /* @__PURE__ */ jsxDEV(w.p, {
32669
+ children: /* @__PURE__ */ jsxDEV(w.pPr, {
32670
+ children: /* @__PURE__ */ jsxDEV(w.pBdr, {
32671
+ children: /* @__PURE__ */ jsxDEV(w.bottom, {
32672
+ "w-val": "single",
32673
+ "w-sz": "6",
32674
+ "w-space": "1",
32675
+ "w-color": "auto"
32676
+ }, undefined, false, undefined, this)
32677
+ }, undefined, false, undefined, this)
32678
+ }, undefined, false, undefined, this)
32679
+ }, undefined, false, undefined, this);
32680
+ }
32681
+ function TextRunElement({ run }) {
32682
+ return /* @__PURE__ */ jsxDEV(w.r, {
32683
+ children: [
32684
+ /* @__PURE__ */ jsxDEV(RunProperties, {
32685
+ run
32686
+ }, undefined, false, undefined, this),
32687
+ /* @__PURE__ */ jsxDEV(w.t, {
32688
+ "xml:space": "preserve",
32689
+ children: run.text
32690
+ }, undefined, false, undefined, this)
32691
+ ]
32692
+ }, undefined, true, undefined, this);
32693
+ }
32694
+ function RunProperties({ run }) {
32695
+ const isEmpty = FORMATTING_KEYS.every((key) => run[key] == null);
32696
+ if (isEmpty)
32697
+ return null;
32698
+ return /* @__PURE__ */ jsxDEV(w.rPr, {
32699
+ children: [
32700
+ run.runStyle && /* @__PURE__ */ jsxDEV(w.rStyle, {
32701
+ "w-val": run.runStyle
32702
+ }, undefined, false, undefined, this),
32703
+ run.font && /* @__PURE__ */ jsxDEV(w.rFonts, {
32704
+ "w-ascii": run.font,
32705
+ "w-hAnsi": run.font
32706
+ }, undefined, false, undefined, this),
32707
+ run.bold && /* @__PURE__ */ jsxDEV(w.b, {}, undefined, false, undefined, this),
32708
+ run.italic && /* @__PURE__ */ jsxDEV(w.i, {}, undefined, false, undefined, this),
32709
+ run.allCaps && /* @__PURE__ */ jsxDEV(w.caps, {}, undefined, false, undefined, this),
32710
+ run.smallCaps && /* @__PURE__ */ jsxDEV(w.smallCaps, {}, undefined, false, undefined, this),
32711
+ run.strike && /* @__PURE__ */ jsxDEV(w.strike, {}, undefined, false, undefined, this),
32712
+ (run.color || run.colorTheme) && /* @__PURE__ */ jsxDEV(w.color, {
32713
+ "w-val": run.color ?? "auto",
32714
+ "w-themeColor": run.colorTheme,
32715
+ "w-themeTint": run.colorThemeTint,
32716
+ "w-themeShade": run.colorThemeShade
32717
+ }, undefined, false, undefined, this),
32718
+ run.sizeHalfPoints !== undefined && /* @__PURE__ */ jsxDEV(w.sz, {
32719
+ "w-val": String(run.sizeHalfPoints)
32720
+ }, undefined, false, undefined, this),
32721
+ run.highlight && /* @__PURE__ */ jsxDEV(w.highlight, {
32722
+ "w-val": run.highlight
32723
+ }, undefined, false, undefined, this),
32724
+ run.underline && /* @__PURE__ */ jsxDEV(w.u, {
32725
+ "w-val": run.underline,
32726
+ "w-color": run.underlineColor
32727
+ }, undefined, false, undefined, this),
32728
+ run.shade && /* @__PURE__ */ jsxDEV(w.shd, {
32729
+ "w-val": "clear",
32730
+ "w-color": "auto",
32731
+ "w-fill": run.shade
32732
+ }, undefined, false, undefined, this),
32733
+ run.vertAlign && /* @__PURE__ */ jsxDEV(w.vertAlign, {
32734
+ "w-val": run.vertAlign
32735
+ }, undefined, false, undefined, this)
32736
+ ]
32737
+ }, undefined, true, undefined, this);
32738
+ }
32739
+ function ParagraphProperties({
32740
+ options
32741
+ }) {
32742
+ const hasTabs = options.tabs !== undefined && options.tabs.length > 0;
32743
+ if (!options.style && !options.alignment && !options.list && !hasTabs)
32744
+ return null;
32745
+ return /* @__PURE__ */ jsxDEV(w.pPr, {
32746
+ children: [
32747
+ options.style && /* @__PURE__ */ jsxDEV(w.pStyle, {
32748
+ "w-val": options.style
32749
+ }, undefined, false, undefined, this),
32750
+ options.list && /* @__PURE__ */ jsxDEV(w.numPr, {
32751
+ children: [
32752
+ /* @__PURE__ */ jsxDEV(w.ilvl, {
32753
+ "w-val": String(options.list.level)
32754
+ }, undefined, false, undefined, this),
32755
+ /* @__PURE__ */ jsxDEV(w.numId, {
32756
+ "w-val": String(options.list.numId)
32757
+ }, undefined, false, undefined, this)
32758
+ ]
32759
+ }, undefined, true, undefined, this),
32760
+ hasTabs && /* @__PURE__ */ jsxDEV(w.tabs, {
32761
+ children: options.tabs?.map((stop) => /* @__PURE__ */ jsxDEV(w.tab, {
32762
+ "w-val": stop.align,
32763
+ "w-pos": String(Math.round(stop.pos))
32764
+ }, undefined, false, undefined, this))
32765
+ }, undefined, false, undefined, this),
32766
+ options.alignment && /* @__PURE__ */ jsxDEV(w.jc, {
32767
+ "w-val": options.alignment
32768
+ }, undefined, false, undefined, this)
32769
+ ]
32770
+ }, undefined, true, undefined, this);
32771
+ }
32772
+ var PPR_CHILD_ORDER, RPR_CHILD_ORDER, FORMATTING_KEYS;
32773
+ var init_blocks = __esm(() => {
32774
+ init_jsx();
32775
+ init_parser();
32776
+ init_task_list();
32777
+ init_jsx_dev_runtime();
32778
+ PPR_CHILD_ORDER = [
32779
+ "w:pStyle",
32780
+ "w:keepNext",
32781
+ "w:keepLines",
32782
+ "w:pageBreakBefore",
32783
+ "w:framePr",
32784
+ "w:widowControl",
32785
+ "w:numPr",
32786
+ "w:suppressLineNumbers",
32787
+ "w:pBdr",
32788
+ "w:shd",
32789
+ "w:tabs",
32790
+ "w:suppressAutoHyphens",
32791
+ "w:bidi",
32792
+ "w:adjustRightInd",
32793
+ "w:snapToGrid",
32794
+ "w:spacing",
32795
+ "w:ind",
32796
+ "w:contextualSpacing",
32797
+ "w:mirrorIndents",
32798
+ "w:suppressOverlap",
32799
+ "w:jc",
32800
+ "w:textDirection",
32801
+ "w:textAlignment",
32802
+ "w:textboxTightWrap",
32803
+ "w:outlineLvl",
32804
+ "w:divId",
32805
+ "w:cnfStyle",
32806
+ "w:rPr",
32807
+ "w:sectPr",
32808
+ "w:pPrChange"
32809
+ ];
32810
+ RPR_CHILD_ORDER = [
32811
+ "w:rStyle",
32812
+ "w:rFonts",
32813
+ "w:b",
32814
+ "w:bCs",
32815
+ "w:i",
32816
+ "w:iCs",
32817
+ "w:caps",
32818
+ "w:smallCaps",
32819
+ "w:strike",
32820
+ "w:dstrike",
32821
+ "w:outline",
32822
+ "w:shadow",
32823
+ "w:emboss",
32824
+ "w:imprint",
32825
+ "w:noProof",
32826
+ "w:snapToGrid",
32827
+ "w:vanish",
32828
+ "w:webHidden",
32829
+ "w:color",
32830
+ "w:spacing",
32831
+ "w:w",
32832
+ "w:kern",
32833
+ "w:position",
32834
+ "w:sz",
32835
+ "w:szCs",
32836
+ "w:highlight",
32837
+ "w:u",
32838
+ "w:effect",
32839
+ "w:bdr",
32840
+ "w:shd",
32841
+ "w:fitText",
32842
+ "w:vertAlign",
32843
+ "w:rtl",
32844
+ "w:cs",
32845
+ "w:em",
32846
+ "w:lang",
32847
+ "w:eastAsianLayout",
32848
+ "w:specVanish",
32849
+ "w:oMath"
32850
+ ];
32851
+ FORMATTING_KEYS = [
32852
+ "runStyle",
32853
+ "font",
32854
+ "bold",
32855
+ "italic",
32856
+ "allCaps",
32857
+ "smallCaps",
32858
+ "strike",
32859
+ "color",
32860
+ "colorTheme",
32861
+ "sizeHalfPoints",
32862
+ "highlight",
32863
+ "underline",
32864
+ "shade",
32865
+ "vertAlign"
32866
+ ];
32867
+ });
32868
+
32533
32869
  // src/core/ast/document/styles.tsx
32534
32870
  function isBaselineStyle(styleId) {
32535
32871
  return Object.hasOwn(BASELINE, styleId);
32536
32872
  }
32873
+ function baselineCatalog() {
32874
+ return Object.keys(BASELINE).map((id) => BASELINE[id]());
32875
+ }
32537
32876
 
32538
32877
  class StylesView {
32539
32878
  tree;
@@ -32615,6 +32954,79 @@ class StylesView {
32615
32954
  return;
32616
32955
  root.children.push(build());
32617
32956
  }
32957
+ setDefaultFont(fontName) {
32958
+ const rPr = this.#ensureDocDefaultsRPr();
32959
+ let rFonts = rPr.findChild("w:rFonts");
32960
+ if (!rFonts) {
32961
+ rFonts = XmlNode2.element("w:rFonts");
32962
+ insertRprChildInOrder(rPr, rFonts);
32963
+ }
32964
+ applyRunFont(rFonts, fontName);
32965
+ }
32966
+ setDefaultSizeHalfPoints(halfPoints) {
32967
+ const rPr = this.#ensureDocDefaultsRPr();
32968
+ const value = String(halfPoints);
32969
+ let sz = rPr.findChild("w:sz");
32970
+ if (!sz) {
32971
+ sz = XmlNode2.element("w:sz");
32972
+ insertRprChildInOrder(rPr, sz);
32973
+ }
32974
+ sz.setAttribute("w:val", value);
32975
+ let szCs = rPr.findChild("w:szCs");
32976
+ if (!szCs) {
32977
+ szCs = XmlNode2.element("w:szCs");
32978
+ insertRprChildInOrder(rPr, szCs);
32979
+ }
32980
+ szCs.setAttribute("w:val", value);
32981
+ }
32982
+ explicitFontStyleIds() {
32983
+ const root = XmlNode2.findRoot(this.tree, "w:styles");
32984
+ if (!root)
32985
+ return [];
32986
+ const out = [];
32987
+ for (const style of root.findChildren("w:style")) {
32988
+ const ascii = style.findChild("w:rPr")?.findChild("w:rFonts")?.getAttribute("w:ascii");
32989
+ if (!ascii)
32990
+ continue;
32991
+ const id = style.getAttribute("w:styleId");
32992
+ if (id)
32993
+ out.push(id);
32994
+ }
32995
+ return out;
32996
+ }
32997
+ overrideStyleFonts(fontName) {
32998
+ const root = XmlNode2.findRoot(this.tree, "w:styles");
32999
+ if (!root)
33000
+ return 0;
33001
+ let count = 0;
33002
+ for (const style of root.findChildren("w:style")) {
33003
+ const rFonts = style.findChild("w:rPr")?.findChild("w:rFonts");
33004
+ if (!rFonts)
33005
+ continue;
33006
+ applyRunFont(rFonts, fontName);
33007
+ count++;
33008
+ }
33009
+ return count;
33010
+ }
33011
+ #ensureDocDefaultsRPr() {
33012
+ const root = this.ensureStylesRoot();
33013
+ let docDefaults = root.findChild("w:docDefaults");
33014
+ if (!docDefaults) {
33015
+ docDefaults = XmlNode2.element("w:docDefaults");
33016
+ root.children.unshift(docDefaults);
33017
+ }
33018
+ let rPrDefault = docDefaults.findChild("w:rPrDefault");
33019
+ if (!rPrDefault) {
33020
+ rPrDefault = XmlNode2.element("w:rPrDefault");
33021
+ docDefaults.children.unshift(rPrDefault);
33022
+ }
33023
+ let rPr = rPrDefault.findChild("w:rPr");
33024
+ if (!rPr) {
33025
+ rPr = XmlNode2.element("w:rPr");
33026
+ rPrDefault.children.push(rPr);
33027
+ }
33028
+ return rPr;
33029
+ }
32618
33030
  ensureStylesRoot() {
32619
33031
  const root = XmlNode2.findRoot(this.tree, "w:styles");
32620
33032
  if (!root)
@@ -32628,6 +33040,14 @@ class StylesView {
32628
33040
  stylesRoot.children.push(BASELINE[styleId]());
32629
33041
  }
32630
33042
  }
33043
+ function applyRunFont(rFonts, fontName) {
33044
+ rFonts.setAttribute("w:ascii", fontName);
33045
+ rFonts.setAttribute("w:hAnsi", fontName);
33046
+ rFonts.setAttribute("w:cs", fontName);
33047
+ delete rFonts.attributes["w:asciiTheme"];
33048
+ delete rFonts.attributes["w:hAnsiTheme"];
33049
+ delete rFonts.attributes["w:cstheme"];
33050
+ }
32631
33051
  function NormalStyle() {
32632
33052
  return /* @__PURE__ */ jsxDEV(w.style, {
32633
33053
  "w-type": "paragraph",
@@ -32641,6 +33061,80 @@ function NormalStyle() {
32641
33061
  ]
32642
33062
  }, undefined, true, undefined, this);
32643
33063
  }
33064
+ function TitleStyle() {
33065
+ return /* @__PURE__ */ jsxDEV(w.style, {
33066
+ "w-type": "paragraph",
33067
+ "w-styleId": "Title",
33068
+ children: [
33069
+ /* @__PURE__ */ jsxDEV(w.name, {
33070
+ "w-val": "Title"
33071
+ }, undefined, false, undefined, this),
33072
+ /* @__PURE__ */ jsxDEV(w.basedOn, {
33073
+ "w-val": "Normal"
33074
+ }, undefined, false, undefined, this),
33075
+ /* @__PURE__ */ jsxDEV(w.next, {
33076
+ "w-val": "Normal"
33077
+ }, undefined, false, undefined, this),
33078
+ /* @__PURE__ */ jsxDEV(w.qFormat, {}, undefined, false, undefined, this),
33079
+ /* @__PURE__ */ jsxDEV(w.pPr, {
33080
+ children: /* @__PURE__ */ jsxDEV(w.spacing, {
33081
+ "w-after": "60"
33082
+ }, undefined, false, undefined, this)
33083
+ }, undefined, false, undefined, this),
33084
+ /* @__PURE__ */ jsxDEV(w.rPr, {
33085
+ children: [
33086
+ /* @__PURE__ */ jsxDEV(w.rFonts, {
33087
+ "w-ascii": "Calibri Light",
33088
+ "w-hAnsi": "Calibri Light"
33089
+ }, undefined, false, undefined, this),
33090
+ /* @__PURE__ */ jsxDEV(w.color, {
33091
+ "w-val": "1F3864"
33092
+ }, undefined, false, undefined, this),
33093
+ /* @__PURE__ */ jsxDEV(w.sz, {
33094
+ "w-val": "56"
33095
+ }, undefined, false, undefined, this)
33096
+ ]
33097
+ }, undefined, true, undefined, this)
33098
+ ]
33099
+ }, undefined, true, undefined, this);
33100
+ }
33101
+ function SubtitleStyle() {
33102
+ return /* @__PURE__ */ jsxDEV(w.style, {
33103
+ "w-type": "paragraph",
33104
+ "w-styleId": "Subtitle",
33105
+ children: [
33106
+ /* @__PURE__ */ jsxDEV(w.name, {
33107
+ "w-val": "Subtitle"
33108
+ }, undefined, false, undefined, this),
33109
+ /* @__PURE__ */ jsxDEV(w.basedOn, {
33110
+ "w-val": "Normal"
33111
+ }, undefined, false, undefined, this),
33112
+ /* @__PURE__ */ jsxDEV(w.next, {
33113
+ "w-val": "Normal"
33114
+ }, undefined, false, undefined, this),
33115
+ /* @__PURE__ */ jsxDEV(w.qFormat, {}, undefined, false, undefined, this),
33116
+ /* @__PURE__ */ jsxDEV(w.pPr, {
33117
+ children: /* @__PURE__ */ jsxDEV(w.spacing, {
33118
+ "w-after": "160"
33119
+ }, undefined, false, undefined, this)
33120
+ }, undefined, false, undefined, this),
33121
+ /* @__PURE__ */ jsxDEV(w.rPr, {
33122
+ children: [
33123
+ /* @__PURE__ */ jsxDEV(w.rFonts, {
33124
+ "w-ascii": "Calibri Light",
33125
+ "w-hAnsi": "Calibri Light"
33126
+ }, undefined, false, undefined, this),
33127
+ /* @__PURE__ */ jsxDEV(w.color, {
33128
+ "w-val": "5A5A5A"
33129
+ }, undefined, false, undefined, this),
33130
+ /* @__PURE__ */ jsxDEV(w.sz, {
33131
+ "w-val": "28"
33132
+ }, undefined, false, undefined, this)
33133
+ ]
33134
+ }, undefined, true, undefined, this)
33135
+ ]
33136
+ }, undefined, true, undefined, this);
33137
+ }
32644
33138
  function HeadingStyle({
32645
33139
  styleId,
32646
33140
  displayName,
@@ -33009,11 +33503,14 @@ function EndnoteTextStyle() {
33009
33503
  var STYLES_PART_NAME = "word/styles.xml", STYLES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", STYLES_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", EMPTY_STYLES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
33010
33504
  <w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>`, BASELINE;
33011
33505
  var init_styles = __esm(() => {
33506
+ init_blocks();
33012
33507
  init_jsx();
33013
33508
  init_parser();
33014
33509
  init_jsx_dev_runtime();
33015
33510
  BASELINE = {
33016
33511
  Normal: () => /* @__PURE__ */ jsxDEV(NormalStyle, {}, undefined, false, undefined, this),
33512
+ Title: () => /* @__PURE__ */ jsxDEV(TitleStyle, {}, undefined, false, undefined, this),
33513
+ Subtitle: () => /* @__PURE__ */ jsxDEV(SubtitleStyle, {}, undefined, false, undefined, this),
33017
33514
  Heading1: () => /* @__PURE__ */ jsxDEV(HeadingStyle, {
33018
33515
  styleId: "Heading1",
33019
33516
  displayName: "heading 1",
@@ -33062,6 +33559,28 @@ var init_styles = __esm(() => {
33062
33559
  italic: true,
33063
33560
  color: "1F4D78"
33064
33561
  }, undefined, false, undefined, this),
33562
+ Heading7: () => /* @__PURE__ */ jsxDEV(HeadingStyle, {
33563
+ styleId: "Heading7",
33564
+ displayName: "heading 7",
33565
+ outlineLevel: 6,
33566
+ sizeHalfPoints: 22,
33567
+ color: "2E74B5"
33568
+ }, undefined, false, undefined, this),
33569
+ Heading8: () => /* @__PURE__ */ jsxDEV(HeadingStyle, {
33570
+ styleId: "Heading8",
33571
+ displayName: "heading 8",
33572
+ outlineLevel: 7,
33573
+ sizeHalfPoints: 22,
33574
+ italic: true,
33575
+ color: "272727"
33576
+ }, undefined, false, undefined, this),
33577
+ Heading9: () => /* @__PURE__ */ jsxDEV(HeadingStyle, {
33578
+ styleId: "Heading9",
33579
+ displayName: "heading 9",
33580
+ outlineLevel: 8,
33581
+ sizeHalfPoints: 22,
33582
+ color: "272727"
33583
+ }, undefined, false, undefined, this),
33065
33584
  Quote: () => /* @__PURE__ */ jsxDEV(QuoteStyle, {}, undefined, false, undefined, this),
33066
33585
  IntenseQuote: () => /* @__PURE__ */ jsxDEV(IntenseQuoteStyle, {}, undefined, false, undefined, this),
33067
33586
  Code: () => /* @__PURE__ */ jsxDEV(CodeStyle, {}, undefined, false, undefined, this),
@@ -33225,6 +33744,7 @@ var init_document = __esm(() => {
33225
33744
  var init_ast = __esm(() => {
33226
33745
  init_document();
33227
33746
  init_body();
33747
+ init_styles();
33228
33748
  init_text();
33229
33749
  });
33230
33750
 
@@ -34235,289 +34755,6 @@ var init_comments2 = __esm(() => {
34235
34755
  };
34236
34756
  });
34237
34757
 
34238
- // src/core/blocks.tsx
34239
- function Paragraph({
34240
- style,
34241
- alignment,
34242
- list,
34243
- taskState,
34244
- tabs,
34245
- text: text2,
34246
- runs,
34247
- ...formatting
34248
- }) {
34249
- const resolvedRuns = runs ?? textToRuns(text2 ?? "", formatting);
34250
- return /* @__PURE__ */ jsxDEV(w.p, {
34251
- children: [
34252
- /* @__PURE__ */ jsxDEV(ParagraphProperties, {
34253
- options: { style, alignment, list, tabs }
34254
- }, undefined, false, undefined, this),
34255
- taskState && /* @__PURE__ */ jsxDEV(TaskCheckbox, {
34256
- checked: taskState === "checked"
34257
- }, undefined, false, undefined, this),
34258
- taskState && /* @__PURE__ */ jsxDEV(w.r, {
34259
- children: /* @__PURE__ */ jsxDEV(w.t, {
34260
- "xml:space": "preserve",
34261
- children: " "
34262
- }, undefined, false, undefined, this)
34263
- }, undefined, false, undefined, this),
34264
- resolvedRuns.map((run) => /* @__PURE__ */ jsxDEV(RunElement, {
34265
- run
34266
- }, undefined, false, undefined, this))
34267
- ]
34268
- }, undefined, true, undefined, this);
34269
- }
34270
- function textToRuns(text2, formatting) {
34271
- if (!text2.includes(`
34272
- `) && !text2.includes("\t")) {
34273
- return [{ type: "text", text: text2, ...formatting }];
34274
- }
34275
- const runs = [];
34276
- for (const segment of text2.split(/(\n|\t)/)) {
34277
- if (segment === "")
34278
- continue;
34279
- if (segment === `
34280
- `)
34281
- runs.push({ type: "break", kind: "line" });
34282
- else if (segment === "\t")
34283
- runs.push({ type: "tab" });
34284
- else
34285
- runs.push({ type: "text", text: segment, ...formatting });
34286
- }
34287
- return runs;
34288
- }
34289
- function RunElement({ run }) {
34290
- if (run.type === "text")
34291
- return /* @__PURE__ */ jsxDEV(TextRunElement, {
34292
- run
34293
- }, undefined, false, undefined, this);
34294
- if (run.type === "break") {
34295
- return /* @__PURE__ */ jsxDEV(w.r, {
34296
- children: /* @__PURE__ */ jsxDEV(w.br, {
34297
- "w-type": run.kind === "line" ? undefined : run.kind
34298
- }, undefined, false, undefined, this)
34299
- }, undefined, false, undefined, this);
34300
- }
34301
- if (run.type === "tab") {
34302
- return /* @__PURE__ */ jsxDEV(w.r, {
34303
- children: /* @__PURE__ */ jsxDEV(w.tab, {}, undefined, false, undefined, this)
34304
- }, undefined, false, undefined, this);
34305
- }
34306
- return null;
34307
- }
34308
- function applyParagraphOptionsInPlace(rebuilt, options) {
34309
- if (!options.style && !options.alignment && !options.tabs)
34310
- return;
34311
- let pPr = rebuilt.find((child2) => child2.tag === "w:pPr");
34312
- if (!pPr) {
34313
- pPr = new XmlNode2("w:pPr");
34314
- rebuilt.unshift(pPr);
34315
- }
34316
- if (options.tabs) {
34317
- pPr.children = pPr.children.filter((child2) => child2.tag !== "w:tabs");
34318
- if (options.tabs.length > 0) {
34319
- const tabsNode = new XmlNode2("w:tabs");
34320
- for (const stop of options.tabs) {
34321
- tabsNode.children.push(new XmlNode2("w:tab", {
34322
- "w:val": stop.align,
34323
- "w:pos": String(Math.round(stop.pos))
34324
- }));
34325
- }
34326
- insertPprChildInOrder(pPr, tabsNode);
34327
- }
34328
- }
34329
- if (options.style) {
34330
- const existingStyle = pPr.findChild("w:pStyle");
34331
- if (existingStyle) {
34332
- existingStyle.setAttribute("w:val", options.style);
34333
- } else {
34334
- insertPprChildInOrder(pPr, new XmlNode2("w:pStyle", { "w:val": options.style }));
34335
- }
34336
- }
34337
- if (options.alignment) {
34338
- const existingJc = pPr.findChild("w:jc");
34339
- if (existingJc) {
34340
- existingJc.setAttribute("w:val", options.alignment);
34341
- } else {
34342
- insertPprChildInOrder(pPr, new XmlNode2("w:jc", { "w:val": options.alignment }));
34343
- }
34344
- }
34345
- }
34346
- function pprChildRank(tag) {
34347
- const index = PPR_CHILD_ORDER.indexOf(tag);
34348
- if (index >= 0)
34349
- return index;
34350
- return PPR_CHILD_ORDER.indexOf("w:rPr") - 0.5;
34351
- }
34352
- function insertPprChildInOrder(pPr, child2) {
34353
- const rank = pprChildRank(child2.tag);
34354
- const at = pPr.children.findIndex((existing) => pprChildRank(existing.tag) > rank);
34355
- if (at < 0)
34356
- pPr.children.push(child2);
34357
- else
34358
- pPr.children.splice(at, 0, child2);
34359
- }
34360
- function HorizontalRule() {
34361
- return /* @__PURE__ */ jsxDEV(w.p, {
34362
- children: /* @__PURE__ */ jsxDEV(w.pPr, {
34363
- children: /* @__PURE__ */ jsxDEV(w.pBdr, {
34364
- children: /* @__PURE__ */ jsxDEV(w.bottom, {
34365
- "w-val": "single",
34366
- "w-sz": "6",
34367
- "w-space": "1",
34368
- "w-color": "auto"
34369
- }, undefined, false, undefined, this)
34370
- }, undefined, false, undefined, this)
34371
- }, undefined, false, undefined, this)
34372
- }, undefined, false, undefined, this);
34373
- }
34374
- function TextRunElement({ run }) {
34375
- return /* @__PURE__ */ jsxDEV(w.r, {
34376
- children: [
34377
- /* @__PURE__ */ jsxDEV(RunProperties, {
34378
- run
34379
- }, undefined, false, undefined, this),
34380
- /* @__PURE__ */ jsxDEV(w.t, {
34381
- "xml:space": "preserve",
34382
- children: run.text
34383
- }, undefined, false, undefined, this)
34384
- ]
34385
- }, undefined, true, undefined, this);
34386
- }
34387
- function RunProperties({ run }) {
34388
- const isEmpty = FORMATTING_KEYS.every((key) => run[key] == null);
34389
- if (isEmpty)
34390
- return null;
34391
- return /* @__PURE__ */ jsxDEV(w.rPr, {
34392
- children: [
34393
- run.runStyle && /* @__PURE__ */ jsxDEV(w.rStyle, {
34394
- "w-val": run.runStyle
34395
- }, undefined, false, undefined, this),
34396
- run.font && /* @__PURE__ */ jsxDEV(w.rFonts, {
34397
- "w-ascii": run.font,
34398
- "w-hAnsi": run.font
34399
- }, undefined, false, undefined, this),
34400
- run.bold && /* @__PURE__ */ jsxDEV(w.b, {}, undefined, false, undefined, this),
34401
- run.italic && /* @__PURE__ */ jsxDEV(w.i, {}, undefined, false, undefined, this),
34402
- run.allCaps && /* @__PURE__ */ jsxDEV(w.caps, {}, undefined, false, undefined, this),
34403
- run.smallCaps && /* @__PURE__ */ jsxDEV(w.smallCaps, {}, undefined, false, undefined, this),
34404
- run.strike && /* @__PURE__ */ jsxDEV(w.strike, {}, undefined, false, undefined, this),
34405
- (run.color || run.colorTheme) && /* @__PURE__ */ jsxDEV(w.color, {
34406
- "w-val": run.color ?? "auto",
34407
- "w-themeColor": run.colorTheme,
34408
- "w-themeTint": run.colorThemeTint,
34409
- "w-themeShade": run.colorThemeShade
34410
- }, undefined, false, undefined, this),
34411
- run.sizeHalfPoints !== undefined && /* @__PURE__ */ jsxDEV(w.sz, {
34412
- "w-val": String(run.sizeHalfPoints)
34413
- }, undefined, false, undefined, this),
34414
- run.highlight && /* @__PURE__ */ jsxDEV(w.highlight, {
34415
- "w-val": run.highlight
34416
- }, undefined, false, undefined, this),
34417
- run.underline && /* @__PURE__ */ jsxDEV(w.u, {
34418
- "w-val": run.underline,
34419
- "w-color": run.underlineColor
34420
- }, undefined, false, undefined, this),
34421
- run.shade && /* @__PURE__ */ jsxDEV(w.shd, {
34422
- "w-val": "clear",
34423
- "w-color": "auto",
34424
- "w-fill": run.shade
34425
- }, undefined, false, undefined, this),
34426
- run.vertAlign && /* @__PURE__ */ jsxDEV(w.vertAlign, {
34427
- "w-val": run.vertAlign
34428
- }, undefined, false, undefined, this)
34429
- ]
34430
- }, undefined, true, undefined, this);
34431
- }
34432
- function ParagraphProperties({
34433
- options
34434
- }) {
34435
- const hasTabs = options.tabs !== undefined && options.tabs.length > 0;
34436
- if (!options.style && !options.alignment && !options.list && !hasTabs)
34437
- return null;
34438
- return /* @__PURE__ */ jsxDEV(w.pPr, {
34439
- children: [
34440
- options.style && /* @__PURE__ */ jsxDEV(w.pStyle, {
34441
- "w-val": options.style
34442
- }, undefined, false, undefined, this),
34443
- options.list && /* @__PURE__ */ jsxDEV(w.numPr, {
34444
- children: [
34445
- /* @__PURE__ */ jsxDEV(w.ilvl, {
34446
- "w-val": String(options.list.level)
34447
- }, undefined, false, undefined, this),
34448
- /* @__PURE__ */ jsxDEV(w.numId, {
34449
- "w-val": String(options.list.numId)
34450
- }, undefined, false, undefined, this)
34451
- ]
34452
- }, undefined, true, undefined, this),
34453
- hasTabs && /* @__PURE__ */ jsxDEV(w.tabs, {
34454
- children: options.tabs?.map((stop) => /* @__PURE__ */ jsxDEV(w.tab, {
34455
- "w-val": stop.align,
34456
- "w-pos": String(Math.round(stop.pos))
34457
- }, undefined, false, undefined, this))
34458
- }, undefined, false, undefined, this),
34459
- options.alignment && /* @__PURE__ */ jsxDEV(w.jc, {
34460
- "w-val": options.alignment
34461
- }, undefined, false, undefined, this)
34462
- ]
34463
- }, undefined, true, undefined, this);
34464
- }
34465
- var PPR_CHILD_ORDER, FORMATTING_KEYS;
34466
- var init_blocks = __esm(() => {
34467
- init_jsx();
34468
- init_parser();
34469
- init_task_list();
34470
- init_jsx_dev_runtime();
34471
- PPR_CHILD_ORDER = [
34472
- "w:pStyle",
34473
- "w:keepNext",
34474
- "w:keepLines",
34475
- "w:pageBreakBefore",
34476
- "w:framePr",
34477
- "w:widowControl",
34478
- "w:numPr",
34479
- "w:suppressLineNumbers",
34480
- "w:pBdr",
34481
- "w:shd",
34482
- "w:tabs",
34483
- "w:suppressAutoHyphens",
34484
- "w:bidi",
34485
- "w:adjustRightInd",
34486
- "w:snapToGrid",
34487
- "w:spacing",
34488
- "w:ind",
34489
- "w:contextualSpacing",
34490
- "w:mirrorIndents",
34491
- "w:suppressOverlap",
34492
- "w:jc",
34493
- "w:textDirection",
34494
- "w:textAlignment",
34495
- "w:textboxTightWrap",
34496
- "w:outlineLvl",
34497
- "w:divId",
34498
- "w:cnfStyle",
34499
- "w:rPr",
34500
- "w:sectPr",
34501
- "w:pPrChange"
34502
- ];
34503
- FORMATTING_KEYS = [
34504
- "runStyle",
34505
- "font",
34506
- "bold",
34507
- "italic",
34508
- "allCaps",
34509
- "smallCaps",
34510
- "strike",
34511
- "color",
34512
- "colorTheme",
34513
- "sizeHalfPoints",
34514
- "highlight",
34515
- "underline",
34516
- "shade",
34517
- "vertAlign"
34518
- ];
34519
- });
34520
-
34521
34758
  // src/core/code-block/style.tsx
34522
34759
  function ensureCodeBlockStyles(document2, language) {
34523
34760
  document2.ensureStyles().ensureStyle("Code");
@@ -50352,6 +50589,88 @@ var init_edit = __esm(() => {
50352
50589
  };
50353
50590
  });
50354
50591
 
50592
+ // src/core/fonts/index.ts
50593
+ class Fonts {
50594
+ document;
50595
+ constructor(document2) {
50596
+ this.document = document2;
50597
+ }
50598
+ async setDefault(fontName, opts = {}) {
50599
+ const styles = this.document.ensureStyles();
50600
+ styles.setDefaultFont(fontName);
50601
+ if (opts.sizeHalfPoints !== undefined) {
50602
+ styles.setDefaultSizeHalfPoints(opts.sizeHalfPoints);
50603
+ }
50604
+ const themeUpdated = await applyThemeLatinFonts(this.document.pkg, themePartName(this.document.relationships), fontName);
50605
+ const explicitStyles = styles.explicitFontStyleIds();
50606
+ let repointed = 0;
50607
+ if (opts.all) {
50608
+ repointed += styles.overrideStyleFonts(fontName);
50609
+ repointed += repointTreeFonts(this.document.documentTree, fontName);
50610
+ if (this.document.footnotes) {
50611
+ repointed += repointTreeFonts(this.document.footnotes.tree, fontName);
50612
+ }
50613
+ if (this.document.endnotes) {
50614
+ repointed += repointTreeFonts(this.document.endnotes.tree, fontName);
50615
+ }
50616
+ }
50617
+ return {
50618
+ font: fontName,
50619
+ sizeHalfPoints: opts.sizeHalfPoints,
50620
+ themeUpdated,
50621
+ explicitStyles,
50622
+ repointed,
50623
+ all: Boolean(opts.all)
50624
+ };
50625
+ }
50626
+ }
50627
+ function themePartName(relationships) {
50628
+ const rel2 = relationships.list().find((info) => info.type === THEME_RELATIONSHIP_TYPE);
50629
+ if (!rel2)
50630
+ return "word/theme/theme1.xml";
50631
+ return rel2.target.startsWith("/") ? rel2.target.slice(1) : `word/${rel2.target}`;
50632
+ }
50633
+ async function applyThemeLatinFonts(pkg, partName, fontName) {
50634
+ const tree = await pkg.readPart(partName);
50635
+ if (!tree)
50636
+ return false;
50637
+ const fontScheme = XmlNode2.findRoot(tree, "a:theme")?.findChild("a:themeElements")?.findChild("a:fontScheme");
50638
+ if (!fontScheme)
50639
+ return false;
50640
+ let changed = false;
50641
+ for (const slot of ["a:majorFont", "a:minorFont"]) {
50642
+ const latin = fontScheme.findChild(slot)?.findChild("a:latin");
50643
+ if (!latin)
50644
+ continue;
50645
+ latin.setAttribute("typeface", fontName);
50646
+ delete latin.attributes.panose;
50647
+ changed = true;
50648
+ }
50649
+ if (changed)
50650
+ pkg.writeText(partName, XmlNode2.serialize(tree));
50651
+ return changed;
50652
+ }
50653
+ function repointTreeFonts(tree, fontName) {
50654
+ let count = 0;
50655
+ const visit = (node) => {
50656
+ if (node.tag === "w:rFonts") {
50657
+ applyRunFont(node, fontName);
50658
+ count++;
50659
+ return;
50660
+ }
50661
+ for (const child2 of node.children)
50662
+ visit(child2);
50663
+ };
50664
+ for (const node of tree)
50665
+ visit(node);
50666
+ return count;
50667
+ }
50668
+ var THEME_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
50669
+ var init_fonts = __esm(() => {
50670
+ init_styles();
50671
+ init_parser();
50672
+ });
50673
+
50355
50674
  // src/core/image/drawing.tsx
50356
50675
  class Images {
50357
50676
  document;
@@ -57730,6 +58049,26 @@ var init_image = __esm(() => {
57730
58049
  init_source();
57731
58050
  });
57732
58051
 
58052
+ // src/core/literal-text.tsx
58053
+ function literalParagraphs(text2, options = {}) {
58054
+ return splitLiteralLines(text2).map((line) => /* @__PURE__ */ jsxDEV(Paragraph, {
58055
+ text: line,
58056
+ ...options
58057
+ }, undefined, false, undefined, this));
58058
+ }
58059
+ function splitLiteralLines(text2) {
58060
+ const normalized = text2.replace(/\r\n?/g, `
58061
+ `);
58062
+ const trimmed = normalized.endsWith(`
58063
+ `) ? normalized.slice(0, -1) : normalized;
58064
+ return trimmed.split(`
58065
+ `);
58066
+ }
58067
+ var init_literal_text = __esm(() => {
58068
+ init_blocks();
58069
+ init_jsx_dev_runtime();
58070
+ });
58071
+
57733
58072
  // src/core/markdown/errors.ts
57734
58073
  var MarkdownImportError;
57735
58074
  var init_errors = __esm(() => {
@@ -72247,7 +72586,7 @@ class Insert {
72247
72586
  ensureCodeBlockStyles(this.document, spec.language);
72248
72587
  }
72249
72588
  const blocks = Array.isArray(built) ? built : [built];
72250
- if (spec.kind === "text" || spec.kind === "runs" || spec.kind === "markdown") {
72589
+ if (spec.kind === "text" || spec.kind === "runs" || spec.kind === "markdown" || spec.kind === "literal") {
72251
72590
  inheritFormattingFromAnchor(blocks, blockRef.node);
72252
72591
  }
72253
72592
  if (opts.track ?? this.document.isTrackChangesEnabled()) {
@@ -72301,6 +72640,8 @@ async function buildInsertedParagraph(document4, spec, paragraphOptions) {
72301
72640
  return buildEquationParagraph(spec, paragraphOptions);
72302
72641
  case "markdown":
72303
72642
  return buildMarkdownBlocks(document4, spec);
72643
+ case "literal":
72644
+ return literalParagraphs(spec.text, paragraphOptions);
72304
72645
  }
72305
72646
  }
72306
72647
  async function buildMarkdownBlocks(document4, spec) {
@@ -72480,6 +72821,7 @@ var init_insert = __esm(() => {
72480
72821
  init_equation();
72481
72822
  init_image();
72482
72823
  init_jsx();
72824
+ init_literal_text();
72483
72825
  init_markdown2();
72484
72826
  init_sections();
72485
72827
  init_table();
@@ -80570,7 +80912,9 @@ var init_core2 = __esm(() => {
80570
80912
  init_package();
80571
80913
  init_comments2();
80572
80914
  init_edit();
80915
+ init_fonts();
80573
80916
  init_insert();
80917
+ init_literal_text();
80574
80918
  init_locators();
80575
80919
  init_markdown2();
80576
80920
  init_parser();
@@ -80650,6 +80994,8 @@ function ackTarget(ack) {
80650
80994
  return plural(applied, "change");
80651
80995
  if (str(ack.mode))
80652
80996
  return `tracking ${ack.mode}`;
80997
+ if (str(ack.font))
80998
+ return str(ack.font);
80653
80999
  if (Array.isArray(ack.batch))
80654
81000
  return plural(ack.batch.length, "change");
80655
81001
  if (str(ack.path))
@@ -82010,6 +82356,7 @@ async function run7(args) {
82010
82356
  title: { type: "string" },
82011
82357
  author: { type: "string" },
82012
82358
  text: { type: "string" },
82359
+ "text-file": { type: "string" },
82013
82360
  from: { type: "string" },
82014
82361
  force: { type: "boolean" },
82015
82362
  "dry-run": { type: "boolean" },
@@ -82029,8 +82376,10 @@ async function run7(args) {
82029
82376
  }
82030
82377
  const text6 = parsed.values.text;
82031
82378
  const fromPath = parsed.values.from;
82032
- if (text6 !== undefined && fromPath !== undefined) {
82033
- return fail("USAGE", "Pass either --text or --from, not both", "--text seeds a single paragraph; --from parses a markdown file into the body.");
82379
+ const textFilePath = parsed.values["text-file"];
82380
+ const contentSources = [text6, fromPath, textFilePath].filter((value) => value !== undefined);
82381
+ if (contentSources.length > 1) {
82382
+ return fail("USAGE", "Pass at most one of --text, --text-file, --from", "--text seeds one paragraph; --text-file seeds literal multi-paragraph text; --from parses a markdown file into the body.");
82034
82383
  }
82035
82384
  const dryRun = Boolean(parsed.values["dry-run"]);
82036
82385
  const destination = path2;
@@ -82043,6 +82392,7 @@ async function run7(args) {
82043
82392
  dryRun: true,
82044
82393
  path: destination,
82045
82394
  ...text6 !== undefined ? { text: text6 } : {},
82395
+ ...textFilePath !== undefined ? { textFile: textFilePath } : {},
82046
82396
  ...fromPath !== undefined ? { from: fromPath } : {}
82047
82397
  });
82048
82398
  return EXIT2.OK;
@@ -82057,6 +82407,11 @@ async function run7(args) {
82057
82407
  if (typeof applied === "number")
82058
82408
  return applied;
82059
82409
  blockCount = applied.blockCount;
82410
+ } else if (textFilePath !== undefined) {
82411
+ const applied = await applyLiteralToBody(destination, textFilePath);
82412
+ if (typeof applied === "number")
82413
+ return applied;
82414
+ blockCount = applied.blockCount;
82060
82415
  }
82061
82416
  await respondAck({
82062
82417
  ok: true,
@@ -82085,9 +82440,22 @@ async function applyMarkdownToBody(docxPath, markdownPath) {
82085
82440
  }
82086
82441
  throw error;
82087
82442
  }
82088
- if (blocks.length === 0) {
82089
- return { blockCount: 1 };
82443
+ return replacePlaceholderAndSave(document4, blocks);
82444
+ }
82445
+ async function applyLiteralToBody(docxPath, textFilePath) {
82446
+ let source2;
82447
+ try {
82448
+ source2 = textFilePath === "-" ? await new Response(Bun.stdin.stream()).text() : await Bun.file(textFilePath).text();
82449
+ } catch (error) {
82450
+ const message = error instanceof Error ? error.message : String(error);
82451
+ return fail("FILE_NOT_FOUND", `Failed to read --text-file ${textFilePath}: ${message}`);
82090
82452
  }
82453
+ const document4 = await Document.open(docxPath);
82454
+ return replacePlaceholderAndSave(document4, literalParagraphs(source2));
82455
+ }
82456
+ async function replacePlaceholderAndSave(document4, blocks) {
82457
+ if (blocks.length === 0)
82458
+ return { blockCount: 1 };
82091
82459
  const body = document4.body.body;
82092
82460
  const placeholderIndex = body.children.findIndex((child2) => child2.tag === "w:p");
82093
82461
  if (placeholderIndex === -1) {
@@ -82105,14 +82473,21 @@ Usage:
82105
82473
  Options:
82106
82474
  --title TEXT Document title
82107
82475
  --author TEXT Document author (default: $DOCX_AUTHOR)
82108
- --text TEXT Seed first paragraph with this text. Mutex with --from.
82476
+ --text TEXT Seed first paragraph with this text. One content source
82477
+ only (mutex with --text-file / --from).
82478
+ --text-file PATH Seed the body with LITERAL multi-paragraph text from PATH
82479
+ (use "-" for stdin), NOT parsed as markdown \u2014 every
82480
+ character lands verbatim, each newline starts a new
82481
+ paragraph. Use for prose GFM would corrupt ("3. note"
82482
+ stays "3.", *x* / [t](u) / bare URLs / {++x++} untouched).
82483
+ One content source only.
82109
82484
  --from PATH Seed the body with parsed markdown from PATH (use "-" for
82110
- stdin). Mutex with --text. Uses the same markdown dialect
82111
- as 'docx insert --markdown'. This is the canonical way to
82112
- build a whole .docx from a markdown file. Footnote/endnote
82113
- bodies keep bold/italic + hyperlinks; footnote labels
82114
- renumber to [^fnN] on import. (Under track-changes, note
82115
- bodies flatten to plain text.)
82485
+ stdin). One content source only. Uses the same markdown
82486
+ dialect as 'docx insert --markdown'. This is the canonical
82487
+ way to build a whole .docx from a markdown file.
82488
+ Footnote/endnote bodies keep bold/italic + hyperlinks;
82489
+ footnote labels renumber to [^fnN] on import. (Under
82490
+ track-changes, note bodies flatten to plain text.)
82116
82491
  --force Overwrite if FILE already exists
82117
82492
  --dry-run Print what would be created; do not write the file
82118
82493
  -v, --verbose Print the success ack JSON (default: a one-line confirmation)
@@ -82128,6 +82503,8 @@ Examples:
82128
82503
  docx create out.docx --title "Spec" --author "Claude" --text "First paragraph."
82129
82504
  docx create out.docx --from draft.md
82130
82505
  cat draft.md | docx create out.docx --from -
82506
+ docx create out.docx --text-file reviewer-notes.txt
82507
+ cat notes.txt | docx create out.docx --text-file -
82131
82508
 
82132
82509
  For a doc that opens with a code block, chain create with insert:
82133
82510
  docx create out.docx
@@ -83095,7 +83472,7 @@ async function commitRangeProps(document4, opts, options) {
83095
83472
  throw error;
83096
83473
  }
83097
83474
  if (applied === 0) {
83098
- return fail("BLOCK_NOT_FOUND", options.tabs !== undefined ? `No paragraphs with tab stops in ${opts.locator} \u2014 --tabs only adjusts tab-using lines (the ones \`read\` flags with docx:layout).` : `No paragraphs in ${opts.locator} to restyle.`);
83475
+ return fail("BLOCK_NOT_FOUND", options.tabs !== undefined ? `No non-list paragraphs with tab stops in ${opts.locator} \u2014 --tabs only adjusts tab-using lines (the ones \`read\` flags with docx:layout), and skips bullets.` : `No paragraphs in ${opts.locator} to restyle.`);
83099
83476
  }
83100
83477
  await document4.save(opts.outputPath);
83101
83478
  return emitEditAck(opts);
@@ -83106,7 +83483,7 @@ function scopeRangeProps(node2, options) {
83106
83483
  out.style = options.style;
83107
83484
  if (options.alignment !== undefined)
83108
83485
  out.alignment = options.alignment;
83109
- if (options.tabs !== undefined && paragraphHasTabStops(node2)) {
83486
+ if (options.tabs !== undefined && paragraphHasTabStops(node2) && !isListParagraph(node2)) {
83110
83487
  out.tabs = options.tabs;
83111
83488
  }
83112
83489
  if (out.style === undefined && out.alignment === undefined && out.tabs === undefined)
@@ -83116,6 +83493,9 @@ function scopeRangeProps(node2, options) {
83116
83493
  function paragraphHasTabStops(node2) {
83117
83494
  return node2.findChild("w:pPr")?.findChild("w:tabs") !== undefined;
83118
83495
  }
83496
+ function isListParagraph(node2) {
83497
+ return node2.findChild("w:pPr")?.findChild("w:numPr") !== undefined;
83498
+ }
83119
83499
  async function commitEquationEdit(document4, spec, opts) {
83120
83500
  if (spec.latex === undefined && spec.display === undefined) {
83121
83501
  return fail("USAGE", "--equation requires --equation NEW_LATEX, --display, or --inline");
@@ -85426,6 +85806,9 @@ async function runInsertBatch(filePath, batchSource, values2) {
85426
85806
  const placement = await parseTargetPlacement(entryValues);
85427
85807
  if (typeof placement === "number")
85428
85808
  return placement;
85809
+ if ("boundary" in placement) {
85810
+ return fail("USAGE", `entry ${index2}: --at-start/--at-end aren't supported in --batch (use --after/--before with a locator)`);
85811
+ }
85429
85812
  const spec = await chooseContentSpec(entryValues);
85430
85813
  if (typeof spec === "number")
85431
85814
  return spec;
@@ -85546,7 +85929,10 @@ var init_batch3 = __esm(() => {
85546
85929
  SINGLE_SHOT_FLAGS2 = [
85547
85930
  "after",
85548
85931
  "before",
85932
+ "at-start",
85933
+ "at-end",
85549
85934
  "text",
85935
+ "text-file",
85550
85936
  "runs",
85551
85937
  "page-break",
85552
85938
  "column-break",
@@ -85615,13 +86001,14 @@ async function run22(args) {
85615
86001
  const document4 = await openOrFail(opts.filePath);
85616
86002
  if (typeof document4 === "number")
85617
86003
  return document4;
85618
- const blockRef = await resolveBlockOrFail(document4, opts.placement.locator);
85619
- if (typeof blockRef === "number")
85620
- return blockRef;
86004
+ const resolved = await resolvePlacement(document4, opts.placement);
86005
+ if (typeof resolved === "number")
86006
+ return resolved;
86007
+ const { blockRef, mode, locator } = resolved;
85621
86008
  let blocks;
85622
86009
  try {
85623
86010
  blocks = await new Insert(document4).paragraph(blockRef, opts.spec, opts.paragraphOptions, {
85624
- placement: opts.placement.mode,
86011
+ placement: mode,
85625
86012
  authorFlag: opts.authorFlag,
85626
86013
  track: resolveTracked(document4, opts.trackFlag)
85627
86014
  });
@@ -85631,16 +86018,16 @@ async function run22(args) {
85631
86018
  }
85632
86019
  throw error;
85633
86020
  }
85634
- return commitInsert(document4, blockRef, blocks, opts);
86021
+ return commitInsert(document4, blockRef, blocks, opts, mode, locator);
85635
86022
  }
85636
- async function commitInsert(document4, blockRef, blocks, opts) {
86023
+ async function commitInsert(document4, blockRef, blocks, opts, mode, anchorLocator) {
85637
86024
  if (opts.dryRun) {
85638
86025
  await respond({
85639
86026
  operation: "insert",
85640
86027
  dryRun: true,
85641
86028
  path: opts.filePath,
85642
- anchor: opts.placement.locator,
85643
- placement: opts.placement.mode,
86029
+ anchor: anchorLocator,
86030
+ placement: mode,
85644
86031
  ...opts.outputPath ? { output: opts.outputPath } : {}
85645
86032
  });
85646
86033
  return EXIT2.OK;
@@ -85649,7 +86036,7 @@ async function commitInsert(document4, blockRef, blocks, opts) {
85649
86036
  if (targetIndex === -1) {
85650
86037
  return fail("BLOCK_NOT_FOUND", "Block reference is stale (parent does not contain it)");
85651
86038
  }
85652
- const insertIndex = opts.placement.mode === "after" ? targetIndex + 1 : targetIndex;
86039
+ const insertIndex = mode === "after" ? targetIndex + 1 : targetIndex;
85653
86040
  blockRef.parent.splice(insertIndex, 0, ...blocks);
85654
86041
  await document4.save(opts.outputPath);
85655
86042
  document4.reread();
@@ -85665,8 +86052,8 @@ async function commitInsert(document4, blockRef, blocks, opts) {
85665
86052
  operation: "insert",
85666
86053
  path: destination,
85667
86054
  locators,
85668
- anchor: opts.placement.locator,
85669
- placement: opts.placement.mode
86055
+ anchor: anchorLocator,
86056
+ placement: mode
85670
86057
  }, isLayoutAffecting(opts.spec) ? renderVerifyHint(destination) : undefined);
85671
86058
  return EXIT2.OK;
85672
86059
  }
@@ -85711,16 +86098,61 @@ async function buildSingleShotOptions(filePath, values2) {
85711
86098
  async function parseTargetPlacement(values2) {
85712
86099
  const after = values2.after;
85713
86100
  const before = values2.before;
85714
- if (!after && !before) {
85715
- return fail("USAGE", "Missing locator: pass --after or --before", HELP18);
85716
- }
85717
- if (after && before) {
85718
- return fail("USAGE", "Pass either --after or --before, not both", HELP18);
85719
- }
86101
+ const atStart = Boolean(values2["at-start"]);
86102
+ const atEnd = Boolean(values2["at-end"]);
86103
+ const chosen = [
86104
+ after !== undefined ? "--after" : null,
86105
+ before !== undefined ? "--before" : null,
86106
+ atStart ? "--at-start" : null,
86107
+ atEnd ? "--at-end" : null
86108
+ ].filter((flag) => flag !== null);
86109
+ if (chosen.length === 0) {
86110
+ return fail("USAGE", "Missing placement: pass --after, --before, --at-start, or --at-end", HELP18);
86111
+ }
86112
+ if (chosen.length > 1) {
86113
+ return fail("USAGE", `Pass exactly one placement, got ${chosen.join(" + ")}`, HELP18);
86114
+ }
86115
+ if (atStart)
86116
+ return { boundary: "start" };
86117
+ if (atEnd)
86118
+ return { boundary: "end" };
85720
86119
  if (after !== undefined)
85721
86120
  return { mode: "after", locator: after };
85722
86121
  return { mode: "before", locator: before };
85723
86122
  }
86123
+ async function resolvePlacement(document4, placement) {
86124
+ if ("boundary" in placement) {
86125
+ return resolveBoundaryAnchor(document4, placement.boundary);
86126
+ }
86127
+ const blockRef = await resolveBlockOrFail(document4, placement.locator);
86128
+ if (typeof blockRef === "number")
86129
+ return blockRef;
86130
+ return { blockRef, mode: placement.mode, locator: placement.locator };
86131
+ }
86132
+ async function resolveBoundaryAnchor(document4, boundary) {
86133
+ const bodyChildren = document4.body.body.children;
86134
+ const refs = [...document4.body.blockReferences.entries()].filter(([, ref]) => ref.parent === bodyChildren && (ref.node.tag === "w:p" || ref.node.tag === "w:tbl"));
86135
+ if (refs.length > 0) {
86136
+ const entry = boundary === "start" ? refs[0] : refs[refs.length - 1];
86137
+ if (entry) {
86138
+ const [locator, blockRef] = entry;
86139
+ return {
86140
+ blockRef,
86141
+ mode: boundary === "start" ? "before" : "after",
86142
+ locator
86143
+ };
86144
+ }
86145
+ }
86146
+ const sectPr = bodyChildren.find((child2) => child2.tag === "w:sectPr");
86147
+ if (!sectPr) {
86148
+ return fail("BLOCK_NOT_FOUND", "Document body has no blocks to anchor against");
86149
+ }
86150
+ return {
86151
+ blockRef: { node: sectPr, parent: bodyChildren },
86152
+ mode: "before",
86153
+ locator: "start"
86154
+ };
86155
+ }
85724
86156
  async function chooseContentSpec(values2) {
85725
86157
  if (values2.section !== undefined || values2.columns !== undefined || values2.type !== undefined) {
85726
86158
  return fail("USAGE", "insert no longer creates section/column layout \u2014 use `docx sections`", "To put paragraphs pN\u2026pM in N columns: `docx sections --at pN-pM --columns N`. To recount an existing section: `docx sections --at sN --columns N`.");
@@ -85745,6 +86177,8 @@ async function chooseContentSpec(values2) {
85745
86177
  switch (chosen.flag) {
85746
86178
  case "text":
85747
86179
  return buildTextSpec(values2);
86180
+ case "text-file":
86181
+ return resolveLiteralSpec(values2);
85748
86182
  case "runs": {
85749
86183
  const runs = await parseRunsArg(values2.runs);
85750
86184
  return typeof runs === "number" ? runs : { kind: "runs", runs };
@@ -85789,6 +86223,16 @@ async function resolveMarkdownSpec(values2, flag) {
85789
86223
  return fail("FILE_NOT_FOUND", `Failed to read --markdown-file ${path2}: ${message}`);
85790
86224
  }
85791
86225
  }
86226
+ async function resolveLiteralSpec(values2) {
86227
+ const path2 = values2["text-file"];
86228
+ try {
86229
+ const text6 = path2 === "-" ? await new Response(Bun.stdin.stream()).text() : await Bun.file(path2).text();
86230
+ return { kind: "literal", text: text6 };
86231
+ } catch (error) {
86232
+ const message = error instanceof Error ? error.message : String(error);
86233
+ return fail("FILE_NOT_FOUND", `Failed to read --text-file ${path2}: ${message}`);
86234
+ }
86235
+ }
85792
86236
  async function resolveCodeSpec(values2, flag) {
85793
86237
  const language = values2.language;
85794
86238
  if (flag === "code") {
@@ -85965,18 +86409,31 @@ var init_insert2 = __esm(() => {
85965
86409
 
85966
86410
  Usage:
85967
86411
  docx insert FILE (--after | --before) LOCATOR <content> [options]
86412
+ docx insert FILE (--at-start | --at-end) <content> [options]
85968
86413
  docx insert FILE --batch FILE.jsonl [options] # many inserts, one read
85969
86414
  docx insert FILE --batch - [options] # read JSONL from stdin
85970
86415
 
85971
- Locator (one required) \u2014 where to place the new block, relative to:
86416
+ Placement (exactly one required) \u2014 where to put the new block:
85972
86417
  --after LOCATOR Insert after the block at LOCATOR
85973
86418
  --before LOCATOR Insert before the block at LOCATOR
85974
86419
  LOCATOR is one of:
85975
86420
  ${ANCHOR_FORMS2}
85976
86421
  See \`docx info locators\`.
86422
+ --at-start Insert at the very top of the document (before the first
86423
+ paragraph/table) \u2014 no locator needed, works on a fresh doc.
86424
+ --at-end Insert at the very end (after the last paragraph/table, but
86425
+ before the trailing section properties). No locator needed.
86426
+ (--at-start/--at-end are single-shot only, not --batch.)
85977
86427
 
85978
86428
  Content (one required):
85979
86429
  --text TEXT Insert a paragraph with this text
86430
+ --text-file PATH Insert literal multi-paragraph text from PATH (use "-" for
86431
+ stdin), NOT parsed as markdown \u2014 every character lands
86432
+ verbatim. Each newline starts a new paragraph (blank lines
86433
+ become empty paragraphs). Use this for prose that must stay
86434
+ untouched: "3. note" stays "3." (no list renumber), *x* /
86435
+ [t](u) / bare URLs / {++x++} are NOT interpreted. (--text /
86436
+ --markdown go through GFM and would corrupt such content.)
85980
86437
  --runs JSON Insert a paragraph with custom runs (Run[] JSON)
85981
86438
  --page-break Insert an empty paragraph containing a page break
85982
86439
  --column-break Insert an empty paragraph containing a column break
@@ -86097,18 +86554,27 @@ Examples:
86097
86554
  docx insert doc.docx --after p3 --markdown $'# Heading\\n\\n- a\\n- b'
86098
86555
  docx insert doc.docx --after p3 --markdown-file README.md
86099
86556
  cat draft.md | docx insert doc.docx --after p3 --markdown-file -
86557
+ docx insert doc.docx --at-start --text "Title" --style Title
86558
+ docx insert doc.docx --after p3 --text-file reviewer-notes.txt
86559
+ cat notes.txt | docx insert doc.docx --at-end --text-file -
86100
86560
  docx insert doc.docx --batch additions.jsonl
86101
86561
 
86102
86562
  Batch JSONL example (keys mirror the flags; one insert per line):
86103
86563
  {"after": "p3", "text": "New clause.", "style": "Heading2"}
86104
86564
  {"before": "p0", "text": "ALERT", "color": "CC0000", "bold": true}
86105
86565
  {"after": "p5", "markdown": "## Summary\\n\\n- point a\\n- point b"}
86566
+ Ordering guarantee: entries apply in file order, and several entries anchored
86567
+ after the SAME block stack in that order \u2014 so three lines all "after": "p0"
86568
+ land as p1, p2, p3 in the order written (not reversed).
86106
86569
  `;
86107
86570
  OPTION_SPEC3 = {
86108
86571
  after: { type: "string" },
86109
86572
  before: { type: "string" },
86573
+ "at-start": { type: "boolean" },
86574
+ "at-end": { type: "boolean" },
86110
86575
  batch: { type: "string" },
86111
86576
  text: { type: "string" },
86577
+ "text-file": { type: "string" },
86112
86578
  runs: { type: "string" },
86113
86579
  "page-break": { type: "boolean" },
86114
86580
  "column-break": { type: "boolean" },
@@ -86156,6 +86622,7 @@ Batch JSONL example (keys mirror the flags; one insert per line):
86156
86622
  ];
86157
86623
  CONTENT_KINDS = [
86158
86624
  { flag: "text", subFlags: ["color", "bold", "italic", "url"] },
86625
+ { flag: "text-file", subFlags: [] },
86159
86626
  { flag: "runs", subFlags: [] },
86160
86627
  { flag: "page-break", subFlags: [] },
86161
86628
  { flag: "column-break", subFlags: [] },
@@ -88028,6 +88495,8 @@ function layoutHazardNote(paragraph2, ctx) {
88028
88495
  ]
88029
88496
  ], [paragraph2.id])}`;
88030
88497
  }
88498
+ if (paragraph2.list)
88499
+ return "";
88031
88500
  const tabs = paragraph2.tabStops ?? [];
88032
88501
  if (tabs.some((tab) => tab.align === "right"))
88033
88502
  return "";
@@ -89723,9 +90192,13 @@ __export(exports_styles, {
89723
90192
  run: () => run37
89724
90193
  });
89725
90194
  async function run37(args) {
90195
+ if (args[0] === "set-default-font") {
90196
+ return runSetDefaultFont(args.slice(1));
90197
+ }
89726
90198
  const parsed = await tryParseArgs(args, {
89727
90199
  at: { type: "string" },
89728
90200
  used: { type: "boolean" },
90201
+ catalog: { type: "boolean" },
89729
90202
  json: { type: "boolean" },
89730
90203
  help: { type: "boolean", short: "h" }
89731
90204
  }, HELP33);
@@ -89735,6 +90208,15 @@ async function run37(args) {
89735
90208
  await writeStdout(HELP33);
89736
90209
  return EXIT2.OK;
89737
90210
  }
90211
+ if (parsed.values.catalog) {
90212
+ const metas2 = baselineCatalog().map(styleMeta);
90213
+ if (parsed.values.json) {
90214
+ await respond(metas2);
90215
+ return EXIT2.OK;
90216
+ }
90217
+ await writeStdout(formatList(metas2));
90218
+ return EXIT2.OK;
90219
+ }
89738
90220
  const path2 = parsed.positionals[0];
89739
90221
  if (!path2)
89740
90222
  return fail("USAGE", "Missing FILE argument", HELP33);
@@ -89770,6 +90252,73 @@ async function run37(args) {
89770
90252
  await writeStdout(formatList(metas));
89771
90253
  return EXIT2.OK;
89772
90254
  }
90255
+ async function runSetDefaultFont(args) {
90256
+ const parsed = await tryParseArgs(args, { size: { type: "string" }, all: { type: "boolean" }, ...SAVE_FLAGS }, FONT_HELP);
90257
+ if (typeof parsed === "number")
90258
+ return parsed;
90259
+ if (parsed.values.help) {
90260
+ await writeStdout(FONT_HELP);
90261
+ return EXIT2.OK;
90262
+ }
90263
+ setVerboseAck(Boolean(parsed.values.verbose));
90264
+ const filePath = parsed.positionals[0];
90265
+ if (!filePath)
90266
+ return fail("USAGE", "Missing FILE argument", FONT_HELP);
90267
+ const fontName = parsed.positionals[1];
90268
+ if (!fontName) {
90269
+ return fail("USAGE", 'Missing FONT name (e.g. "Times New Roman")', FONT_HELP);
90270
+ }
90271
+ let sizeHalfPoints;
90272
+ const sizeRaw = parsed.values.size;
90273
+ if (sizeRaw !== undefined) {
90274
+ if (!/^\s*\d+(\.\d+)?\s*$/.test(sizeRaw) || Number.parseFloat(sizeRaw) <= 0) {
90275
+ return fail("USAGE", `--size must be a positive number of points, got "${sizeRaw}"`);
90276
+ }
90277
+ sizeHalfPoints = Math.round(Number.parseFloat(sizeRaw) * 2);
90278
+ }
90279
+ const all2 = Boolean(parsed.values.all);
90280
+ const outputPath = parsed.values.output;
90281
+ const dryRun = Boolean(parsed.values["dry-run"]);
90282
+ const document4 = await openOrFail(filePath);
90283
+ if (typeof document4 === "number")
90284
+ return document4;
90285
+ const result = await new Fonts(document4).setDefault(fontName, {
90286
+ sizeHalfPoints,
90287
+ all: all2
90288
+ });
90289
+ if (dryRun) {
90290
+ await respond({
90291
+ operation: "styles.set-default-font",
90292
+ dryRun: true,
90293
+ path: filePath,
90294
+ font: fontName,
90295
+ ...sizeHalfPoints !== undefined ? { sizePt: sizeHalfPoints / 2 } : {},
90296
+ all: all2,
90297
+ themeUpdated: result.themeUpdated,
90298
+ ...all2 ? { repointed: result.repointed } : { explicitStyles: result.explicitStyles },
90299
+ ...outputPath ? { output: outputPath } : {}
90300
+ });
90301
+ return EXIT2.OK;
90302
+ }
90303
+ await document4.save(outputPath);
90304
+ const count = result.explicitStyles.length;
90305
+ const leftover = !all2 && count > 0 ? `${count === 1 ? "1 style keeps" : `${count} styles keep`} their own font (${formatStyleList(result.explicitStyles)}); pass --all to override them too.` : undefined;
90306
+ await respondAck({
90307
+ ok: true,
90308
+ operation: "styles.set-default-font",
90309
+ path: outputPath ?? filePath,
90310
+ font: fontName,
90311
+ ...sizeHalfPoints !== undefined ? { sizePt: sizeHalfPoints / 2 } : {},
90312
+ themeUpdated: result.themeUpdated,
90313
+ all: all2,
90314
+ ...all2 ? { repointed: result.repointed } : { explicitStyles: result.explicitStyles }
90315
+ }, leftover);
90316
+ return EXIT2.OK;
90317
+ }
90318
+ function formatStyleList(ids) {
90319
+ const shown = ids.slice(0, 5).join(", ");
90320
+ return ids.length > 5 ? `${shown}, \u2026` : shown;
90321
+ }
89773
90322
  function styleMeta(node2) {
89774
90323
  const meta = {
89775
90324
  id: node2.getAttribute("w:styleId") ?? "",
@@ -89869,10 +90418,12 @@ function formatDetail(detail) {
89869
90418
  `)}
89870
90419
  `;
89871
90420
  }
89872
- var HELP33 = `docx styles \u2014 list the styles available to apply, or describe one
90421
+ var HELP33 = `docx styles \u2014 list the styles available to apply, describe one, or set the document font
89873
90422
 
89874
90423
  Usage:
89875
90424
  docx styles FILE [--used] [--at STYLEID] [--json]
90425
+ docx styles --catalog [--json]
90426
+ docx styles set-default-font FILE "Font Name" [--size N] [--all] # set the document-wide font
89876
90427
 
89877
90428
  The style catalog lives in word/styles.xml, not in the document body \u2014 so
89878
90429
  unlike everything else, you can't see it by reading the doc. Use this to learn
@@ -89883,6 +90434,10 @@ Options:
89883
90434
  --at STYLEID Describe one style (id, type, name, basedOn, key formatting)
89884
90435
  --used List only the styles actually applied somewhere in the body
89885
90436
  (paragraph styles + character/run styles)
90437
+ --catalog List the built-in styles docx-cli can apply on demand \u2014 every
90438
+ \`--style NAME\` value that \`insert\`/\`edit\` will auto-provision
90439
+ (Title, Subtitle, Heading1\u20139, Quote, IntenseQuote, Code, \u2026)
90440
+ even when the doc doesn't contain them yet. No FILE needed.
89886
90441
  --json Structured output (a JSON array for the list; an object for --at)
89887
90442
  -h, --help Show this help
89888
90443
 
@@ -89892,10 +90447,41 @@ Output:
89892
90447
  {code, error, hint?} with a nonzero exit.
89893
90448
 
89894
90449
  Examples:
89895
- docx styles report.docx # full catalog
90450
+ docx styles report.docx # styles defined in this doc
89896
90451
  docx styles report.docx --used # only styles the doc uses
90452
+ docx styles --catalog # built-ins you can apply via --style
89897
90453
  docx styles report.docx --at Caption # what does Caption look like?
89898
90454
  docx styles report.docx --json | jq '.[].id'
90455
+ docx styles set-default-font report.docx "Times New Roman" # whole-doc font
90456
+ docx styles set-default-font report.docx "Georgia" --all # incl. explicit fonts
90457
+
90458
+ See \`docx styles set-default-font --help\` for the font-setting details.
90459
+ `, FONT_HELP = `docx styles set-default-font \u2014 set the document-wide default font
90460
+
90461
+ Usage:
90462
+ docx styles set-default-font FILE "Font Name" [--size N] [--all] [options]
90463
+
90464
+ A document font lives in TWO places at once \u2014 word/styles.xml (<w:docDefaults>)
90465
+ and the theme font scheme (word/theme/theme1.xml, major + minor) \u2014 and setting
90466
+ only one silently loses to the other. This sets both, so body text AND
90467
+ theme-following headings adopt the font. Styles/runs that pin their OWN font
90468
+ (e.g. a code block's monospace, a deliberately-Arial run) are preserved; pass
90469
+ --all to repoint those too.
90470
+
90471
+ Options:
90472
+ --size N Also set the default font size, in points (e.g. 12).
90473
+ --all Repoint EVERY explicit font \u2014 styles, body runs, and notes \u2014
90474
+ onto FONT too, for a guaranteed-uniform document (overrides
90475
+ even code monospace and per-run font choices).
90476
+ -o, --output PATH Write to PATH instead of overwriting FILE
90477
+ --dry-run Print what would change; do not write the file
90478
+ -v, --verbose Print the full success ack JSON
90479
+ -h, --help Show this help
90480
+
90481
+ Examples:
90482
+ docx styles set-default-font report.docx "Times New Roman"
90483
+ docx styles set-default-font report.docx "Calibri" --size 11
90484
+ docx styles set-default-font report.docx "Georgia" --all
89899
90485
  `;
89900
90486
  var init_styles2 = __esm(() => {
89901
90487
  init_core2();
@@ -92252,7 +92838,7 @@ Examples:
92252
92838
  // package.json
92253
92839
  var package_default = {
92254
92840
  name: "bun-docx",
92255
- version: "0.14.1",
92841
+ version: "0.15.0",
92256
92842
  description: "CLI for AI agents (Claude, Codex) to read, edit, and comment on .docx files with full format fidelity.",
92257
92843
  keywords: [
92258
92844
  "docx",