@beyondwork/docx-react-component 1.0.132 → 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 (94) hide show
  1. package/dist/api/public-types.cjs +161 -68
  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 +3 -3
  5. package/dist/api/v3.cjs +9878 -7387
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{chunk-QUTVR72L.js → chunk-3YR47WTD.js} +296 -587
  10. package/dist/{chunk-RYMMKOFI.js → chunk-5KTJKTNE.js} +32 -0
  11. package/dist/{chunk-UP2KDOYE.js → chunk-74R5B2EZ.js} +6 -2
  12. package/dist/{chunk-6736GA6J.js → chunk-7Y6JCIK3.js} +1 -1
  13. package/dist/{chunk-43JAPM2F.js → chunk-EBSI6VQX.js} +546 -144
  14. package/dist/{chunk-JVTDBX67.js → chunk-EFEW7BTT.js} +2 -2
  15. package/dist/{chunk-YUHNDEV5.js → chunk-ESEEWELA.js} +3534 -1870
  16. package/dist/{chunk-XYTWOJII.js → chunk-IJD6D7HU.js} +745 -103
  17. package/dist/{chunk-UFPBYJMA.js → chunk-INLRCC4N.js} +2 -2
  18. package/dist/{chunk-N5FTU4HZ.js → chunk-MQ5GAJ54.js} +68 -39
  19. package/dist/{chunk-W2I47J2Q.js → chunk-NJFKPDNG.js} +216 -2
  20. package/dist/{chunk-LPLJZJT2.js → chunk-O4EDZR44.js} +131 -70
  21. package/dist/{chunk-4HGFJ6Z2.js → chunk-PZIEOEJZ.js} +1 -1
  22. package/dist/{chunk-C5LXKR54.js → chunk-QTRJLKR2.js} +1 -1
  23. package/dist/{chunk-SZ6BJA4Q.js → chunk-REFHJ2FN.js} +3 -3
  24. package/dist/{chunk-ZDYGRO2Z.js → chunk-RP76USJE.js} +1 -1
  25. package/dist/{chunk-RBWJHRNP.js → chunk-T66OS7MN.js} +8 -3
  26. package/dist/{chunk-ALWXYGXP.js → chunk-V2JF42SI.js} +2 -2
  27. package/dist/{chunk-CDEZGLQ3.js → chunk-VA24T4EB.js} +1 -1
  28. package/dist/{chunk-6TLZ6CMP.js → chunk-WDDFU2N2.js} +2 -2
  29. package/dist/{chunk-U3UMKA7B.js → chunk-XBQFDBXE.js} +1 -1
  30. package/dist/core/commands/formatting-commands.d.cts +1 -1
  31. package/dist/core/commands/formatting-commands.d.ts +1 -1
  32. package/dist/core/commands/image-commands.cjs +32 -0
  33. package/dist/core/commands/image-commands.d.cts +1 -1
  34. package/dist/core/commands/image-commands.d.ts +1 -1
  35. package/dist/core/commands/image-commands.js +5 -5
  36. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  37. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  38. package/dist/core/commands/style-commands.d.cts +1 -1
  39. package/dist/core/commands/style-commands.d.ts +1 -1
  40. package/dist/core/commands/table-structure-commands.cjs +32 -0
  41. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  42. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  43. package/dist/core/commands/table-structure-commands.js +4 -4
  44. package/dist/core/commands/text-commands.cjs +99 -38
  45. package/dist/core/commands/text-commands.d.cts +12 -1
  46. package/dist/core/commands/text-commands.d.ts +12 -1
  47. package/dist/core/commands/text-commands.js +5 -5
  48. package/dist/core/selection/mapping.d.cts +1 -1
  49. package/dist/core/selection/mapping.d.ts +1 -1
  50. package/dist/core/state/editor-state.d.cts +1 -1
  51. package/dist/core/state/editor-state.d.ts +1 -1
  52. package/dist/index.cjs +5365 -2298
  53. package/dist/index.d.cts +4 -4
  54. package/dist/index.d.ts +4 -4
  55. package/dist/index.js +388 -63
  56. package/dist/io/docx-session.cjs +7 -2
  57. package/dist/io/docx-session.d.cts +3 -3
  58. package/dist/io/docx-session.d.ts +3 -3
  59. package/dist/io/docx-session.js +4 -4
  60. package/dist/legal.js +3 -3
  61. package/dist/{loader-MAa8VpzW.d.cts → loader-CK3lZy4h.d.cts} +2 -2
  62. package/dist/{loader-CfpeEPAa.d.ts → loader-CQXplstv.d.ts} +2 -2
  63. package/dist/{public-types-KBS6JnOs.d.cts → public-types-BR1SYK2F.d.cts} +783 -189
  64. package/dist/{public-types-Cjs8glST.d.ts → public-types-DXNZVKrS.d.ts} +783 -189
  65. package/dist/public-types.cjs +161 -68
  66. package/dist/public-types.d.cts +1 -1
  67. package/dist/public-types.d.ts +1 -1
  68. package/dist/public-types.js +3 -3
  69. package/dist/runtime/collab.d.cts +2 -2
  70. package/dist/runtime/collab.d.ts +2 -2
  71. package/dist/runtime/document-runtime.cjs +1597 -444
  72. package/dist/runtime/document-runtime.d.cts +1 -1
  73. package/dist/runtime/document-runtime.d.ts +1 -1
  74. package/dist/runtime/document-runtime.js +14 -14
  75. package/dist/{session-CkoH8FoY.d.ts → session-C9UjrhJF.d.ts} +2 -2
  76. package/dist/{session-wwe0Gib-.d.cts → session-CSbwkgII.d.cts} +2 -2
  77. package/dist/session.cjs +7 -2
  78. package/dist/session.d.cts +4 -4
  79. package/dist/session.d.ts +4 -4
  80. package/dist/session.js +5 -5
  81. package/dist/tailwind.cjs +451 -650
  82. package/dist/tailwind.d.cts +1 -1
  83. package/dist/tailwind.d.ts +1 -1
  84. package/dist/tailwind.js +7 -7
  85. package/dist/{types-B3SGRW0w.d.cts → types-CZtAueri.d.cts} +1 -1
  86. package/dist/{types-CH7NWqVL.d.ts → types-RzkCXDNV.d.ts} +1 -1
  87. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  88. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  89. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  90. package/dist/ui-tailwind.cjs +451 -650
  91. package/dist/ui-tailwind.d.cts +3 -2
  92. package/dist/ui-tailwind.d.ts +3 -2
  93. package/dist/ui-tailwind.js +7 -7
  94. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  TextTransactionError
