@beyondwork/docx-react-component 1.0.122 → 1.0.124

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 +351 -56
  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-EMDH4IQN.js → chunk-4B74ETJI.js} +4 -3
  13. package/dist/{chunk-QNGJRZ2D.js → chunk-4IPEZYQX.js} +1 -1
  14. package/dist/{chunk-S4ANOS2M.js → chunk-7PC6XUNO.js} +2 -2
  15. package/dist/{chunk-TMU7JMXX.js → chunk-A74Y5NE4.js} +11 -15
  16. package/dist/{chunk-3OFSP2IX.js → chunk-BOHHIVQ2.js} +3 -3
  17. package/dist/{chunk-TFSXOIAI.js → chunk-FNWKE74J.js} +43 -3
  18. package/dist/{chunk-3TUQCHYT.js → chunk-H6IL5ABU.js} +47 -7
  19. package/dist/{chunk-GON2DNTE.js → chunk-HXHQA4BU.js} +1 -1
  20. package/dist/{chunk-3OHVK2D6.js → chunk-IR7QV2BX.js} +17 -1
  21. package/dist/{chunk-ZKSDVHGH.js → chunk-KOHQFZMM.js} +1 -1
  22. package/dist/{chunk-XVFENXLK.js → chunk-LGWNN3L2.js} +2 -2
  23. package/dist/{chunk-UHQOUTAX.js → chunk-MPH4ZQS4.js} +377 -50
  24. package/dist/{chunk-GZW2ERUO.js → chunk-N4VIXI2Z.js} +3 -3
  25. package/dist/{chunk-OBCP6VTG.js → chunk-NAMAWCXN.js} +1 -1
  26. package/dist/{chunk-QFU7ZOAD.js → chunk-PFYUJU3Q.js} +176 -36
  27. package/dist/{chunk-PCXTMEGY.js → chunk-Q76XPPTA.js} +24 -14
  28. package/dist/{chunk-37SEJQ3G.js → chunk-RSYN6FTS.js} +2 -2
  29. package/dist/{chunk-UWDWGQH5.js → chunk-TY4DIJO3.js} +1 -1
  30. package/dist/{chunk-IT2DK3A7.js → chunk-ZMRO6P3A.js} +9 -7
  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 +1198 -191
  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 +12 -15
  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 +10 -14
  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 +14 -612
  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/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createSearchPlugin,
5
5
  performSearch,
6
6
  searchPluginKey
7
- } from "./chunk-QNGJRZ2D.js";
7
+ } from "./chunk-4IPEZYQX.js";
8
8
  import {
9
9
  CODE_METADATA_TABLE,
10
10
  KNOWN_DIAGNOSTIC_CODES,
@@ -26,7 +26,7 @@ import {
26
26
  splitListParagraph,
27
27
  toggleBulletedList,
28
28
  toggleNumberedList
29
- } from "./chunk-UHQOUTAX.js";
29
+ } from "./chunk-MPH4ZQS4.js";
30
30
  import {
31
31
  applyParagraphStyleToDocument
32
32
  } from "./chunk-6EXNNAO6.js";
@@ -37,7 +37,7 @@ import {
37
37
  setSectionPageNumberingAtSectionIndex,
38
38
  updateSectionLayoutAtSectionIndex
39
39
  } from "./chunk-M6XR534O.js";
