@beyondwork/docx-react-component 1.0.128 → 1.0.130

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 (108) hide show
  1. package/dist/api/public-types.cjs +809 -78
  2. package/dist/api/public-types.d.cts +2 -2
  3. package/dist/api/public-types.d.ts +2 -2
  4. package/dist/api/public-types.js +4 -4
  5. package/dist/api/v3.cjs +2059 -402
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +13 -13
  9. package/dist/{canonical-document-CXCFCbAz.d.cts → canonical-document-BMtONpgf.d.cts} +6 -0
  10. package/dist/{canonical-document-CXCFCbAz.d.ts → canonical-document-BMtONpgf.d.ts} +6 -0
  11. package/dist/{chunk-MWSBGJQO.js → chunk-35RHOE6I.js} +105 -4
  12. package/dist/{chunk-2QL5DAKF.js → chunk-3YCQM2RV.js} +6 -6
  13. package/dist/{chunk-ESJ2MES5.js → chunk-4YCWECLZ.js} +1 -1
  14. package/dist/{chunk-4EENH4FG.js → chunk-6TBLDBCL.js} +1 -1
  15. package/dist/{chunk-XRACP43Q.js → chunk-7G5GR3VV.js} +469 -32
  16. package/dist/{chunk-CXSYRB37.js → chunk-A3GSNB4G.js} +183 -55
  17. package/dist/{chunk-5DGKFNQT.js → chunk-A66ZVUAT.js} +150 -1
  18. package/dist/{chunk-YIYM4ZAP.js → chunk-CI2TD3T4.js} +1 -1
  19. package/dist/{chunk-TQDQU2E3.js → chunk-DGA7M77X.js} +2 -2
  20. package/dist/{chunk-EB6M3GE6.js → chunk-FM4K4XFJ.js} +100 -97
  21. package/dist/{chunk-D5HYZQTG.js → chunk-HYHCRMR7.js} +1 -1
  22. package/dist/{chunk-6F5QW44A.js → chunk-KNHMXKC6.js} +2 -2
  23. package/dist/{chunk-4YJVRIUB.js → chunk-M7YRJX6V.js} +61 -29
  24. package/dist/{chunk-KFCQYZXR.js → chunk-OVLZQ6FZ.js} +61 -0
  25. package/dist/{chunk-BYSRJ4FE.js → chunk-PHMWH23E.js} +1 -1
  26. package/dist/{chunk-ZDOAUP3V.js → chunk-Q7Y57KOK.js} +2 -2
  27. package/dist/{chunk-LZVBNDGU.js → chunk-QXKQPUOM.js} +3 -3
  28. package/dist/{chunk-CX42VC67.js → chunk-SYQWQ6FE.js} +1 -1
  29. package/dist/{chunk-KV435YXO.js → chunk-T5YYFDZB.js} +1 -1
  30. package/dist/{chunk-YHZHPXDB.js → chunk-THVM6EP5.js} +419 -24
  31. package/dist/{chunk-V6XVZFFH.js → chunk-VRKK2CSZ.js} +111 -90
  32. package/dist/{chunk-OL2UEHRP.js → chunk-WUDSNHWF.js} +1 -1
  33. package/dist/{chunk-LCYYR57Q.js → chunk-WZDKNF37.js} +666 -107
  34. package/dist/{chunk-6EROGFUF.js → chunk-YLL7MF5C.js} +444 -131
  35. package/dist/{chunk-YD2JE54B.js → chunk-ZVC23LKV.js} +1 -1
  36. package/dist/compare.cjs +100 -97
  37. package/dist/compare.d.cts +1 -1
  38. package/dist/compare.d.ts +1 -1
  39. package/dist/compare.js +3 -3
  40. package/dist/core/commands/formatting-commands.d.cts +2 -2
  41. package/dist/core/commands/formatting-commands.d.ts +2 -2
  42. package/dist/core/commands/image-commands.cjs +182 -54
  43. package/dist/core/commands/image-commands.d.cts +2 -2
  44. package/dist/core/commands/image-commands.d.ts +2 -2
  45. package/dist/core/commands/image-commands.js +5 -5
  46. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  47. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  48. package/dist/core/commands/style-commands.d.cts +2 -2
  49. package/dist/core/commands/style-commands.d.ts +2 -2
  50. package/dist/core/commands/table-structure-commands.cjs +182 -54
  51. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  52. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  53. package/dist/core/commands/table-structure-commands.js +4 -4
  54. package/dist/core/commands/text-commands.cjs +182 -54
  55. package/dist/core/commands/text-commands.d.cts +2 -2
  56. package/dist/core/commands/text-commands.d.ts +2 -2
  57. package/dist/core/commands/text-commands.js +5 -5
  58. package/dist/core/selection/mapping.d.cts +2 -2
  59. package/dist/core/selection/mapping.d.ts +2 -2
  60. package/dist/core/state/editor-state.d.cts +2 -2
  61. package/dist/core/state/editor-state.d.ts +2 -2
  62. package/dist/index.cjs +2765 -557
  63. package/dist/index.d.cts +5 -5
  64. package/dist/index.d.ts +5 -5
  65. package/dist/index.js +52 -28
  66. package/dist/io/docx-session.cjs +267 -211
  67. package/dist/io/docx-session.d.cts +4 -4
  68. package/dist/io/docx-session.d.ts +4 -4
  69. package/dist/io/docx-session.js +6 -6
  70. package/dist/legal.cjs +9 -20
  71. package/dist/legal.d.cts +1 -1
  72. package/dist/legal.d.ts +1 -1
  73. package/dist/legal.js +3 -3
  74. package/dist/{loader-19ct2Be0.d.ts → loader-B-aL5HGD.d.ts} +3 -3
  75. package/dist/{loader-CoXQ2wGd.d.cts → loader-DiY_ZgKl.d.cts} +3 -3
  76. package/dist/{measurement-backend-canvas-Q3MJMEYX.js → measurement-backend-canvas-F7ZYDACK.js} +1 -1
  77. package/dist/{public-types-B-CskQen.d.cts → public-types-DyqnxxO9.d.ts} +252 -2
  78. package/dist/{public-types-7KZsNGE2.d.ts → public-types-gvubspUI.d.cts} +252 -2
  79. package/dist/public-types.cjs +809 -78
  80. package/dist/public-types.d.cts +2 -2
  81. package/dist/public-types.d.ts +2 -2
  82. package/dist/public-types.js +4 -4
  83. package/dist/runtime/collab.d.cts +3 -3
  84. package/dist/runtime/collab.d.ts +3 -3
  85. package/dist/runtime/document-runtime.cjs +1887 -313
  86. package/dist/runtime/document-runtime.d.cts +2 -2
  87. package/dist/runtime/document-runtime.d.ts +2 -2
  88. package/dist/runtime/document-runtime.js +17 -17
  89. package/dist/{session-B5015J4v.d.cts → session-BUN6B-Vj.d.cts} +3 -3
  90. package/dist/{session-C2i8-d6v.d.ts → session-CDB0hohT.d.ts} +3 -3
  91. package/dist/session.cjs +267 -211
  92. package/dist/session.d.cts +5 -5
  93. package/dist/session.d.ts +5 -5
  94. package/dist/session.js +7 -7
  95. package/dist/tailwind.cjs +809 -78
  96. package/dist/tailwind.d.cts +2 -2
  97. package/dist/tailwind.d.ts +2 -2
  98. package/dist/tailwind.js +8 -8
  99. package/dist/{types-DNhN0WeN.d.cts → types-C4bz3kDU.d.cts} +2 -2
  100. package/dist/{types-yvrQuGX9.d.ts → types-VWH6CRvG.d.ts} +2 -2
  101. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  102. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  103. package/dist/ui-tailwind/editor-surface/search-plugin.js +5 -5
  104. package/dist/ui-tailwind.cjs +809 -78
  105. package/dist/ui-tailwind.d.cts +3 -3
  106. package/dist/ui-tailwind.d.ts +3 -3
  107. package/dist/ui-tailwind.js +8 -8
  108. package/package.json +1 -1