3
- } from "./chunk-N5FTU4HZ.js";
3
+ } from "./chunk-MQ5GAJ54.js";
4
4
  import {
5
5
  replaceParagraphScope,
6
6
  resolveParagraphScope
7
- } from "./chunk-C5LXKR54.js";
7
+ } from "./chunk-QTRJLKR2.js";
8
8
  import {
9
9
  cloneParagraphProperties,
10
10
  cloneStoryUnit,
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  NO_EDITABLE_TARGETS_INDEX,
12
12
  createEditorSurfaceSnapshot
13
- } from "./chunk-U3UMKA7B.js";
13
+ } from "./chunk-XBQFDBXE.js";
14
14
  import {
15
15
  createSelectionSnapshot
16
16
  } from "./chunk-OYGMRRR7.js";
@@ -24,7 +24,38 @@ var TextTransactionError = class extends Error {
24
24
  this.code = code;
25
25
  }
26
26
  };
27
+ function isUsableScopeSurface(surface, document) {
28
+ if (surface.viewportBlockRanges !== null) return false;
29
+ const root = document.content;
30
+ if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
31
+ return false;
32
+ }
33
+ return surface.blocks.length === root.children.length;
34
+ }
35
+ function createScopeSurfaceCache(document, selection, precomputedSurface, telemetry) {
36
+ let cached;
37
+ if (precomputedSurface && isUsableScopeSurface(precomputedSurface, document)) {
38
+ cached = precomputedSurface;
39
+ telemetry?.onPrecomputedSurfaceHit?.();
40
+ }
41
+ return {
42
+ get() {
43
+ if (cached) return cached;
44
+ telemetry?.onScopeSurfaceBuild?.();
45
+ cached = createEditorSurfaceSnapshot(document, selection, void 0, {
46
+ editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
47
+ });
48
+ return cached;
49
+ }
50
+ };
51
+ }
27
52
  function applyTextTransaction(document, selection, intent, options) {
53
+ const scopeSurfaceCache = createScopeSurfaceCache(
54
+ document,
55
+ selection,
56
+ options.precomputedSurface,
57
+ options.surfaceTelemetry
58
+ );
28
59
  if (options.textTarget) {
29
60
  if (options.textTarget.kind === "hyperlink-display") {
30
61
  const targetedHyperlinkResult = tryApplyHyperlinkDisplayTransaction(
@@ -60,7 +91,8 @@ function applyTextTransaction(document, selection, intent, options) {
60
91
  document,
61
92
  selection,
62
93
  intent,
63
- options
94
+ options,
95
+ scopeSurfaceCache
64
96
  );
65
97
  if (targetedTableResult) {
66
98
  return targetedTableResult;
@@ -74,7 +106,8 @@ function applyTextTransaction(document, selection, intent, options) {
74
106
  const tableStructureRefusal = resolveTargetlessTableStructureInsertRefusal(
75
107
  document,
76
108
  selection,
77
- intent
109
+ intent,
110
+ scopeSurfaceCache
78
111
  );
79
112
  if (tableStructureRefusal) {
80
113
  throw new TextTransactionError("unsupported_content", tableStructureRefusal);
@@ -84,7 +117,8 @@ function applyTextTransaction(document, selection, intent, options) {
84
117
  document,
85
118
  selection,
86
119
  intent,
87
- options
120
+ options,
121
+ scopeSurfaceCache
88
122
  );
89
123
  if (topLevelParagraphResult) {
90
124
  return topLevelParagraphResult;
@@ -93,7 +127,8 @@ function applyTextTransaction(document, selection, intent, options) {
93
127
  document,
94
128
  selection,
95
129
  intent,
96
- options
130
+ options,
131
+ scopeSurfaceCache
97
132
  );
98
133
  if (sdtScopedResult) {
99
134
  return sdtScopedResult;
@@ -102,7 +137,8 @@ function applyTextTransaction(document, selection, intent, options) {
102
137
  document,
103
138
  selection,
104
139
  intent,
105
- options
140
+ options,
141
+ scopeSurfaceCache
106
142
  );
107
143
  if (tableScopedResult) {
108
144
  return tableScopedResult;
@@ -155,9 +191,9 @@ function applyLinearTextTransaction(document, selection, intent, options) {
155
191
  storyText: createPlainText(nextStory)
156
192
  };
157
193
  }
158
- function tryApplyTableParagraphTransaction(document, selection, intent, options) {
194
+ function tryApplyTableParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
159
195
  const tableTarget = options.textTarget?.kind === "table-paragraph" ? options.textTarget : void 0;
160
- const scope = resolveTableParagraphScope(document, selection, tableTarget);
196
+ const scope = resolveTableParagraphScope(document, selection, tableTarget, scopeSurfaceCache);
161
197
  if (!scope) {
162
198
  return null;
163
199
  }
@@ -280,7 +316,11 @@ function tryApplyTargetedTextLeafTransaction(document, selection, intent, option
280
316
  };
281
317
  }
282
318
  function tryApplyHyperlinkDisplayTransaction(document, selection, intent, options) {
283
- const scope = resolveTargetedHyperlinkDisplayScope(document, selection, options.textTarget);
319
+ const scope = resolveTargetedHyperlinkDisplayScope(
320
+ document,
321
+ selection,
322
+ options.textTarget
323
+ );
284
324
  if (!scope) {
285
325
  return null;
286
326
  }
@@ -338,8 +378,8 @@ function tryApplyHyperlinkDisplayTransaction(document, selection, intent, option
338
378
  storyText: localResult.storyText
339
379
  };
340
380
  }
341
- function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options) {
342
- const scope = resolveTopLevelSdtParagraphScope(document, selection);
381
+ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
382
+ const scope = resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache);
343
383
  if (!scope) {
344
384
  return null;
345
385
  }
@@ -391,8 +431,8 @@ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, op
391
431
  storyText: localResult.storyText
392
432
  };
393
433
  }
394
- function tryApplyTopLevelParagraphTransaction(document, selection, intent, options) {
395
- const scope = resolveTopLevelParagraphScope(document, selection);
434
+ function tryApplyTopLevelParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
435
+ const scope = resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache);
396
436
  if (!scope) {
397
437
  return null;
398
438
  }
@@ -502,17 +542,15 @@ function resolveTargetedHyperlinkDisplayScope(document, selection, target) {
502
542
  replace: resolved.replace
503
543
  };
504
544
  }
505
- function resolveTableParagraphScope(document, selection, target) {
545
+ function resolveTableParagraphScope(document, selection, target, scopeSurfaceCache) {
506
546
  if (target) {
507
- return resolveTargetedTableParagraphScope(document, selection, target);
547
+ return resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache);
508
548
  }
509
549
  const root = document.content;
510
550
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
511
551
  return null;
512
552
  }
513
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
514
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
515
- });
553
+ const surface = scopeSurfaceCache.get();
516
554
  const selectionFrom = Math.min(selection.anchor, selection.head);
517
555
  const selectionTo = Math.max(selection.anchor, selection.head);
518
556
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -617,7 +655,7 @@ function resolveTableParagraphScope(document, selection, target) {
617
655
  }
618
656
  return null;
619
657
  }
620
- function resolveTargetlessTableStructureInsertRefusal(document, selection, intent) {
658
+ function resolveTargetlessTableStructureInsertRefusal(document, selection, intent, scopeSurfaceCache) {
621
659
  if (!isCollapsedInsertIntent(intent, selection)) {
622
660
  return null;
623
661
  }
@@ -625,9 +663,7 @@ function resolveTargetlessTableStructureInsertRefusal(document, selection, inten
625
663
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
626
664
  return null;
627
665
  }
628
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
629
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
630
- });
666
+ const surface = scopeSurfaceCache.get();
631
667
  if (!selectionTouchesTableStructureBoundary(surface.blocks, selection.anchor)) {
632
668
  return null;
633
669
  }
@@ -641,7 +677,7 @@ function isCollapsedInsertIntent(intent, selection) {
641
677
  const rangeTo = intent.range ? Math.max(intent.range.from, intent.range.to) : Math.max(selection.anchor, selection.head);
642
678
  return rangeFrom === rangeTo;
643
679
  }
644
- function resolveTargetedTableParagraphScope(document, selection, target) {
680
+ function resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache) {
645
681
  const root = document.content;
646
682
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
647
683
  return null;
@@ -654,7 +690,8 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
654
690
  root,
655
691
  document,
656
692
  selection,
657
- target
693
+ target,
694
+ scopeSurfaceCache
658
695
  );
659
696
  if (targetScope) {
660
697
  return targetScope;
@@ -677,9 +714,7 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
677
714
  if (cell.verticalMerge === "continue") {
678
715
  return "unsupported";
679
716
  }
680
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
681
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
682
- });
717
+ const surface = scopeSurfaceCache.get();
683
718
  const surfaceBlock = surface.blocks[target.tableBlockIndex];
684
719
  const surfaceRow = surfaceBlock?.kind === "table" ? surfaceBlock.rows[target.rowIndex] : void 0;
685
720
  const surfaceCell = surfaceRow?.cells[target.cellIndex];
@@ -743,16 +778,14 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
743
778
  }
