@beyondwork/docx-react-component 1.0.125 → 1.0.127

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 (59) hide show
  1. package/dist/api/public-types.d.cts +1 -1
  2. package/dist/api/public-types.d.ts +1 -1
  3. package/dist/api/v3.cjs +84 -25
  4. package/dist/api/v3.d.cts +2 -2
  5. package/dist/api/v3.d.ts +2 -2
  6. package/dist/api/v3.js +2 -2
  7. package/dist/{chunk-JN444Z5S.js → chunk-46KNRA4C.js} +34 -24
  8. package/dist/{chunk-4G3OS2H6.js → chunk-LZVBNDGU.js} +3 -0
  9. package/dist/{chunk-QT3LX4FA.js → chunk-PUMZWE2D.js} +311 -39
  10. package/dist/{chunk-OHTK7F3F.js → chunk-XRACP43Q.js} +51 -2
  11. package/dist/core/commands/formatting-commands.d.cts +1 -1
  12. package/dist/core/commands/formatting-commands.d.ts +1 -1
  13. package/dist/core/commands/image-commands.d.cts +1 -1
  14. package/dist/core/commands/image-commands.d.ts +1 -1
  15. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  16. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  17. package/dist/core/commands/style-commands.d.cts +1 -1
  18. package/dist/core/commands/style-commands.d.ts +1 -1
  19. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  20. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  21. package/dist/core/commands/text-commands.cjs +3 -0
  22. package/dist/core/commands/text-commands.d.cts +2 -1
  23. package/dist/core/commands/text-commands.d.ts +2 -1
  24. package/dist/core/commands/text-commands.js +1 -1
  25. package/dist/core/selection/mapping.d.cts +1 -1
  26. package/dist/core/selection/mapping.d.ts +1 -1
  27. package/dist/core/state/editor-state.d.cts +1 -1
  28. package/dist/core/state/editor-state.d.ts +1 -1
  29. package/dist/index.cjs +424 -72
  30. package/dist/index.d.cts +4 -4
  31. package/dist/index.d.ts +4 -4
  32. package/dist/index.js +27 -8
  33. package/dist/io/docx-session.d.cts +3 -3
  34. package/dist/io/docx-session.d.ts +3 -3
  35. package/dist/{loader-B1MxvbeV.d.ts → loader-CFICtb9m.d.ts} +2 -2
  36. package/dist/{loader-CJXsswcd.d.cts → loader-DveZOVuC.d.cts} +2 -2
  37. package/dist/{public-types-BEGhv2YR.d.ts → public-types-Cgl3efbO.d.ts} +51 -6
  38. package/dist/{public-types-DrhlQ5Zy.d.cts → public-types-beSYFJRR.d.cts} +51 -6
  39. package/dist/public-types.d.cts +1 -1
  40. package/dist/public-types.d.ts +1 -1
  41. package/dist/runtime/collab.d.cts +2 -2
  42. package/dist/runtime/collab.d.ts +2 -2
  43. package/dist/runtime/document-runtime.cjs +315 -38
  44. package/dist/runtime/document-runtime.d.cts +1 -1
  45. package/dist/runtime/document-runtime.d.ts +1 -1
  46. package/dist/runtime/document-runtime.js +3 -3
  47. package/dist/{session-Bp3zqnkS.d.cts → session-B7u82EJF.d.cts} +2 -2
  48. package/dist/{session-xMOU_NtL.d.ts → session-BWMJ9jm4.d.ts} +2 -2
  49. package/dist/session.d.cts +4 -4
  50. package/dist/session.d.ts +4 -4
  51. package/dist/tailwind.d.cts +1 -1
  52. package/dist/tailwind.d.ts +1 -1
  53. package/dist/{types-DDPxEygX.d.cts → types-BQjdVZsh.d.cts} +1 -1
  54. package/dist/{types-BFT8536T.d.ts → types-DvvmS5A7.d.ts} +1 -1
  55. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  56. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  57. package/dist/ui-tailwind.d.cts +2 -2
  58. package/dist/ui-tailwind.d.ts +2 -2
  59. package/package.json +1 -1