@@ -2107,26 +2107,35 @@ function buildParagraphPropertiesXml(paragraph) {
2107
2107
  if (frameXml) children.push(frameXml);
2108
2108
  }
2109
2109
  pushOnOffParagraphProperty(children, "widowControl", paragraph.widowControl);
2110
- if (paragraph.outlineLevel !== void 0) {
2111
- children.push(`<w:outlineLvl w:val="${paragraph.outlineLevel}"/>`);
2112
- }
2113
2110
  if (paragraph.numbering) {
2114
2111
  children.push(serializeParagraphNumberingProperties(paragraph.numbering));
2115
2112
  }
2113
+ pushOnOffParagraphProperty(children, "suppressLineNumbers", paragraph.suppressLineNumbers);
2114
+ if (paragraph.borders) {
2115
+ const bordersXml = serializeParagraphBorders(paragraph.borders);
2116
+ if (bordersXml) children.push(bordersXml);
2117
+ }
2118
+ if (paragraph.shading) {
2119
+ const shadingXml = serializeParagraphShading(paragraph.shading);
2120
+ if (shadingXml) children.push(shadingXml);
2121
+ }
2122
+ if (paragraph.tabStops && paragraph.tabStops.length > 0) {
2123
+ const tabsXml = paragraph.tabStops.map((tab) => {
2124
+ const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
2125
+ return `<w:tab w:val="${escapeXmlAttribute2(tab.align)}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
2126
+ }).join("");
2127
+ children.push(`<w:tabs>${tabsXml}</w:tabs>`);
2128
+ }
2129
+ pushOnOffParagraphProperty(children, "bidi", paragraph.bidi);
2116
2130
  if (paragraph.spacing) {
2117
2131
  const s = paragraph.spacing;
2118
2132
  const attrs = [];
2119
2133
  if (s.before !== void 0) attrs.push(`w:before="${twip(s.before)}"`);
2120
2134
  if (s.after !== void 0) attrs.push(`w:after="${twip(s.after)}"`);
2121
2135
  if (s.line !== void 0) attrs.push(`w:line="${twip(s.line)}"`);
2122
- if (s.lineRule !== void 0) attrs.push(`w:lineRule="${s.lineRule}"`);
2136
+ if (s.lineRule !== void 0) attrs.push(`w:lineRule="${escapeXmlAttribute2(s.lineRule)}"`);
2123
2137
  if (attrs.length > 0) children.push(`<w:spacing ${attrs.join(" ")}/>`);
2124
2138
  }
2125
- if (paragraph.contextualSpacing === true) {
2126
- children.push("<w:contextualSpacing/>");
2127
- } else if (paragraph.contextualSpacing === false) {
2128
- children.push(`<w:contextualSpacing w:val="false"/>`);
2129
- }
2130
2139
  if (paragraph.indentation) {
2131
2140
  const ind = paragraph.indentation;
2132
2141
  const attrs = [];
@@ -2136,33 +2145,20 @@ function buildParagraphPropertiesXml(paragraph) {
2136
2145
  if (ind.hanging !== void 0) attrs.push(`w:hanging="${twip(ind.hanging)}"`);
2137
2146
  if (attrs.length > 0) children.push(`<w:ind ${attrs.join(" ")}/>`);
2138
2147
  }
2139
- if (paragraph.alignment) {
2140
- children.push(`<w:jc w:val="${paragraph.alignment}"/>`);
2148
+ if (paragraph.contextualSpacing === true) {
2149
+ children.push("<w:contextualSpacing/>");
2150
+ } else if (paragraph.contextualSpacing === false) {
2151
+ children.push(`<w:contextualSpacing w:val="false"/>`);
2141
2152
  }
2142
- if (paragraph.borders) {
2143
- const bordersXml = serializeParagraphBorders(paragraph.borders);
2144
- if (bordersXml) {
2145
- children.push(bordersXml);
2146
- }
2153
+ if (paragraph.alignment) {
2154
+ children.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
2147
2155
  }
2148
- if (paragraph.shading) {
2149
- const shadingXml = serializeParagraphShading(paragraph.shading);
2150
- if (shadingXml) {
2151
- children.push(shadingXml);
2152
- }
2156
+ if (paragraph.outlineLevel !== void 0) {
2157
+ children.push(`<w:outlineLvl w:val="${paragraph.outlineLevel}"/>`);
2153
2158
  }
2154
- pushOnOffParagraphProperty(children, "bidi", paragraph.bidi);
2155
- pushOnOffParagraphProperty(children, "suppressLineNumbers", paragraph.suppressLineNumbers);
2156
2159
  if (paragraph.cnfStyle) {
2157
2160
  children.push(`<w:cnfStyle w:val="${escapeXmlAttribute2(paragraph.cnfStyle)}"/>`);
2158
2161
  }
2159
- if (paragraph.tabStops && paragraph.tabStops.length > 0) {
2160
- const tabsXml = paragraph.tabStops.map((tab) => {
2161
- const leaderAttr = tab.leader ? ` w:leader="${tab.leader}"` : "";
2162
- return `<w:tab w:val="${tab.align}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
2163
- }).join("");
2164
- children.push(`<w:tabs>${tabsXml}</w:tabs>`);
2165
- }
2166
2162
  if (children.length === 0) return "";