744
779
  };
745
780
  }
746
- function resolveTargetedTableParagraphScopeByPath(root, document, selection, target) {
781
+ function resolveTargetedTableParagraphScopeByPath(root, document, selection, target, scopeSurfaceCache) {
747
782
  if (!target.blockPath) return null;
748
783
  const tokens = parseCanonicalBlockPath(target.blockPath);
749
784
  if (!tokens) return null;
750
785
  const resolved = resolveBlockPathInCanonicalBlocks(root.children, tokens, 0);
751
786
  if (!resolved || resolved.block.type !== "paragraph") return null;
752
787
  if (resolved.hasVerticalMergeContinuation) return null;
753
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
754
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
755
- });
788
+ const surface = scopeSurfaceCache.get();
756
789
  const surfaceResolved = resolveBlockPathInSurfaceBlocks(surface.blocks, tokens, 0);
757
790
  if (!surfaceResolved || surfaceResolved.kind !== "paragraph") return null;
758
791
  if (surfaceResolved.hasVerticalMergeContinuation) return null;
@@ -1207,14 +1240,12 @@ function resolveBlockPathInSurfaceBlocks(blocks, tokens, tokenIndex, hasVertical
1207
1240
  hasVerticalMergeContinuation || cell.verticalMerge === "continue"
1208
1241
  );