@@ -22,7 +22,7 @@ import {
22
22
  insertText,
23
23
  outdentParagraphAtSelection,
24
24
  splitParagraph
25
- } from "./chunk-4G3OS2H6.js";
25
+ } from "./chunk-LZVBNDGU.js";
26
26
  import {
27
27
  applyFormattingOperationToDocument,
28
28
  applyTextMarkOperationToDocumentRange,
@@ -74,7 +74,7 @@ import {
74
74
  resolveHeadingPath,
75
75
  resolveScope,
76
76
  serializeFragmentToWordML
77
- } from "./chunk-OHTK7F3F.js";
77
+ } from "./chunk-XRACP43Q.js";
78
78
  import {
79
79
  ISSUE_METADATA_ID,
80
80
  LAYOUT_ENGINE_VERSION,
@@ -164,7 +164,8 @@ import {
164
164
  collectStoryBlockContexts,
165
165
  createEditableTargetBlockCache,
166
166
  createHeaderFooterStoryKey,
167
- sha256TextHex
167
+ sha256TextHex,
168
+ validateEditableTargetRef
168
169
  } from "./chunk-5DGKFNQT.js";
169
170
  import {
170
171
  setActiveSerializeTelemetryBus
@@ -1131,19 +1132,19 @@ function listBatchRevisionIds(store) {
1131
1132
  }
1132
1133
 
1133
1134
  // src/core/commands/list-commands.ts
1134
- function toggleNumberedList(document, paragraphIndexes, context) {
1135
- return toggleListKind(document, paragraphIndexes, "numbered", context);
1135
+ function toggleNumberedList(document, paragraphIndexes, context, options = {}) {
1136
+ return toggleListKind(document, paragraphIndexes, "numbered", context, options);
1136
1137
  }
1137
- function toggleBulletedList(document, paragraphIndexes, context) {
1138
- return toggleListKind(document, paragraphIndexes, "bulleted", context);
1138
+ function toggleBulletedList(document, paragraphIndexes, context, options = {}) {
1139
+ return toggleListKind(document, paragraphIndexes, "bulleted", context, options);
1139
1140
  }
1140
- function indentListItems(document, paragraphIndexes, context) {
1141
- return adjustListLevels(document, paragraphIndexes, 1, context);
1141
+ function indentListItems(document, paragraphIndexes, context, options = {}) {
1142
+ return adjustListLevels(document, paragraphIndexes, 1, context, options);
1142
1143
  }
1143
- function outdentListItems(document, paragraphIndexes, context) {
1144
- return adjustListLevels(document, paragraphIndexes, -1, context);
1144
+ function outdentListItems(document, paragraphIndexes, context, options = {}) {
1145
+ return adjustListLevels(document, paragraphIndexes, -1, context, options);
1145
1146
  }
1146
- function splitListParagraph(document, paragraphIndex, paragraphIsEmpty, context) {
1147
+ function splitListParagraph(document, paragraphIndex, paragraphIsEmpty, context, options = {}) {
1147
1148
  if (!paragraphIsEmpty) {
1148
1149
  return {
1149
1150
  document,
@@ -1153,7 +1154,30 @@ function splitListParagraph(document, paragraphIndex, paragraphIsEmpty, context)
1153
1154
  }
1154
1155
  const working = cloneEnvelope(document, context.timestamp);
1155
1156
  const paragraphs = captureEditableParagraphs(working);
1156
- const target = paragraphs[paragraphIndex];
1157
+ const resolved = resolveListCommandParagraphIndexes(
1158
+ working,
1159
+ paragraphs,
1160
+ [paragraphIndex],
1161
+ context,
1162
+ normalizeListCommandTargets(options)
1163
+ );
1164
+ if (resolved.blockedReason) {
1165
+ return {
1166
+ document: working,
1167
+ affectedParagraphIndexes: [],
1168
+ action: "blocked",
1169
+ blockedReason: resolved.blockedReason
1170
+ };
1171
+ }
1172
+ const resolvedParagraphIndex = resolved.paragraphIndexes[0];
1173
+ if (resolvedParagraphIndex === void 0) {
1174
+ return {
1175
+ document: working,
1176
+ affectedParagraphIndexes: [],
1177
+ action: "split"
1178
+ };
1179
+ }
1180
+ const target = paragraphs[resolvedParagraphIndex];
1157
1181
  if (!target?.numbering) {
1158
1182
  return {
1159
1183
  document: working,
@@ -1168,21 +1192,44 @@ function splitListParagraph(document, paragraphIndex, paragraphIsEmpty, context)
1168
1192
  };
1169
1193
  return {
1170
1194
  document: working,
1171
- affectedParagraphIndexes: [paragraphIndex],
1195
+ affectedParagraphIndexes: [resolvedParagraphIndex],
1172
1196
  action: "outdented"
1173
1197
  };
1174
1198
  }
1175
1199
  delete target.numbering;
1176
1200
  return {
1177
1201
  document: working,
1178
- affectedParagraphIndexes: [paragraphIndex],
1202
+ affectedParagraphIndexes: [resolvedParagraphIndex],
1179
1203
  action: "removed"
1180
1204
  };
1181
1205
  }
1182
- function backspaceAtListStart(document, paragraphIndex, context) {
1206
+ function backspaceAtListStart(document, paragraphIndex, context, options = {}) {
1183
1207
  const working = cloneEnvelope(document, context.timestamp);
1184
1208
  const paragraphs = captureEditableParagraphs(working);
1185
- const target = paragraphs[paragraphIndex];
1209
+ const resolved = resolveListCommandParagraphIndexes(
1210
+ working,
1211
+ paragraphs,
1212
+ [paragraphIndex],
1213
+ context,
1214
+ normalizeListCommandTargets(options)
1215
+ );
1216
+ if (resolved.blockedReason) {
1217
+ return {
1218
+ document: working,
1219
+ affectedParagraphIndexes: [],
1220
+ handled: true,
1221
+ blockedReason: resolved.blockedReason
1222
+ };
1223
+ }
1224
+ const resolvedParagraphIndex = resolved.paragraphIndexes[0];
1225
+ if (resolvedParagraphIndex === void 0) {
1226
+ return {
1227
+ document: working,
1228
+ affectedParagraphIndexes: [],
1229
+ handled: false
1230
+ };
1231
+ }
1232
+ const target = paragraphs[resolvedParagraphIndex];
1186
1233
  if (!target?.numbering) {
1187
1234
  return {
1188
1235
  document: working,
@@ -1200,14 +1247,35 @@ function backspaceAtListStart(document, paragraphIndex, context) {
1200
1247
  }
1201
1248
  return {
1202
1249
  document: working,
1203
- affectedParagraphIndexes: [paragraphIndex],
1250
+ affectedParagraphIndexes: [resolvedParagraphIndex],
1204
1251
  handled: true
1205
1252
  };
1206
1253
  }
1207
- function restartNumbering(document, paragraphIndex, context, startAt = 1) {
1254
+ function restartNumbering(document, paragraphIndex, context, startAt = 1, options = {}) {
1208
1255
  const working = cloneEnvelope(document, context.timestamp);
1209
1256
  const paragraphs = captureEditableParagraphs(working);
1210
- const target = paragraphs[paragraphIndex];
1257
+ const resolved = resolveListCommandParagraphIndexes(
1258
+ working,
1259
+ paragraphs,
1260
+ [paragraphIndex],
1261
+ context,
1262
+ normalizeListCommandTargets(options)
1263
+ );
1264
+ if (resolved.blockedReason) {
1265
+ return {
1266
+ document: working,
1267
+ affectedParagraphIndexes: [],
1268
+ blockedReason: resolved.blockedReason
1269
+ };
1270
+ }
1271
+ const resolvedParagraphIndex = resolved.paragraphIndexes[0];
1272
+ if (resolvedParagraphIndex === void 0) {
1273
+ return {
1274
+ document: working,
1275
+ affectedParagraphIndexes: []
1276
+ };
1277
+ }
1278
+ const target = paragraphs[resolvedParagraphIndex];
1211
1279
  if (!target?.numbering) {
1212
1280
  return {
1213
1281
  document: working,
@@ -1232,7 +1300,7 @@ function restartNumbering(document, paragraphIndex, context, startAt = 1) {
1232
1300
  })
1233
1301
  };
1234
1302
  const affectedParagraphIndexes = [];
1235
- for (let index = paragraphIndex; index < paragraphs.length; index += 1) {
1303
+ for (let index = resolvedParagraphIndex; index < paragraphs.length; index += 1) {
1236
1304
  const paragraph = paragraphs[index];
1237
1305
  if (!paragraph?.numbering) {
1238
1306
  break;
@@ -1253,10 +1321,31 @@ function restartNumbering(document, paragraphIndex, context, startAt = 1) {
1253
1321
  createdNumberingInstanceId: numberingInstanceId
1254
1322
  };
1255
1323
  }
1256
- function continueNumbering(document, paragraphIndex, context) {
1324
+ function continueNumbering(document, paragraphIndex, context, options = {}) {
1257
1325
  const working = cloneEnvelope(document, context.timestamp);
1258
1326
  const paragraphs = captureEditableParagraphs(working);
1259
- const target = paragraphs[paragraphIndex];
1327
+ const resolved = resolveListCommandParagraphIndexes(
1328
+ working,
1329
+ paragraphs,
1330
+ [paragraphIndex],
1331
+ context,
1332
+ normalizeListCommandTargets(options)
1333
+ );
1334
+ if (resolved.blockedReason) {
1335
+ return {
1336
+ document: working,
1337
+ affectedParagraphIndexes: [],
1338
+ blockedReason: resolved.blockedReason
1339
+ };
1340
+ }
1341
+ const resolvedParagraphIndex = resolved.paragraphIndexes[0];
1342
+ if (resolvedParagraphIndex === void 0) {
1343
+ return {
1344
+ document: working,
1345
+ affectedParagraphIndexes: []
1346
+ };
1347
+ }
1348
+ const target = paragraphs[resolvedParagraphIndex];
1260
1349
  if (!target?.numbering) {
1261
1350
  return {
1262
1351
  document: working,
@@ -1275,7 +1364,7 @@ function continueNumbering(document, paragraphIndex, context) {
1275
1364
  const compatibleInstanceId = findPreviousCompatibleInstance(
1276
1365
  paragraphs,
1277
1366
  catalog,
1278
- paragraphIndex,
1367
+ resolvedParagraphIndex,
1279
1368
  currentKind
1280
1369
  );
1281
1370
  if (!compatibleInstanceId || compatibleInstanceId === currentInstanceId) {
@@ -1285,7 +1374,7 @@ function continueNumbering(document, paragraphIndex, context) {
1285
1374
  };
1286
1375
  }
1287
1376
  const affectedParagraphIndexes = [];
1288
- for (let index = paragraphIndex; index < paragraphs.length; index += 1) {
1377
+ for (let index = resolvedParagraphIndex; index < paragraphs.length; index += 1) {
1289
1378
  const paragraph = paragraphs[index];
1290
1379
  if (!paragraph?.numbering) {
1291
1380
  break;
@@ -1306,10 +1395,24 @@ function continueNumbering(document, paragraphIndex, context) {
1306
1395
  createdNumberingInstanceId: compatibleInstanceId
1307
1396
  };
1308
1397
  }
1309
- function toggleListKind(document, paragraphIndexes, kind, context) {
1398
+ function toggleListKind(document, paragraphIndexes, kind, context, options) {
1310
1399
  const working = cloneEnvelope(document, context.timestamp);
1311
1400
  const paragraphs = captureEditableParagraphs(working);
1312
- const normalizedIndexes = normalizeParagraphIndexes(paragraphs, paragraphIndexes);
1401
+ const resolved = resolveListCommandParagraphIndexes(
1402
+ working,
1403
+ paragraphs,
1404
+ paragraphIndexes,
1405
+ context,
1406
+ normalizeListCommandTargets(options)
1407
+ );
1408
+ if (resolved.blockedReason) {
1409
+ return {
1410
+ document: working,
1411
+ affectedParagraphIndexes: [],
1412
+ blockedReason: resolved.blockedReason
1413
+ };
1414
+ }
1415
+ const normalizedIndexes = resolved.paragraphIndexes;
1313
1416
  if (normalizedIndexes.length === 0) {
1314
1417
  return {
1315
1418
  document: working,
@@ -1346,10 +1449,24 @@ function toggleListKind(document, paragraphIndexes, kind, context) {
1346
1449
  createdNumberingInstanceId: numberingInstanceId
1347
1450
  };
1348
1451
  }
1349
- function adjustListLevels(document, paragraphIndexes, delta, context) {
1452
+ function adjustListLevels(document, paragraphIndexes, delta, context, options) {
1350
1453
  const working = cloneEnvelope(document, context.timestamp);
1351
1454
  const paragraphs = captureEditableParagraphs(working);
1352
- const affectedParagraphIndexes = normalizeParagraphIndexes(paragraphs, paragraphIndexes).filter(
1455
+ const resolved = resolveListCommandParagraphIndexes(
1456
+ working,
1457
+ paragraphs,
1458
+ paragraphIndexes,
1459
+ context,
1460
+ normalizeListCommandTargets(options)
1461
+ );
1462
+ if (resolved.blockedReason) {
1463
+ return {
1464
+ document: working,
1465
+ affectedParagraphIndexes: [],
1466
+ blockedReason: resolved.blockedReason
1467
+ };
1468
+ }
1469
+ const affectedParagraphIndexes = resolved.paragraphIndexes.filter(
1353
1470
  (index) => Boolean(paragraphs[index]?.numbering)
1354
1471
  );
1355
1472
  for (const index of affectedParagraphIndexes) {
@@ -1367,6 +1484,121 @@ function adjustListLevels(document, paragraphIndexes, delta, context) {
1367
1484
  affectedParagraphIndexes
1368
1485
  };
1369
1486
  }
1487
+ function normalizeListCommandTargets(options) {
1488
+ if (options.editableTargets !== void 0) return options.editableTargets;
1489
+ return options.editableTarget ? [options.editableTarget] : [];
1490
+ }
1491
+ function resolveListCommandParagraphIndexes(document, paragraphs, paragraphIndexes, context, editableTargets) {
1492
+ if (editableTargets.length === 0) {
1493
+ return { paragraphIndexes: normalizeParagraphIndexes(paragraphs, paragraphIndexes) };
1494
+ }
1495
+ const currentTargets = collectEditableTargetRefs(document, context.editableTargetCache);
1496
+ const paragraphIndexByTargetKey = /* @__PURE__ */ new Map();
1497
+ let paragraphIndex = 0;
1498
+ for (const target of currentTargets) {
1499
+ if (!isParagraphTextTarget(target)) continue;
1500
+ if (!paragraphIndexByTargetKey.has(target.targetKey)) {
1501
+ paragraphIndexByTargetKey.set(target.targetKey, paragraphIndex);
1502
+ paragraphIndex += 1;
1503
+ }
1504
+ }
1505
+ const resolvedIndexes = [];
1506
+ for (const target of editableTargets) {
1507
+ const blockedReason = validateListCommandTarget(target, currentTargets, context);
1508
+ if (blockedReason) return { paragraphIndexes: [], blockedReason };
1509
+ const current = findCurrentListCommandTarget(target, currentTargets);
1510
+ if (!current) {
1511
+ return {
1512
+ paragraphIndexes: [],
1513
+ blockedReason: {
1514
+ code: "list_target_not_found",
1515
+ message: "List editable target no longer resolves in the current canonical document."
1516
+ }
1517
+ };
1518
+ }
1519
+ if (!sameResolvedListCommandTarget(target, current)) {
1520
+ return {
1521
+ paragraphIndexes: [],
1522
+ blockedReason: {
1523
+ code: "list_target_stale",
1524
+ message: "List editable target is stale for the current canonical document."
1525
+ }
1526
+ };
1527
+ }
1528
+ const currentIndex = paragraphIndexByTargetKey.get(current.targetKey);
1529
+ if (currentIndex === void 0) {
1530
+ return {
1531
+ paragraphIndexes: [],
1532
+ blockedReason: {
1533
+ code: "list_target_position_unavailable",
1534
+ message: "List editable target resolved but could not be mapped to a current paragraph."
1535
+ }
1536
+ };
1537
+ }
1538
+ resolvedIndexes.push(currentIndex);
1539
+ }
1540
+ return { paragraphIndexes: normalizeParagraphIndexes(paragraphs, resolvedIndexes) };
1541
+ }
1542
+ function validateListCommandTarget(target, currentTargets, context) {
1543
+ const shapeIssues = validateEditableTargetRef(target);
1544
+ if (shapeIssues.length > 0) {
1545
+ return {
1546
+ code: "list_target_malformed",
1547
+ message: `List editable target is malformed: ${shapeIssues[0]?.path ?? "$"}.`
1548
+ };
1549
+ }
1550
+ if (context.activeStoryKey !== void 0 && target.storyKey !== context.activeStoryKey) {
1551
+ return {
1552
+ code: "list_target_wrong_story",
1553
+ message: "List editable target does not belong to the active story."
1554
+ };
1555
+ }
1556
+ if (target.commandFamily !== "text-leaf" || target.listAddress === void 0) {
1557
+ return {
1558
+ code: "list_target_required",
1559
+ message: "List commands require a validated list item editable target."
1560
+ };
1561
+ }
1562
+ if (target.editability !== "editable" || target.posture.blockers.length > 0) {
1563
+ return {
1564
+ code: "list_target_non_editable",
1565
+ message: target.posture.blockers.length > 0 ? `List editable target is not editable: ${target.posture.blockers.join(", ")}.` : "List editable target is not editable."
1566
+ };
1567
+ }
1568
+ if (!findCurrentListCommandTarget(target, currentTargets)) {
1569
+ return {
1570
+ code: "list_target_not_found",
1571
+ message: "List editable target no longer resolves in the current canonical document."
1572
+ };
1573
+ }
1574
+ return void 0;
1575
+ }
1576
+ function findCurrentListCommandTarget(target, currentTargets) {
1577
+ return currentTargets.find(
1578
+ (candidate) => isParagraphTextTarget(candidate) && candidate.listAddress !== void 0 && (candidate.targetKey === target.targetKey || candidate.listAddress.addressKey === target.listAddress?.addressKey)
1579
+ );
1580
+ }
1581
+ function sameResolvedListCommandTarget(left, right) {
1582
+ return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.blockType === right.staleCheck.blockType && left.listAddress?.addressKey === right.listAddress?.addressKey && left.listAddress?.resolver?.staleHash === right.listAddress?.resolver?.staleHash && jsonStable(left.sourceRef) === jsonStable(right.sourceRef);
1583
+ }
1584
+ function isParagraphTextTarget(target) {
1585
+ return target.commandFamily === "text-leaf" && target.staleCheck.blockType === "paragraph" && target.leafPath.endsWith("/inline");
1586
+ }
1587
+ function jsonStable(value) {
1588
+ return JSON.stringify(sortJson(value));
1589
+ }
1590
+ function sortJson(value) {
1591
+ if (Array.isArray(value)) return value.map(sortJson);
1592
+ if (value && typeof value === "object") {
1593
+ const record = value;
1594
+ const sorted = {};
1595
+ for (const key of Object.keys(record).sort()) {
1596
+ sorted[key] = sortJson(record[key]);
1597
+ }
1598
+ return sorted;
1599
+ }
1600
+ return value;
1601
+ }
1370
1602
  function ensureDefaultInstance(catalog, kind) {
1371
1603
  const existing = Object.values(catalog.instances).find(
1372
1604
  (instance) => getListKind(catalog, instance.numberingInstanceId) === kind
@@ -1876,6 +2108,13 @@ function withCommandTextTarget(context, command) {
1876
2108
  textTarget: command.textTarget
1877
2109
  };
1878
2110
  }
2111
+ function listCommandContext(context) {
2112
+ return {
2113
+ timestamp: context.timestamp,
2114
+ ...context.activeStoryKey !== void 0 ? { activeStoryKey: context.activeStoryKey } : {},
2115
+ ...context.editableTargetCache !== void 0 ? { editableTargetCache: context.editableTargetCache } : {}
2116
+ };
2117
+ }
1879
2118
  function executeEditorCommand(state, command, context) {
1880
2119
  switch (command.type) {
1881
2120
  case "selection.set":
@@ -2517,7 +2756,17 @@ function executeEditorCommand(state, command, context) {
2517
2756
  });
2518
2757
  }
2519
2758
  case "list.toggle": {
2520
- const result = command.kind === "bulleted" ? toggleBulletedList(state.document, command.paragraphIndexes, { timestamp: context.timestamp }) : toggleNumberedList(state.document, command.paragraphIndexes, { timestamp: context.timestamp });
2759
+ const result = command.kind === "bulleted" ? toggleBulletedList(
2760
+ state.document,
2761
+ command.paragraphIndexes ?? [],
2762
+ listCommandContext(context),
2763
+ { editableTargets: command.editableTargets }
2764
+ ) : toggleNumberedList(
2765
+ state.document,
2766
+ command.paragraphIndexes ?? [],
2767
+ listCommandContext(context),
2768
+ { editableTargets: command.editableTargets }
2769
+ );
2521
2770
  return buildDocumentReplaceTransaction(state, context, {
2522
2771
  changed: result.affectedParagraphIndexes.length > 0,
2523
2772
  document: result.document,
@@ -2525,7 +2774,12 @@ function executeEditorCommand(state, command, context) {
2525
2774
  });
2526
2775
  }
2527
2776
  case "list.indent": {
2528
- const result = indentListItems(state.document, command.paragraphIndexes, { timestamp: context.timestamp });
2777
+ const result = indentListItems(
2778
+ state.document,
2779
+ command.paragraphIndexes ?? [],
2780
+ listCommandContext(context),
2781
+ { editableTargets: command.editableTargets }
2782
+ );
2529
2783
  return buildDocumentReplaceTransaction(state, context, {
2530
2784
  changed: result.affectedParagraphIndexes.length > 0,
2531
2785
  document: result.document,
@@ -2533,7 +2787,12 @@ function executeEditorCommand(state, command, context) {
2533
2787
  });
2534
2788
  }
2535
2789
  case "list.outdent": {
2536
- const result = outdentListItems(state.document, command.paragraphIndexes, { timestamp: context.timestamp });
2790
+ const result = outdentListItems(
2791
+ state.document,
2792
+ command.paragraphIndexes ?? [],
2793
+ listCommandContext(context),
2794
+ { editableTargets: command.editableTargets }
2795
+ );
2537
2796
  return buildDocumentReplaceTransaction(state, context, {
2538
2797
  changed: result.affectedParagraphIndexes.length > 0,
2539
2798
  document: result.document,
@@ -2543,9 +2802,10 @@ function executeEditorCommand(state, command, context) {
2543
2802
  case "list.restart-numbering": {
2544
2803
  const result = restartNumbering(
2545
2804
  state.document,
2546
- command.paragraphIndex,
2547
- { timestamp: context.timestamp },
2548
- command.startAt
2805
+ command.paragraphIndex ?? -1,
2806
+ listCommandContext(context),
2807
+ command.startAt,
2808
+ { editableTarget: command.editableTarget }
2549
2809
  );
2550
2810
  return buildDocumentReplaceTransaction(state, context, {
2551
2811
  changed: result.affectedParagraphIndexes.length > 0,
@@ -2556,8 +2816,9 @@ function executeEditorCommand(state, command, context) {
2556
2816
  case "list.continue-numbering": {
2557
2817
  const result = continueNumbering(
2558
2818
  state.document,
2559
- command.paragraphIndex,
2560
- { timestamp: context.timestamp }
2819
+ command.paragraphIndex ?? -1,
2820
+ listCommandContext(context),
2821
+ { editableTarget: command.editableTarget }
2561
2822
  );
2562
2823
  return buildDocumentReplaceTransaction(state, context, {
2563
2824
  changed: result.affectedParagraphIndexes.length > 0,
@@ -14057,6 +14318,8 @@ function createDocumentRuntime(options) {
14057
14318
  documentMode: workflowCoordinator.getEffectiveDocumentMode(commandSelection),
14058
14319
  defaultAuthorId: defaultAuthorId ?? void 0,
14059
14320
  renderSnapshot: cachedRenderSnapshot,
14321
+ activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
14322
+ editableTargetCache: editableTargetBlockCache,
14060
14323
  ...resolvedFragmentTextTarget ? { textTarget: resolvedFragmentTextTarget } : {}
14061
14324
  };
14062
14325
  const preSelection = commandSelection;
@@ -16650,14 +16913,18 @@ function createDocumentRuntime(options) {
16650
16913
  blockedReasons: [blockedReason]
16651
16914
  });
16652
16915
  }
16653
- const textTarget = targetResolution?.kind === "accepted" ? targetResolution.textTarget : legacyTextTarget;
16916
+ const listBoundaryDeleteUsesStoryText = targetResolution?.kind === "accepted" && editableTarget?.listAddress?.operationScope === "list-text" && isTopLevelMainStoryBlockPath(editableTarget.blockPath) && selection.isCollapsed && (commandForDispatch.type === "text.delete-backward" && selection.anchor === targetResolution.range.from || commandForDispatch.type === "text.delete-forward" && selection.anchor === targetResolution.range.to);
16917
+ const textTarget = targetResolution?.kind === "accepted" && !listBoundaryDeleteUsesStoryText ? targetResolution.textTarget : legacyTextTarget;
16654
16918
  const context = {
16655
16919
  timestamp,
16656
16920
  documentMode: textOptions.documentModeOverride ?? workflowCoordinator.getEffectiveDocumentMode(selection),
16657
16921
  defaultAuthorId: defaultAuthorId ?? void 0,
16658
16922
  renderSnapshot: cachedRenderSnapshot,
16923
+ activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
16924
+ editableTargetCache: editableTargetBlockCache,
16659
16925
  activeStorySize: cachedRenderSnapshot.surface?.storySize,
16660
16926
  textTarget,
16927
+ preserveNumberingOnSplit: commandForDispatch.type === "paragraph.split" && targetResolution?.kind === "accepted" && editableTarget?.listAddress?.operationScope === "list-text",
16661
16928
  rejectTargetlessTableStructureInsert: true
16662
16929
  };
16663
16930
  const baseState = selection === state.selection ? state : {
@@ -16956,7 +17223,9 @@ function createDocumentRuntime(options) {
16956
17223
  timestamp: clock(),
16957
17224
  documentMode: workflowCoordinator.getEffectiveDocumentMode(state.selection),
16958
17225
  defaultAuthorId: defaultAuthorId ?? void 0,
16959
- renderSnapshot: cachedRenderSnapshot
17226
+ renderSnapshot: cachedRenderSnapshot,
17227
+ activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
17228
+ editableTargetCache: editableTargetBlockCache
16960
17229
  };
16961
17230
  try {
16962
17231
  const transaction = executeEditorCommand(
@@ -19513,6 +19782,9 @@ function stripStoryTarget(selection) {
19513
19782
  const { storyTarget: _storyTarget, ...rest } = selection;
19514
19783
  return rest;
19515
19784
  }
19785
+ function isTopLevelMainStoryBlockPath(blockPath) {
19786
+ return typeof blockPath === "string" && /^main\/block\[\d+\]$/u.test(blockPath);
19787
+ }
19516
19788
  function toInternalSelectionSnapshot(selection) {
19517
19789
  return {
19518
19790
  anchor: selection.anchor,
@@ -6597,7 +6597,52 @@ function compileReplacement(inputs) {
6597
6597
 
6598
6598
  // src/runtime/scopes/replacement/apply.ts
6599
6599
  function documentHash2(doc) {
6600
- return JSON.stringify(doc.content);
6600
+ let hash = 2166136261;
6601
+ const mix = (value) => {
6602
+ for (let i = 0; i < value.length; i += 1) {
6603
+ hash ^= value.charCodeAt(i);
6604
+ hash = Math.imul(hash, 16777619);
6605
+ }
6606
+ };
6607
+ const visit = (value) => {
6608
+ if (value === null) {
6609
+ mix("null");
6610
+ return;
6611
+ }
6612
+ switch (typeof value) {
6613
+ case "string":
6614
+ case "number":
6615
+ case "boolean":
6616
+ case "bigint":
6617
+ mix(`${typeof value}:${String(value)}`);
6618
+ return;
6619
+ case "undefined":
6620
+ mix("undefined");
6621
+ return;
6622
+ case "object":
6623
+ if (Array.isArray(value)) {
6624
+ mix(`[${value.length}`);
6625
+ for (const item of value) visit(item);
6626
+ mix("]");
6627
+ return;
6628
+ }
6629
+ {
6630
+ const record = value;
6631
+ const keys = Object.keys(record).sort();
6632
+ mix(`{${keys.length}`);
6633
+ for (const key of keys) {
6634
+ mix(key);
6635
+ visit(record[key]);
6636
+ }
6637
+ mix("}");
6638
+ }
6639
+ return;
6640
+ default:
6641
+ mix(typeof value);
6642
+ }
6643
+ };
6644
+ visit(doc.content);
6645
+ return (hash >>> 0).toString(36).padStart(7, "0");
6601
6646
  }
6602
6647
  function compileScopeById(document, overlay, scopeId) {
6603
6648
  const paragraphIndexByBlockIndex = buildParagraphIndexMap(document);
@@ -8094,7 +8139,8 @@ function rejectCommand(code, message) {
8094
8139
  };
8095
8140
  }
8096
8141
  function sameResolvedTarget2(left, right) {
8097
- return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && sameTextTargetStaleCheck(left, right) && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.targetTextLength === right.staleCheck.targetTextLength && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType && left.staleCheck.wordParaId === right.staleCheck.wordParaId && left.staleCheck.wordTextId === right.staleCheck.wordTextId && jsonStable(left.staleCheck.sourceRef) === jsonStable(right.staleCheck.sourceRef) && jsonStable(left.sourceRef) === jsonStable(right.sourceRef) && jsonStable(left.table) === jsonStable(right.table) && jsonStable(left.editableOwner) === jsonStable(right.editableOwner);
8142
+ const textTargetLengthDrift = hasTextTargetLengthDrift(left, right);
8143
+ return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && sameTextTargetStaleCheck(left, right) && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.targetTextLength === right.staleCheck.targetTextLength && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType && left.staleCheck.wordParaId === right.staleCheck.wordParaId && left.staleCheck.wordTextId === right.staleCheck.wordTextId && (textTargetLengthDrift || jsonStable(left.staleCheck.sourceRef) === jsonStable(right.staleCheck.sourceRef)) && (textTargetLengthDrift || jsonStable(left.sourceRef) === jsonStable(right.sourceRef)) && jsonStable(left.table) === jsonStable(right.table) && jsonStable(left.editableOwner) === jsonStable(right.editableOwner);
8098
8144
  }
8099
8145
  function sameTextTargetStaleCheck(left, right) {
8100
8146
  if (left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength) {
@@ -8102,6 +8148,9 @@ function sameTextTargetStaleCheck(left, right) {
8102
8148
  }
8103
8149
  return left.commandFamily === "text-leaf" && left.staleCheck.paragraphTextLength !== void 0 && right.staleCheck.paragraphTextLength !== void 0 && left.staleCheck.paragraphTextLength !== right.staleCheck.paragraphTextLength;
8104
8150
  }
8151
+ function hasTextTargetLengthDrift(left, right) {
8152
+ return left.commandFamily === "text-leaf" && left.staleCheck.paragraphTextLength !== void 0 && right.staleCheck.paragraphTextLength !== void 0 && left.staleCheck.paragraphTextLength !== right.staleCheck.paragraphTextLength;
8153
+ }
8105
8154
  function locateTargetRange(document, surface, target) {
8106
8155
  if (target.kind === "hyperlink-text") {
8107
8156
  return locateHyperlinkDisplayRange(document, surface, target);
@@ -1,6 +1,6 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-DrhlQ5Zy.cjs';
3
+ export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-beSYFJRR.cjs';
4
4
  import '../../canonical-document-CXCFCbAz.cjs';
5
5
  import 'react';
6
6
  import 'yjs';
@@ -1,6 +1,6 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-BEGhv2YR.js';
3
+ export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-Cgl3efbO.js';
4
4
  import '../../canonical-document-CXCFCbAz.js';
5
5
  import 'react';
6
6
  import 'yjs';
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocumentEnvelope, S as SelectionSnapshot, g as TransactionMapping } from '../../public-types-DrhlQ5Zy.cjs';
1
+ import { C as CanonicalDocumentEnvelope, S as SelectionSnapshot, g as TransactionMapping } from '../../public-types-beSYFJRR.cjs';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocumentEnvelope, S as SelectionSnapshot, g as TransactionMapping } from '../../public-types-BEGhv2YR.js';
1
+ import { C as CanonicalDocumentEnvelope, S as SelectionSnapshot, g as TransactionMapping } from '../../public-types-Cgl3efbO.js';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -1,4 +1,4 @@
1
- import { h as SelectionSnapshot, M as MarginPresetDefinition, i as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-DrhlQ5Zy.cjs';
1
+ import { h as SelectionSnapshot, M as MarginPresetDefinition, i as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-beSYFJRR.cjs';
2
2
  import { C as CanonicalDocument, P as PageSize, a as PageMargins, b as ColumnProperties, c as PageNumbering } from '../../canonical-document-CXCFCbAz.cjs';
3
3
  import 'react';
4
4
  import 'yjs';
@@ -1,4 +1,4 @@
1
- import { h as SelectionSnapshot, M as MarginPresetDefinition, i as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-BEGhv2YR.js';
1
+ import { h as SelectionSnapshot, M as MarginPresetDefinition, i as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-Cgl3efbO.js';
2
2
  import { C as CanonicalDocument, P as PageSize, a as PageMargins, b as ColumnProperties, c as PageNumbering } from '../../canonical-document-CXCFCbAz.js';
3
3
  import 'react';
4
4
  import 'yjs';