@beyondwork/docx-react-component 1.0.133 → 1.0.134

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 (70) hide show
  1. package/dist/api/public-types.cjs +3 -1
  2. package/dist/api/public-types.d.cts +1 -1
  3. package/dist/api/public-types.d.ts +1 -1
  4. package/dist/api/public-types.js +1 -1
  5. package/dist/api/v3.cjs +688 -45
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +3 -3
  9. package/dist/{chunk-S3PEKX6H.js → chunk-3YR47WTD.js} +53 -547
  10. package/dist/{chunk-57HTKX3P.js → chunk-74R5B2EZ.js} +1 -1
  11. package/dist/{chunk-KL4TZSZV.js → chunk-7Y6JCIK3.js} +1 -1
  12. package/dist/{chunk-3JEE5RJU.js → chunk-EBSI6VQX.js} +457 -16
  13. package/dist/{chunk-OTRVGNZQ.js → chunk-ESEEWELA.js} +547 -2
  14. package/dist/{chunk-224TSMEB.js → chunk-IJD6D7HU.js} +137 -41
  15. package/dist/{chunk-CVSD3UNK.js → chunk-O4EDZR44.js} +3 -1
  16. package/dist/{chunk-ZFCZ7XXH.js → chunk-VA24T4EB.js} +1 -1
  17. package/dist/core/commands/formatting-commands.d.cts +1 -1
  18. package/dist/core/commands/formatting-commands.d.ts +1 -1
  19. package/dist/core/commands/image-commands.d.cts +1 -1
  20. package/dist/core/commands/image-commands.d.ts +1 -1
  21. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  22. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  23. package/dist/core/commands/style-commands.d.cts +1 -1
  24. package/dist/core/commands/style-commands.d.ts +1 -1
  25. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  26. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  27. package/dist/core/commands/text-commands.d.cts +1 -1
  28. package/dist/core/commands/text-commands.d.ts +1 -1
  29. package/dist/core/selection/mapping.d.cts +1 -1
  30. package/dist/core/selection/mapping.d.ts +1 -1
  31. package/dist/core/state/editor-state.d.cts +1 -1
  32. package/dist/core/state/editor-state.d.ts +1 -1
  33. package/dist/index.cjs +1289 -615
  34. package/dist/index.d.cts +4 -4
  35. package/dist/index.d.ts +4 -4
  36. package/dist/index.js +105 -19
  37. package/dist/io/docx-session.d.cts +3 -3
  38. package/dist/io/docx-session.d.ts +3 -3
  39. package/dist/{loader-B2H99237.d.cts → loader-CK3lZy4h.d.cts} +2 -2
  40. package/dist/{loader-DfTjqVwn.d.ts → loader-CQXplstv.d.ts} +2 -2
  41. package/dist/{public-types-S8gTYwKo.d.cts → public-types-BR1SYK2F.d.cts} +140 -3
  42. package/dist/{public-types-B5lOUIrP.d.ts → public-types-DXNZVKrS.d.ts} +140 -3
  43. package/dist/public-types.cjs +3 -1
  44. package/dist/public-types.d.cts +1 -1
  45. package/dist/public-types.d.ts +1 -1
  46. package/dist/public-types.js +1 -1
  47. package/dist/runtime/collab.d.cts +2 -2
  48. package/dist/runtime/collab.d.ts +2 -2
  49. package/dist/runtime/document-runtime.cjs +591 -54
  50. package/dist/runtime/document-runtime.d.cts +1 -1
  51. package/dist/runtime/document-runtime.d.ts +1 -1
  52. package/dist/runtime/document-runtime.js +4 -4
  53. package/dist/{session-CBDIOYXA.d.ts → session-C9UjrhJF.d.ts} +2 -2
  54. package/dist/{session-CR2A1hGZ.d.cts → session-CSbwkgII.d.cts} +2 -2
  55. package/dist/session.d.cts +4 -4
  56. package/dist/session.d.ts +4 -4
  57. package/dist/tailwind.cjs +54 -546
  58. package/dist/tailwind.d.cts +1 -1
  59. package/dist/tailwind.d.ts +1 -1
  60. package/dist/tailwind.js +4 -4
  61. package/dist/{types-yty2K-hk.d.cts → types-CZtAueri.d.cts} +1 -1
  62. package/dist/{types-B-90ywjU.d.ts → types-RzkCXDNV.d.ts} +1 -1
  63. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  64. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  65. package/dist/ui-tailwind/editor-surface/search-plugin.js +2 -2
  66. package/dist/ui-tailwind.cjs +54 -546
  67. package/dist/ui-tailwind.d.cts +2 -2
  68. package/dist/ui-tailwind.d.ts +2 -2
  69. package/dist/ui-tailwind.js +4 -4
  70. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PAGE_STACK_GAP_PX,