1209
1242
  }
1210
- function resolveTopLevelParagraphScope(document, selection) {
1243
+ function resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache) {
1211
1244
  const root = document.content;
1212
1245
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
1213
1246
  return null;
1214
1247
  }
1215
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
1216
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
1217
- });
1248
+ const surface = scopeSurfaceCache.get();
1218
1249
  const selectionFrom = Math.min(selection.anchor, selection.head);
1219
1250
  const selectionTo = Math.max(selection.anchor, selection.head);
1220
1251
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -1243,14 +1274,12 @@ function resolveTopLevelParagraphScope(document, selection) {
1243
1274
  }
1244
1275
  return null;
1245
1276
  }
1246
- function resolveTopLevelSdtParagraphScope(document, selection) {
1277
+ function resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache) {
1247
1278
  const root = document.content;
1248
1279
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
1249
1280
  return null;
1250
1281
  }
1251
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
1252
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
1253
- });
1282
+ const surface = scopeSurfaceCache.get();
1254
1283
  const selectionFrom = Math.min(selection.anchor, selection.head);
1255
1284
  const selectionTo = Math.max(selection.anchor, selection.head);
1256
1285
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  collectEditableTargetRefs
3
- } from "./chunk-RYMMKOFI.js";
3
+ } from "./chunk-5KTJKTNE.js";
4
4
 