2167
2163
  return `<w:pPr>${children.join("")}</w:pPr>`;
2168
2164
  }
@@ -2727,79 +2723,86 @@ function serializeRunProperties(marks) {
2727
2723
  if (!marks || marks.length === 0) {
2728
2724
  return "";
2729
2725
  }
2726
+ const orderedTypes = [
2727
+ "fontFamily",
2728
+ "bold",
2729
+ "italic",
2730
+ "allCaps",
2731
+ "smallCaps",
2732
+ "strikethrough",
2733
+ "doubleStrikethrough",
2734
+ "shadow",
2735
+ "emboss",
2736
+ "imprint",
2737
+ "vanish",
2738
+ "textColor",
2739
+ "charSpacing",
2740
+ "kerning",
2741
+ "position",
2742
+ "fontSize",
2743
+ "highlight",
2744
+ "underline",
2745
+ "backgroundColor",
2746
+ "lang",
2747
+ "textFill"
2748
+ ];
2730
2749
  const markParts = [];
2731
- for (const mark of marks) {
2732
- switch (mark.type) {
2733
- case "bold":
2734
- markParts.push("<w:b/>");
2735
- break;
2736
- case "italic":
2737
- markParts.push("<w:i/>");
2738
- break;
2739
- case "underline":
2740
- markParts.push(`<w:u w:val="single"/>`);
2741
- break;
2742
- case "strikethrough":
2743
- markParts.push("<w:strike/>");
2744
- break;
2745
- case "doubleStrikethrough":
2746
- markParts.push("<w:dstrike/>");
2747
- break;
2748
- case "vanish":
2749
- markParts.push("<w:vanish/>");
2750
- break;
2751
- case "lang":
2752
- markParts.push(`<w:lang w:val="${escapeXmlAttribute2(mark.val)}"/>`);
2753
- break;
2754
- case "highlight":
2755
- markParts.push(`<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`);
2756
- break;
2757
- case "backgroundColor":
2758
- markParts.push(
2759
- `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`
2760
- );
2761
- break;
2762
- case "charSpacing":
2763
- markParts.push(`<w:spacing w:val="${mark.val}"/>`);
2764
- break;
2765
- case "kerning":
2766
- markParts.push(`<w:kern w:val="${mark.val}"/>`);
2767
- break;
2768
- case "emboss":
2769
- markParts.push("<w:emboss/>");
2770
- break;
2771
- case "imprint":
2772
- markParts.push("<w:imprint/>");
2773
- break;
2774
- case "shadow":
2775
- markParts.push("<w:shadow/>");
2776
- break;
2777
- case "position":
2778
- markParts.push(`<w:position w:val="${mark.val}"/>`);
2779
- break;
2780
- case "textFill":
2781
- markParts.push(mark.xml);
2782
- break;
2783
- case "fontFamily":
2784
- markParts.push(`<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`);
2785
- break;
2786
- case "fontSize":
2787
- markParts.push(`<w:sz w:val="${mark.val}"/>`);
2788
- break;
2789
- case "textColor":
2790
- markParts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
2791
- break;
2792
- case "smallCaps":
2793
- markParts.push("<w:smallCaps/>");
2794
- break;
2795
- case "allCaps":
2796
- markParts.push("<w:caps/>");
2797
- break;
2750
+ for (const type of orderedTypes) {
2751
+ for (const mark of marks) {
2752
+ if (mark.type !== type) continue;
2753
+ const xml = serializeRunPropertyMark(mark);
2754
+ if (xml) markParts.push(xml);
2798
2755
  }
2799
2756
  }
2800
2757
  const children = markParts.join("");
2801
2758
  return children.length > 0 ? `<w:rPr>${children}</w:rPr>` : "";
2802
2759
  }
2760
+ function serializeRunPropertyMark(mark) {
2761
+ switch (mark.type) {
2762
+ case "bold":
2763
+ return "<w:b/>";
2764
+ case "italic":
2765
+ return "<w:i/>";
2766
+ case "underline":
2767
+ return `<w:u w:val="single"/>`;
2768
+ case "strikethrough":
2769
+ return "<w:strike/>";
2770
+ case "doubleStrikethrough":
2771
+ return "<w:dstrike/>";
2772
+ case "vanish":
2773
+ return "<w:vanish/>";
2774
+ case "lang":
2775
+ return `<w:lang w:val="${escapeXmlAttribute2(mark.val)}"/>`;
2776
+ case "highlight":
2777
+ return `<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`;
2778
+ case "backgroundColor":
2779
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`;
2780
+ case "charSpacing":
2781
+ return `<w:spacing w:val="${mark.val}"/>`;
2782
+ case "kerning":
2783
+ return `<w:kern w:val="${mark.val}"/>`;
2784
+ case "emboss":
2785
+ return "<w:emboss/>";
2786
+ case "imprint":
2787
+ return "<w:imprint/>";
2788
+ case "shadow":
2789
+ return "<w:shadow/>";
2790
+ case "position":
2791
+ return `<w:position w:val="${mark.val}"/>`;
2792
+ case "textFill":
2793
+ return mark.xml;
2794
+ case "fontFamily":
2795
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
2796
+ case "fontSize":
2797
+ return `<w:sz w:val="${mark.val}"/>`;
2798
+ case "textColor":
2799
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
2800
+ case "smallCaps":
2801
+ return "<w:smallCaps/>";
2802
+ case "allCaps":
2803
+ return "<w:caps/>";
2804
+ }
2805
+ }
2803
2806
  function requiresPreservedSpace(text) {
2804
2807
  return /^\s/.test(text) || /\s$/.test(text) || text.includes(" ");
2805
2808
  }
@@ -5907,6 +5910,13 @@ function buildParagraphPropertiesXml2(paragraph) {
5907
5910
  const frameXml = buildFrameXml(paragraph.frameProperties);
5908
5911
  if (frameXml) parts.push(frameXml);
5909
5912
  }
5913
+ if (paragraph.tabStops && paragraph.tabStops.length > 0) {
5914
+ const tabsXml = paragraph.tabStops.map((tab) => {
5915
+ const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
5916
+ return `<w:tab w:val="${escapeXmlAttribute2(tab.align)}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
5917
+ }).join("");
5918
+ parts.push(`<w:tabs>${tabsXml}</w:tabs>`);
5919
+ }
5910
5920
  if (paragraph.spacing) {
5911
5921
  const s = paragraph.spacing;
5912
5922
  const attrs = [];
@@ -5928,13 +5938,6 @@ function buildParagraphPropertiesXml2(paragraph) {
5928
5938
  if (paragraph.alignment) {
5929
5939
  parts.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
5930
5940
  }
5931
- if (paragraph.tabStops && paragraph.tabStops.length > 0) {
5932
- const tabsXml = paragraph.tabStops.map((tab) => {
5933
- const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
5934
- return `<w:tab w:val="${tab.align}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
5935
- }).join("");
5936
- parts.push(`<w:tabs>${tabsXml}</w:tabs>`);
5937
- }
5938
5941
  return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
5939
5942
  }
5940
5943
  function serializeInlineNode2(node) {
@@ -6003,51 +6006,60 @@ function buildRunPropertiesXml2(marks) {
6003
6006
  if (!marks || marks.length === 0) {
6004
6007
  return "";
6005
6008
  }
6009
+ const orderedTypes = [
6010
+ "fontFamily",
6011
+ "bold",
6012
+ "italic",
6013
+ "allCaps",
6014
+ "smallCaps",
6015
+ "strikethrough",
6016
+ "doubleStrikethrough",
6017
+ "textColor",
6018
+ "fontSize",
6019
+ "highlight",
6020
+ "underline",
6021
+ "backgroundColor"
6022
+ ];
6006
6023
  const parts = [];
6007
- for (const mark of marks) {
6008
- switch (mark.type) {
6009
- case "bold":
6010
- parts.push("<w:b/>");
6011
- break;
6012
- case "italic":
6013
- parts.push("<w:i/>");
6014
- break;
6015
- case "underline":
6016
- parts.push('<w:u w:val="single"/>');
6017
- break;
6018
- case "strikethrough":
6019
- parts.push("<w:strike/>");
6020
- break;
6021
- case "doubleStrikethrough":
6022
- parts.push("<w:dstrike/>");
6023
- break;
6024
- case "fontFamily":
6025
- parts.push(`<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`);
6026
- break;
6027
- case "fontSize":
6028
- parts.push(`<w:sz w:val="${twip(mark.val)}"/>`);
6029
- break;
6030
- case "textColor":
6031
- parts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
6032
- break;
6033
- case "highlight":
6034
- parts.push(`<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`);
6035
- break;
6036
- case "backgroundColor":
6037
- parts.push(`<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`);
6038
- break;
6039
- case "smallCaps":
6040
- parts.push("<w:smallCaps/>");
6041
- break;
6042
- case "allCaps":
6043
- parts.push("<w:caps/>");
6044
- break;
6045
- default:
6046
- break;
6024
+ for (const type of orderedTypes) {
6025
+ for (const mark of marks) {
6026
+ if (mark.type !== type) continue;
6027
+ const xml = serializeRunPropertyMark2(mark);
6028
+ if (xml) parts.push(xml);
6047
6029
  }
6048
6030
  }
6049
6031
  return parts.length > 0 ? `<w:rPr>${parts.join("")}</w:rPr>` : "";
6050
6032
  }
6033
+ function serializeRunPropertyMark2(mark) {
6034
+ switch (mark.type) {
6035
+ case "bold":
6036
+ return "<w:b/>";
6037
+ case "italic":
6038
+ return "<w:i/>";
6039
+ case "underline":
6040
+ return `<w:u w:val="single"/>`;
6041
+ case "strikethrough":
6042
+ return "<w:strike/>";
6043
+ case "doubleStrikethrough":
6044
+ return "<w:dstrike/>";
6045
+ case "fontFamily":
6046
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
6047
+ case "fontSize":
6048
+ return `<w:sz w:val="${twip(mark.val)}"/>`;
6049
+ case "textColor":
6050
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
6051
+ case "highlight":
6052
+ return `<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`;
6053
+ case "backgroundColor":
6054
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`;
6055
+ case "smallCaps":
6056
+ return "<w:smallCaps/>";
6057
+ case "allCaps":
6058
+ return "<w:caps/>";
6059
+ default:
6060
+ return "";
6061
+ }
6062
+ }
6051
6063
  function requiresPreservedSpace3(text) {
6052
6064
  return text.length > 0 && (text[0] === " " || text[text.length - 1] === " " || text.includes(" "));
6053
6065
  }
@@ -6221,9 +6233,6 @@ function buildParagraphPropertiesXml3(paragraph) {
6221
6233
  const frameXml = buildFrameXml(paragraph.frameProperties);
6222
6234
  if (frameXml) parts.push(frameXml);
6223
6235
  }
6224
- if (paragraph.alignment) {
6225
- parts.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
6226
- }
6227
6236
  if (paragraph.spacing) {
6228
6237
  const attrs = [];
6229
6238
  if (paragraph.spacing.before !== void 0) attrs.push(`w:before="${twip(paragraph.spacing.before)}"`);
@@ -6244,6 +6253,9 @@ function buildParagraphPropertiesXml3(paragraph) {
6244
6253
  parts.push(`<w:ind ${attrs.join(" ")}/>`);
6245
6254
  }
6246
6255
  }
6256
+ if (paragraph.alignment) {
6257
+ parts.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
6258
+ }
6247
6259
  return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
6248
6260
  }
6249
6261
  function serializeInlineNode3(node) {
@@ -6304,47 +6316,59 @@ function buildRunPropertiesXml3(marks) {
6304
6316
  if (!marks || marks.length === 0) {
6305
6317
  return "";
6306
6318
  }
6307
- const parts = [];
6319
+ const orderedTypes = [
6320
+ "fontFamily",
6321
+ "bold",
6322
+ "italic",
6323
+ "allCaps",
6324
+ "smallCaps",
6325
+ "strikethrough",
6326
+ "doubleStrikethrough",
6327
+ "textColor",
6328
+ "fontSize",
6329
+ "underline"
6330
+ ];
6331
+ const supportedTypes = new Set(orderedTypes);
6308
6332
  for (const mark of marks) {
6309
- switch (mark.type) {
6310
- case "bold":
6311
- parts.push("<w:b/>");
6312
- break;
6313
- case "italic":
6314
- parts.push("<w:i/>");
6315
- break;
6316
- case "underline":
6317
- parts.push('<w:u w:val="single"/>');
6318
- break;
6319
- case "strikethrough":
6320
- parts.push("<w:strike/>");
6321
- break;
6322
- case "doubleStrikethrough":
6323
- parts.push("<w:dstrike/>");
6324
- break;
6325
- case "fontFamily":
6326
- parts.push(
6327
- `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`
6328
- );
6329
- break;
6330
- case "fontSize":
6331
- parts.push(`<w:sz w:val="${twip(mark.val)}"/>`);
6332
- break;
6333
- case "textColor":
6334
- parts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
6335
- break;
6336
- case "smallCaps":
6337
- parts.push("<w:smallCaps/>");
6338
- break;
6339
- case "allCaps":
6340
- parts.push("<w:caps/>");
6341
- break;
6342
- default:
6343
- throw new Error(`Cannot safely serialize ${mark.type} marks in note sub-parts.`);
6333
+ if (!supportedTypes.has(mark.type)) {
6334
+ throw new Error(`Cannot safely serialize ${mark.type} marks in note sub-parts.`);
6335
+ }
6336
+ }
6337
+ const parts = [];
6338
+ for (const type of orderedTypes) {
6339
+ for (const mark of marks) {
6340
+ if (mark.type !== type) continue;
6341
+ parts.push(serializeRunPropertyMark3(mark));
6344
6342
  }
6345
6343
  }
6346
6344
  return parts.length > 0 ? `<w:rPr>${parts.join("")}</w:rPr>` : "";
6347
6345
  }
6346
+ function serializeRunPropertyMark3(mark) {
6347
+ switch (mark.type) {
6348
+ case "bold":
6349
+ return "<w:b/>";
6350
+ case "italic":
6351
+ return "<w:i/>";
6352
+ case "underline":
6353
+ return `<w:u w:val="single"/>`;
6354
+ case "strikethrough":
6355
+ return "<w:strike/>";
6356
+ case "doubleStrikethrough":
6357
+ return "<w:dstrike/>";
6358
+ case "fontFamily":
6359
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
6360
+ case "fontSize":
6361
+ return `<w:sz w:val="${twip(mark.val)}"/>`;
6362
+ case "textColor":
6363
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
6364
+ case "smallCaps":
6365
+ return "<w:smallCaps/>";
6366
+ case "allCaps":
6367
+ return "<w:caps/>";
6368
+ default:
6369
+ throw new Error(`Cannot safely serialize ${mark.type} marks in note sub-parts.`);
6370
+ }
6371
+ }
6348
6372
  function compareNoteIds(left, right) {
6349
6373
  return Number.parseInt(left.noteId, 10) - Number.parseInt(right.noteId, 10);
6350
6374
  }
@@ -14149,8 +14173,7 @@ function resolveContentType(path, contentTypes) {
14149
14173
  // src/io/ooxml/parse-bookmark-references.ts
14150
14174
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
14151
14175
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
14152
- var FLD_SIMPLE_INSTR_DOUBLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*"([^"]*)"/gi;
14153
- var FLD_SIMPLE_INSTR_SINGLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*'([^']*)'/gi;
14176
+ var FLD_SIMPLE_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*(["'])([\s\S]*?)\1/gi;
14154
14177
  var TOC_FIELD_RE = /\bTOC\b/;
14155
14178
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
14156
14179
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -14169,21 +14192,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14169
14192
  }
14170
14193
  INSTR_TEXT_RE.lastIndex = 0;
14171
14194
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
14172
- const instrText = m[1] ?? "";
14173
- scanFieldInstruction(instrText, retained, () => {
14174
- retainAllToc = true;
14195
+ retainInstructionReferences(m[1] ?? "", retained, (value) => {
14196
+ retainAllToc = retainAllToc || value;
14175
14197
  });
14176
14198
  }
14177
- FLD_SIMPLE_INSTR_DOUBLE_RE.lastIndex = 0;
14178
- while ((m = FLD_SIMPLE_INSTR_DOUBLE_RE.exec(documentXml)) !== null) {
14179
- scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
14180
- retainAllToc = true;
14181
- });
14182
- }
14183
- FLD_SIMPLE_INSTR_SINGLE_RE.lastIndex = 0;
14184
- while ((m = FLD_SIMPLE_INSTR_SINGLE_RE.exec(documentXml)) !== null) {
14185
- scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
14186
- retainAllToc = true;
14199
+ FLD_SIMPLE_INSTR_RE.lastIndex = 0;
14200
+ while ((m = FLD_SIMPLE_INSTR_RE.exec(documentXml)) !== null) {
14201
+ retainInstructionReferences(m[2] ?? "", retained, (value) => {
14202
+ retainAllToc = retainAllToc || value;
14187
14203
  });
14188
14204
  }
14189
14205
  retainRevisionBoundedBookmarks(documentXml, retained);
@@ -14193,17 +14209,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14193
14209
  retainAll
14194
14210
  };
14195
14211
  }
14196
- function scanFieldInstruction(instrText, retained, retainToc) {
14197
- if (TOC_FIELD_RE.test(instrText)) retainToc();
14212
+ function retainInstructionReferences(instrText, retained, setRetainAllToc) {
14213
+ if (TOC_FIELD_RE.test(instrText)) setRetainAllToc(true);
14198
14214
  REFLIKE_FIELD_RE.lastIndex = 0;
14199
14215
  let r;
14200
14216
  while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
14201
14217
  if (r[1]) retained.add(r[1]);
14202
14218
  }
14203
14219
  }
14204
- function decodeXmlAttribute(value) {
14205
- return value.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
14206
- }
14207
14220
  function retainRevisionBoundedBookmarks(documentXml, retained) {
14208
14221
  const starts = /* @__PURE__ */ new Map();
14209
14222
  BOOKMARK_START_RE.lastIndex = 0;
@@ -14592,7 +14605,7 @@ function parseNumberingXml(xml, context) {
14592
14605
  abstractDefinitions[abstractNumberingId] = {
14593
14606
  abstractNumberingId,
14594
14607
  ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "abstractNum", rawId, childXmlPath) } : {},
14595
- levels: readLevels(child),
14608
+ levels: readLevels(child, context, childXmlPath, rawId),
14596
14609
  ...nsid ? { nsid } : {},
14597
14610
  ...multiLevelType ? { multiLevelType } : {},
14598
14611
  ...tplc ? { tplc } : {},
@@ -14613,7 +14626,7 @@ function parseNumberingXml(xml, context) {
14613
14626
  numberingInstanceId,
14614
14627
  ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "num", rawId, childXmlPath) } : {},
14615
14628
  abstractNumberingId: toCanonicalAbstractNumberingId(rawAbstractId),
14616
- overrides: readOverrides(child)
14629
+ overrides: readOverrides(child, context, childXmlPath, rawId)
14617
14630
  };