40
- import "./chunk-OBCP6VTG.js";
40
+ import "./chunk-NAMAWCXN.js";
41
41
  import {
42
42
  createRuntimeCollabSync,
43
43
  createRuntimeCommandAppliedBridge
@@ -45,7 +45,7 @@ import {
45
45
  import {
46
46
  insertPageBreak,
47
47
  insertTable
48
- } from "./chunk-3OFSP2IX.js";
48
+ } from "./chunk-BOHHIVQ2.js";
49
49
  import {
50
50
  getFormattingStateFromRenderSnapshot
51
51
  } from "./chunk-Y4XZCMCS.js";
@@ -53,13 +53,13 @@ import {
53
53
  insertImage,
54
54
  repositionFloatingImage,
55
55
  resizeImage
56
- } from "./chunk-37SEJQ3G.js";
57
- import "./chunk-3OHVK2D6.js";
56
+ } from "./chunk-RSYN6FTS.js";
57
+ import "./chunk-IR7QV2BX.js";
58
58
  import {
59
59
  getTableStructureContext,
60
60
  tableStructureActionHandleForTarget
61
- } from "./chunk-XVFENXLK.js";
62
- import "./chunk-ZKSDVHGH.js";
61
+ } from "./chunk-LGWNN3L2.js";
62
+ import "./chunk-KOHQFZMM.js";
63
63
  import {
64
64
  OverlayAnchorBridgeProvider,
65
65
  PAGE_CHROME_DEFAULTS,
@@ -84,7 +84,7 @@ import {
84
84
  resolveSelectionToolRegistry,
85
85
  shouldRenderAbsoluteFloatingImageInPageOverlay,
86
86
  shouldRenderSelectionToolKind
87
- } from "./chunk-QFU7ZOAD.js";
87
+ } from "./chunk-PFYUJU3Q.js";
88
88
  import {
89
89
  PREDICTED_LANE_COUNTERS,
90
90
  createInertGeometryFacet,
@@ -92,7 +92,7 @@ import {
92
92
  incrementInvalidationCounter,
93
93
  recordPerfSample,
94
94
  startPerfProbe
95
- } from "./chunk-GZW2ERUO.js";
95
+ } from "./chunk-N4VIXI2Z.js";
96
96
  import {
97
97
  composeSeriesColor,
98
98
  computeStructuralHash,
@@ -106,12 +106,12 @@ import {
106
106
  resolveColor,
107
107
  tryReadLaycacheEnvelope,
108
108
  writeEnvelopeToOpcPackage
109
- } from "./chunk-IT2DK3A7.js";
109
+ } from "./chunk-ZMRO6P3A.js";
110
110
  import {
111
111
  findTextMatches,
112
112
  parseCanonicalFragmentFromWordML,
113
113
  searchDocument
114
- } from "./chunk-PCXTMEGY.js";
114
+ } from "./chunk-Q76XPPTA.js";
115
115
  import {
116
116
  clearLocalCursorState,
117
117
  getCursorColorForUser,
@@ -121,7 +121,7 @@ import {
121
121
  import {
122
122
  resolveChromePreset,
123
123
  resolveChromeVisibilityForPreset
124
- } from "./chunk-GON2DNTE.js";
124
+ } from "./chunk-HXHQA4BU.js";
125
125
  import {
126
126
  CAPABILITY_BY_ID,
127
127
  ISSUE_METADATA_ID,
@@ -137,7 +137,7 @@ import {
137
137
  deriveCapabilities,
138
138
  sanitizeMarkdown,
139
139
  sha256Hex
140
- } from "./chunk-G3B2OBCZ.js";
140
+ } from "./chunk-ZRHLLPSJ.js";
141
141
  import "./chunk-KFCQYZXR.js";
142
142
  import "./chunk-QIO6V46H.js";
143
143
  import {
@@ -145,7 +145,7 @@ import {
145
145
  getStoryBlocks,
146
146
  replaceStoryBlocks,
147
147
  stableChartId
148
- } from "./chunk-3TUQCHYT.js";
148
+ } from "./chunk-H6IL5ABU.js";
149
149
  import "./chunk-CX42VC67.js";
150
150
  import {
151
151
  createDefaultCanonicalDocument,
@@ -156,14 +156,14 @@ import {
156
156
  SessionNotOpenError,
157
157
  SessionNotWiredError,
158
158
  isReopenBarrier
159
- } from "./chunk-S4ANOS2M.js";
159
+ } from "./chunk-7PC6XUNO.js";
160
160
  import {
161
161
  createHmacSigner,
162
162
  createHmacVerifier,
163
163
  loadDocxSessionSync,
164
164
  signWorkflowPayloadXml,
165
165
  verifyWorkflowPayloadXml
166
- } from "./chunk-EMDH4IQN.js";
166
+ } from "./chunk-4B74ETJI.js";
167
167
  import {
168
168
  EDITOR_SESSION_STATE_VERSION,
169
169
  assertEditorSessionState,
@@ -172,8 +172,8 @@ import {
172
172
  editorSessionStateFromPersistedSnapshot,
173
173
  persistedSnapshotFromEditorSessionState,
174
174
  validateEditorSessionState
175
- } from "./chunk-UWDWGQH5.js";
176
- import "./chunk-TMU7JMXX.js";
175
+ } from "./chunk-TY4DIJO3.js";
176
+ import "./chunk-A74Y5NE4.js";
177
177
  import {
178
178
  decodePersistedSourcePackageBytes,
179
179
  hasValidPersistedSourcePackageDigest
@@ -185,7 +185,7 @@ import {
185
185
  collectEditableTargetRefs,
186
186
  createHeaderFooterStoryKey,
187
187
  createNoteStoryKey
188
- } from "./chunk-TFSXOIAI.js";
188
+ } from "./chunk-FNWKE74J.js";
189
189
  import {
190
190
  readOpcPackage
191
191
  } from "./chunk-OL2UEHRP.js";
@@ -5247,7 +5247,6 @@ var editorSchema = new Schema({
5247
5247
  }
5248
5248
  }
5249
5249
  const pageBreak = node.attrs.pageBreakBefore;
5250
- if (pageBreak) styles.push("border-top: 2px dashed rgba(0,0,0,0.1); padding-top: 8px; margin-top: 16px");
5251
5250
  const framePr = node.attrs.frameProperties;
5252
5251
  const hasPosition = typeof framePr?.xTwips === "number" || typeof framePr?.yTwips === "number" || typeof framePr?.xAlign === "string" || typeof framePr?.yAlign === "string";
