@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
package/dist/session.cjs CHANGED
@@ -2793,26 +2793,35 @@ function buildParagraphPropertiesXml(paragraph) {
2793
2793
  if (frameXml) children.push(frameXml);
2794
2794
  }
2795
2795
  pushOnOffParagraphProperty(children, "widowControl", paragraph.widowControl);
2796
- if (paragraph.outlineLevel !== void 0) {
2797
- children.push(`<w:outlineLvl w:val="${paragraph.outlineLevel}"/>`);
2798
- }
2799
2796
  if (paragraph.numbering) {
2800
2797
  children.push(serializeParagraphNumberingProperties(paragraph.numbering));
2801
2798
  }
2799
+ pushOnOffParagraphProperty(children, "suppressLineNumbers", paragraph.suppressLineNumbers);
2800
+ if (paragraph.borders) {
2801
+ const bordersXml = serializeParagraphBorders(paragraph.borders);
2802
+ if (bordersXml) children.push(bordersXml);
2803
+ }
2804
+ if (paragraph.shading) {
2805
+ const shadingXml = serializeParagraphShading(paragraph.shading);
2806
+ if (shadingXml) children.push(shadingXml);
2807
+ }
2808
+ if (paragraph.tabStops && paragraph.tabStops.length > 0) {
2809
+ const tabsXml = paragraph.tabStops.map((tab) => {
2810
+ const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
2811
+ return `<w:tab w:val="${escapeXmlAttribute2(tab.align)}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
2812
+ }).join("");
2813
+ children.push(`<w:tabs>${tabsXml}</w:tabs>`);
2814
+ }
2815
+ pushOnOffParagraphProperty(children, "bidi", paragraph.bidi);
2802
2816
  if (paragraph.spacing) {
2803
2817
  const s = paragraph.spacing;
2804
2818
  const attrs = [];
2805
2819
  if (s.before !== void 0) attrs.push(`w:before="${twip(s.before)}"`);
2806
2820
  if (s.after !== void 0) attrs.push(`w:after="${twip(s.after)}"`);
2807
2821
  if (s.line !== void 0) attrs.push(`w:line="${twip(s.line)}"`);
2808
- if (s.lineRule !== void 0) attrs.push(`w:lineRule="${s.lineRule}"`);
2822
+ if (s.lineRule !== void 0) attrs.push(`w:lineRule="${escapeXmlAttribute2(s.lineRule)}"`);
2809
2823
  if (attrs.length > 0) children.push(`<w:spacing ${attrs.join(" ")}/>`);
2810
2824
  }
2811
- if (paragraph.contextualSpacing === true) {
2812
- children.push("<w:contextualSpacing/>");
2813
- } else if (paragraph.contextualSpacing === false) {
2814
- children.push(`<w:contextualSpacing w:val="false"/>`);
2815
- }
2816
2825
  if (paragraph.indentation) {
2817
2826
  const ind = paragraph.indentation;
2818
2827
  const attrs = [];
@@ -2822,33 +2831,20 @@ function buildParagraphPropertiesXml(paragraph) {
2822
2831
  if (ind.hanging !== void 0) attrs.push(`w:hanging="${twip(ind.hanging)}"`);
2823
2832
  if (attrs.length > 0) children.push(`<w:ind ${attrs.join(" ")}/>`);
2824
2833
  }
2825
- if (paragraph.alignment) {
2826
- children.push(`<w:jc w:val="${paragraph.alignment}"/>`);
2834
+ if (paragraph.contextualSpacing === true) {
2835
+ children.push("<w:contextualSpacing/>");
2836
+ } else if (paragraph.contextualSpacing === false) {
2837
+ children.push(`<w:contextualSpacing w:val="false"/>`);
2827
2838
  }
2828
- if (paragraph.borders) {
2829
- const bordersXml = serializeParagraphBorders(paragraph.borders);
2830
- if (bordersXml) {
2831
- children.push(bordersXml);
2832
- }
2839
+ if (paragraph.alignment) {
2840
+ children.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
2833
2841
  }
2834
- if (paragraph.shading) {
2835
- const shadingXml = serializeParagraphShading(paragraph.shading);
2836
- if (shadingXml) {
2837
- children.push(shadingXml);
2838
- }
2842
+ if (paragraph.outlineLevel !== void 0) {
2843
+ children.push(`<w:outlineLvl w:val="${paragraph.outlineLevel}"/>`);
2839
2844
  }
2840
- pushOnOffParagraphProperty(children, "bidi", paragraph.bidi);
2841
- pushOnOffParagraphProperty(children, "suppressLineNumbers", paragraph.suppressLineNumbers);
2842
2845
  if (paragraph.cnfStyle) {
2843
2846
  children.push(`<w:cnfStyle w:val="${escapeXmlAttribute2(paragraph.cnfStyle)}"/>`);
2844
2847
  }
2845
- if (paragraph.tabStops && paragraph.tabStops.length > 0) {
2846
- const tabsXml = paragraph.tabStops.map((tab) => {
2847
- const leaderAttr = tab.leader ? ` w:leader="${tab.leader}"` : "";
2848
- return `<w:tab w:val="${tab.align}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
2849
- }).join("");
2850
- children.push(`<w:tabs>${tabsXml}</w:tabs>`);
2851
- }
2852
2848
  if (children.length === 0) return "";