5
5
  // src/api/v3/_ux-response.ts
6
6
  function emitUxResponse(runtime, res) {
@@ -2110,6 +2110,218 @@ function createScopeFamily(ctx) {
2110
2110
  };
2111
2111
  }
2112
2112
 
2113
+ // src/api/v3/ui/lists.ts
2114
+ var SUPPORTED_COMMANDS = [
2115
+ "toggle-numbered",
2116
+ "toggle-bulleted",
2117
+ "indent",
2118
+ "outdent",
2119
+ "restart-numbering",
2120
+ "continue-numbering"
2121
+ ];
2122
+ var UNSUPPORTED_COMMANDS = [
2123
+ "create",
2124
+ "attach",
2125
+ "detach",
2126
+ "join",
2127
+ "separate",
2128
+ "split",
2129
+ "set-value",
2130
+ "apply-template",
2131
+ "capture-template",
2132
+ "apply-preset",
2133
+ "set-level-numbering",
2134
+ "set-level-bullet",
2135
+ "set-level-picture-bullet",
2136
+ "set-level-alignment",
2137
+ "set-level-indents",
2138
+ "set-level-trailing-character",
2139
+ "set-level-marker-font",
2140
+ "set-level-text",
2141
+ "set-level-start",
2142
+ "set-level-layout",
2143
+ "convert-to-text",
2144
+ "paste-fragment",
2145
+ "drop-fragment"
2146
+ ];
2147
+ function createListsFamily(ctx) {
2148
+ return {
2149
+ list(filter) {
2150
+ const rows = collectListReadbacks(ctx);
2151
+ const filtered = filter?.storyKey === void 0 ? rows : rows.filter((row) => row.storyKey === filter.storyKey);
2152
+ if (typeof filter?.limit === "number") {
2153
+ return filtered.slice(0, Math.max(0, filter.limit));
2154
+ }
2155
+ return filtered;
2156
+ },
2157
+ get(target) {
2158
+ return findReadback(collectListReadbacks(ctx), target);
2159
+ },
2160
+ previewCommand(target) {
2161
+ const row = findReadback(collectListReadbacks(ctx), target);
2162
+ if (!row) {
2163
+ return {
2164
+ command: target.command,
2165
+ supported: false,
2166
+ blockers: [
2167
+ {
2168
+ command: target.command,
2169
+ enabled: false,
2170
+ reason: "list-target-not-found",
2171
+ ownerLayer: "L10"
2172
+ }
2173
+ ]
2174
+ };
2175
+ }
2176
+ const command = row.commandSupport.find((candidate) => candidate.command === target.command);
2177
+ const blocker = command && !command.enabled ? [command] : [];
2178
+ return {
2179
+ command: target.command,
2180
+ supported: Boolean(command?.enabled),
2181
+ target: row,
2182
+ blockers: blocker,
2183
+ canJoin: row.canJoin,
2184
+ canContinuePrevious: row.canContinuePrevious
2185
+ };
2186
+ }
2187
+ };
2188
+ }
2189
+ function collectListReadbacks(ctx) {
2190
+ const surface = ctx.handle.getRenderSnapshot().surface;
2191
+ if (!surface) return [];
2192
+ const paragraphs = [];
2193
+ collectParagraphs(surface.blocks, paragraphs);
2194
+ for (const secondary of surface.secondaryStories) {
2195
+ collectParagraphs(secondary.blocks, paragraphs);
2196
+ }
2197
+ const rows = [];
2198
+ for (let index = 0; index < paragraphs.length; index += 1) {
2199
+ const entry = paragraphs[index];
2200
+ if (!entry) continue;
2201
+ const row = rowForParagraph(entry.block, paragraphs, index);
2202
+ if (row) rows.push(row);
2203
+ }
2204
+ return rows;
2205
+ }
2206
+ function collectParagraphs(blocks, out) {
2207
+ for (const block of blocks) {
2208
+ switch (block.kind) {
2209
+ case "paragraph":
2210
+ out.push({ block });
2211
+ break;
2212
+ case "table":
2213
+ for (const row of block.rows) {
2214
+ for (const cell of row.cells) {
2215
+ collectParagraphs(cell.content, out);
2216
+ }
2217
+ }
2218
+ break;
2219
+ case "sdt_block":
2220
+ collectParagraphs(block.children, out);
2221
+ break;
2222
+ default:
2223
+ break;
2224
+ }
2225
+ }
2226
+ }
2227
+ function rowForParagraph(block, paragraphs, paragraphIndex) {
2228
+ const target = block.editableTarget;
2229
+ const listAddress = target?.listAddress;
2230
+ const numbering = block.numbering;
2231
+ if (!target || !listAddress || !numbering || !block.resolvedNumbering) return null;
2232
+ const listKind = inferListKind(block.resolvedNumbering);
2233
+ const previousParagraph = paragraphs[paragraphIndex - 1]?.block;
2234
+ const canJoin = Boolean(
2235
+ previousParagraph?.numbering && previousParagraph.numbering.numberingInstanceId !== numbering.numberingInstanceId && inferListKind(previousParagraph.resolvedNumbering) === listKind
2236
+ );
2237
+ const canContinuePrevious = paragraphs.slice(0, paragraphIndex).some(
2238
+ ({ block: previous }) => Boolean(
2239
+ previous.numbering && previous.numbering.numberingInstanceId !== numbering.numberingInstanceId && inferListKind(previous.resolvedNumbering) === listKind
2240
+ )
2241
+ );
2242
+ const actionHandle = `list-action:${listAddress.addressKey}`;
2243
+ const blockers = target.posture.blockers;
2244
+ const commandSupport = commandAvailability({
2245
+ actionHandle,
2246
+ blockers,
2247
+ canContinuePrevious
2248
+ });
2249
+ return {
2250
+ source: "surface-render-snapshot",
2251
+ targetKey: target.targetKey,
2252
+ actionHandle,
2253
+ kind: target.kind,
2254
+ storyKey: target.storyKey,
2255
+ blockPath: target.blockPath,
2256
+ leafPath: target.leafPath,
2257
+ addressKey: listAddress.addressKey,
2258
+ hierarchyPath: [numbering.level],
2259
+ numberingInstanceId: numbering.numberingInstanceId,
2260
+ level: numbering.level,
2261
+ listKind,
2262
+ ...block.resolvedNumbering.text !== void 0 ? { markerText: block.resolvedNumbering.text } : {},
2263
+ ...block.resolvedNumbering.suffix !== void 0 ? { suffix: block.resolvedNumbering.suffix } : {},
2264
+ requestedFormat: block.resolvedNumbering.formatPosture?.requestedFormat ?? block.resolvedNumbering.format,
2265
+ renderedFormat: block.resolvedNumbering.formatPosture?.renderedFormat ?? block.resolvedNumbering.format,
2266
+ ...block.resolvedNumbering.formatPosture ? { formatPosture: block.resolvedNumbering.formatPosture } : {},
2267
+ ...block.resolvedNumbering.markerTextPosture ? { markerTextPosture: block.resolvedNumbering.markerTextPosture } : {},
2268
+ ...block.resolvedNumbering.pictureBulletPosture ? { pictureBulletPosture: block.resolvedNumbering.pictureBulletPosture } : {},
2269
+ authoredTextRange: { from: block.from, to: block.to },
2270
+ editability: target.editability,
2271
+ blockers,
2272
+ supportedCommands: SUPPORTED_COMMANDS,
2273
+ unsupportedCommands: UNSUPPORTED_COMMANDS,
2274
+ commandSupport,
2275
+ canJoin,
2276
+ canContinuePrevious,
2277
+ staleDiscriminators: {
2278
+ paragraphTextHash: target.staleCheck.paragraphTextHash,
2279
+ paragraphTextLength: target.staleCheck.paragraphTextLength,
2280
+ inlineCount: target.staleCheck.inlineCount,
2281
+ listAddressStaleHash: listAddress.resolver?.staleHash
2282
+ },
2283
+ geometry: block.resolvedNumbering.geometry,
2284
+ ...!block.resolvedNumbering.geometry.markerLane ? { geometryUnavailableReason: "marker-geometry-unavailable" } : {}
2285
+ };
2286
+ }
2287
+ function commandAvailability(input) {
2288
+ const out = [];
2289
+ for (const command of SUPPORTED_COMMANDS) {
2290
+ const blockedReason = input.blockers[0];
2291
+ const continueBlocked = command === "continue-numbering" && !input.canContinuePrevious;
2292
+ out.push({
2293
+ command,
2294
+ enabled: !blockedReason && !continueBlocked,
2295
+ ...!blockedReason && !continueBlocked ? { actionHandle: input.actionHandle } : {},
2296
+ ...blockedReason ? { reason: blockedReason, ownerLayer: "L07" } : {},
2297
+ ...continueBlocked ? { reason: "list-continue-target-missing", ownerLayer: "L07" } : {}
2298
+ });
2299
+ }
2300
+ for (const command of UNSUPPORTED_COMMANDS) {
2301
+ out.push({
2302
+ command,
2303
+ enabled: false,
2304
+ reason: "list-command-unsupported",
2305
+ ownerLayer: "L07"
2306
+ });
2307
+ }
2308
+ return out;
2309
+ }
2310
+ function findReadback(rows, target) {
2311
+ const addressKey = target.addressKey ?? addressKeyFromActionHandle(target.actionHandle);
2312
+ return rows.find(
2313
+ (row) => target.targetKey !== void 0 && row.targetKey === target.targetKey || addressKey !== void 0 && row.addressKey === addressKey || target.actionHandle !== void 0 && row.actionHandle === target.actionHandle
2314
+ ) ?? null;
2315
+ }
2316
+ function addressKeyFromActionHandle(actionHandle) {
2317
+ const prefix = "list-action:";
2318
+ return actionHandle?.startsWith(prefix) ? actionHandle.slice(prefix.length) : void 0;
2319
+ }
2320
+ function inferListKind(resolved) {
2321
+ if (!resolved) return "numbered";
2322
+ return resolved.format === "bullet" || resolved.picBulletId !== void 0 || resolved.pictureBulletPosture !== void 0 ? "bulleted" : "numbered";
2323
+ }
2324
+
2113
2325
  // src/api/v3/ui/_create.ts
2114
2326
  function createUiApi(handle, factory) {
2115
2327
  const ctx = createUiApiContext(handle);
@@ -2124,7 +2336,8 @@ function createUiApi(handle, factory) {
2124
2336
  overlays: createOverlaysFamily(ctx),
2125
2337
  chrome: createChromeFamily(ctx),
2126
2338
  debug: createDebugFamily(ctx),
2127
- scope: createScopeFamily(ctx)
2339
+ scope: createScopeFamily(ctx),
2340
+ lists: createListsFamily(ctx)
2128
2341
  };
2129
2342
  Object.freeze(api.session);
2130
2343
  Object.freeze(api.surface);
@@ -2133,6 +2346,7 @@ function createUiApi(handle, factory) {
2133
2346
  Object.freeze(api.chrome);
2134
2347
  Object.freeze(api.debug);
2135
2348
  Object.freeze(api.scope);
2349
+ Object.freeze(api.lists);
2136
2350
  return Object.freeze(api);
2137
2351
  }
2138
2352