@beyondwork/docx-react-component 1.0.121 → 1.0.123

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 (102) hide show
  1. package/dist/api/public-types.cjs +318 -32
  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 +3 -3
  5. package/dist/api/v3.cjs +349 -62
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{canonical-document-ByIqTd4s.d.cts → canonical-document-CG2TgAzj.d.cts} +1 -1
  10. package/dist/{canonical-document-ByIqTd4s.d.ts → canonical-document-CG2TgAzj.d.ts} +1 -1
  11. package/dist/{chunk-B4YHWFE3.js → chunk-32ZAOQ54.js} +1 -1
  12. package/dist/{chunk-QNGJRZ2D.js → chunk-4IPEZYQX.js} +1 -1
  13. package/dist/{chunk-3OFSP2IX.js → chunk-BOHHIVQ2.js} +3 -3
  14. package/dist/{chunk-EMDH4IQN.js → chunk-E5IBDE5E.js} +4 -3
  15. package/dist/{chunk-TFSXOIAI.js → chunk-FNWKE74J.js} +43 -3
  16. package/dist/{chunk-IT2DK3A7.js → chunk-H2YQKA55.js} +9 -7
  17. package/dist/{chunk-3TUQCHYT.js → chunk-H6IL5ABU.js} +47 -7
  18. package/dist/{chunk-GON2DNTE.js → chunk-HXHQA4BU.js} +1 -1
  19. package/dist/{chunk-3OHVK2D6.js → chunk-IR7QV2BX.js} +17 -1
  20. package/dist/{chunk-ZKSDVHGH.js → chunk-KOHQFZMM.js} +1 -1
  21. package/dist/{chunk-XVFENXLK.js → chunk-LGWNN3L2.js} +2 -2
  22. package/dist/{chunk-TMU7JMXX.js → chunk-MB7RJBSN.js} +9 -21
  23. package/dist/{chunk-UWDWGQH5.js → chunk-ML4A4WUN.js} +1 -1
  24. package/dist/{chunk-GZW2ERUO.js → chunk-N4VIXI2Z.js} +3 -3
  25. package/dist/{chunk-S4ANOS2M.js → chunk-NNPVA5VL.js} +2 -2
  26. package/dist/{chunk-QFU7ZOAD.js → chunk-PFYUJU3Q.js} +176 -36
  27. package/dist/{chunk-37SEJQ3G.js → chunk-RSYN6FTS.js} +2 -2
  28. package/dist/{chunk-OBCP6VTG.js → chunk-RWERZWHR.js} +1 -1
  29. package/dist/{chunk-UHQOUTAX.js → chunk-SGSJ4DQA.js} +377 -50
  30. package/dist/{chunk-PCXTMEGY.js → chunk-UHJLCPLU.js} +24 -14
  31. package/dist/{chunk-G3B2OBCZ.js → chunk-ZRHLLPSJ.js} +271 -26
  32. package/dist/compare.d.cts +1 -1
  33. package/dist/compare.d.ts +1 -1
  34. package/dist/core/commands/formatting-commands.d.cts +2 -2
  35. package/dist/core/commands/formatting-commands.d.ts +2 -2
  36. package/dist/core/commands/image-commands.cjs +50 -9
  37. package/dist/core/commands/image-commands.d.cts +2 -2
  38. package/dist/core/commands/image-commands.d.ts +2 -2
  39. package/dist/core/commands/image-commands.js +5 -5
  40. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  41. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  42. package/dist/core/commands/style-commands.d.cts +2 -2
  43. package/dist/core/commands/style-commands.d.ts +2 -2
  44. package/dist/core/commands/table-structure-commands.cjs +50 -9
  45. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  46. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  47. package/dist/core/commands/table-structure-commands.js +4 -4
  48. package/dist/core/commands/text-commands.cjs +66 -9
  49. package/dist/core/commands/text-commands.d.cts +3 -2
  50. package/dist/core/commands/text-commands.d.ts +3 -2
  51. package/dist/core/commands/text-commands.js +5 -5
  52. package/dist/core/selection/mapping.d.cts +2 -2
  53. package/dist/core/selection/mapping.d.ts +2 -2
  54. package/dist/core/state/editor-state.d.cts +2 -2
  55. package/dist/core/state/editor-state.d.ts +2 -2
  56. package/dist/index.cjs +1196 -197
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +278 -85
  60. package/dist/io/docx-session.cjs +10 -21
  61. package/dist/io/docx-session.d.cts +4 -4
  62. package/dist/io/docx-session.d.ts +4 -4
  63. package/dist/io/docx-session.js +4 -4
  64. package/dist/legal.cjs +8 -20
  65. package/dist/legal.d.cts +1 -1
  66. package/dist/legal.d.ts +1 -1
  67. package/dist/legal.js +3 -3
  68. package/dist/{loader-BF8ju_LK.d.ts → loader-D9KCtj4m.d.cts} +4 -22
  69. package/dist/{loader-g54WRvj1.d.cts → loader-D9y4ZRjj.d.ts} +4 -22
  70. package/dist/{public-types-Dl1jiWjk.d.ts → public-types-CNnMHZM9.d.ts} +263 -213
  71. package/dist/{public-types-D_y4Ptcj.d.cts → public-types-DajNGKV4.d.cts} +263 -213
  72. package/dist/public-types.cjs +318 -32
  73. package/dist/public-types.d.cts +2 -2
  74. package/dist/public-types.d.ts +2 -2
  75. package/dist/public-types.js +3 -3
  76. package/dist/runtime/collab.d.cts +3 -3
  77. package/dist/runtime/collab.d.ts +3 -3
  78. package/dist/runtime/document-runtime.cjs +752 -77
  79. package/dist/runtime/document-runtime.d.cts +2 -2
  80. package/dist/runtime/document-runtime.d.ts +2 -2
  81. package/dist/runtime/document-runtime.js +14 -14
  82. package/dist/{session-C1EPAkcI.d.ts → session-DEmaOEjA.d.ts} +3 -3
  83. package/dist/{session-D15QOO0Q.d.cts → session-DyQGlryH.d.cts} +3 -3
  84. package/dist/session.cjs +12 -618
  85. package/dist/session.d.cts +5 -5
  86. package/dist/session.d.ts +5 -5
  87. package/dist/session.js +7 -9
  88. package/dist/tailwind.cjs +489 -63
  89. package/dist/tailwind.d.cts +2 -2
  90. package/dist/tailwind.d.ts +2 -2
  91. package/dist/tailwind.js +7 -7
  92. package/dist/{types-BoSRp2Vg.d.cts → types-CxE1aZiv.d.cts} +2 -2
  93. package/dist/{types-DEvRwq9C.d.ts → types-DjJNaE9c.d.ts} +2 -2
  94. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  95. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  96. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  97. package/dist/ui-tailwind/theme/tokens.css +387 -0
  98. package/dist/ui-tailwind.cjs +489 -63
  99. package/dist/ui-tailwind.d.cts +3 -3
  100. package/dist/ui-tailwind.d.ts +3 -3
  101. package/dist/ui-tailwind.js +7 -7
  102. package/package.json +7 -3
package/dist/tailwind.cjs CHANGED
@@ -880,14 +880,13 @@ var TOOLBAR_CHROME_REGISTRY = [
880
880
  surfaces: ["top-toolbar"],
881
881
  group: "text",
882
882
  presets: ["advanced", "review", "workflow"],
883
- roles: ALL_ROLES,
883
+ roles: EDITOR_AND_REVIEW,
884
884
  fullPlacement: "inline",
885
885
  compactPlacement: "overflow",
886
886
  runtimeBehavior: "formatting",
887
887
  rolePlacement: {
888
888
  editor: "inline",
889
- review: "inline",
890
- workflow: "overflow"
889
+ review: "overflow"
891
890
  }
892
891
  },