3
3
  resolveDefaultZoom
4
- } from "./chunk-CVSD3UNK.js";
4
+ } from "./chunk-O4EDZR44.js";
5
5
  import {
6
6
  MAIN_STORY_KEY,
7
7
  collectCanonicalLayoutInputs,
@@ -8,7 +8,7 @@ import {
8
8
  getRevisionRangeState,
9
9
  selectionTouchesRange,
10
10
  shouldHideInCleanMode
11
- } from "./chunk-S3PEKX6H.js";
11
+ } from "./chunk-3YR47WTD.js";
12
12
 
13
13
  // src/ui-tailwind/editor-surface/tw-editor-surface.tsx
14
14
  import { useMemo } from "react";
@@ -48,7 +48,7 @@ import {
48
48
  buildGeometryDebugEntry,
49
49
  collectLineBoxesForRegion,
50
50
  createGeometryFacet
51
- } from "./chunk-57HTKX3P.js";
51
+ } from "./chunk-74R5B2EZ.js";
52
52
  import {
53
53
  AI_ACTION_POLICIES,
54
54
  allocateNumberingInstance,
@@ -83,7 +83,7 @@ import {
83
83
  sameScopeParagraphPath,
84
84
  serializeFragmentToWordML,
85
85
  setStartOverride
86
- } from "./chunk-224TSMEB.js";
86
+ } from "./chunk-IJD6D7HU.js";
87
87
  import {
88
88
  ISSUE_METADATA_ID,
89
89
  LAYOUT_ENGINE_VERSION,
@@ -121,7 +121,7 @@ import {
121
121
  setWorkspaceMode,
122
122
  setZoomLevel,
123
123
  snapCommentAnchorAwayFromTable
124
- } from "./chunk-CVSD3UNK.js";
124
+ } from "./chunk-O4EDZR44.js";
125
125
  import {
126
126
  countLogicalPositions,
127
127
  createPlainText,
@@ -130,6 +130,7 @@ import {
130
130
  serializeTextStory
131
131
  } from "./chunk-QIO6V46H.js";
132
132
  import {
133
+ NO_EDITABLE_TARGETS_INDEX,
133
134
  ThemeColorResolver,
134
135
  createEditorSurfaceSnapshot,
135
136
  createFieldResolver,
@@ -528,9 +529,11 @@ function applyRevisionAction(options) {
528
529
  );
529
530
  }
530
531
  const slice = story.units.slice(range.from, range.to);
531
- if (slice.some(
532
- (unit) => unit.kind === "paragraph_break" || unit.kind === "opaque_block" || unit.kind === "structural_block"
533
- )) {
532
+ const touchesStructuralContent = slice.some(
533
+ (unit) => unit.kind === "opaque_block" || unit.kind === "structural_block"
534
+ );
535
+ const touchesParagraphBoundary = slice.some((unit) => unit.kind === "paragraph_break");
536
+ if (touchesStructuralContent || touchesParagraphBoundary && !canApplyRuntimeTextBlockDeletion(revision, options.intent)) {
534
537
  return skippedResult(
535
538
  options,
536
539
  "structural-range",
@@ -538,7 +541,7 @@ function applyRevisionAction(options) {
538
541
  );
539
542
  }
540
543
  if (slice.some(
541
- (unit) => unit.kind === "image" || unit.kind === "opaque_inline"
544
+ (unit) => unit.kind === "image" || unit.kind === "opaque_inline" || unit.kind === "protected_inline"
542
545
  )) {
543
546
  return skippedResult(
544
547
  options,
@@ -593,6 +596,9 @@ function applyRevisionAction(options) {
593
596
  detachedRevisionIds: findNewDetachedRevisionIds(options.store, nextStore)
594
597
  };
595
598
  }
599
+ function canApplyRuntimeTextBlockDeletion(revision, intent) {
600
+ return revision.metadata.source === "runtime" && (intent === "accept" && revision.kind === "deletion" && (revision.metadata.semanticKind === "replacement" || revision.metadata.semanticKind === "deletion") || intent === "reject" && revision.kind === "insertion" && (revision.metadata.semanticKind === "replacement" || revision.metadata.semanticKind === "structural-change"));
601
+ }
596
602
  function applyPairedMoveAction(options, revision) {
597
603
  const resultingStatus = toResultingStatus(options.intent);
598
604
  return {
@@ -2235,6 +2241,11 @@ function executeEditorCommand(state, command, context) {
2235
2241
  );
2236
2242
  return buildDocumentReplaceTransaction(state, context, result);
2237
2243
  }
2244
+ case "fragment.insert-tracked": {
2245
+ const result = applySuggestingFragmentInsert(state, command.fragment, context);
2246
+ if (result) return result;
2247
+ return createTransaction(state, { historyBoundary: "skip", markDirty: false });
2248
+ }
2238
2249
  case "runtime.set-read-only":
2239
2250
  return createTransaction(
2240
2251
  {
@@ -3480,7 +3491,7 @@ function applyTextCommand(state, timestamp, apply) {
3480
3491
  const reviewState = remapReviewStateAfterContentChange(
3481
3492
  state,
3482
3493
  result.document,
3483
- result.mapping
3494
+ result.mapping ?? createEmptyMapping()
3484
3495
  );
3485
3496
  const scopeTagTouches = collectScopeTagTouches(
3486
3497
  state.document.review.comments,
@@ -3820,6 +3831,38 @@ function isSingleParagraphSuggestingRange(document, from, to) {
3820
3831
  );
3821
3832
  return ranges.some((range) => from >= range.start && to <= range.end);
3822
3833
  }
3834
+ function isTextOnlySuggestingRange(document, from, to) {
3835
+ const story = parseTextStory(document.content);
3836
+ const range = normalizeTextStoryRange(story, from, to);
3837
+ if (!range) {
3838
+ return isSingleParagraphSuggestingRange(document, from, to);
3839
+ }
3840
+ const rootStoryTextOnly = story.units.slice(range.from, range.to).every(isSuggestingTextReplacementUnit);
3841
+ if (rootStoryTextOnly) return true;
3842
+ return isSingleParagraphSuggestingRange(document, from, to);
3843
+ }
3844
+ function normalizeTextStoryRange(story, from, to) {
3845
+ const start = Math.min(from, to);
3846
+ const end = Math.max(from, to);
3847
+ if (start < 0 || end > story.size) return null;
3848
+ return { from: start, to: end };
3849
+ }
3850
+ function isSuggestingTextReplacementUnit(unit) {
3851
+ switch (unit.kind) {
3852
+ case "text":
3853
+ case "tab":
3854
+ case "hard_break":
3855
+ case "paragraph_break":
3856
+ case "scope_marker":
3857
+ return true;
3858
+ case "protected_inline":
3859
+ case "image":
3860
+ case "opaque_inline":
3861
+ case "opaque_block":
3862
+ case "structural_block":
3863
+ return false;
3864
+ }
3865
+ }
3823
3866
  function collectSuggestingParagraphRanges(blocks, startCursor, output, addRootParagraphBoundaries) {
3824
3867
  let cursor = startCursor;
3825
3868
  for (let index = 0; index < blocks.length; index += 1) {
@@ -3892,10 +3935,10 @@ function applySuggestingInsert(state, text, context, formatting) {
3892
3935
  const from = Math.min(selection.anchor, selection.head);
3893
3936
  const to = Math.max(selection.anchor, selection.head);
3894
3937
  const isCollapsed = from === to;
3895
- if (!isCollapsed && !isSingleParagraphSuggestingRange(state.document, from, to)) {
3938
+ if (!isCollapsed && !isTextOnlySuggestingRange(state.document, from, to)) {
3896
3939
  return createSuggestingUnsupportedTransaction(
3897
3940
  state,
3898
- "Suggesting mode does not yet support multi-paragraph replacement ranges."
3941
+ "Suggesting mode text replacement ranges must contain only editable text and paragraph breaks."
3899
3942
  );
3900
3943
  }
3901
3944
  if (isCollapsed) {
@@ -4004,7 +4047,7 @@ function applySuggestingInsert(state, text, context, formatting) {
4004
4047
  const reviewState = remapReviewStateAfterContentChange(
4005
4048
  state,
4006
4049
  result.document,
4007
- result.mapping
4050
+ result.mapping ?? createEmptyMapping()
4008
4051
  );
4009
4052
  const replacementSuggestionId = createSuggestingRevisionId(
4010
4053
  reviewState.document.review.revisions,
@@ -4069,6 +4112,131 @@ function applySuggestingInsert(state, text, context, formatting) {
4069
4112
  activeCommentId: reviewState.activeCommentId
4070
4113
  }
4071
4114
  },
4115
+ {
4116
+ historyBoundary: "push",
4117
+ markDirty: true,
4118
+ mapping: result.mapping ?? createEmptyMapping(),
4119
+ effects: {
4120
+ ...reviewState.effects,
4121
+ revisionAuthored: { changeId: insertionRevision.changeId, kind: "insertion" }
4122
+ }
4123
+ }
4124
+ );
4125
+ }
4126
+ function applySuggestingFragmentInsert(state, fragment, context) {
4127
+ if (state.readOnly) {
4128
+ return createTransaction(state, { historyBoundary: "skip", markDirty: false });
4129
+ }
4130
+ if (fragment.blocks.length === 0) {
4131
+ return createTransaction(state, { historyBoundary: "skip", markDirty: false });
4132
+ }
4133
+ if (!isTrackableSuggestingFragment(fragment)) {
4134
+ return createSuggestingUnsupportedTransaction(
4135
+ state,
4136
+ "Suggesting mode structured fragment replacement supports paragraph/text fragments only."
4137
+ );
4138
+ }
4139
+ const authorId = context.defaultAuthorId ?? "unknown";
4140
+ const selection = state.selection;
4141
+ const from = Math.min(selection.anchor, selection.head);
4142
+ const to = Math.max(selection.anchor, selection.head);
4143
+ const isCollapsed = from === to;
4144
+ if (!isCollapsed && !isTextOnlySuggestingRange(state.document, from, to)) {
4145
+ return createSuggestingUnsupportedTransaction(
4146
+ state,
4147
+ "Suggesting mode structured fragment replacement ranges must contain only editable text and paragraph breaks."
4148
+ );
4149
+ }
4150
+ const storyBefore = parseTextStory(state.document.content);
4151
+ const insertSelection = createSelectionSnapshot(to, to);
4152
+ const result = structureLayer.applyFragmentInsert(
4153
+ state.document,
4154
+ insertSelection,
4155
+ fragment,
4156
+ context
4157
+ );
4158
+ if (!result.changed) {
4159
+ return createTransaction(state, { historyBoundary: "skip", markDirty: false });
4160
+ }
4161
+ const storyAfter = parseTextStory(result.document.content);
4162
+ const insertedFrom = to;
4163
+ const insertedTo = to + Math.max(0, storyAfter.size - storyBefore.size);
4164
+ if (insertedTo <= insertedFrom) {
4165
+ return createTransaction(state, { historyBoundary: "skip", markDirty: false });
4166
+ }
4167
+ const reviewState = remapReviewStateAfterContentChange(
4168
+ state,
4169
+ result.document,
4170
+ result.mapping ?? createEmptyMapping()
4171
+ );
4172
+ const replacementSuggestionId = !isCollapsed ? createSuggestingRevisionId(
4173
+ reviewState.document.review.revisions,
4174
+ context.timestamp,
4175
+ authorId
4176
+ ) : void 0;
4177
+ let deletionRevision = !isCollapsed ? createAuthoredRevision(
4178
+ reviewState.document.review.revisions,
4179
+ "deletion",
4180
+ from,
4181
+ to,
4182
+ authorId,
4183
+ context.timestamp,
4184
+ createSuggestionMetadata({
4185
+ suggestionId: replacementSuggestionId,
4186
+ semanticKind: "replacement"
4187
+ })
4188
+ ) : void 0;
4189
+ const insertionRevision = createAuthoredRevision(
4190
+ {
4191
+ ...reviewState.document.review.revisions,
4192
+ ...deletionRevision ? { [deletionRevision.changeId]: deletionRevision } : {}
4193
+ },
4194
+ "insertion",
4195
+ insertedFrom,
4196
+ insertedTo,
4197
+ authorId,
4198
+ context.timestamp,
4199
+ createSuggestionMetadata(
4200
+ deletionRevision ? {
4201
+ suggestionId: replacementSuggestionId,
4202
+ semanticKind: "replacement",
4203
+ linkedRevisionIds: [deletionRevision.changeId]
4204
+ } : {
4205
+ semanticKind: "structural-change"
4206
+ }
4207
+ )
4208
+ );
4209
+ if (deletionRevision) {
4210
+ deletionRevision = {
4211
+ ...deletionRevision,
4212
+ metadata: {
4213
+ ...deletionRevision.metadata,
4214
+ linkedRevisionIds: [insertionRevision.changeId]
4215
+ }
4216
+ };
4217
+ }
4218
+ const finalDocument = {
4219
+ ...reviewState.document,
4220
+ review: {
4221
+ ...reviewState.document.review,
4222
+ revisions: {
4223
+ ...reviewState.document.review.revisions,
4224
+ ...deletionRevision ? { [deletionRevision.changeId]: deletionRevision } : {},
4225
+ [insertionRevision.changeId]: insertionRevision
4226
+ }
4227
+ }
4228
+ };
4229
+ return createTransaction(
4230
+ {
4231
+ ...state,
4232
+ document: finalDocument,
4233
+ selection: createSelectionSnapshot(insertedTo, insertedTo),
4234
+ warnings: reviewState.warnings,
4235
+ runtime: {
4236
+ ...state.runtime,
4237
+ activeCommentId: reviewState.activeCommentId
4238
+ }
4239
+ },
4072
4240
  {
4073
4241
  historyBoundary: "push",
4074
4242
  markDirty: true,
@@ -4080,6 +4248,10 @@ function applySuggestingInsert(state, text, context, formatting) {
4080
4248
  }
4081
4249
  );
4082
4250
  }
4251
+ function isTrackableSuggestingFragment(fragment) {
4252
+ const story = parseTextStory({ type: "doc", children: fragment.blocks });
4253
+ return story.units.every(isSuggestingTextReplacementUnit);
4254
+ }
4083
4255
  function applySuggestingDelete(state, direction, context) {
4084
4256
  if (state.readOnly) {
4085
4257
  return createTransaction(state, { historyBoundary: "skip", markDirty: false });
@@ -4089,10 +4261,10 @@ function applySuggestingDelete(state, direction, context) {
4089
4261
  const from = Math.min(selection.anchor, selection.head);
4090
4262
  const to = Math.max(selection.anchor, selection.head);
4091
4263
  const isCollapsed = from === to;
4092
- if (!isCollapsed && !isSingleParagraphSuggestingRange(state.document, from, to)) {
4264
+ if (!isCollapsed && !isTextOnlySuggestingRange(state.document, from, to)) {
4093
4265
  return createSuggestingUnsupportedTransaction(
4094
4266
  state,
4095
- "Suggesting mode does not yet support multi-paragraph deletion ranges."
4267
+ "Suggesting mode text deletion ranges must contain only editable text and paragraph breaks."
4096
4268
  );
4097
4269
  }
4098
4270
  let deleteFrom;
@@ -14651,7 +14823,20 @@ function createDocumentRuntime(options) {
14651
14823
  selection: prepared.selection
14652
14824
  };
14653
14825
  resolvedReplayTextTarget = prepared.textTarget;
14654
- } else if (command.type === "field.refresh" || command.type === "toc.refresh" || command.type === "bookmark.edit-content" || command.type === "hyperlink.update-destination") {
14826
+ } else {
14827
+ const selectedListItemDeleteCommand = createSelectedListItemDeleteReplayCommand({
14828
+ command,
14829
+ document: replayState.document,
14830
+ selection: replayState.selection,
14831
+ surface: replaySnapshot.surface?.blocks ?? [],
14832
+ storyTarget: replayStory,
14833
+ timestamp: context.timestamp
14834
+ });
14835
+ if (selectedListItemDeleteCommand) {
14836
+ executableCommand = selectedListItemDeleteCommand;
14837
+ }
14838
+ }
14839
+ if (command.type === "field.refresh" || command.type === "toc.refresh" || command.type === "bookmark.edit-content" || command.type === "hyperlink.update-destination") {
14655
14840
  const prepared = prepareModeledTargetCommandForExecution(
14656
14841
  command,
14657
14842
  replayState.document,
@@ -14795,7 +14980,20 @@ function createDocumentRuntime(options) {
14795
14980
  selection: prepared.selection
14796
14981
  };
14797
14982
  resolvedReplayTextTarget = prepared.textTarget;
14798
- } else if (command.type === "field.refresh" || command.type === "toc.refresh" || command.type === "bookmark.edit-content" || command.type === "hyperlink.update-destination") {
14983
+ } else {
14984
+ const selectedListItemDeleteCommand = createSelectedListItemDeleteReplayCommand({
14985
+ command,
14986
+ document: stateForCommand.document,
14987
+ selection: stateForCommand.selection,
14988
+ surface: snapshotForCommand.surface?.blocks ?? [],
14989
+ storyTarget: replayStory,
14990
+ timestamp: context.timestamp
14991
+ });
14992
+ if (selectedListItemDeleteCommand) {
14993
+ executableCommand = selectedListItemDeleteCommand;
14994
+ }
14995
+ }
14996
+ if (command.type === "field.refresh" || command.type === "toc.refresh" || command.type === "bookmark.edit-content" || command.type === "hyperlink.update-destination") {
14799
14997
  const prepared = prepareModeledTargetCommandForExecution(
14800
14998
  command,
14801
14999
  stateForCommand.document,
@@ -15216,6 +15414,50 @@ function createDocumentRuntime(options) {
15216
15414
  } catch (error) {
15217
15415
  emitError(toRuntimeError(error));
15218
15416
  }
15417
+ } else if (step.kind === "fragment-replace-tracked" && step.range && step.fragment && Array.isArray(step.fragment.blocks)) {
15418
+ const editableTarget = resolveEditableTargetHint(step.editableTargetHint);
15419
+ if (editableTarget === null) {
15420
+ emit({
15421
+ type: "command_blocked",
15422
+ documentId: state.documentId,
15423
+ command: "applyScopeReplacement",
15424
+ reasons: [{
15425
+ code: "unsupported_surface",
15426
+ message: "Scope replacement editable target no longer resolves."
15427
+ }]
15428
+ });
15429
+ continue;
15430
+ }
15431
+ const dispatchRange = mapSemanticStepRangeToEditableTarget(
15432
+ step.range,
15433
+ step.editableTargetHint,
15434
+ editableTarget?.range
15435
+ );
15436
+ const anchor = {
15437
+ kind: "range",
15438
+ from: dispatchRange.from,
15439
+ to: dispatchRange.to,
15440
+ assoc: { start: -1, end: 1 }
15441
+ };
15442
+ const timestamp = clock();
15443
+ try {
15444
+ applyTextCommandInActiveStory(
15445
+ {
15446
+ type: "fragment.insert-tracked",
15447
+ fragment: step.fragment,
15448
+ ...editableTarget?.target ? { editableTarget: editableTarget.target } : {},
15449
+ origin: createOrigin("api", timestamp)
15450
+ },
15451
+ {
15452
+ selection: createSelectionFromPublicAnchor(anchor),
15453
+ blockedCommandName: "applyScopeReplacement",
15454
+ documentModeOverride: "suggesting",
15455
+ skipWorkflowGuard: true
15456
+ }
15457
+ );
15458
+ } catch (error) {
15459
+ emitError(toRuntimeError(error));
15460
+ }
15219
15461
  } else if (step.kind === "text-insert-tracked" && step.range && typeof step.text === "string") {
15220
15462
  const editableTarget = resolveEditableTargetHint(step.editableTargetHint);
15221
15463
  if (editableTarget === null) {
@@ -17198,6 +17440,38 @@ function createDocumentRuntime(options) {
17198
17440
  const preSelection = selection;
17199
17441
  const preActiveStory = activeStory;
17200
17442
  const priorDocument = state.document;
17443
+ const selectedListItemDelete = createSelectedListItemDeleteReplacement({
17444
+ command: commandForDispatch,
17445
+ document: state.document,
17446
+ editableTarget,
17447
+ selection,
17448
+ targetResolution,
17449
+ timestamp
17450
+ });
17451
+ if (selectedListItemDelete && activeStory.kind === "main" && context.documentMode !== "suggesting") {
17452
+ const replacementCommand = {
17453
+ type: "document.replace",
17454
+ document: selectedListItemDelete.document,
17455
+ selection: selectedListItemDelete.selection,
17456
+ mapping: selectedListItemDelete.mapping,
17457
+ protectionSelection: selection,
17458
+ origin: commandForDispatch.origin
17459
+ };
17460
+ const transaction = executeEditorCommand(baseState, replacementCommand, context);
17461
+ commit(transaction);
17462
+ options.onCommandApplied?.(commandForDispatch, transaction, context, {
17463
+ preSelection,
17464
+ activeStory: preActiveStory,
17465
+ priorDocument
17466
+ });
17467
+ return completeDispatch(classifyAck({
17468
+ command: commandForDispatch,
17469
+ opId,
17470
+ priorState: baseState,
17471
+ transaction,
17472
+ newRevisionToken: state.revisionToken
17473
+ }));
17474
+ }
17201
17475
  if (activeStory.kind === "main") {
17202
17476
  const mainTransaction = executeEditorCommand(baseState, commandForDispatch, context);
17203
17477
  commit(mainTransaction);
@@ -18392,7 +18666,8 @@ function getStoryPlainText(document, storyTarget, cache) {
18392
18666
  const plainText = createEditorSurfaceSnapshot(
18393
18667
  document,
18394
18668
  createSelectionSnapshot(0, 0),
18395
- storyTarget
18669
+ storyTarget,
18670
+ { editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX }
18396
18671
  ).plainText;
18397
18672
  cache.set(key, plainText);
18398
18673
  return plainText;
@@ -20077,6 +20352,172 @@ function stripStoryTarget(selection) {
20077
20352
  function isTopLevelMainStoryBlockPath(blockPath) {
20078
20353
  return typeof blockPath === "string" && /^main\/block\[\d+\]$/u.test(blockPath);
20079
20354
  }
20355
+ function createSelectedListItemDeleteReplacement(input) {
20356
+ const { command, document, editableTarget, selection, targetResolution, timestamp } = input;
20357
+ if (command.type !== "text.delete-backward" && command.type !== "text.delete-forward") {
20358
+ return null;
20359
+ }
20360
+ if (selection.isCollapsed || editableTarget?.listAddress?.operationScope !== "list-text" || targetResolution?.kind !== "accepted") {
20361
+ return null;
20362
+ }
20363
+ const selectionFrom = Math.min(selection.anchor, selection.head);
20364
+ const selectionTo = Math.max(selection.anchor, selection.head);
20365
+ if (selectionFrom !== targetResolution.range.from || selectionTo !== targetResolution.range.to) {
20366
+ return null;
20367
+ }
20368
+ const root = document.content;
20369
+ const replacement = removeNumberedParagraphAtMainStoryPath(root.children, editableTarget.blockPath);
20370
+ if (!replacement) {
20371
+ return null;
20372
+ }
20373
+ const nextDocument = {
20374
+ ...document,
20375
+ updatedAt: timestamp,
20376
+ content: {
20377
+ ...root,
20378
+ children: replacement.blocks
20379
+ }
20380
+ };
20381
+ const nextStorySize = parseTextStory(nextDocument.content).size;
20382
+ const nextAnchor = Math.min(selectionFrom, nextStorySize);
20383
+ return {
20384
+ document: nextDocument,
20385
+ selection: createSelectionSnapshot(nextAnchor, nextAnchor),
20386
+ mapping: {
20387
+ steps: [{
20388
+ from: selectionFrom,
20389
+ to: selectionTo,
20390
+ insertSize: 0
20391
+ }],
20392
+ metadata: {
20393
+ invalidatesStructures: true
20394
+ }
20395
+ }
20396
+ };
20397
+ }
20398
+ function removeNumberedParagraphAtMainStoryPath(blocks, blockPath) {
20399
+ const tokens = parseMainStoryBlockPathTokens(blockPath);
20400
+ if (!tokens) return null;
20401
+ return removeNumberedParagraphFromBlocks(blocks, tokens);
20402
+ }
20403
+ function removeNumberedParagraphFromBlocks(blocks, tokens) {
20404
+ const [token, ...rest] = tokens;
20405
+ if (!token || token.kind !== "block") return null;
20406
+ const block = blocks[token.index];
20407
+ if (!block) return null;
20408
+ if (rest.length === 0) {
20409
+ if (block.type !== "paragraph" || !block.numbering) {
20410
+ return null;
20411
+ }
20412
+ if (blocks.length === 1) {
20413
+ return { blocks: [{ type: "paragraph", children: [] }] };
20414
+ }
20415
+ return {
20416
+ blocks: [
20417
+ ...blocks.slice(0, token.index),
20418
+ ...blocks.slice(token.index + 1)
20419
+ ]
20420
+ };
20421
+ }
20422
+ const next = rest[0];
20423
+ if (block.type === "table" && next?.kind === "row") {
20424
+ const updatedTable = removeNumberedParagraphFromTable(block, rest);
20425
+ if (!updatedTable) return null;
20426
+ return {
20427
+ blocks: [
20428
+ ...blocks.slice(0, token.index),
20429
+ updatedTable,
20430
+ ...blocks.slice(token.index + 1)
20431
+ ]
20432
+ };
20433
+ }
20434
+ if ((block.type === "sdt" || block.type === "custom_xml") && next?.kind === "block") {
20435
+ const updatedChildren = removeNumberedParagraphFromBlocks(block.children, rest);
20436
+ if (!updatedChildren) return null;
20437
+ return {
20438
+ blocks: [
20439
+ ...blocks.slice(0, token.index),
20440
+ { ...block, children: updatedChildren.blocks },
20441
+ ...blocks.slice(token.index + 1)
20442
+ ]
20443
+ };
20444
+ }
20445
+ return null;
20446
+ }
20447
+ function removeNumberedParagraphFromTable(table, tokens) {
20448
+ const [rowToken, cellToken, ...childTokens] = tokens;
20449
+ if (rowToken?.kind !== "row" || cellToken?.kind !== "cell" || childTokens[0]?.kind !== "block") {
20450
+ return null;
20451
+ }
20452
+ const row2 = table.rows[rowToken.index];
20453
+ const cell = row2?.cells[cellToken.index];
20454
+ if (!row2 || !cell) return null;
20455
+ const updatedChildren = removeNumberedParagraphFromBlocks(cell.children, childTokens);
20456
+ if (!updatedChildren) return null;
20457
+ const nextCells = [
20458
+ ...row2.cells.slice(0, cellToken.index),
20459
+ { ...cell, children: updatedChildren.blocks },
20460
+ ...row2.cells.slice(cellToken.index + 1)
20461
+ ];
20462
+ const nextRows = [
20463
+ ...table.rows.slice(0, rowToken.index),
20464
+ { ...row2, cells: nextCells },
20465
+ ...table.rows.slice(rowToken.index + 1)
20466
+ ];
20467
+ return { ...table, rows: nextRows };
20468
+ }
20469
+ function createSelectedListItemDeleteReplayCommand(input) {
20470
+ const { command, document, selection, surface, storyTarget, timestamp } = input;
20471
+ if (command.type !== "text.delete-backward" && command.type !== "text.delete-forward") {
20472
+ return null;
20473
+ }
20474
+ const editableTarget = command.editableTarget;
20475
+ if (!editableTarget) {
20476
+ return null;
20477
+ }
20478
+ const targetResolution = resolveEditableTextTarget({
20479
+ document,
20480
+ selection,
20481
+ surface,
20482
+ target: editableTarget,
20483
+ activeStoryKey: canonicalEditableTargetStoryKey(storyTarget)
20484
+ });
20485
+ const replacement = createSelectedListItemDeleteReplacement({
20486
+ command,
20487
+ document,
20488
+ editableTarget,
20489
+ selection,
20490
+ targetResolution,
20491
+ timestamp
20492
+ });
20493
+ if (!replacement || storyTarget.kind !== "main") {
20494
+ return null;
20495
+ }
20496
+ return {
20497
+ type: "document.replace",
20498
+ document: replacement.document,
20499
+ selection: replacement.selection,
20500
+ mapping: replacement.mapping,
20501
+ protectionSelection: selection,
20502
+ origin: command.origin
20503
+ };
20504
+ }
20505
+ function parseMainStoryBlockPathTokens(blockPath) {
20506
+ const parts = blockPath?.split("/") ?? [];
20507
+ if (parts[0] !== "main" || parts.length < 2) {
20508
+ return null;
20509
+ }
20510
+ const tokens = [];
20511
+ for (const part of parts.slice(1)) {
20512
+ const match = /^(block|row|cell)\[(\d+)\]$/u.exec(part);
20513
+ if (!match) return null;
20514
+ tokens.push({
20515
+ kind: match[1],
20516
+ index: Number.parseInt(match[2], 10)
20517
+ });
20518
+ }
20519
+ return tokens;
20520
+ }
20080
20521
  function toInternalSelectionSnapshot(selection) {
20081
20522
  return {
20082
20523
  anchor: selection.anchor,