2853
2849
  return `<w:pPr>${children.join("")}</w:pPr>`;
2854
2850
  }
@@ -3413,79 +3409,86 @@ function serializeRunProperties(marks) {
3413
3409
  if (!marks || marks.length === 0) {
3414
3410
  return "";
3415
3411
  }
3412
+ const orderedTypes = [
3413
+ "fontFamily",
3414
+ "bold",
3415
+ "italic",
3416
+ "allCaps",
3417
+ "smallCaps",
3418
+ "strikethrough",
3419
+ "doubleStrikethrough",
3420
+ "shadow",
3421
+ "emboss",
3422
+ "imprint",
3423
+ "vanish",
3424
+ "textColor",
3425
+ "charSpacing",
3426
+ "kerning",
3427
+ "position",
3428
+ "fontSize",
3429
+ "highlight",
3430
+ "underline",
3431
+ "backgroundColor",
3432
+ "lang",
3433
+ "textFill"
3434
+ ];
3416
3435
  const markParts = [];
3417
- for (const mark of marks) {
3418
- switch (mark.type) {
3419
- case "bold":
3420
- markParts.push("<w:b/>");
3421
- break;
3422
- case "italic":
3423
- markParts.push("<w:i/>");
3424
- break;
3425
- case "underline":
3426
- markParts.push(`<w:u w:val="single"/>`);
3427
- break;
3428
- case "strikethrough":
3429
- markParts.push("<w:strike/>");
3430
- break;
3431
- case "doubleStrikethrough":
3432
- markParts.push("<w:dstrike/>");
3433
- break;
3434
- case "vanish":
3435
- markParts.push("<w:vanish/>");
3436
- break;
3437
- case "lang":
3438
- markParts.push(`<w:lang w:val="${escapeXmlAttribute2(mark.val)}"/>`);
3439
- break;
3440
- case "highlight":
3441
- markParts.push(`<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`);
3442
- break;
3443
- case "backgroundColor":
3444
- markParts.push(
3445
- `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`
3446
- );
3447
- break;
3448
- case "charSpacing":
3449
- markParts.push(`<w:spacing w:val="${mark.val}"/>`);
3450
- break;
3451
- case "kerning":
3452
- markParts.push(`<w:kern w:val="${mark.val}"/>`);
3453
- break;
3454
- case "emboss":
3455
- markParts.push("<w:emboss/>");
3456
- break;
3457
- case "imprint":
3458
- markParts.push("<w:imprint/>");
3459
- break;
3460
- case "shadow":
3461
- markParts.push("<w:shadow/>");
3462
- break;
3463
- case "position":
3464
- markParts.push(`<w:position w:val="${mark.val}"/>`);
3465
- break;
3466
- case "textFill":
3467
- markParts.push(mark.xml);
3468
- break;
3469
- case "fontFamily":
3470
- markParts.push(`<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`);
3471
- break;
3472
- case "fontSize":
3473
- markParts.push(`<w:sz w:val="${mark.val}"/>`);
3474
- break;
3475
- case "textColor":
3476
- markParts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
3477
- break;
3478
- case "smallCaps":
3479
- markParts.push("<w:smallCaps/>");
3480
- break;
3481
- case "allCaps":
3482
- markParts.push("<w:caps/>");
3483
- break;
3436
+ for (const type of orderedTypes) {
3437
+ for (const mark of marks) {
3438
+ if (mark.type !== type) continue;
3439
+ const xml = serializeRunPropertyMark(mark);
3440
+ if (xml) markParts.push(xml);
3484
3441
  }
3485
3442
  }
3486
3443
  const children = markParts.join("");
3487
3444
  return children.length > 0 ? `<w:rPr>${children}</w:rPr>` : "";
3488
3445
  }
3446
+ function serializeRunPropertyMark(mark) {
3447
+ switch (mark.type) {
3448
+ case "bold":
3449
+ return "<w:b/>";
3450
+ case "italic":
3451
+ return "<w:i/>";
3452
+ case "underline":
3453
+ return `<w:u w:val="single"/>`;
3454
+ case "strikethrough":
3455
+ return "<w:strike/>";
3456
+ case "doubleStrikethrough":
3457
+ return "<w:dstrike/>";
3458
+ case "vanish":
3459
+ return "<w:vanish/>";
3460
+ case "lang":
3461
+ return `<w:lang w:val="${escapeXmlAttribute2(mark.val)}"/>`;
3462
+ case "highlight":
3463
+ return `<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`;
3464
+ case "backgroundColor":
3465
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`;
3466
+ case "charSpacing":
3467
+ return `<w:spacing w:val="${mark.val}"/>`;
3468
+ case "kerning":
3469
+ return `<w:kern w:val="${mark.val}"/>`;
3470
+ case "emboss":
3471
+ return "<w:emboss/>";
3472
+ case "imprint":
3473
+ return "<w:imprint/>";
3474
+ case "shadow":
3475
+ return "<w:shadow/>";
3476
+ case "position":
3477
+ return `<w:position w:val="${mark.val}"/>`;
3478
+ case "textFill":
3479
+ return mark.xml;
3480
+ case "fontFamily":
3481
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
3482
+ case "fontSize":
3483
+ return `<w:sz w:val="${mark.val}"/>`;
3484
+ case "textColor":
3485
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
3486
+ case "smallCaps":
3487
+ return "<w:smallCaps/>";
3488
+ case "allCaps":
3489
+ return "<w:caps/>";
3490
+ }
3491
+ }
3489
3492
  function requiresPreservedSpace(text) {
3490
3493
  return /^\s/.test(text) || /\s$/.test(text) || text.includes(" ");
3491
3494
  }
@@ -6593,6 +6596,13 @@ function buildParagraphPropertiesXml2(paragraph) {
6593
6596
  const frameXml = buildFrameXml(paragraph.frameProperties);
6594
6597
  if (frameXml) parts.push(frameXml);
6595
6598
  }
6599
+ if (paragraph.tabStops && paragraph.tabStops.length > 0) {
6600
+ const tabsXml = paragraph.tabStops.map((tab) => {
6601
+ const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
6602
+ return `<w:tab w:val="${escapeXmlAttribute2(tab.align)}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
6603
+ }).join("");
6604
+ parts.push(`<w:tabs>${tabsXml}</w:tabs>`);
6605
+ }
6596
6606
  if (paragraph.spacing) {
6597
6607
  const s = paragraph.spacing;
6598
6608
  const attrs = [];
@@ -6614,13 +6624,6 @@ function buildParagraphPropertiesXml2(paragraph) {
6614
6624
  if (paragraph.alignment) {
6615
6625
  parts.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
6616
6626
  }
6617
- if (paragraph.tabStops && paragraph.tabStops.length > 0) {
6618
- const tabsXml = paragraph.tabStops.map((tab) => {
6619
- const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
6620
- return `<w:tab w:val="${tab.align}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
6621
- }).join("");
6622
- parts.push(`<w:tabs>${tabsXml}</w:tabs>`);
6623
- }
6624
6627
  return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
6625
6628
  }
6626
6629
  function serializeInlineNode2(node) {
@@ -6689,51 +6692,60 @@ function buildRunPropertiesXml2(marks) {
6689
6692
  if (!marks || marks.length === 0) {
6690
6693
  return "";
6691
6694
  }
6695
+ const orderedTypes = [
6696
+ "fontFamily",
6697
+ "bold",
6698
+ "italic",
6699
+ "allCaps",
6700
+ "smallCaps",
6701
+ "strikethrough",
6702
+ "doubleStrikethrough",
6703
+ "textColor",
6704
+ "fontSize",
6705
+ "highlight",
6706
+ "underline",
6707
+ "backgroundColor"
6708
+ ];
6692
6709
  const parts = [];
6693
- for (const mark of marks) {
6694
- switch (mark.type) {
6695
- case "bold":
6696
- parts.push("<w:b/>");
6697
- break;
6698
- case "italic":
6699
- parts.push("<w:i/>");
6700
- break;
6701
- case "underline":
6702
- parts.push('<w:u w:val="single"/>');
6703
- break;
6704
- case "strikethrough":
6705
- parts.push("<w:strike/>");
6706
- break;
6707
- case "doubleStrikethrough":
6708
- parts.push("<w:dstrike/>");
6709
- break;
6710
- case "fontFamily":
6711
- parts.push(`<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`);
6712
- break;
6713
- case "fontSize":
6714
- parts.push(`<w:sz w:val="${twip(mark.val)}"/>`);
6715
- break;
6716
- case "textColor":
6717
- parts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
6718
- break;
6719
- case "highlight":
6720
- parts.push(`<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`);
6721
- break;
6722
- case "backgroundColor":
6723
- parts.push(`<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`);
6724
- break;
6725
- case "smallCaps":
6726
- parts.push("<w:smallCaps/>");
6727
- break;
6728
- case "allCaps":
6729
- parts.push("<w:caps/>");
6730
- break;
6731
- default:
6732
- break;
6710
+ for (const type of orderedTypes) {
6711
+ for (const mark of marks) {
6712
+ if (mark.type !== type) continue;
6713
+ const xml = serializeRunPropertyMark2(mark);
6714
+ if (xml) parts.push(xml);
6733
6715
  }
6734
6716
  }
6735
6717
  return parts.length > 0 ? `<w:rPr>${parts.join("")}</w:rPr>` : "";
6736
6718
  }
6719
+ function serializeRunPropertyMark2(mark) {
6720
+ switch (mark.type) {
6721
+ case "bold":
6722
+ return "<w:b/>";
6723
+ case "italic":
6724
+ return "<w:i/>";
6725
+ case "underline":
6726
+ return `<w:u w:val="single"/>`;
6727
+ case "strikethrough":
6728
+ return "<w:strike/>";
6729
+ case "doubleStrikethrough":
6730
+ return "<w:dstrike/>";
6731
+ case "fontFamily":
6732
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
6733
+ case "fontSize":
6734
+ return `<w:sz w:val="${twip(mark.val)}"/>`;
6735
+ case "textColor":
6736
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
6737
+ case "highlight":
6738
+ return `<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`;
6739
+ case "backgroundColor":
6740
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`;
6741
+ case "smallCaps":
6742
+ return "<w:smallCaps/>";
6743
+ case "allCaps":
6744
+ return "<w:caps/>";
6745
+ default:
6746
+ return "";
6747
+ }
6748
+ }
6737
6749
  function requiresPreservedSpace3(text) {
6738
6750
  return text.length > 0 && (text[0] === " " || text[text.length - 1] === " " || text.includes(" "));
6739
6751
  }
@@ -6907,9 +6919,6 @@ function buildParagraphPropertiesXml3(paragraph) {
6907
6919
  const frameXml = buildFrameXml(paragraph.frameProperties);
6908
6920
  if (frameXml) parts.push(frameXml);
6909
6921
  }
6910
- if (paragraph.alignment) {
6911
- parts.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
6912
- }
6913
6922
  if (paragraph.spacing) {
6914
6923
  const attrs = [];
6915
6924
  if (paragraph.spacing.before !== void 0) attrs.push(`w:before="${twip(paragraph.spacing.before)}"`);
@@ -6930,6 +6939,9 @@ function buildParagraphPropertiesXml3(paragraph) {
6930
6939
  parts.push(`<w:ind ${attrs.join(" ")}/>`);
6931
6940
  }
6932
6941
  }
6942
+ if (paragraph.alignment) {
6943
+ parts.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
6944
+ }
6933
6945
  return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
6934
6946
  }
6935
6947
  function serializeInlineNode3(node) {
@@ -6990,47 +7002,59 @@ function buildRunPropertiesXml3(marks) {
6990
7002
  if (!marks || marks.length === 0) {
6991
7003
  return "";
6992
7004
  }
6993
- const parts = [];
7005
+ const orderedTypes = [
7006
+ "fontFamily",
7007
+ "bold",
7008
+ "italic",
7009
+ "allCaps",
7010
+ "smallCaps",
7011
+ "strikethrough",
7012
+ "doubleStrikethrough",
7013
+ "textColor",
7014
+ "fontSize",
7015
+ "underline"
7016
+ ];
7017
+ const supportedTypes = new Set(orderedTypes);
6994
7018
  for (const mark of marks) {
6995
- switch (mark.type) {
6996
- case "bold":
6997
- parts.push("<w:b/>");
6998
- break;
6999
- case "italic":
7000
- parts.push("<w:i/>");
7001
- break;
7002
- case "underline":
7003
- parts.push('<w:u w:val="single"/>');
7004
- break;
7005
- case "strikethrough":
7006
- parts.push("<w:strike/>");
7007
- break;
7008
- case "doubleStrikethrough":
7009
- parts.push("<w:dstrike/>");
7010
- break;
7011
- case "fontFamily":
7012
- parts.push(
7013
- `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`
7014
- );
7015
- break;
7016
- case "fontSize":
7017
- parts.push(`<w:sz w:val="${twip(mark.val)}"/>`);
7018
- break;
7019
- case "textColor":
7020
- parts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
7021
- break;
7022
- case "smallCaps":
7023
- parts.push("<w:smallCaps/>");
7024
- break;
7025
- case "allCaps":
7026
- parts.push("<w:caps/>");
7027
- break;
7028
- default:
7029
- throw new Error(`Cannot safely serialize ${mark.type} marks in note sub-parts.`);
7019
+ if (!supportedTypes.has(mark.type)) {
7020
+ throw new Error(`Cannot safely serialize ${mark.type} marks in note sub-parts.`);
7021
+ }
7022
+ }
7023
+ const parts = [];
7024
+ for (const type of orderedTypes) {
7025
+ for (const mark of marks) {
7026
+ if (mark.type !== type) continue;
7027
+ parts.push(serializeRunPropertyMark3(mark));
7030
7028
  }
7031
7029
  }
7032
7030
  return parts.length > 0 ? `<w:rPr>${parts.join("")}</w:rPr>` : "";
7033
7031
  }
7032
+ function serializeRunPropertyMark3(mark) {
7033
+ switch (mark.type) {
7034
+ case "bold":
7035
+ return "<w:b/>";
7036
+ case "italic":
7037
+ return "<w:i/>";
7038
+ case "underline":
7039
+ return `<w:u w:val="single"/>`;
7040
+ case "strikethrough":
7041
+ return "<w:strike/>";
7042
+ case "doubleStrikethrough":
7043
+ return "<w:dstrike/>";
7044
+ case "fontFamily":
7045
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
7046
+ case "fontSize":
7047
+ return `<w:sz w:val="${twip(mark.val)}"/>`;
7048
+ case "textColor":
7049
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
7050
+ case "smallCaps":
7051
+ return "<w:smallCaps/>";
7052
+ case "allCaps":
7053
+ return "<w:caps/>";
7054
+ default:
7055
+ throw new Error(`Cannot safely serialize ${mark.type} marks in note sub-parts.`);
7056
+ }
7057
+ }
7034
7058
  function compareNoteIds(left, right) {
7035
7059
  return Number.parseInt(left.noteId, 10) - Number.parseInt(right.noteId, 10);
7036
7060
  }
@@ -14825,8 +14849,7 @@ function resolveContentType(path, contentTypes) {
14825
14849
  // src/io/ooxml/parse-bookmark-references.ts
14826
14850
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
14827
14851
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
14828
- var FLD_SIMPLE_INSTR_DOUBLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*"([^"]*)"/gi;
14829
- var FLD_SIMPLE_INSTR_SINGLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*'([^']*)'/gi;
14852
+ var FLD_SIMPLE_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*(["'])([\s\S]*?)\1/gi;
14830
14853
  var TOC_FIELD_RE = /\bTOC\b/;
14831
14854
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
14832
14855
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -14845,21 +14868,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14845
14868
  }
14846
14869
  INSTR_TEXT_RE.lastIndex = 0;
14847
14870
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
14848
- const instrText = m[1] ?? "";
14849
- scanFieldInstruction(instrText, retained, () => {
14850
- retainAllToc = true;
14871
+ retainInstructionReferences(m[1] ?? "", retained, (value) => {
14872
+ retainAllToc = retainAllToc || value;
14851
14873
  });
14852
14874
  }
14853
- FLD_SIMPLE_INSTR_DOUBLE_RE.lastIndex = 0;
14854
- while ((m = FLD_SIMPLE_INSTR_DOUBLE_RE.exec(documentXml)) !== null) {
14855
- scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
14856
- retainAllToc = true;
14857
- });
14858
- }
14859
- FLD_SIMPLE_INSTR_SINGLE_RE.lastIndex = 0;
14860
- while ((m = FLD_SIMPLE_INSTR_SINGLE_RE.exec(documentXml)) !== null) {
14861
- scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
14862
- retainAllToc = true;
14875
+ FLD_SIMPLE_INSTR_RE.lastIndex = 0;
14876
+ while ((m = FLD_SIMPLE_INSTR_RE.exec(documentXml)) !== null) {
14877
+ retainInstructionReferences(m[2] ?? "", retained, (value) => {
14878
+ retainAllToc = retainAllToc || value;
14863
14879
  });
14864
14880
  }
14865
14881
  retainRevisionBoundedBookmarks(documentXml, retained);
@@ -14869,17 +14885,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14869
14885
  retainAll
14870
14886
  };
14871
14887
  }
14872
- function scanFieldInstruction(instrText, retained, retainToc) {
14873
- if (TOC_FIELD_RE.test(instrText)) retainToc();
14888
+ function retainInstructionReferences(instrText, retained, setRetainAllToc) {
14889
+ if (TOC_FIELD_RE.test(instrText)) setRetainAllToc(true);
14874
14890
  REFLIKE_FIELD_RE.lastIndex = 0;
14875
14891
  let r;
14876
14892
  while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
14877
14893
  if (r[1]) retained.add(r[1]);
14878
14894
  }
14879
14895
  }
14880
- function decodeXmlAttribute(value) {
14881
- return value.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
14882
- }
14883
14896
  function retainRevisionBoundedBookmarks(documentXml, retained) {
14884
14897
  const starts = /* @__PURE__ */ new Map();
14885
14898
  BOOKMARK_START_RE.lastIndex = 0;
@@ -15268,7 +15281,7 @@ function parseNumberingXml(xml, context) {
15268
15281
  abstractDefinitions[abstractNumberingId] = {
15269
15282
  abstractNumberingId,
15270
15283
  ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "abstractNum", rawId, childXmlPath) } : {},
15271
- levels: readLevels(child),
15284
+ levels: readLevels(child, context, childXmlPath, rawId),
15272
15285
  ...nsid ? { nsid } : {},
15273
15286
  ...multiLevelType ? { multiLevelType } : {},
15274
15287
  ...tplc ? { tplc } : {},
@@ -15289,7 +15302,7 @@ function parseNumberingXml(xml, context) {
15289
15302
  numberingInstanceId,
15290
15303
  ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "num", rawId, childXmlPath) } : {},
15291
15304
  abstractNumberingId: toCanonicalAbstractNumberingId(rawAbstractId),
15292
- overrides: readOverrides(child)
15305
+ overrides: readOverrides(child, context, childXmlPath, rawId)
15293
15306
  };