5253
5252
  if (framePr && framePr.dropCap !== "drop" && framePr.dropCap !== "margin" && hasPosition) {
@@ -5311,15 +5310,7 @@ var editorSchema = new Schema({
5311
5310
  const numberingPicBulletSrc = node.attrs.numberingPicBulletSrc;
5312
5311
  const children = [];
5313
5312
  if (pageBreak) {
5314
- children.push([
5315
- "span",
5316
- {
5317
- class: "mb-2 inline-flex items-center gap-2 text-[10px] font-medium uppercase tracking-[var(--tracking-eyebrow)] text-tertiary",
5318
- contenteditable: "false",
5319
- "data-page-break-before": "true"
5320
- },
5321
- "Page break"
5322
- ]);
5313
+ attrs["data-page-break-before"] = "true";
5323
5314
  }
5324
5315
  if (numberingPrefix || numberingPicBulletSrc) {
5325
5316
  const hasResolvedMarkerWidth = typeof numberingMarkerWidth === "number" && numberingMarkerWidth > 0;
@@ -5644,7 +5635,6 @@ var editorSchema = new Schema({
5644
5635
  "section",
5645
5636
  {
5646
5637
  class: "my-0 border-0 bg-transparent p-0",
5647
- style: "min-height:var(--wre-page-frame-height-px,1056px);position:relative",
5648
5638
  "data-node-type": "sdt_block",
5649
5639
  "data-sdt-page-break": "true"
5650
5640
  },
@@ -6000,6 +5990,34 @@ var editorSchema = new Schema({
6000
5990
  ];
6001
5991
  }
6002
5992
  },
5993
+ textbox_inline: {
5994
+ inline: true,
5995
+ group: "inline",
5996
+ content: "text*",
5997
+ marks: "_",
5998
+ selectable: true,
5999
+ isolating: true,
6000
+ attrs: {
6001
+ label: { default: "Text box" },
6002
+ detail: { default: null },
6003
+ targetKey: { default: null },
6004
+ geometry: { default: null }
6005
+ },
6006
+ toDOM(node) {
6007
+ const title = node.attrs.detail ?? node.attrs.label;
6008
+ return [
6009
+ "span",
6010
+ {
6011
+ class: "inline-block min-w-[2ch] max-w-full align-middle mx-0.5 rounded-[2px] border border-border bg-surface px-1 py-0.5 text-primary",
6012
+ "data-node-type": "textbox_inline",
6013
+ "data-editable-target-key": node.attrs.targetKey ?? "",
6014
+ "data-shape-geometry": node.attrs.geometry ?? "",
6015
+ title
6016
+ },
6017
+ 0
6018
+ ];
6019
+ }
6020
+ },
6003
6021
  wordart_atom: {
6004
6022
  inline: true,
6005
6023
  group: "inline",
@@ -6378,16 +6396,16 @@ function buildPositionMap(surface) {
6378
6396
  const pmDocSize = walkBlocks(surface.blocks, 1, entries, protectedInlineEntries, { rootLevel: true });
6379
6397
  const runtimeStorySize = surface.storySize;
6380
6398
  const runtimeToPm = (runtimePos) => {
6381
- const firstEditable = entries.find(isRuntimeRestorableEntry);
6399
+ const firstEditable = entries.find(isStoryRuntimeRestorableEntry);
6382
6400
  if (runtimePos <= 0) {
6383
6401
  return firstEditable?.pmStart ?? 1;
6384
6402
  }
6385
6403
  if (runtimePos >= runtimeStorySize) {
6386
- return lastRestorableEntry(entries)?.pmEnd ?? pmDocSize - 1;
6404
+ return lastStoryRestorableEntry(entries)?.pmEnd ?? pmDocSize - 1;
6387
6405
  }
6388
6406
  let previous = null;
6389
6407
  for (const entry of entries) {
6390
- if (!isRuntimeRestorableEntry(entry)) {
6408
+ if (!isStoryRuntimeRestorableEntry(entry)) {
6391
6409
  continue;
6392
6410
  }
6393
6411
  if (entry.runtimeStart === entry.runtimeEnd && runtimePos === entry.runtimeStart) {
@@ -6401,12 +6419,12 @@ function buildPositionMap(surface) {
6401
6419
  }
6402
6420
  previous = entry;
6403
6421
  }
6404
- return lastRestorableEntry(entries)?.pmEnd ?? 1;
6422
+ return lastStoryRestorableEntry(entries)?.pmEnd ?? 1;
6405
6423
  };
6406
6424
  return {
6407
6425
  runtimeToPm,
6408
6426
  runtimeToPmWithContext(input) {
6409
- const targetEntry = input.editableTarget ? findRestorableEntryForTarget(entries, input.editableTarget) : void 0;
6427
+ const targetEntry = input.editableTarget ? findRestorableEntryForTarget(entries, input.editableTarget, input.runtimePos) : void 0;
6410
6428
  if (targetEntry) {
6411
6429
  return pmForRuntimeInTargetEntry(targetEntry, input.runtimePos, protectedInlineEntries);
6412
6430
  }
@@ -6507,7 +6525,7 @@ function isEditablePmRange(entries, protectedInlineEntries, pmDocSize, runtimeSt
6507
6525
  if (entry.editable === false) return false;
6508
6526
  }
6509
6527
  for (const entry of protectedInlineEntries) {
6510
- if (pmRangeTouchesEntry(start, end, entry)) return false;
6528
+ if (entry.editable === false && pmRangeTouchesEntry(start, end, entry)) return false;
6511
6529
  }
6512
6530
  return true;
6513
6531
  }
@@ -6515,9 +6533,9 @@ function protectedInlineEntryAtPm(protectedInlineEntries, pmPos) {
6515
6533
  return protectedInlineEntries.find((entry) => pmPos > entry.pmStart && pmPos < entry.pmEnd);
6516
6534
  }
6517
6535
  function pmForRuntimeInTargetEntry(entry, runtimePos, protectedInlineEntries) {
6518
- const runtimeDelta = Math.max(
6519
- 0,
6520
- Math.min(runtimePos - entry.runtimeStart, entry.runtimeEnd - entry.runtimeStart)
6536
+ const runtimeDelta = Math.min(
6537
+ runtimePos - entry.runtimeStart,
6538
+ entry.runtimeEnd - entry.runtimeStart
6521
6539
  );
6522
6540
  let pmPos = entry.pmStart + runtimeDelta;
6523
6541
  for (const protectedEntry of protectedInlineEntries) {
@@ -6546,10 +6564,13 @@ function nearestRuntimeGapPm(runtimePos, previous, next) {
6546
6564
  function isRuntimeRestorableEntry(entry) {
6547
6565
  return entry.editable !== false && entry.restorable !== false;
6548
6566
  }
6549
- function lastRestorableEntry(entries) {
6567
+ function isStoryRuntimeRestorableEntry(entry) {
6568
+ return isRuntimeRestorableEntry(entry) && entry.runtimeSpace !== "target";
6569
+ }
6570
+ function lastStoryRestorableEntry(entries) {
6550
6571
  for (let index = entries.length - 1; index >= 0; index -= 1) {
6551
6572
  const entry = entries[index];
6552
- if (isRuntimeRestorableEntry(entry)) {
6573
+ if (isStoryRuntimeRestorableEntry(entry)) {
6553
6574
  return entry;
6554
6575
  }
6555
6576
  }
@@ -6580,27 +6601,90 @@ function walkBlocks(blocks, pmCursor, entries, protectedInlineEntries, context)
6580
6601
  const runtimeLength = block.to - block.from;
6581
6602
  const tableCell = context.tableCell ?? tableCellFromEditableTarget(block.editableTarget);
6582
6603
  const editable = context.editable !== false;
6583
- entries.push({
6584
- runtimeStart: block.from,
6585
- pmStart: pmContentStart,
6586
- runtimeEnd: block.to,
6587
- pmEnd: pmContentStart + runtimeLength,
6588
- editable,
6589
- insideTable: context.insideTable === true || context.tableCell !== void 0,
6590
- editableTarget: block.editableTarget,
6591
- textTarget: editable && tableCell ? {
6592
- kind: "table-paragraph",
6593
- tableBlockIndex: tableCell.tableBlockIndex,
6594
- rowIndex: tableCell.rowIndex,
6595
- cellIndex: tableCell.cellIndex,
6596
- childIndex: blockIndex,
6597
- paragraphStart: block.from,
6598
- paragraphEnd: block.to,
6599
- ...block.editableTarget ? { blockPath: block.editableTarget.blockPath } : {}
6600
- } : void 0
6601
- });
6602
- addProtectedInlineEntries(block, pmContentStart, protectedInlineEntries);
6603
- nextPmCursor += runtimeLength + 2;
6604
+ const textTarget = editable && tableCell ? {
6605
+ kind: "table-paragraph",
6606
+ tableBlockIndex: tableCell.tableBlockIndex,
6607
+ rowIndex: tableCell.rowIndex,
6608
+ cellIndex: tableCell.cellIndex,
6609
+ childIndex: blockIndex,
6610
+ paragraphStart: block.from,
6611
+ paragraphEnd: block.to,
6612
+ ...block.editableTarget ? { blockPath: block.editableTarget.blockPath } : {}
6613
+ } : void 0;
6614
+ const insideTable = context.insideTable === true || context.tableCell !== void 0;
6615
+ let pmSegmentCursor = pmContentStart;
6616
+ let emittedStoryEntry = false;
6617
+ if (block.editableTarget !== void 0) {
6618
+ entries.push({
6619
+ runtimeStart: block.from,
6620
+ pmStart: pmContentStart,
6621
+ runtimeEnd: block.from,
6622
+ pmEnd: pmContentStart,
6623
+ editable,
6624
+ insideTable,
6625
+ runtimeSpace: "target",
6626
+ editableTarget: block.editableTarget,
6627
+ textTarget
6628
+ });
6629
+ }
6630
+ for (const segment of block.segments) {
6631
+ const pmSize = pmSizeForSegment(segment);
6632
+ const textBoxParagraph = firstEditableTextBoxParagraph(segment);
6633
+ if (textBoxParagraph?.editableTarget) {
6634
+ const textLength = Math.max(0, textBoxParagraph.textLength);
6635
+ const textStart = pmSegmentCursor + 1;
6636
+ entries.push({
6637
+ runtimeStart: 0,
6638
+ pmStart: textStart,
6639
+ runtimeEnd: textLength,
6640
+ pmEnd: textStart + textLength,
6641
+ editable: true,
6642
+ restorable: true,
6643
+ runtimeSpace: "target",
6644
+ editableTarget: textBoxParagraph.editableTarget
6645
+ });
6646
+ } else if (isStoryTextSegment(segment)) {
6647
+ entries.push({
6648
+ runtimeStart: segment.from,
6649
+ pmStart: pmSegmentCursor,
6650
+ runtimeEnd: segment.to,
6651
+ pmEnd: pmSegmentCursor + Math.max(0, segment.to - segment.from),
6652
+ editable,
6653
+ insideTable,
6654
+ editableTarget: block.editableTarget,
6655
+ textTarget
6656
+ });
6657
+ emittedStoryEntry = true;
6658
+ }
6659
+ addProtectedInlineEntryForSegment(segment, pmSegmentCursor, protectedInlineEntries);
6660
+ pmSegmentCursor += pmSize;
6661
+ }
6662
+ if (block.editableTarget !== void 0 && block.to !== block.from) {
6663
+ entries.push({
6664
+ runtimeStart: block.to,
6665
+ pmStart: pmSegmentCursor,
6666
+ runtimeEnd: block.to,
6667
+ pmEnd: pmSegmentCursor,
6668
+ editable,
6669
+ insideTable,
6670
+ runtimeSpace: "target",
6671
+ editableTarget: block.editableTarget,
6672
+ textTarget
6673
+ });
6674
+ }
6675
+ if (!emittedStoryEntry || runtimeLength === 0) {
6676
+ entries.push({
6677
+ runtimeStart: block.from,
6678
+ pmStart: pmContentStart,
6679
+ runtimeEnd: block.to,
6680
+ pmEnd: pmContentStart,
6681
+ editable,
6682
+ insideTable,
6683
+ editableTarget: block.editableTarget,
6684
+ textTarget
6685
+ });
6686
+ }
6687
+ nextPmCursor += pmSegmentCursor - pmContentStart + 2;
6604
6688
  break;
6605
6689
  }
6606
6690
  case "opaque_block": {
@@ -6657,21 +6741,39 @@ function walkBlocks(blocks, pmCursor, entries, protectedInlineEntries, context)
6657
6741
  }
6658
6742
  return nextPmCursor;
6659
6743
  }
6660
- function addProtectedInlineEntries(block, pmContentStart, protectedInlineEntries) {
6661
- for (const segment of block.segments) {
6662
- if (segment.kind !== "opaque_inline" && segment.kind !== "shape") {
6663
- continue;
6664
- }
6665
- const runtimeLength = Math.max(1, segment.to - segment.from);
6666
- const pmStart = pmContentStart + Math.max(0, segment.from - block.from);
6667
- protectedInlineEntries.push({
6668
- runtimeStart: segment.from,
6669
- pmStart,
6670
- runtimeEnd: segment.to,
6671
- pmEnd: pmStart + runtimeLength,
6672
- editable: false
6673
- });
6744
+ function pmSizeForSegment(segment) {
6745
+ const textBoxParagraph = firstEditableTextBoxParagraph(segment);
6746
+ if (textBoxParagraph) {
6747
+ return Math.max(0, textBoxParagraph.textLength) + 2;
6748
+ }
6749
+ return Math.max(1, segment.to - segment.from);
6750
+ }
6751
+ function isStoryTextSegment(segment) {
6752
+ return segment.kind === "text" || segment.kind === "tab" || segment.kind === "hard_break";
6753
+ }
6754
+ function firstEditableTextBoxParagraph(segment) {
6755
+ if (segment.kind !== "shape" || segment.isTextBox !== true || segment.txbxBody?.status !== "modeled") {
6756
+ return null;
6757
+ }
6758
+ return segment.txbxBody.paragraphs.find(
6759
+ (paragraph) => paragraph.editableTarget?.editability === "editable" && paragraph.editableTarget.posture.blockers.length === 0
6760
+ ) ?? null;
6761
+ }
6762
+ function addProtectedInlineEntryForSegment(segment, pmStart, protectedInlineEntries) {
6763
+ if (segment.kind !== "opaque_inline" && segment.kind !== "shape") {
6764
+ return;
6765
+ }
6766
+ if (firstEditableTextBoxParagraph(segment)) {
6767
+ return;
6674
6768
  }
6769
+ const runtimeLength = Math.max(1, segment.to - segment.from);
6770
+ protectedInlineEntries.push({
6771
+ runtimeStart: segment.from,
6772
+ pmStart,
6773
+ runtimeEnd: segment.to,
6774
+ pmEnd: pmStart + runtimeLength,
6775
+ editable: false
6776
+ });
6675
6777
  }
6676
6778
  function hasEditableTargetInBlocks(blocks) {
6677
6779
  for (const block of blocks) {
@@ -6702,21 +6804,46 @@ function findInertEntryForTarget(entries, target) {
6702
6804
  return entry.editable === false && candidate?.targetKey === target.targetKey && candidate.storyKey === target.storyKey && candidate.blockPath === target.blockPath && candidate.leafPath === target.leafPath && candidate.kind === target.kind;
6703
6805
  });
6704
6806
  }
6705
- function findRestorableEntryForTarget(entries, target) {
6807
+ function findRestorableEntryForTarget(entries, target, runtimePos) {
6706
6808
  if ("editableOwner" in target && target.editableOwner && isSyntheticLayoutContinuationTarget(target)) {
6707
- return findRestorableEntryForOwner(entries, target.editableOwner);
6809
+ return findRestorableEntryForOwner(entries, target.editableOwner, runtimePos);
6708
6810
  }
6709
- return entries.find((entry) => {
6811
+ return selectRestorableEntryForRuntime(entries, runtimePos, (entry) => {
6710
6812
  const candidate = entry.editableTarget;
6711
6813
  return isRuntimeRestorableEntry(entry) && candidate?.targetKey === target.targetKey && candidate.storyKey === target.storyKey && candidate.blockPath === target.blockPath && candidate.leafPath === target.leafPath && candidate.kind === target.kind;
6712
6814
  });
6713
6815
  }
6714
- function findRestorableEntryForOwner(entries, owner) {
6715
- return entries.find((entry) => {
6816
+ function findRestorableEntryForOwner(entries, owner, runtimePos) {
6817
+ return selectRestorableEntryForRuntime(entries, runtimePos, (entry) => {
6716
6818
  const candidate = entry.editableTarget;
6717
6819
  return isRuntimeRestorableEntry(entry) && candidate?.targetKey === owner.targetKey && candidate.storyKey === owner.storyKey && candidate.blockPath === owner.blockPath && candidate.leafPath === owner.leafPath && candidate.kind === owner.kind && candidate.commandFamily === owner.commandFamily;
6718
6820
  });
6719
6821
  }
6822
+ function selectRestorableEntryForRuntime(entries, runtimePos, predicate) {
6823
+ const candidates = entries.filter(predicate);
6824
+ if (candidates.length === 0 || runtimePos === void 0) {
6825
+ return candidates[0];
6826
+ }
6827
+ const containing = candidates.filter(
6828
+ (entry) => runtimePos >= entry.runtimeStart && runtimePos <= entry.runtimeEnd
6829
+ );
6830
+ if (containing.length > 0) {
6831
+ return containing.sort(
6832
+ (left, right) => left.runtimeEnd - left.runtimeStart - (right.runtimeEnd - right.runtimeStart)
6833
+ )[0];
6834
+ }
6835
+ return candidates.sort((left, right) => {
6836
+ const leftDistance = Math.min(
6837
+ Math.abs(runtimePos - left.runtimeStart),
6838
+ Math.abs(runtimePos - left.runtimeEnd)
6839
+ );
6840
+ const rightDistance = Math.min(
6841
+ Math.abs(runtimePos - right.runtimeStart),
6842
+ Math.abs(runtimePos - right.runtimeEnd)
6843
+ );
6844
+ return leftDistance - rightDistance;
6845
+ })[0];
6846
+ }
6720
6847
  function isSyntheticLayoutContinuationTarget(target) {
6721
6848
  return target.commandFamily === "text-leaf" && target.table?.operationScope === "text" && target.table.verticalMerge === "continue" && target.posture.blockers.includes("synthetic-layout-cell");
6722
6849
  }
@@ -7171,6 +7298,24 @@ function buildInlineContent(segment, mediaPreviews, showUnsupportedObjectPreview
7171
7298
  case "opaque_inline":
7172
7299
  return [buildOpaqueInlineOrComplexAtom(segment, mediaPreviews, showUnsupportedObjectPreviews)];
7173
7300
  case "shape": {
7301
+ const textBoxParagraph = firstEditableTextBoxParagraph2(segment);
7302
+ if (textBoxParagraph) {
7303
+ const content = textBoxParagraph.runs.flatMap(
7304
+ (run) => textBoxRunToPMNodes(run)
7305
+ );
7306
+ const fallbackContent = content.length > 0 && textBoxParagraph.text.length > 0 ? content : textBoxParagraph.text.length > 0 ? [editorSchema.text(textBoxParagraph.text)] : [];
7307
+ return [
7308
+ editorSchema.nodes.textbox_inline.create(
7309
+ {
7310
+ label: segment.label,
7311
+ detail: segment.detail,
7312
+ targetKey: textBoxParagraph.editableTarget?.targetKey ?? null,
7313
+ geometry: segment.geometry ?? null
7314
+ },
7315
+ fallbackContent
7316
+ )
7317
+ ];
7318
+ }
7174
7319
  const renderInPageOverlay = renderAbsoluteFloatingObjectsInPageOverlay && shouldRenderAbsoluteFloatingImageInPageOverlay(segment.anchor);
7175
7320
  return [
7176
7321
  editorSchema.nodes.shape_atom.create({
@@ -7211,6 +7356,28 @@ function buildInlineContent(segment, mediaPreviews, showUnsupportedObjectPreview
7211
7356
  return [];
7212
7357
  }
7213
7358
  }
7359
+ function firstEditableTextBoxParagraph2(segment) {
7360
+ if (segment.isTextBox !== true || segment.txbxBody?.status !== "modeled") {
7361
+ return null;
7362
+ }
7363
+ return segment.txbxBody.paragraphs.find(
7364
+ (paragraph) => paragraph.editableTarget?.editability === "editable" && paragraph.editableTarget.posture.blockers.length === 0
7365
+ ) ?? null;
7366
+ }
7367
+ function textBoxRunToPMNodes(run) {
7368
+ if (run.kind !== "text" || !run.text) return [];
7369
+ const segment = {
7370
+ segmentId: `textbox-run-${run.inlineIndex}`,
7371
+ kind: "text",
7372
+ from: 0,
7373
+ to: run.textLength ?? Array.from(run.text).length,
7374
+ text: run.text,
7375
+ ...run.marks && run.marks.length > 0 ? { marks: run.marks } : {},
7376
+ ...run.markAttrs ? { markAttrs: run.markAttrs } : {}
7377
+ };
7378
+ const marks = applyEffectiveMarks(segment, editorSchema);
7379
+ return [editorSchema.text(run.text, marks.length > 0 ? marks : void 0)];
7380
+ }
7214
7381
  function buildTable(block, mediaPreviews, showUnsupportedObjectPreviews, renderAbsoluteFloatingObjectsInPageOverlay) {
7215
7382
  const rows = [];
7216
7383
  for (const row of block.rows) {
@@ -8766,13 +8933,20 @@ function createPredictedPositionMap(canonical, pendingOps) {
8766
8933
  },
8767
8934
  pmToRuntimeWithContext(pmPos) {
8768
8935
  let adjusted = pmPos;
8769
- for (const op of pendingOps) {
8770
- const opPmStart = canonical.runtimeToPm(op.fromRuntime);
8936
+ for (let index = 0; index < pendingOps.length; index += 1) {
8937
+ const op = pendingOps[index];
8938
+ const opPmStart = canonical.runtimeToPm(
8939
+ canonicalRuntimeForPredictedOp(pendingOps, index)
8940
+ );
8771
8941
  if (adjusted > opPmStart) {
8772
8942
  adjusted -= opSizeDelta(op);
8773
8943
  }
8774
8944
  }
8775
- return canonical.pmToRuntimeWithContext(Math.max(1, adjusted));
8945
+ const context = canonical.pmToRuntimeWithContext(Math.max(1, adjusted));
8946
+ return {
8947
+ ...context,
8948
+ runtimePos: applyPendingOpsToCanonicalRuntime(context.runtimePos, pendingOps)
8949
+ };
8776
8950
  },
8777
8951
  ...canonical.isPmRangeEditable ? {
8778
8952
  isPmRangeEditable(fromPm, toPm) {
@@ -8792,6 +8966,25 @@ function createPredictedPositionMap(canonical, pendingOps) {
8792
8966
  }
8793
8967
  };
8794
8968
  }
8969
+ function canonicalRuntimeForPredictedOp(pendingOps, opIndex) {
8970
+ let runtimePos = pendingOps[opIndex]?.fromRuntime ?? 0;
8971
+ for (let index = 0; index < opIndex; index += 1) {
8972
+ const op = pendingOps[index];
8973
+ if (op.fromRuntime <= runtimePos) {
8974
+ runtimePos -= opSizeDelta(op);
8975
+ }
8976
+ }
8977
+ return Math.max(0, runtimePos);
8978
+ }
8979
+ function applyPendingOpsToCanonicalRuntime(runtimePos, pendingOps) {
8980
+ let transformed = runtimePos;
8981
+ for (const op of pendingOps) {
8982
+ if (op.fromRuntime <= transformed) {
8983
+ transformed += opSizeDelta(op);
8984
+ }
8985
+ }
8986
+ return Math.max(0, transformed);
8987
+ }
8795
8988
  function totalDelta(pendingOps) {
8796
8989
  let delta = 0;
8797
8990
  for (const op of pendingOps) {
@@ -14149,7 +14149,7 @@ function resolveContentType(path, contentTypes) {
14149
14149
  // src/io/ooxml/parse-bookmark-references.ts
14150
14150
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
14151
14151
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
14152
- var SIMPLE_FIELD_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*"([^"]*)"/gi;
14152
+ var FLD_SIMPLE_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*(?:\bw:instr|\binstr)\s*=\s*(["'])([\s\S]*?)\1/gi;
14153
14153
  var TOC_FIELD_RE = /\bTOC\b/;
14154
14154
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
14155
14155
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -14168,15 +14168,11 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14168
14168
  }
14169
14169
  INSTR_TEXT_RE.lastIndex = 0;
14170
14170
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
14171
- if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
14172
- retainAllToc = true;
14173
- }
14171
+ if (scanInstructionText(m[1] ?? "", retained)) retainAllToc = true;
14174
14172
  }
14175
- SIMPLE_FIELD_INSTR_RE.lastIndex = 0;
14176
- while ((m = SIMPLE_FIELD_INSTR_RE.exec(documentXml)) !== null) {
14177
- if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
14178
- retainAllToc = true;
14179
- }
14173
+ FLD_SIMPLE_INSTR_RE.lastIndex = 0;
14174
+ while ((m = FLD_SIMPLE_INSTR_RE.exec(documentXml)) !== null) {
14175
+ if (scanInstructionText(m[2] ?? "", retained)) retainAllToc = true;
14180
14176
  }
14181
14177
  retainRevisionBoundedBookmarks(documentXml, retained);
14182
14178
  return {
@@ -14185,11 +14181,11 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14185
14181
  retainAll
14186
14182
  };
14187
14183
  }
14188
- function scanInstructionForRetainedBookmarks(instruction, retained) {
14189
- const hasTocField = TOC_FIELD_RE.test(instruction);
14184
+ function scanInstructionText(instrText, retained) {
14185
+ const hasTocField = TOC_FIELD_RE.test(instrText);
14190
14186
  REFLIKE_FIELD_RE.lastIndex = 0;
14191
14187
  let r;
14192
- while ((r = REFLIKE_FIELD_RE.exec(instruction)) !== null) {
14188
+ while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
14193
14189
  if (r[1]) retained.add(r[1]);
14194
14190
  }
14195
14191
  return hasTocField;
@@ -17696,7 +17692,7 @@ var SAFE_TABLE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
17696
17692
  "FORMULA"
17697
17693
  ]);
17698
17694
  var RISKY_TABLE_MARKUP_RE = /<w:(ins|del|moveFrom|moveTo|rPrChange|pPrChange|tblPrChange|trPrChange|tcPrChange|sectPrChange|cellIns|cellDel|cellMerge|smartTag)\b/;
17699
- var SIMPLE_FIELD_INSTR_RE2 = /\bw:instr="([^"]*)"/g;
17695
+ var SIMPLE_FIELD_INSTR_RE = /\bw:instr="([^"]*)"/g;
17700
17696
  var COMPLEX_FIELD_TOKEN_RE = /<(?:\w+:)?fldChar\b[^>]*?(?:\w+:)?fldCharType="(begin|separate|end)"[^>]*?(?:\/>|>[\s\S]*?<\/(?:\w+:)?fldChar>)|<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gu;
17701
17697
  function decodeXmlEntities5(text) {
17702
17698
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
@@ -17737,7 +17733,7 @@ function isSafeTableFieldInstruction(instruction) {
17737
17733
  }
17738
17734
  function tableRequiresOpaquePreservation(rawXml) {
17739
17735
  if (RISKY_TABLE_MARKUP_RE.test(rawXml)) return true;
17740
- const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE2)].map(
17736
+ const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE)].map(
17741
17737
  (match) => match[1] ?? ""
17742
17738
  );
17743
17739
  const complexInstructions = extractComplexFieldInstructionsFromRaw(rawXml);
@@ -23350,7 +23346,8 @@ function parseCommentDefinitions(commentsXml, extensions, durableIds) {
23350
23346
  const createdAt = normalizeImportedTimestamp2(
23351
23347
  readStringAttr(child, "w:date")
23352
23348
  );
23353
- const initials = readStringAttr(child, "w:initials");
23349
+ const rawInitials = readStringAttr(child, "w:initials");
23350
+ const initials = rawInitials !== void 0 && rawInitials.trim().length > 0 ? rawInitials : void 0;
23354
23351
  const paragraphNodes = child.children.filter(
23355
23352
  (node) => node.type === "element" && localName(node.name) === "p"
23356
23353
  );