893
892
  {
@@ -895,14 +894,13 @@ var TOOLBAR_CHROME_REGISTRY = [
895
894
  surfaces: ["top-toolbar"],
896
895
  group: "text",
897
896
  presets: ["simple", "advanced", "review", "workflow"],
898
- roles: ALL_ROLES,
897
+ roles: EDITOR_AND_REVIEW,
899
898
  fullPlacement: "inline",
900
899
  compactPlacement: "inline",
901
900
  runtimeBehavior: "formatting",
902
901
  rolePlacement: {
903
902
  editor: "inline",
904
- review: "inline",
905
- workflow: "overflow"
903
+ review: "overflow"
906
904
  }
907
905
  },
908
906
  {
@@ -1029,10 +1027,9 @@ var TOOLBAR_CHROME_REGISTRY = [
1029
1027
  surfaces: ["top-toolbar"],
1030
1028
  group: "review",
1031
1029
  presets: ["simple", "advanced", "review", "workflow"],
1032
- // Visible in every role, but editor/review roles render it inside the
1033
- // role action region (see ROLE_ACTION_SETS) and the right cluster
1034
- // suppresses it via `isChromeItemOwnedByRoleRegion` to avoid duplication.
1035
- roles: ALL_ROLES,
1030
+ // Comment authoring belongs to Edit / Review. Workflow mode keeps scope
1031
+ // and work-item controls primary instead of carrying review chrome.
1032
+ roles: EDITOR_AND_REVIEW,
1036
1033
  fullPlacement: "inline",
1037
1034
  compactPlacement: "inline",
1038
1035
  runtimeBehavior: "comment"
@@ -2598,12 +2595,16 @@ function TwToolbar(props) {
2598
2595
  const showUpdateActions = isToolbarChromeItemVisible(scopedChromePolicy, "update-actions");
2599
2596
  const showSidebarToggle = (props.showSidebarToggle ?? false) && isToolbarChromeItemVisible(scopedChromePolicy, "sidebar-toggle");
2600
2597
  const showStyleSelectorsInRow = getToolbarChromePlacement(scopedChromePolicy, "text-style-selectors") === "inline";
2598
+ const showStyleSelectorsInOverflow = getToolbarChromePlacement(scopedChromePolicy, "text-style-selectors") === "overflow";
2599
+ const showInlineFormattingInOverflow = getToolbarChromePlacement(scopedChromePolicy, "inline-formatting") === "overflow";
2600
+ const showTextColorsInOverflow = getToolbarChromePlacement(scopedChromePolicy, "text-colors") === "overflow";
2601
+ const showParagraphAlignmentInOverflow = getToolbarChromePlacement(scopedChromePolicy, "paragraph-alignment") === "overflow";
2601
2602
  const showListActionsInRow = getToolbarChromePlacement(scopedChromePolicy, "list-actions") === "inline";
2602
2603
  const showSpacingActionsInRow = getToolbarChromePlacement(scopedChromePolicy, "indentation") === "inline";
2603
2604
  const showListContinuationInRow = getToolbarChromePlacement(scopedChromePolicy, "list-continuation") === "inline";
2604
2605
  const showInsertActionsInRow = getToolbarChromePlacement(scopedChromePolicy, "insert-actions") === "inline";
2605
2606
  const showUpdateActionsInRow = getToolbarChromePlacement(scopedChromePolicy, "update-actions") === "inline";
2606
- const showCompactOverflow = getToolbarChromePlacement(scopedChromePolicy, "text-style-selectors") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "list-actions") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "indentation") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "list-continuation") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "insert-actions") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "update-actions") === "overflow";
2607
+ const showCompactOverflow = getToolbarChromePlacement(scopedChromePolicy, "text-style-selectors") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "inline-formatting") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "text-colors") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "paragraph-alignment") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "list-actions") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "indentation") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "list-continuation") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "insert-actions") === "overflow" || getToolbarChromePlacement(scopedChromePolicy, "update-actions") === "overflow";
2607
2608
  const showPostFormattingDivider = showListActionsInRow || showSpacingActionsInRow || showInsertActionsInRow || showUpdateActionsInRow || showCompactOverflow;
2608
2609
  const zoomLabel = typeof zoomLevel === "number" ? `${zoomLevel}%` : zoomLevel === "pageWidth" ? "Fit width" : "Fit page";
2609
2610
  const showZoomSteppers = responsiveTier === "wide";
@@ -2898,14 +2899,26 @@ function TwToolbar(props) {
2898
2899
  insertDisabledReason,
2899
2900
  paragraphStyles,
2900
2901
  showInsertMenu: getToolbarChromePlacement(scopedChromePolicy, "insert-actions") === "overflow",
2902
+ showInlineFormatting: showInlineFormattingInOverflow,
2901
2903
  showListActions: getToolbarChromePlacement(scopedChromePolicy, "list-actions") === "overflow",
2902
2904
  showParagraphActions: getToolbarChromePlacement(scopedChromePolicy, "indentation") === "overflow",
2905
+ showParagraphAlignment: showParagraphAlignmentInOverflow,
2903
2906
  showListContinuation: getToolbarChromePlacement(scopedChromePolicy, "list-continuation") === "overflow",
2904
- showStyleSelectors: getToolbarChromePlacement(scopedChromePolicy, "text-style-selectors") === "overflow",
2907
+ showStyleSelectors: showStyleSelectorsInOverflow,
2908
+ showTextColors: showTextColorsInOverflow,
2905
2909
  showUpdateActions: getToolbarChromePlacement(scopedChromePolicy, "update-actions") === "overflow",
2906
2910
  onSetParagraphStyle: props.onSetParagraphStyle,
2907
2911
  onSetFontFamily: props.onSetFontFamily,
2908
2912
  onSetFontSize: props.onSetFontSize,
2913
+ onToggleBold: props.onToggleBold,
2914
+ onToggleItalic: props.onToggleItalic,
2915
+ onToggleUnderline: props.onToggleUnderline,
2916
+ onToggleStrikethrough: props.onToggleStrikethrough,
2917
+ onToggleSuperscript: props.onToggleSuperscript,
2918
+ onToggleSubscript: props.onToggleSubscript,
2919
+ onSetTextColor: props.onSetTextColor,
2920
+ onSetHighlightColor: props.onSetHighlightColor,
2921
+ onSetAlignment: props.onSetAlignment,
2909
2922
  onToggleBulletedList: props.onToggleBulletedList,
2910
2923
  onToggleNumberedList: props.onToggleNumberedList,
2911
2924
  onOutdent: props.onOutdent,
@@ -3415,8 +3428,8 @@ function ToolbarFontSizeSelect(props) {
3415
3428
  function ToolbarCompactOverflow(props) {
3416
3429
  const [open, setOpen] = import_react4.default.useState(false);
3417
3430
  const overflowGroups = [
3418
- props.showStyleSelectors ? "Format" : null,
3419
- props.showListActions || props.showParagraphActions || props.showListContinuation ? "Paragraph" : null,
3431
+ props.showStyleSelectors || props.showInlineFormatting || props.showTextColors ? "Format" : null,
3432
+ props.showListActions || props.showParagraphActions || props.showParagraphAlignment || props.showListContinuation ? "Paragraph" : null,
3420
3433
  props.showInsertMenu ? "Insert" : null,
3421
3434
  props.showUpdateActions ? "Update" : null
3422
3435
  ].filter((label) => Boolean(label));
@@ -3501,6 +3514,129 @@ function ToolbarCompactOverflow(props) {
3501
3514
  ] })
3502
3515
  ] })