15294
15307
  break;
15295
15308
  }
@@ -15310,6 +15323,16 @@ function createNumberingSourceRef(partPath, element, rawId, xmlPath) {
15310
15323
  ...xmlPath !== void 0 ? { xmlPath } : {}
15311
15324
  };
15312
15325
  }
15326
+ function createNumberingChildSourceRef(partPath, element, sourceIdSuffix, xmlPath) {
15327
+ if (partPath === void 0) return void 0;
15328
+ return {
15329
+ sourceId: `part:${partPath}#${sourceIdSuffix}`,
15330
+ partPath,
15331
+ storyKind: "numbering",
15332
+ element,
15333
+ ...xmlPath !== void 0 ? { xmlPath } : {}
15334
+ };
15335
+ }
15313
15336
  function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
15314
15337
  let widthEmu;
15315
15338
  let heightEmu;
@@ -15386,18 +15409,29 @@ function toCanonicalAbstractNumberingId(value) {
15386
15409
  function toCanonicalNumberingInstanceId(value) {
15387
15410
  return value.startsWith("num:") ? value : `num:${value}`;
15388
15411
  }
15389
- function readLevels(abstractNode) {
15412
+ function readLevels(abstractNode, context, abstractXmlPath, rawAbstractId) {
15390
15413
  const levels = [];
15414
+ let levelOrdinal = 0;
15391
15415
  for (const child of abstractNode.children) {
15392
15416
  if (child.type !== "element" || localName(child.name) !== "lvl") {
15393
15417
  continue;
15394
15418
  }
15419
+ levelOrdinal += 1;
15395
15420
  const rawLevel = readStringAttr(child, "w:ilvl");
15396
15421
  const level = rawLevel === void 0 ? void 0 : parseInteger(rawLevel);
15397
15422
  if (level === void 0) {
15398
15423
  continue;
15399
15424
  }
15400
- const definition = readLevelDefinition(child, level);
15425
+ const definition = readLevelDefinition(
15426
+ child,
15427
+ level,
15428
+ createNumberingChildSourceRef(
15429
+ context?.partPath,
15430
+ "lvl",
15431
+ `abstractNum:${rawAbstractId}:lvl:${level}`,
15432
+ `${abstractXmlPath}/lvl[${levelOrdinal}]`
15433
+ )
15434
+ );
15401
15435
  if (!definition) {
15402
15436
  continue;
15403
15437
  }
@@ -15405,12 +15439,14 @@ function readLevels(abstractNode) {
15405
15439
  }
15406
15440
  return levels.sort((left, right) => left.level - right.level);
15407
15441
  }
15408
- function readOverrides(numNode) {
15442
+ function readOverrides(numNode, context, numXmlPath, rawNumId) {
15409
15443
  const overrides = [];
15444
+ let overrideOrdinal = 0;
15410
15445
  for (const child of numNode.children) {
15411
15446
  if (child.type !== "element" || localName(child.name) !== "lvlOverride") {
15412
15447
  continue;
15413
15448
  }
15449
+ overrideOrdinal += 1;
15414
15450
  const rawLevel = readStringAttr(child, "w:ilvl");
15415
15451
  const level = rawLevel === void 0 ? void 0 : parseInteger(rawLevel);
15416
15452
  if (level === void 0) {
@@ -15420,8 +15456,26 @@ function readOverrides(numNode) {
15420
15456
  const rawStart = startOverrideNode ? readStringAttr(startOverrideNode, "w:val") : void 0;
15421
15457
  const startAt = rawStart === void 0 ? void 0 : parseInteger(rawStart);
15422
15458
  const levelDefinitionNode = findChildElementOptional2(child, "lvl");
15423
- const levelDefinition = levelDefinitionNode ? readLevelOverrideDefinition(levelDefinitionNode, level) : void 0;
15459
+ const overrideXmlPath = `${numXmlPath}/lvlOverride[${overrideOrdinal}]`;
15460
+ const levelDefinition = levelDefinitionNode ? readLevelOverrideDefinition(
15461
+ levelDefinitionNode,
15462
+ level,
15463
+ createNumberingChildSourceRef(
15464
+ context?.partPath,
15465
+ "lvl",
15466
+ `num:${rawNumId}:lvlOverride:${level}:lvl`,
15467
+ `${overrideXmlPath}/lvl[1]`
15468
+ )
15469
+ ) : void 0;
15424
15470
  overrides.push({
15471
+ ...context?.partPath !== void 0 ? {
15472
+ sourceRef: createNumberingChildSourceRef(
15473
+ context.partPath,
15474
+ "lvlOverride",
15475
+ `num:${rawNumId}:lvlOverride:${level}`,
15476
+ overrideXmlPath
15477
+ )
15478
+ } : {},
15425
15479
  level,
15426
15480
  ...startAt !== void 0 ? { startAt } : {},
15427
15481
  ...levelDefinition ? { levelDefinition } : {}
@@ -15429,7 +15483,7 @@ function readOverrides(numNode) {
15429
15483
  }
15430
15484
  return overrides.sort((left, right) => left.level - right.level);
15431
15485
  }
15432
- function readLevelDefinition(levelNode, fallbackLevel) {
15486
+ function readLevelDefinition(levelNode, fallbackLevel, sourceRef) {
15433
15487
  const rawLevel = readStringAttr(levelNode, "w:ilvl");
15434
15488
  const level = rawLevel === void 0 ? fallbackLevel : parseInteger(rawLevel);
15435
15489
  if (level === void 0) {
@@ -15459,6 +15513,7 @@ function readLevelDefinition(levelNode, fallbackLevel) {
15459
15513
  const lvlPicBulletNode = findChildElementOptional2(levelNode, "lvlPicBulletId");
15460
15514
  const picBulletId = lvlPicBulletNode ? readStringAttr(lvlPicBulletNode, "w:val") : void 0;
15461
15515
  return {
15516
+ ...sourceRef ? { sourceRef } : {},
15462
15517
  level,
15463
15518
  format,
15464
15519
  text,
@@ -15472,7 +15527,7 @@ function readLevelDefinition(levelNode, fallbackLevel) {
15472
15527
  ...picBulletId !== void 0 ? { picBulletId } : {}
15473
15528
  };
15474
15529
  }
15475
- function readLevelOverrideDefinition(levelNode, fallbackLevel) {
15530
+ function readLevelOverrideDefinition(levelNode, fallbackLevel, sourceRef) {
15476
15531
  const rawLevel = readStringAttr(levelNode, "w:ilvl");
15477
15532
  const level = rawLevel === void 0 ? fallbackLevel : parseInteger(rawLevel);
15478
15533
  if (level === void 0) {
@@ -15506,6 +15561,7 @@ function readLevelOverrideDefinition(levelNode, fallbackLevel) {
15506
15561
  return void 0;
15507
15562
  }
15508
15563
  return {
15564
+ ...sourceRef ? { sourceRef } : {},
15509
15565
  level,
15510
15566
  ...startAt !== void 0 ? { startAt } : {},
15511
15567
  ...format !== void 0 ? { format } : {},