14618
14631
  break;
14619
14632
  }
@@ -14634,6 +14647,16 @@ function createNumberingSourceRef(partPath, element, rawId, xmlPath) {
14634
14647
  ...xmlPath !== void 0 ? { xmlPath } : {}
14635
14648
  };
14636
14649
  }
14650
+ function createNumberingChildSourceRef(partPath, element, sourceIdSuffix, xmlPath) {
14651
+ if (partPath === void 0) return void 0;
14652
+ return {
14653
+ sourceId: `part:${partPath}#${sourceIdSuffix}`,
14654
+ partPath,
14655
+ storyKind: "numbering",
14656
+ element,
14657
+ ...xmlPath !== void 0 ? { xmlPath } : {}
14658
+ };
14659
+ }
14637
14660
  function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
14638
14661
  let widthEmu;
14639
14662
  let heightEmu;
@@ -14710,18 +14733,29 @@ function toCanonicalAbstractNumberingId(value) {
14710
14733
  function toCanonicalNumberingInstanceId(value) {
14711
14734
  return value.startsWith("num:") ? value : `num:${value}`;
14712
14735
  }
14713
- function readLevels(abstractNode) {
14736
+ function readLevels(abstractNode, context, abstractXmlPath, rawAbstractId) {
14714
14737
  const levels = [];
14738
+ let levelOrdinal = 0;
14715
14739
  for (const child of abstractNode.children) {
14716
14740
  if (child.type !== "element" || localName(child.name) !== "lvl") {
14717
14741
  continue;
14718
14742
  }
14743
+ levelOrdinal += 1;
14719
14744
  const rawLevel = readStringAttr(child, "w:ilvl");
14720
14745
  const level = rawLevel === void 0 ? void 0 : parseInteger(rawLevel);
14721
14746
  if (level === void 0) {
14722
14747
  continue;
14723
14748
  }
14724
- const definition = readLevelDefinition(child, level);
14749
+ const definition = readLevelDefinition(
14750
+ child,
14751
+ level,
14752
+ createNumberingChildSourceRef(
14753
+ context?.partPath,
14754
+ "lvl",
14755
+ `abstractNum:${rawAbstractId}:lvl:${level}`,
14756
+ `${abstractXmlPath}/lvl[${levelOrdinal}]`
14757
+ )
14758
+ );
14725
14759
  if (!definition) {
14726
14760
  continue;
14727
14761
  }
@@ -14729,12 +14763,14 @@ function readLevels(abstractNode) {
14729
14763
  }
14730
14764
  return levels.sort((left, right) => left.level - right.level);
14731
14765
  }
14732
- function readOverrides(numNode) {
14766
+ function readOverrides(numNode, context, numXmlPath, rawNumId) {
14733
14767
  const overrides = [];
14768
+ let overrideOrdinal = 0;
14734
14769
  for (const child of numNode.children) {
14735
14770
  if (child.type !== "element" || localName(child.name) !== "lvlOverride") {
14736
14771
  continue;
14737
14772
  }
14773
+ overrideOrdinal += 1;
14738
14774
  const rawLevel = readStringAttr(child, "w:ilvl");
14739
14775
  const level = rawLevel === void 0 ? void 0 : parseInteger(rawLevel);
14740
14776
  if (level === void 0) {
@@ -14744,8 +14780,26 @@ function readOverrides(numNode) {
14744
14780
  const rawStart = startOverrideNode ? readStringAttr(startOverrideNode, "w:val") : void 0;
14745
14781
  const startAt = rawStart === void 0 ? void 0 : parseInteger(rawStart);
14746
14782
  const levelDefinitionNode = findChildElementOptional2(child, "lvl");
14747
- const levelDefinition = levelDefinitionNode ? readLevelOverrideDefinition(levelDefinitionNode, level) : void 0;
14783
+ const overrideXmlPath = `${numXmlPath}/lvlOverride[${overrideOrdinal}]`;
14784
+ const levelDefinition = levelDefinitionNode ? readLevelOverrideDefinition(
14785
+ levelDefinitionNode,
14786
+ level,
14787
+ createNumberingChildSourceRef(
14788
+ context?.partPath,
14789
+ "lvl",
14790
+ `num:${rawNumId}:lvlOverride:${level}:lvl`,
14791
+ `${overrideXmlPath}/lvl[1]`
14792
+ )
14793
+ ) : void 0;
14748
14794
  overrides.push({
14795
+ ...context?.partPath !== void 0 ? {
14796
+ sourceRef: createNumberingChildSourceRef(
14797
+ context.partPath,
14798
+ "lvlOverride",
14799
+ `num:${rawNumId}:lvlOverride:${level}`,
14800
+ overrideXmlPath
14801
+ )
14802
+ } : {},
14749
14803
  level,
14750
14804
  ...startAt !== void 0 ? { startAt } : {},
14751
14805
  ...levelDefinition ? { levelDefinition } : {}
@@ -14753,7 +14807,7 @@ function readOverrides(numNode) {
14753
14807
  }
14754
14808
  return overrides.sort((left, right) => left.level - right.level);
14755
14809
  }
14756
- function readLevelDefinition(levelNode, fallbackLevel) {
14810
+ function readLevelDefinition(levelNode, fallbackLevel, sourceRef) {
14757
14811
  const rawLevel = readStringAttr(levelNode, "w:ilvl");
14758
14812
  const level = rawLevel === void 0 ? fallbackLevel : parseInteger(rawLevel);
14759
14813
  if (level === void 0) {
@@ -14783,6 +14837,7 @@ function readLevelDefinition(levelNode, fallbackLevel) {
14783
14837
  const lvlPicBulletNode = findChildElementOptional2(levelNode, "lvlPicBulletId");
14784
14838
  const picBulletId = lvlPicBulletNode ? readStringAttr(lvlPicBulletNode, "w:val") : void 0;
14785
14839
  return {
14840
+ ...sourceRef ? { sourceRef } : {},
14786
14841
  level,
14787
14842
  format,
14788
14843
  text,
@@ -14796,7 +14851,7 @@ function readLevelDefinition(levelNode, fallbackLevel) {
14796
14851
  ...picBulletId !== void 0 ? { picBulletId } : {}
14797
14852
  };
14798
14853
  }
14799
- function readLevelOverrideDefinition(levelNode, fallbackLevel) {
14854
+ function readLevelOverrideDefinition(levelNode, fallbackLevel, sourceRef) {
14800
14855
  const rawLevel = readStringAttr(levelNode, "w:ilvl");
14801
14856
  const level = rawLevel === void 0 ? fallbackLevel : parseInteger(rawLevel);
14802
14857
  if (level === void 0) {
@@ -14830,6 +14885,7 @@ function readLevelOverrideDefinition(levelNode, fallbackLevel) {
14830
14885
  return void 0;
14831
14886
  }
14832
14887
  return {
14888
+ ...sourceRef ? { sourceRef } : {},
14833
14889
  level,
14834
14890
  ...startAt !== void 0 ? { startAt } : {},
14835
14891
  ...format !== void 0 ? { format } : {},