3503
3516
  ] }) : null,
3517
+ props.showInlineFormatting || props.showTextColors ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1", children: [
3518
+ !props.showStyleSelectors ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "px-1 text-[10px] font-semibold uppercase tracking-[var(--tracking-status)] text-tertiary", children: "Text" }) : null,
3519
+ props.showInlineFormatting ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3520
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3521
+ ToolbarMenuButton,
3522
+ {
3523
+ ariaLabel: "Bold",
3524
+ disabled: !props.canEdit || !props.onToggleBold,
3525
+ disabledReason: props.editDisabledReason,
3526
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Bold, { className: "h-3.5 w-3.5" }),
3527
+ label: "Bold",
3528
+ onClick: () => {
3529
+ props.onToggleBold?.();
3530
+ setOpen(false);
3531
+ }
3532
+ }
3533
+ ),
3534
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3535
+ ToolbarMenuButton,
3536
+ {
3537
+ ariaLabel: "Italic",
3538
+ disabled: !props.canEdit || !props.onToggleItalic,
3539
+ disabledReason: props.editDisabledReason,
3540
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Italic, { className: "h-3.5 w-3.5" }),
3541
+ label: "Italic",
3542
+ onClick: () => {
3543
+ props.onToggleItalic?.();
3544
+ setOpen(false);
3545
+ }
3546
+ }
3547
+ ),
3548
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3549
+ ToolbarMenuButton,
3550
+ {
3551
+ ariaLabel: "Underline",
3552
+ disabled: !props.canEdit || !props.onToggleUnderline,
3553
+ disabledReason: props.editDisabledReason,
3554
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Underline, { className: "h-3.5 w-3.5" }),
3555
+ label: "Underline",
3556
+ onClick: () => {
3557
+ props.onToggleUnderline?.();
3558
+ setOpen(false);
3559
+ }
3560
+ }
3561
+ ),
3562
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3563
+ ToolbarMenuButton,
3564
+ {
3565
+ ariaLabel: "Strikethrough",
3566
+ disabled: !props.canEdit || !props.onToggleStrikethrough,
3567
+ disabledReason: props.editDisabledReason,
3568
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Strikethrough, { className: "h-3.5 w-3.5" }),
3569
+ label: "Strikethrough",
3570
+ onClick: () => {
3571
+ props.onToggleStrikethrough?.();
3572
+ setOpen(false);
3573
+ }
3574
+ }
3575
+ ),
3576
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3577
+ ToolbarMenuButton,
3578
+ {
3579
+ ariaLabel: "Superscript",
3580
+ disabled: !props.canEdit || !props.onToggleSuperscript,
3581
+ disabledReason: props.editDisabledReason,
3582
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Superscript, { className: "h-3.5 w-3.5" }),
3583
+ label: "Superscript",
3584
+ onClick: () => {
3585
+ props.onToggleSuperscript?.();
3586
+ setOpen(false);
3587
+ }
3588
+ }
3589
+ ),
3590
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3591
+ ToolbarMenuButton,
3592
+ {
3593
+ ariaLabel: "Subscript",
3594
+ disabled: !props.canEdit || !props.onToggleSubscript,
3595
+ disabledReason: props.editDisabledReason,
3596
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Subscript, { className: "h-3.5 w-3.5" }),
3597
+ label: "Subscript",
3598
+ onClick: () => {
3599
+ props.onToggleSubscript?.();
3600
+ setOpen(false);
3601
+ }
3602
+ }
3603
+ )
3604
+ ] }) : null,
3605
+ props.showTextColors ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "grid grid-cols-2 gap-2 px-1 pt-1", children: [
3606
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3607
+ ToolbarColorPopover,
3608
+ {
3609
+ ariaLabel: "Text color",
3610
+ colors: TEXT_COLORS.map((value) => ({ value, label: value })),
3611
+ disabled: !props.canEdit || !props.onSetTextColor,
3612
+ disabledReason: props.editDisabledReason,
3613
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Baseline, { className: "h-3.5 w-3.5" }),
3614
+ onSelect: (value) => {
3615
+ if (value) {
3616
+ props.onSetTextColor?.(value);
3617
+ setOpen(false);
3618
+ }
3619
+ },
3620
+ title: "Text color"
3621
+ }
3622
+ ),
3623
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3624
+ ToolbarColorPopover,
3625
+ {
3626
+ ariaLabel: "Highlight color",
3627
+ colors: HIGHLIGHT_COLORS.map((entry) => ({ value: entry.value, label: entry.label })),
3628
+ disabled: !props.canEdit || !props.onSetHighlightColor,
3629
+ disabledReason: props.editDisabledReason,
3630
+ icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Highlighter, { className: "h-3.5 w-3.5" }),
3631
+ onSelect: (value) => {
3632
+ props.onSetHighlightColor?.(value);
3633
+ setOpen(false);
3634
+ },
3635
+ title: "Highlight color"
3636
+ }
3637
+ )
3638
+ ] }) : null
3639
+ ] }) : null,
3504
3640
  props.showListActions ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1", children: [
3505
3641
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "px-1 text-[10px] font-semibold uppercase tracking-[var(--tracking-status)] text-tertiary", children: "Structure" }),
3506
3642
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -3532,8 +3668,20 @@ function ToolbarCompactOverflow(props) {
3532
3668
  }
3533
3669
  )
3534
3670
  ] }) : null,
3535
- props.showParagraphActions || props.showListContinuation && props.activeListContext ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1", children: [
3671
+ props.showParagraphActions || props.showParagraphAlignment || props.showListContinuation && props.activeListContext ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1", children: [
3536
3672
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "px-1 text-[10px] font-semibold uppercase tracking-[var(--tracking-status)] text-tertiary", children: "Paragraph" }),
3673
+ props.showParagraphAlignment ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "px-1 pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3674
+ ToolbarAlignmentPopover,
3675
+ {
3676
+ activeAlignment: props.formattingState?.alignment,
3677
+ disabled: !props.canEdit || !props.onSetAlignment,
3678
+ disabledReason: props.editDisabledReason,
3679
+ onSelect: (alignment) => {
3680
+ props.onSetAlignment?.(alignment);
3681
+ setOpen(false);
3682
+ }
3683
+ }
3684
+ ) }) : null,
3537
3685
  props.showParagraphActions ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3538
3686
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3539
3687
  ToolbarMenuButton,
@@ -7253,12 +7401,13 @@ function buildBlockCacheSignature(context, blockIndex) {
7253
7401
  owner?.targetKey ?? ""
7254
7402
  ].join("|");
7255
7403
  }
7256
- function collectEditableTargetsInBlocks(blocks, context, targets, cache) {
7404
+ function collectEditableTargetsInBlocks(blocks, context, targets, cache, blockIndexOffset = 0) {
7257
7405
  for (let blockIndex = 0; blockIndex < blocks.length; blockIndex += 1) {
7258
7406
  const block = blocks[blockIndex];
7259
7407
  if (!block) continue;
7260
- const blockPath = `${context.basePath}/block[${blockIndex}]`;
7261
- const signature = cache !== void 0 ? buildBlockCacheSignature(context, blockIndex) : "";
7408
+ const absoluteBlockIndex = blockIndex + blockIndexOffset;
7409
+ const blockPath = `${context.basePath}/block[${absoluteBlockIndex}]`;
7410
+ const signature = cache !== void 0 ? buildBlockCacheSignature(context, absoluteBlockIndex) : "";
7262
7411
  if (cache !== void 0) {
7263
7412
  const cached = cache.get(block);
7264
7413
  if (cached !== void 0 && cached.blockPath === blockPath && cached.signature === signature) {
@@ -12127,6 +12276,8 @@ function createSurfaceBlock(block, document2, cursor, counters, formattingContex
12127
12276
  formattingContext,
12128
12277
  promoteSecondaryStoryTextBoxes,
12129
12278
  cullBuild,
12279
+ editableTargetsByBlockPath,
12280
+ blockPath,
12130
12281
  blockPath !== void 0 ? editableTargetsByBlockPath.get(blockPath) : void 0
12131
12282
  );
12132
12283
  }
@@ -12533,7 +12684,7 @@ function getRecursableSdtBlockedReasonCode(block) {
12533
12684
  ].filter(Boolean).join(" ").toLowerCase();
12534
12685
  return searchText.includes("table of contents") || /\btoc\b/u.test(searchText) ? "workflow_preserve_only" : null;
12535
12686
  }
12536
- function createParagraphBlock(paragraphIndex, paragraph, document2, start, formattingContext, promoteSecondaryStoryTextBoxes, cullBuild = false, editableTarget) {
12687
+ function createParagraphBlock(paragraphIndex, paragraph, document2, start, formattingContext, promoteSecondaryStoryTextBoxes, cullBuild = false, editableTargetsByBlockPath = EMPTY_EDITABLE_TARGETS_BY_BLOCK_PATH, blockPath, editableTarget) {
12537
12688
  const themeResolver = formattingContext.theme;
12538
12689
  const effectiveNumbering = formattingContext.resolveEffectiveParagraphNumbering(paragraph);
12539
12690
  let resolvedNumbering = null;
@@ -12598,6 +12749,8 @@ function createParagraphBlock(paragraphIndex, paragraph, document2, start, forma
12598
12749
  document2,
12599
12750
  cursor,
12600
12751
  promoteSecondaryStoryTextBoxes,
12752
+ blockPath !== void 0 ? `${blockPath}/inline[${childIndex}]` : void 0,
12753
+ editableTargetsByBlockPath,
12601
12754
  void 0,
12602
12755
  cullBuild,
12603
12756
  themeResolver,
@@ -12654,7 +12807,7 @@ function isVisibleTocResultInline(node) {
12654
12807
  return false;
12655
12808
  }
12656
12809
  }
12657
- function appendInlineSegments(paragraph, node, document2, start, promoteSecondaryStoryTextBoxes, hyperlinkHref, cullBuild = false, themeResolver, formattingContext) {
12810
+ function appendInlineSegments(paragraph, node, document2, start, promoteSecondaryStoryTextBoxes, inlinePath, editableTargetsByBlockPath = EMPTY_EDITABLE_TARGETS_BY_BLOCK_PATH, hyperlinkHref, cullBuild = false, themeResolver, formattingContext) {
12658
12811
  switch (node.type) {
12659
12812
  case "text": {
12660
12813
  const cloned = node.marks ? cloneMarks2(node.marks) : { marks: [] };
@@ -12707,13 +12860,16 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
12707
12860
  return { nextCursor: start + 1, lockedFragmentIds: [] };
12708
12861
  case "hyperlink": {
12709
12862
  let cursor = start;
12710
- for (const child of node.children) {
12863
+ for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {
12864
+ const child = node.children[childIndex];
12711
12865
  const result = appendInlineSegments(
12712
12866
  paragraph,
12713
12867
  child,
12714
12868
  document2,
12715
12869
  cursor,
12716
12870
  promoteSecondaryStoryTextBoxes,
12871
+ inlinePath !== void 0 ? `${inlinePath}/child[${childIndex}]` : void 0,
12872
+ editableTargetsByBlockPath,
12717
12873
  node.href,
12718
12874
  cullBuild,
12719
12875
  themeResolver,
@@ -12772,6 +12928,33 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
12772
12928
  if (isMicrosoftSensitivityLabelShape(node)) {
12773
12929
  return { nextCursor: start + 1, lockedFragmentIds: [] };
12774
12930
  }
12931
+ if (node.isTextBox && node.txbxBlocks !== void 0) {
12932
+ const txbxTextSegment = extractTxbxFirstTextSegment(node.txbxBlocks);
12933
+ const txbxText = txbxTextSegment?.text ?? node.text;
12934
+ const txbxBody = surfaceTextBoxBodyFromShape(
12935
+ node,
12936
+ void 0,
12937
+ inlinePath,
12938
+ editableTargetsByBlockPath
12939
+ );
12940
+ paragraph.segments.push({
12941
+ segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
12942
+ kind: "shape",
12943
+ from: start,
12944
+ to: start + 1,
12945
+ label: "Text box",
12946
+ detail: createShapeDetail(node),
12947
+ ...node.geometry !== void 0 ? { geometry: node.geometry } : {},
12948
+ isTextBox: true,
12949
+ ...node.textBoxBody ? { textBoxBody: node.textBoxBody } : {},
12950
+ ...node.preserveOnlyObject ? { preserveOnlyObject: surfacePreserveOnlyObject(node.preserveOnlyObject) } : {},
12951
+ ...txbxText ? { txbxText } : {},
12952
+ ...txbxBody ? { txbxBody } : {},
12953
+ ...txbxTextSegment?.marks && txbxTextSegment.marks.length > 0 ? { txbxMarks: txbxTextSegment.marks } : {},
12954
+ ...txbxTextSegment?.markAttrs ? { txbxMarkAttrs: txbxTextSegment.markAttrs } : {}
12955
+ });
12956
+ return { nextCursor: start + 1, lockedFragmentIds: [] };
12957
+ }
12775
12958
  if (promoteSecondaryStoryTextBoxes && node.isTextBox && node.text) {
12776
12959
  return appendTextBoxSegment(
12777
12960
  paragraph,
@@ -12831,7 +13014,7 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
12831
13014
  const anchor = surfaceAnchorFromGeometry(node.anchor);
12832
13015
  const txbxTextSegment = c.isTextBox ? extractTxbxFirstTextSegment(c.txbxBlocks) : void 0;
12833
13016
  const txbxText = txbxTextSegment?.text ?? (c.isTextBox ? c.text : void 0);
12834
- const txbxBody = c.isTextBox ? surfaceTextBoxBodyFromShape(c, node.sourceRef) : void 0;
13017
+ const txbxBody = c.isTextBox ? surfaceTextBoxBodyFromShape(c, node.sourceRef, inlinePath, editableTargetsByBlockPath) : void 0;
12835
13018
  const surfaceFill = c.fill;
12836
13019
  paragraph.segments.push({
12837
13020
  segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
@@ -13008,13 +13191,16 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
13008
13191
  const refHyperlinkHref = (node.fieldFamily === "REF" || node.fieldFamily === "PAGEREF" || node.fieldFamily === "NOTEREF") && node.switches?.hyperlink === true && node.fieldTarget ? `#${node.fieldTarget}` : void 0;
13009
13192
  let cursor = start;
13010
13193
  const lockedIds = [];
13011
- for (const child of node.children) {
13194
+ for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {
13195
+ const child = node.children[childIndex];
13012
13196
  const result = appendInlineSegments(
13013
13197
  paragraph,
13014
13198
  child,
13015
13199
  document2,
13016
13200
  cursor,
13017
13201
  promoteSecondaryStoryTextBoxes,
13202
+ inlinePath !== void 0 ? `${inlinePath}/child[${childIndex}]` : void 0,
13203
+ editableTargetsByBlockPath,
13018
13204
  refHyperlinkHref ?? hyperlinkHref,
13019
13205
  cullBuild,
13020
13206
  themeResolver,
@@ -13261,7 +13447,7 @@ function extractTxbxFirstTextSegment(blocks) {
13261
13447
  }
13262
13448
  return void 0;
13263
13449
  }
13264
- function surfaceTextBoxBodyFromShape(shape, sourceRef) {
13450
+ function surfaceTextBoxBodyFromShape(shape, sourceRef, inlinePath, editableTargetsByBlockPath = EMPTY_EDITABLE_TARGETS_BY_BLOCK_PATH) {
13265
13451
  if (!shape.isTextBox && shape.txbxContentXml === void 0 && shape.txbxBlocks === void 0) {
13266
13452
  return void 0;
13267
13453
  }
@@ -13287,9 +13473,12 @@ function surfaceTextBoxBodyFromShape(shape, sourceRef) {
13287
13473
  (run, inlineIndex) => surfaceTextBoxRunFromLegacyRun(run, inlineIndex)
13288
13474
  ) ?? [];
13289
13475
  const text = runs.map((run) => run.text ?? "").join("");
13476
+ const blockPath = inlinePath !== void 0 ? `${inlinePath}/txbx/block[${blockIndex}]` : void 0;
13477
+ const editableTarget = blockPath !== void 0 ? editableTargetsByBlockPath.get(blockPath) : void 0;
13290
13478
  return [{
13291
13479
  ...block.sourceRef !== void 0 ? { sourceRef: block.sourceRef } : {},
13292
13480
  blockIndex,
13481
+ ...editableTarget !== void 0 ? { editableTarget } : {},
13293
13482
  text,
13294
13483
  textLength: Array.from(text).length,
13295
13484
  ...block.borders !== void 0 ? { borders: block.borders } : {},
@@ -16557,6 +16746,7 @@ function buildPageGraph(inputOrPages, sectionsArg, storiesArg) {
16557
16746
  regions,
16558
16747
  divergences: frameDivergences,
16559
16748
  subParts: input.subParts,
16749
+ anchors: input.anchors,
16560
16750
  pageFieldCounts
16561
16751
  });
16562
16752
  const divergences = builtFrame.divergences;
@@ -16723,6 +16913,7 @@ function buildPageFrame(input) {
16723
16913
  stories: input.stories,
16724
16914
  regions,
16725
16915
  subParts: input.subParts,
16916
+ anchors: input.anchors,
16726
16917
  pageFieldCounts: input.pageFieldCounts
16727
16918
  });
16728
16919
  const divergences = [...input.divergences, ...pageLocalStoryResult.divergences];
@@ -16760,6 +16951,7 @@ function buildPageLocalStoryInstances(input) {
16760
16951
  input.stories.header,
16761
16952
  input.regions.header,
16762
16953
  findHeaderFooterPart(input.subParts?.headers, input.stories.header),
16954
+ input.anchors,
16763
16955
  input.pageFieldCounts
16764
16956
  );
16765
16957
  instances.push(built.instance);
@@ -16776,6 +16968,7 @@ function buildPageLocalStoryInstances(input) {
16776
16968
  input.stories.footer,
16777
16969
  input.regions.footer,
16778
16970
  findHeaderFooterPart(input.subParts?.footers, input.stories.footer),
16971
+ input.anchors,
16779
16972
  input.pageFieldCounts
16780
16973
  );
16781
16974
  instances.push(built.instance);
@@ -16783,7 +16976,7 @@ function buildPageLocalStoryInstances(input) {
16783
16976
  }
16784
16977
  return { instances, divergences };
16785
16978
  }
16786
- function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, displayPageNumber, layout, target, region, source, pageFieldCounts) {
16979
+ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, displayPageNumber, layout, target, region, source, anchors, pageFieldCounts) {
16787
16980
  const measuredFrameHeightTwips = region?.heightTwips ?? 0;
16788
16981
  const sectionPart = target.sectionIndex === void 0 ? "section-unknown" : `section-${target.sectionIndex}`;
16789
16982
  const instanceId = `${frameId}:${target.kind}:${target.variant}:${target.relationshipId}`;
@@ -16804,7 +16997,9 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
16804
16997
  kind: target.kind,
16805
16998
  variant: target.variant,
16806
16999
  relationshipId: target.relationshipId,
16807
- region
17000
+ region,
17001
+ storyBasePath: `${target.kind}:${source.partPath ?? `word/${target.kind}${target.relationshipId}.xml`}`,
17002
+ anchorsByInlinePath: buildAnchorsByInlinePath(anchors)
16808
17003
  }) : { objects: [], divergences: [] };
16809
17004
  const signature = buildPageLocalStorySignature({
16810
17005
  kind: target.kind,
@@ -16858,6 +17053,23 @@ function buildPageLocalStorySignature(input) {
16858
17053
  object.anchorRectTwips?.yTwips ?? "",
16859
17054
  object.anchorRectTwips?.widthTwips ?? "",
16860
17055
  object.anchorRectTwips?.heightTwips ?? "",
17056
+ object.textBoxBody?.bodyKey ?? "",
17057
+ object.textBoxBody?.status ?? "",
17058
+ object.textBoxBody?.unavailableReason ?? "",
17059
+ object.textBoxBody?.contentRectTwips?.xTwips ?? "",
17060
+ object.textBoxBody?.contentRectTwips?.yTwips ?? "",
17061
+ object.textBoxBody?.contentRectTwips?.widthTwips ?? "",
17062
+ object.textBoxBody?.contentRectTwips?.heightTwips ?? "",
17063
+ object.textBoxBody?.paragraphs.map(
17064
+ (paragraph) => [
17065
+ paragraph.paragraphKey,
17066
+ paragraph.rectTwips?.xTwips ?? "",
17067
+ paragraph.rectTwips?.yTwips ?? "",
17068
+ paragraph.rectTwips?.widthTwips ?? "",
17069
+ paragraph.rectTwips?.heightTwips ?? "",
17070
+ paragraph.unavailableReason ?? ""
17071
+ ].join("/")
17072
+ ).join(",") ?? "",
16861
17073
  object.relationshipIds?.join(",") ?? "",
16862
17074
  object.mediaIds?.join(",") ?? "",
16863
17075
  object.wrapMode ?? "",
@@ -17002,6 +17214,10 @@ function truncatePageLocalStoryPreview(text) {
17002
17214
  if (text.length <= MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS) return text;
17003
17215
  return `${text.slice(0, MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS - 1).trimEnd()}\u2026`;
17004
17216
  }
17217
+ function buildAnchorsByInlinePath(anchors) {
17218
+ if (!anchors || anchors.length === 0) return void 0;
17219
+ return new Map(anchors.map((anchor) => [anchor.inlinePath, anchor]));
17220
+ }
17005
17221
  function collectStoryAnchoredObjects(blocks, context) {
17006
17222
  const objects = [];
17007
17223
  const divergences = [];
@@ -17045,26 +17261,45 @@ function collectStoryAnchoredObjects(blocks, context) {
17045
17261
  });
17046
17262
  ordinal += 1;
17047
17263
  };
17048
- const visitBlock = (block) => {
17264
+ const visitBlocks = (blocksToVisit, basePath) => {
17265
+ for (let blockIndex = 0; blockIndex < blocksToVisit.length; blockIndex += 1) {
17266
+ const block = blocksToVisit[blockIndex];
17267
+ if (!block) continue;
17268
+ visitBlock(block, `${basePath}/block[${blockIndex}]`);
17269
+ }
17270
+ };
17271
+ const visitBlock = (block, blockPath) => {
17049
17272
  switch (block.type) {
17050
17273
  case "paragraph":
17051
- for (const child of block.children) visitInline(child);
17274
+ visitInlines(block.children, blockPath, `${blockPath}/inline`);
17052
17275
  break;
17053
17276
  case "table":
17054
- for (const row of block.rows) {
17055
- for (const cell of row.cells) {
17056
- for (const child of cell.children) visitBlock(child);
17277
+ for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
17278
+ const row = block.rows[rowIndex];
17279
+ if (!row) continue;
17280
+ for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
17281
+ const cell = row.cells[cellIndex];
17282
+ if (!cell) continue;
17283
+ visitBlocks(cell.children, `${blockPath}/row[${rowIndex}]/cell[${cellIndex}]`);
17057
17284
  }
17058
17285
  }
17059
17286
  break;
17060
17287
  case "sdt":
17061
- for (const child of block.children) visitBlock(child);
17288
+ case "custom_xml":
17289
+ visitBlocks(block.children, blockPath);
17062
17290
  break;
17063
17291
  default:
17064
17292
  break;
17065
17293
  }
17066
17294
  };
17067
- const visitInline = (inline) => {
17295
+ const visitInlines = (inlines, blockPath, basePath) => {
17296
+ for (let inlineIndex = 0; inlineIndex < inlines.length; inlineIndex += 1) {
17297
+ const inline = inlines[inlineIndex];
17298
+ if (!inline) continue;
17299
+ visitInline(inline, blockPath, `${basePath}[${inlineIndex}]`);
17300
+ }
17301
+ };
17302
+ const visitInline = (inline, blockPath, inlinePath) => {
17068
17303
  switch (inline.type) {
17069
17304
  case "image": {
17070
17305
  pushObject({
@@ -17085,17 +17320,27 @@ function collectStoryAnchoredObjects(blocks, context) {
17085
17320
  inline.anchor.extent.widthEmu,
17086
17321
  inline.anchor.extent.heightEmu
17087
17322
  );
17323
+ const anchorRectTwips = resolveObjectAnchorRectTwips(
17324
+ context.region,
17325
+ extentTwips,
17326
+ inline.anchor.positionH,
17327
+ inline.anchor.positionV
17328
+ );
17329
+ const canonicalAnchor = context.anchorsByInlinePath?.get(inlinePath);
17330
+ const textBoxBody = buildDrawingFrameTextBoxBodyFacts(
17331
+ inline,
17332
+ canonicalAnchor,
17333
+ inlinePath,
17334
+ display,
17335
+ anchorRectTwips
17336
+ );
17088
17337
  pushObject({
17089
17338
  objectId: getDrawingFrameObjectId(inline, context.storyKey, ordinal),
17090
17339
  sourceType: "drawing-frame",
17091
17340
  display,
17092
17341
  extentTwips,
17093
- anchorRectTwips: resolveObjectAnchorRectTwips(
17094
- context.region,
17095
- extentTwips,
17096
- inline.anchor.positionH,
17097
- inline.anchor.positionV
17098
- ),
17342
+ anchorRectTwips,
17343
+ ...textBoxBody ? { textBoxBody } : {},
17099
17344
  ...relationshipIds.length > 0 ? { relationshipIds } : {},
17100
17345
  ...inline.content.type === "picture" && inline.content.mediaId ? { mediaIds: [inline.content.mediaId] } : {},
17101
17346
  preserveOnly: Boolean(preserveHint),
@@ -17103,7 +17348,7 @@ function collectStoryAnchoredObjects(blocks, context) {
17103
17348
  wrapMode: inline.anchor.wrapMode
17104
17349
  });
17105
17350
  if (inline.content.type === "shape") {
17106
- for (const child of inline.content.txbxBlocks ?? []) visitBlock(child);
17351
+ visitBlocks(inline.content.txbxBlocks ?? [], `${inlinePath}/txbx`);
17107
17352
  }
17108
17353
  break;
17109
17354
  }
@@ -17130,10 +17375,11 @@ function collectStoryAnchoredObjects(blocks, context) {
17130
17375
  } : {},
17131
17376
  ...preserveHint?.relationshipIds ? { relationshipIds: [...preserveHint.relationshipIds] } : {},
17132
17377
  preserveOnly: Boolean(preserveHint),
17133
- ...preserveHint ? { preserveHint } : {}
17378
+ ...preserveHint ? { preserveHint } : {},
17379
+ ...inline.type === "vml_shape" && inline.text ? { textBoxBody: buildUnsupportedVmlTextBoxFacts(inline, inlinePath) } : {}
17134
17380
  });
17135
17381
  if (inline.type === "shape") {
17136
- for (const child of inline.txbxBlocks ?? []) visitBlock(child);
17382
+ visitBlocks(inline.txbxBlocks ?? [], `${inlinePath}/txbx`);
17137
17383
  }
17138
17384
  break;
17139
17385
  }
@@ -17155,16 +17401,16 @@ function collectStoryAnchoredObjects(blocks, context) {
17155
17401
  });
17156
17402
  break;
17157
17403
  case "field":
17158
- for (const child of inline.children) visitInline(child);
17404
+ visitInlines(inline.children, blockPath, `${inlinePath}/child`);
17159
17405
  break;
17160
17406
  case "hyperlink":
17161
- for (const child of inline.children) visitInline(child);
17407
+ visitInlines(inline.children, blockPath, `${inlinePath}/child`);
17162
17408
  break;
17163
17409
  default:
17164
17410
  break;
17165
17411
  }
17166
17412
  };
17167
- for (const block of blocks) visitBlock(block);
17413
+ visitBlocks(blocks, context.storyBasePath);
17168
17414
  return { objects, divergences };
17169
17415
  }
17170
17416
  function getDrawingFramePreserveHint(inline) {
@@ -17172,6 +17418,170 @@ function getDrawingFramePreserveHint(inline) {
17172
17418
  if (content.type === "picture") return void 0;
17173
17419
  return content.preserveOnlyObject;
17174
17420
  }
17421
+ function buildDrawingFrameTextBoxBodyFacts(inline, canonicalAnchor, inlinePath, display, anchorRectTwips) {
17422
+ if (inline.content.type !== "shape") return void 0;
17423
+ const content = inline.content;
17424
+ const canonicalBody = canonicalAnchor?.textBoxBody;
17425
+ const hasTextBoxContent = Boolean(
17426
+ canonicalBody || content.isTextBox || content.textBoxBody || content.txbxBlocks?.length
17427
+ );
17428
+ if (!hasTextBoxContent) return void 0;
17429
+ if (!canonicalBody) {
17430
+ return unavailableTextBoxBodyFacts(
17431
+ `${canonicalAnchor?.objectKey ?? inlinePath}:txbx`,
17432
+ "unmodeled-txbx-blocks",
17433
+ content.textBoxBody,
17434
+ content.txbxBlocks?.length ?? 0,
17435
+ countParagraphBlocks(content.txbxBlocks ?? []),
17436
+ 0
17437
+ );
17438
+ }
17439
+ if (display !== "floating") {
17440
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "inline-textbox");
17441
+ }
17442
+ if (!anchorRectTwips) {
17443
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "missing-anchor-rect");
17444
+ }
17445
+ if (canonicalBody.status !== "modeled") {
17446
+ return unavailableTextBoxBodyFactsFromCanonical(
17447
+ canonicalBody,
17448
+ normalizeTextBoxBodyUnavailableReason(canonicalBody.unavailableReason)
17449
+ );
17450
+ }
17451
+ const bodyInsetsTwips = textBoxInsetsTwips(canonicalBody.bodyProperties);
17452
+ if (!bodyInsetsTwips) {
17453
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "missing-body-insets");
17454
+ }
17455
+ const contentRectTwips = rect(
17456
+ anchorRectTwips.xTwips + bodyInsetsTwips.leftTwips,
17457
+ anchorRectTwips.yTwips + bodyInsetsTwips.topTwips,
17458
+ Math.max(0, anchorRectTwips.widthTwips - bodyInsetsTwips.leftTwips - bodyInsetsTwips.rightTwips),
17459
+ Math.max(0, anchorRectTwips.heightTwips - bodyInsetsTwips.topTwips - bodyInsetsTwips.bottomTwips)
17460
+ );
17461
+ return {
17462
+ bodyKey: canonicalBody.bodyKey,
17463
+ status: "modeled",
17464
+ ...canonicalBody.bodyProperties ? { bodyProperties: { ...canonicalBody.bodyProperties } } : {},
17465
+ bodyInsetsTwips,
17466
+ contentRectTwips,
17467
+ blockCount: canonicalBody.blockCount,
17468
+ paragraphCount: canonicalBody.paragraphCount,
17469
+ unsupportedBlockCount: canonicalBody.unsupportedBlockCount,
17470
+ paragraphs: buildTextBoxParagraphFacts(canonicalBody, contentRectTwips)
17471
+ };
17472
+ }
17473
+ function unavailableTextBoxBodyFactsFromCanonical(body, reason) {
17474
+ return {
17475
+ bodyKey: body.bodyKey,
17476
+ status: body.status === "preserve-only" ? "preserve-only" : "unavailable",
17477
+ unavailableReason: reason,
17478
+ ...body.bodyProperties ? { bodyProperties: { ...body.bodyProperties } } : {},
17479
+ blockCount: body.blockCount,
17480
+ paragraphCount: body.paragraphCount,
17481
+ unsupportedBlockCount: body.unsupportedBlockCount,
17482
+ paragraphs: body.paragraphs.map((paragraph) => ({
17483
+ paragraphKey: paragraph.paragraphKey,
17484
+ blockPath: paragraph.blockPath,
17485
+ blockIndex: paragraph.blockIndex,
17486
+ unavailableReason: reason,
17487
+ ...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
17488
+ ...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
17489
+ textLength: paragraph.textLength,
17490
+ runCount: paragraph.runCount
17491
+ }))
17492
+ };
17493
+ }
17494
+ function unavailableTextBoxBodyFacts(bodyKey, reason, bodyProperties, blockCount, paragraphCount, unsupportedBlockCount) {
17495
+ return {
17496
+ bodyKey,
17497
+ status: "unavailable",
17498
+ unavailableReason: reason,
17499
+ ...bodyProperties ? { bodyProperties: { ...bodyProperties } } : {},
17500
+ blockCount,
17501
+ paragraphCount,
17502
+ unsupportedBlockCount,
17503
+ paragraphs: []
17504
+ };
17505
+ }
17506
+ function buildUnsupportedVmlTextBoxFacts(inline, inlinePath) {
17507
+ const hasText = Boolean(inline.text?.length);
17508
+ return {
17509
+ bodyKey: `${inline.preserveOnlyObject?.sourceId ?? inlinePath}:vml-textbox`,
17510
+ status: "unavailable",
17511
+ unavailableReason: "unsupported-vml-textbox",
17512
+ blockCount: hasText ? 1 : 0,
17513
+ paragraphCount: hasText ? 1 : 0,
17514
+ unsupportedBlockCount: hasText ? 1 : 0,
17515
+ paragraphs: []
17516
+ };
17517
+ }
17518
+ function buildTextBoxParagraphFacts(body, contentRectTwips) {
17519
+ const paragraphCount = body.paragraphs.length;
17520
+ if (paragraphCount === 0) return [];
17521
+ const baseHeight = Math.floor(contentRectTwips.heightTwips / paragraphCount);
17522
+ return body.paragraphs.map((paragraph, index) => {
17523
+ const yTwips = contentRectTwips.yTwips + baseHeight * index;
17524
+ const heightTwips = index === paragraphCount - 1 ? Math.max(0, contentRectTwips.yTwips + contentRectTwips.heightTwips - yTwips) : Math.max(0, baseHeight);
17525
+ return {
17526
+ paragraphKey: paragraph.paragraphKey,
17527
+ blockPath: paragraph.blockPath,
17528
+ blockIndex: paragraph.blockIndex,
17529
+ rectTwips: rect(
17530
+ contentRectTwips.xTwips,
17531
+ yTwips,
17532
+ contentRectTwips.widthTwips,
17533
+ heightTwips
17534
+ ),
17535
+ ...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
17536
+ ...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
17537
+ textLength: paragraph.textLength,
17538
+ runCount: paragraph.runCount
17539
+ };
17540
+ });
17541
+ }
17542
+ function textBoxInsetsTwips(bodyProperties) {
17543
+ if (!bodyProperties || bodyProperties.insetLeftEmu === void 0 || bodyProperties.insetTopEmu === void 0 || bodyProperties.insetRightEmu === void 0 || bodyProperties.insetBottomEmu === void 0) {
17544
+ return void 0;
17545
+ }
17546
+ return {
17547
+ leftTwips: Math.max(0, Math.round(bodyProperties.insetLeftEmu / EMUS_PER_TWIP)),
17548
+ topTwips: Math.max(0, Math.round(bodyProperties.insetTopEmu / EMUS_PER_TWIP)),
17549
+ rightTwips: Math.max(0, Math.round(bodyProperties.insetRightEmu / EMUS_PER_TWIP)),
17550
+ bottomTwips: Math.max(0, Math.round(bodyProperties.insetBottomEmu / EMUS_PER_TWIP))
17551
+ };
17552
+ }
17553
+ function normalizeTextBoxBodyUnavailableReason(reason) {
17554
+ switch (reason) {
17555
+ case "txbx-blocks-unavailable":
17556
+ case "empty-body":
17557
+ case "unsupported-content":
17558
+ return reason;
17559
+ default:
17560
+ return "unmodeled-txbx-blocks";
17561
+ }
17562
+ }
17563
+ function countParagraphBlocks(blocks) {
17564
+ let count = 0;
17565
+ const visit = (block) => {
17566
+ if (block.type === "paragraph") {
17567
+ count += 1;
17568
+ return;
17569
+ }
17570
+ if (block.type === "table") {
17571
+ for (const row of block.rows) {
17572
+ for (const cell of row.cells) {
17573
+ for (const child of cell.children) visit(child);
17574
+ }
17575
+ }
17576
+ return;
17577
+ }
17578
+ if (block.type === "sdt" || block.type === "custom_xml") {
17579
+ for (const child of block.children) visit(child);
17580
+ }
17581
+ };
17582
+ for (const block of blocks) visit(block);
17583
+ return count;
17584
+ }
17175
17585
  function collectDrawingRelationshipIds(inline) {
17176
17586
  const content = inline.content;
17177
17587
  if (content.type === "picture") return [content.blipRef];
@@ -17500,12 +17910,34 @@ function freezePageFrame(frame) {
17500
17910
  for (const story of frame.pageLocalStories) {
17501
17911
  Object.freeze(story.resolvedFields);
17502
17912
  Object.freeze(story.previewParts);
17913
+ for (const object of story.anchoredObjects) {
17914
+ freezeStoryAnchoredObject(object);
17915
+ }
17503
17916
  Object.freeze(story.anchoredObjects);
17504
17917
  Object.freeze(story);
17505
17918
  }
17506
17919
  Object.freeze(frame.pageLocalStories);
17507
17920
  Object.freeze(frame);
17508
17921
  }
17922
+ function freezeStoryAnchoredObject(object) {
17923
+ if (object.extentTwips) Object.freeze(object.extentTwips);
17924
+ if (object.anchorRectTwips) Object.freeze(object.anchorRectTwips);
17925
+ if (object.relationshipIds) Object.freeze(object.relationshipIds);
17926
+ if (object.mediaIds) Object.freeze(object.mediaIds);
17927
+ if (object.textBoxBody) {
17928
+ if (object.textBoxBody.bodyProperties) Object.freeze(object.textBoxBody.bodyProperties);
17929
+ if (object.textBoxBody.bodyInsetsTwips) Object.freeze(object.textBoxBody.bodyInsetsTwips);
17930
+ if (object.textBoxBody.contentRectTwips) Object.freeze(object.textBoxBody.contentRectTwips);
17931
+ for (const paragraph of object.textBoxBody.paragraphs) {
17932
+ if (paragraph.rectTwips) Object.freeze(paragraph.rectTwips);
17933
+ Object.freeze(paragraph);
17934
+ }
17935
+ Object.freeze(object.textBoxBody.paragraphs);
17936
+ Object.freeze(object.textBoxBody);
17937
+ }
17938
+ Object.freeze(object.divergenceIds);
17939
+ Object.freeze(object);
17940
+ }
17509
17941
  function normalizePageLocalStoryFieldsForPages(pages) {
17510
17942
  const pageFieldCounts = buildPageFieldCounts(pages);
17511
17943
  return pages.map((page) => {
@@ -19140,7 +19572,8 @@ function createLayoutEngine(options = {}) {
19140
19572
  fragmentsByPageIndex,
19141
19573
  lineBoxesByPageIndex,
19142
19574
  noteAllocationsByPageIndex: pageStack.noteAllocationsByPageIndex,
19143
- subParts: document2.subParts
19575
+ subParts: document2.subParts,
19576
+ anchors: layoutInputs.anchors
19144
19577
  });
19145
19578
  const graph = applyViewportWindowMaterialization(
19146
19579
  measuredGraph,
@@ -19275,7 +19708,8 @@ function createLayoutEngine(options = {}) {
19275
19708
  fragmentsByPageIndex: freshFragmentsByPageIndex,
19276
19709
  lineBoxesByPageIndex: freshLineBoxesByPageIndex,
19277
19710
  noteAllocationsByPageIndex: freshResult.noteAllocationsByPageIndex,
19278
- subParts: document2.subParts
19711
+ subParts: document2.subParts,
19712
+ anchors: layoutInputs.anchors
19279
19713
  });
19280
19714
  const freshNodes = freshGraph.pages;
19281
19715
  const splicedGraph = spliceGraph(priorGraph, freshNodes, firstDirty, convergedTailStart);
@@ -25766,10 +26200,7 @@ var TwPageStackOverlayLayer = ({
25766
26200
  null
25767
26201
  );
25768
26202
  if (warm) {
25769
- return extendPageOverlayRectsAcrossTableBoundaryGaps(
25770
- warm,
25771
- containsTableBoundaryRisk(scrollRoot) ? collectTableEmbeddedBoundaryIndices(scrollRoot) : []
25772
- );
26203
+ return warm;
25773
26204
  }
25774
26205
  }
25775
26206
  return resolveSkeletalPageOverlayRectsFromLayout(facet);
@@ -25810,7 +26241,7 @@ var TwPageStackOverlayLayer = ({
25810
26241
  );
25811
26242
  if (uiRects !== null) {
25812
26243
  incrementInvalidationCounter("overlay.page.ui_api.hit");
25813
- setRectsIfChanged(reconcilePaperRectsWithFlow(uiRects, pageCount));
26244
+ setRectsIfChanged(uiRects);
25814
26245
  return;
25815
26246
  }
25816
26247
  incrementInvalidationCounter("overlay.page.ui_api.fallthrough");
@@ -25825,7 +26256,7 @@ var TwPageStackOverlayLayer = ({
25825
26256
  );
25826
26257
  if (geometryRects !== null) {
25827
26258
  incrementInvalidationCounter("overlay.page.geometry.hit");
25828
- setRectsIfChanged(reconcilePaperRectsWithFlow(geometryRects, pageCount));
26259
+ setRectsIfChanged(geometryRects);
25829
26260
  return;
25830
26261
  }
25831
26262
  incrementInvalidationCounter("overlay.page.geometry.fallthrough");
@@ -26194,11 +26625,6 @@ function buildParagraphStyle(block) {
26194
26625
  style[cssKey] = `${width} ${bStyle} ${color}`;
26195
26626
  }
26196
26627
  }
26197
- if (block.pageBreakBefore) {
26198
- style.borderTop = "2px dashed rgba(0,0,0,0.1)";
26199
- style.paddingTop = "8px";
26200
- style.marginTop = "16px";
26201
- }
26202
26628
  const framePr = block.frameProperties;
26203
26629
  const hasPosition = typeof framePr?.xTwips === "number" || typeof framePr?.yTwips === "number" || typeof framePr?.xAlign === "string" || typeof framePr?.yAlign === "string";
26204
26630
  if (framePr && framePr.dropCap !== "drop" && framePr.dropCap !== "margin" && hasPosition) {
@@ -28010,7 +28436,7 @@ var TwPageStackChromeLayerInner = ({
28010
28436
  const [activeStoryPageIndex, setActiveStoryPageIndex] = import_react29.default.useState(null);
28011
28437
  const refreshRectsNow = import_react29.default.useCallback(() => {
28012
28438
  const pageCount = facet.getPageCount();
28013
- const reconcileRects = (baseRects) => reconcilePageStackRectsWithFlow({
28439
+ const reconcileDomRects = (baseRects) => reconcilePageStackRectsWithFlow({
28014
28440
  baseRects,
28015
28441
  pageCount,
28016
28442
  scrollRoot,
@@ -28018,7 +28444,7 @@ var TwPageStackChromeLayerInner = ({
28018
28444
  });
28019
28445
  const uiRects = resolveUiPageRects(pageCount);
28020
28446
  if (uiRects !== null) {
28021
- setRects(reconcileRects(uiRects));
28447
+ setRects(uiRects);
28022
28448
  return;
28023
28449
  }
28024
28450
  if (geometryFacet) {
@@ -28028,7 +28454,7 @@ var TwPageStackChromeLayerInner = ({
28028
28454
  visiblePageIndexRange
28029
28455
  );
28030
28456
  if (geometryRects !== null) {
28031
- setRects(reconcileRects(geometryRects));
28457
+ setRects(geometryRects);
28032
28458
  return;
28033
28459
  }
28034
28460
  setRects([]);
@@ -28056,7 +28482,7 @@ var TwPageStackChromeLayerInner = ({
28056
28482
  visiblePageIndexRange
28057
28483
  });
28058
28484
  setRects(
28059
- reconcileRects(domRects)
28485
+ reconcileDomRects(domRects)
28060
28486
  );
28061
28487
  } else {
28062
28488
  const widgets = measureWidgetsViaOffsetChain(scrollRoot, {
@@ -28071,7 +28497,7 @@ var TwPageStackChromeLayerInner = ({
28071
28497
  visiblePageIndexRange
28072
28498
  });
28073
28499
  setRects(
28074
- reconcileRects(domRects)
28500
+ reconcileDomRects(domRects)
28075
28501
  );
28076
28502
  }
28077
28503
  }, [facet, geometryFacet, resolveUiPageRects, scrollRoot, visiblePageIndexRange]);