@beyondwork/docx-react-component 1.0.130 → 1.0.132

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 (98) hide show
  1. package/dist/api/public-types.cjs +679 -157
  2. package/dist/api/public-types.d.cts +2 -2
  3. package/dist/api/public-types.d.ts +2 -2
  4. package/dist/api/public-types.js +5 -3
  5. package/dist/api/v3.cjs +371 -32
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{canonical-document-BMtONpgf.d.cts → canonical-document-CfZIc-fC.d.cts} +1 -1
  10. package/dist/{canonical-document-BMtONpgf.d.ts → canonical-document-CfZIc-fC.d.ts} +1 -1
  11. package/dist/{chunk-YLL7MF5C.js → chunk-43JAPM2F.js} +24 -17
  12. package/dist/{chunk-4YCWECLZ.js → chunk-4HGFJ6Z2.js} +1 -1
  13. package/dist/{chunk-HYHCRMR7.js → chunk-6736GA6J.js} +1 -1
  14. package/dist/{chunk-Q7Y57KOK.js → chunk-6TLZ6CMP.js} +2 -2
  15. package/dist/{chunk-DGA7M77X.js → chunk-ALWXYGXP.js} +2 -2
  16. package/dist/{chunk-PHMWH23E.js → chunk-C5LXKR54.js} +1 -1
  17. package/dist/{chunk-6TBLDBCL.js → chunk-CDEZGLQ3.js} +1 -1
  18. package/dist/{chunk-VRKK2CSZ.js → chunk-JVTDBX67.js} +2 -2
  19. package/dist/{chunk-THVM6EP5.js → chunk-LPLJZJT2.js} +1196 -35
  20. package/dist/{chunk-T5YYFDZB.js → chunk-N5FTU4HZ.js} +1 -1
  21. package/dist/{chunk-3YCQM2RV.js → chunk-QUTVR72L.js} +8 -7
  22. package/dist/{chunk-M7YRJX6V.js → chunk-RBWJHRNP.js} +1 -1
  23. package/dist/{chunk-A66ZVUAT.js → chunk-RYMMKOFI.js} +204 -10
  24. package/dist/{chunk-QXKQPUOM.js → chunk-SZ6BJA4Q.js} +3 -3
  25. package/dist/{chunk-A3GSNB4G.js → chunk-U3UMKA7B.js} +147 -13
  26. package/dist/{chunk-KNHMXKC6.js → chunk-UFPBYJMA.js} +2 -2
  27. package/dist/{chunk-35RHOE6I.js → chunk-UP2KDOYE.js} +6 -1162
  28. package/dist/{chunk-CI2TD3T4.js → chunk-W2I47J2Q.js} +1 -1
  29. package/dist/{chunk-7G5GR3VV.js → chunk-XYTWOJII.js} +5 -5
  30. package/dist/{chunk-WZDKNF37.js → chunk-YUHNDEV5.js} +7 -7
  31. package/dist/{chunk-ZVC23LKV.js → chunk-ZDYGRO2Z.js} +1 -1
  32. package/dist/compare.d.cts +1 -1
  33. package/dist/compare.d.ts +1 -1
  34. package/dist/core/commands/formatting-commands.d.cts +2 -2
  35. package/dist/core/commands/formatting-commands.d.ts +2 -2
  36. package/dist/core/commands/image-commands.cjs +312 -20
  37. package/dist/core/commands/image-commands.d.cts +2 -2
  38. package/dist/core/commands/image-commands.d.ts +2 -2
  39. package/dist/core/commands/image-commands.js +5 -5
  40. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  41. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  42. package/dist/core/commands/style-commands.d.cts +2 -2
  43. package/dist/core/commands/style-commands.d.ts +2 -2
  44. package/dist/core/commands/table-structure-commands.cjs +312 -20
  45. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  46. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  47. package/dist/core/commands/table-structure-commands.js +4 -4
  48. package/dist/core/commands/text-commands.cjs +312 -20
  49. package/dist/core/commands/text-commands.d.cts +2 -2
  50. package/dist/core/commands/text-commands.d.ts +2 -2
  51. package/dist/core/commands/text-commands.js +5 -5
  52. package/dist/core/selection/mapping.d.cts +2 -2
  53. package/dist/core/selection/mapping.d.ts +2 -2
  54. package/dist/core/state/editor-state.d.cts +2 -2
  55. package/dist/core/state/editor-state.d.ts +2 -2
  56. package/dist/index.cjs +3015 -2213
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +554 -99
  60. package/dist/io/docx-session.d.cts +4 -4
  61. package/dist/io/docx-session.d.ts +4 -4
  62. package/dist/io/docx-session.js +4 -4
  63. package/dist/legal.d.cts +1 -1
  64. package/dist/legal.d.ts +1 -1
  65. package/dist/legal.js +3 -3
  66. package/dist/{loader-B-aL5HGD.d.ts → loader-CfpeEPAa.d.ts} +3 -3
  67. package/dist/{loader-DiY_ZgKl.d.cts → loader-MAa8VpzW.d.cts} +3 -3
  68. package/dist/{public-types-gvubspUI.d.cts → public-types-Cjs8glST.d.ts} +137 -2
  69. package/dist/{public-types-DyqnxxO9.d.ts → public-types-KBS6JnOs.d.cts} +137 -2
  70. package/dist/public-types.cjs +679 -157
  71. package/dist/public-types.d.cts +2 -2
  72. package/dist/public-types.d.ts +2 -2
  73. package/dist/public-types.js +5 -3
  74. package/dist/runtime/collab.d.cts +3 -3
  75. package/dist/runtime/collab.d.ts +3 -3
  76. package/dist/runtime/document-runtime.cjs +371 -22
  77. package/dist/runtime/document-runtime.d.cts +2 -2
  78. package/dist/runtime/document-runtime.d.ts +2 -2
  79. package/dist/runtime/document-runtime.js +14 -14
  80. package/dist/{session-CDB0hohT.d.ts → session-CkoH8FoY.d.ts} +3 -3
  81. package/dist/{session-BUN6B-Vj.d.cts → session-wwe0Gib-.d.cts} +3 -3
  82. package/dist/session.d.cts +5 -5
  83. package/dist/session.d.ts +5 -5
  84. package/dist/session.js +5 -5
  85. package/dist/tailwind.cjs +492 -202
  86. package/dist/tailwind.d.cts +2 -2
  87. package/dist/tailwind.d.ts +2 -2
  88. package/dist/tailwind.js +7 -7
  89. package/dist/{types-C4bz3kDU.d.cts → types-B3SGRW0w.d.cts} +2 -2
  90. package/dist/{types-VWH6CRvG.d.ts → types-CH7NWqVL.d.ts} +2 -2
  91. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  92. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  93. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  94. package/dist/ui-tailwind.cjs +492 -202
  95. package/dist/ui-tailwind.d.cts +3 -3
  96. package/dist/ui-tailwind.d.ts +3 -3
  97. package/dist/ui-tailwind.js +7 -7
  98. package/package.json +4 -1
@@ -808,6 +808,7 @@ __export(public_types_exports, {
808
808
  buildPagePreviewMaps: () => buildPagePreviewMaps,
809
809
  buildSearchPattern: () => buildSearchPattern,
810
810
  createCanvasBackend: () => createCanvasBackend,
811
+ createPagePatchPlan: () => createPagePatchPlan,
811
812
  createPublicNodeAnchor: () => createPublicNodeAnchor,
812
813
  createPublicRangeAnchor: () => createPublicRangeAnchor,
813
814
  createScopeTagRegistry: () => createScopeTagRegistry,
@@ -1202,6 +1203,372 @@ function storyTargetsEqual(left, right) {
1202
1203
  }
1203
1204
  var MAIN_STORY_TARGET = { kind: "main" };
1204
1205
 
1206
+ // src/runtime/story-context.ts
1207
+ function collectSectionContexts(document2) {
1208
+ const sections = [];
1209
+ let sectionIndex = 0;
1210
+ for (const block of document2.content.children) {
1211
+ if (block.type !== "section_break") {
1212
+ continue;
1213
+ }
1214
+ sections.push({
1215
+ index: sectionIndex,
1216
+ properties: block.sectionProperties
1217
+ });
1218
+ sectionIndex += 1;
1219
+ }
1220
+ sections.push({
1221
+ index: sectionIndex,
1222
+ properties: document2.subParts?.finalSectionProperties
1223
+ });
1224
+ return sections;
1225
+ }
1226
+ function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
1227
+ if (explicitReferences && explicitReferences.length > 0) {
1228
+ return explicitReferences.map((ref) => ({
1229
+ variant: ref.variant,
1230
+ relationshipId: ref.relationshipId
1231
+ }));
1232
+ }
1233
+ return documents.filter(
1234
+ (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
1235
+ ).map((entry) => ({
1236
+ variant: entry.variant,
1237
+ relationshipId: entry.relationshipId
1238
+ }));
1239
+ }
1240
+ function findHeaderFooterDocumentEntry(document2, target) {
1241
+ const documents = target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? [];
1242
+ const matches = documents.filter(
1243
+ (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
1244
+ );
1245
+ if (matches.length === 0) {
1246
+ return void 0;
1247
+ }
1248
+ if (target.sectionIndex !== void 0) {
1249
+ return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
1250
+ }
1251
+ return matches[0];
1252
+ }
1253
+ function sectionSupportsStoryTarget(document2, sectionIndex, target) {
1254
+ if (!findHeaderFooterDocumentEntry(document2, target)) {
1255
+ return false;
1256
+ }
1257
+ const section = collectSectionContexts(document2).find(
1258
+ (candidate) => candidate.index === sectionIndex
1259
+ );
1260
+ if (!section) {
1261
+ return false;
1262
+ }
1263
+ const variants = resolveSectionVariants(
1264
+ target.kind,
1265
+ sectionIndex,
1266
+ target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
1267
+ target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? []
1268
+ );
1269
+ return variants.some(
1270
+ (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
1271
+ );
1272
+ }
1273
+ function normalizeHeaderFooterTarget(document2, target, preferredSectionIndex) {
1274
+ if (!findHeaderFooterDocumentEntry(document2, target)) {
1275
+ return void 0;
1276
+ }
1277
+ if (target.sectionIndex !== void 0) {
1278
+ return sectionSupportsStoryTarget(document2, target.sectionIndex, target) ? target : void 0;
1279
+ }
1280
+ const candidateIndexes = collectSectionContexts(document2).map((section) => section.index).filter(
1281
+ (sectionIndex) => sectionSupportsStoryTarget(document2, sectionIndex, target)
1282
+ );
1283
+ if (candidateIndexes.length === 0) {
1284
+ return void 0;
1285
+ }
1286
+ const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
1287
+ return {
1288
+ ...target,
1289
+ sectionIndex: resolvedSectionIndex
1290
+ };
1291
+ }
1292
+
1293
+ // src/runtime/story-targeting.ts
1294
+ function storyTargetKey(target) {
1295
+ switch (target.kind) {
1296
+ case "main":
1297
+ return "main";
1298
+ case "header":
1299
+ return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
1300
+ case "footer":
1301
+ return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
1302
+ case "footnote":
1303
+ return `footnote:${target.noteId}`;
1304
+ case "endnote":
1305
+ return `endnote:${target.noteId}`;
1306
+ }
1307
+ }
1308
+ function getStoryBlocks(document2, target) {
1309
+ if (target.kind === "main") {
1310
+ return document2.content.children;
1311
+ }
1312
+ const subParts = document2.subParts;
1313
+ if (!subParts) {
1314
+ return [];
1315
+ }
1316
+ switch (target.kind) {
1317
+ case "header": {
1318
+ const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
1319
+ return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
1320
+ }
1321
+ case "footer": {
1322
+ const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
1323
+ return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
1324
+ }
1325
+ case "footnote":
1326
+ return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
1327
+ case "endnote":
1328
+ return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
1329
+ }
1330
+ }
1331
+
1332
+ // src/runtime/render/render-frame-diff.ts
1333
+ function diffRenderFrames(prev, next) {
1334
+ if (!prev) {
1335
+ return {
1336
+ addedPages: next.pages.map((p) => p.page.pageIndex),
1337
+ removedPages: [],
1338
+ unchangedPages: [],
1339
+ changedPages: []
1340
+ };
1341
+ }
1342
+ const prevByIndex = /* @__PURE__ */ new Map();
1343
+ for (const page of prev.pages) {
1344
+ prevByIndex.set(page.page.pageIndex, page);
1345
+ }
1346
+ const nextIndices = /* @__PURE__ */ new Set();
1347
+ for (const page of next.pages) {
1348
+ nextIndices.add(page.page.pageIndex);
1349
+ }
1350
+ const addedPages = [];
1351
+ const removedPages = [];
1352
+ const unchangedPages = [];
1353
+ const changedPages = [];
1354
+ for (const nextPage of next.pages) {
1355
+ const pageIndex = nextPage.page.pageIndex;
1356
+ const prevPage = prevByIndex.get(pageIndex);
1357
+ if (!prevPage) {
1358
+ addedPages.push(pageIndex);
1359
+ continue;
1360
+ }
1361
+ const regions = diffPage(prevPage, nextPage, prev.decorationIndex, next.decorationIndex);
1362
+ const frameChanged = !rectEquals(prevPage.frame, nextPage.frame);
1363
+ const reservationsChanged = !reservationsEqual(
1364
+ prevPage.chromeReservations,
1365
+ nextPage.chromeReservations
1366
+ );
1367
+ if (regions.length === 0 && !frameChanged && !reservationsChanged) {
1368
+ unchangedPages.push(pageIndex);
1369
+ } else {
1370
+ changedPages.push({
1371
+ pageIndex,
1372
+ regions,
1373
+ ...frameChanged ? { pageFrameChanged: true } : {}
1374
+ });
1375
+ }
1376
+ }
1377
+ for (const prevPage of prev.pages) {
1378
+ if (!nextIndices.has(prevPage.page.pageIndex)) {
1379
+ removedPages.push(prevPage.page.pageIndex);
1380
+ }
1381
+ }
1382
+ return { addedPages, removedPages, unchangedPages, changedPages };
1383
+ }
1384
+ function createPagePatchPlan(prev, next, diff = diffRenderFrames(prev, next), options = {}) {
1385
+ const prevByIndex = indexPagesByIndex(prev?.pages ?? []);
1386
+ const nextByIndex = indexPagesByIndex(next.pages);
1387
+ const addedPages = diff.addedPages.map(
1388
+ (pageIndex) => pageIdForIndex(nextByIndex, pageIndex)
1389
+ );
1390
+ const removedPages = diff.removedPages.map(
1391
+ (pageIndex) => pageIdForIndex(prevByIndex, pageIndex)
1392
+ );
1393
+ const unchangedPages = diff.unchangedPages.map(
1394
+ (pageIndex) => pageIdForIndex(nextByIndex, pageIndex)
1395
+ );
1396
+ const changedPages = diff.changedPages.map(
1397
+ (entry) => createPagePatchEntry(entry, pageIdForIndex(nextByIndex, entry.pageIndex), options)
1398
+ );
1399
+ return {
1400
+ layoutRevision: options.layoutRevision ?? next.revision,
1401
+ geometryRevision: options.geometryRevision ?? next.revision,
1402
+ addedPages,
1403
+ removedPages,
1404
+ unchangedPages,
1405
+ changedPages,
1406
+ mountChanges: resolveMountChanges({
1407
+ addedPages,
1408
+ removedPages,
1409
+ mountedPageIds: options.mountedPageIds,
1410
+ requestedMountPageIds: options.requestedMountPageIds
1411
+ })
1412
+ };
1413
+ }
1414
+ function createPagePatchEntry(entry, pageId, options) {
1415
+ const regionChanges = entry.regions.map((region) => region.kind);
1416
+ const fragmentChanges = uniqueStrings(
1417
+ entry.regions.flatMap((region) => region.changedBlockIds)
1418
+ );
1419
+ const overlayLaneChanges = !entry.pageFrameChanged && entry.regions.length === 0 ? ["chrome-reservations"] : [];
1420
+ return {
1421
+ pageId,
1422
+ pageIndex: entry.pageIndex,
1423
+ frameChanged: entry.pageFrameChanged === true,
1424
+ regionChanges,
1425
+ fragmentChanges,
1426
+ lineBoxChanges: fragmentChanges,
1427
+ overlayLaneChanges,
1428
+ reason: options.reason ?? (overlayLaneChanges.length > 0 ? "overlay" : "layout")
1429
+ };
1430
+ }
1431
+ function resolveMountChanges(input) {
1432
+ if (!input.mountedPageIds || !input.requestedMountPageIds) {
1433
+ return {
1434
+ mountPageIds: input.addedPages,
1435
+ unmountPageIds: input.removedPages
1436
+ };
1437
+ }
1438
+ const mounted = new Set(input.mountedPageIds);
1439
+ const requested = new Set(input.requestedMountPageIds);
1440
+ return {
1441
+ mountPageIds: input.requestedMountPageIds.filter((pageId) => !mounted.has(pageId)),
1442
+ unmountPageIds: input.mountedPageIds.filter((pageId) => !requested.has(pageId))
1443
+ };
1444
+ }
1445
+ function indexPagesByIndex(pages) {
1446
+ return new Map(pages.map((page) => [page.page.pageIndex, page]));
1447
+ }
1448
+ function pageIdForIndex(pages, pageIndex) {
1449
+ return pages.get(pageIndex)?.page.pageId ?? `page:${pageIndex}`;
1450
+ }
1451
+ function uniqueStrings(values) {
1452
+ return [...new Set(values)];
1453
+ }
1454
+ function diffPage(prev, next, prevIndex, nextIndex) {
1455
+ const changed = [];
1456
+ const bodyChanges = diffRegion(prev.regions.body, next.regions.body, prevIndex, nextIndex);
1457
+ if (bodyChanges.length > 0) {
1458
+ changed.push({ kind: "body", changedBlockIds: bodyChanges });
1459
+ }
1460
+ const headerChanges = diffOptionalRegion(
1461
+ prev.regions.header,
1462
+ next.regions.header,
1463
+ prevIndex,
1464
+ nextIndex
1465
+ );
1466
+ if (headerChanges.length > 0) {
1467
+ changed.push({ kind: "header", changedBlockIds: headerChanges });
1468
+ }
1469
+ const footerChanges = diffOptionalRegion(
1470
+ prev.regions.footer,
1471
+ next.regions.footer,
1472
+ prevIndex,
1473
+ nextIndex
1474
+ );
1475
+ if (footerChanges.length > 0) {
1476
+ changed.push({ kind: "footer", changedBlockIds: footerChanges });
1477
+ }
1478
+ const prevFoot = prev.regions.footnotes ?? [];
1479
+ const nextFoot = next.regions.footnotes ?? [];
1480
+ if (prevFoot.length !== nextFoot.length) {
1481
+ changed.push({ kind: "footnote-area", changedBlockIds: ["<count-changed>"] });
1482
+ } else {
1483
+ for (let i = 0; i < prevFoot.length; i += 1) {
1484
+ const fChanges = diffRegion(prevFoot[i], nextFoot[i], prevIndex, nextIndex);
1485
+ if (fChanges.length > 0) {
1486
+ changed.push({ kind: "footnote-area", changedBlockIds: fChanges });
1487
+ }
1488
+ }
1489
+ }
1490
+ return changed;
1491
+ }
1492
+ function diffOptionalRegion(prev, next, prevIndex, nextIndex) {
1493
+ if (!prev && !next) return [];
1494
+ if (!prev && next) return ["<added>"];
1495
+ if (prev && !next) return ["<removed>"];
1496
+ return diffRegion(prev, next, prevIndex, nextIndex);
1497
+ }
1498
+ function diffRegion(prev, next, prevIndex, nextIndex) {
1499
+ const changed = [];
1500
+ if (!rectEquals(prev.frame, next.frame)) {
1501
+ changed.push("<region-frame>");
1502
+ }
1503
+ const prevBlocks = /* @__PURE__ */ new Map();
1504
+ for (const block of prev.blocks) {
1505
+ prevBlocks.set(block.fragment.blockId, block);
1506
+ }
1507
+ const nextIds = /* @__PURE__ */ new Set();
1508
+ for (const block of next.blocks) {
1509
+ nextIds.add(block.fragment.blockId);
1510
+ const prevBlock = prevBlocks.get(block.fragment.blockId);
1511
+ if (!prevBlock) {
1512
+ changed.push(block.fragment.blockId);
1513
+ continue;
1514
+ }
1515
+ if (!blocksStructurallyEqual(prevBlock, block, prevIndex, nextIndex)) {
1516
+ changed.push(block.fragment.blockId);
1517
+ }
1518
+ }
1519
+ for (const blockId of prevBlocks.keys()) {
1520
+ if (!nextIds.has(blockId)) changed.push(blockId);
1521
+ }
1522
+ return changed;
1523
+ }
1524
+ function blocksStructurallyEqual(a, b, aIndex, bIndex) {
1525
+ if (a.kind !== b.kind) return false;
1526
+ if (a.fragment.regionKind !== b.fragment.regionKind) return false;
1527
+ if (a.fragment.from !== b.fragment.from) return false;
1528
+ if (a.fragment.to !== b.fragment.to) return false;
1529
+ if (!rectEquals(a.frame, b.frame)) return false;
1530
+ if (a.lines.length !== b.lines.length) return false;
1531
+ for (let i = 0; i < a.lines.length; i += 1) {
1532
+ if (!rectEquals(a.lines[i].frame, b.lines[i].frame)) return false;
1533
+ }
1534
+ const aHash = decorationHashForBlock(a.frame, aIndex);
1535
+ const bHash = decorationHashForBlock(b.frame, bIndex);
1536
+ if (aHash !== bHash) return false;
1537
+ return true;
1538
+ }
1539
+ function decorationHashForBlock(blockFrame, index) {
1540
+ const tokens = [];
1541
+ for (const lane of [index.workflow, index.comments, index.revisions, index.search, index.locked]) {
1542
+ for (const entry of lane) {
1543
+ if (rectIntersects(entry.frame, blockFrame)) {
1544
+ tokens.push(`${entry.kind}:${entry.refId}`);
1545
+ }
1546
+ }
1547
+ }
1548
+ tokens.sort();
1549
+ return tokens.join("|");
1550
+ }
1551
+ function reservationsEqual(a, b) {
1552
+ return a.railLaneTwips === b.railLaneTwips && a.balloonLaneTwips === b.balloonLaneTwips && a.footnoteAreaTwips === b.footnoteAreaTwips && a.pageFrameWidthPx === b.pageFrameWidthPx && a.pageFrameHeightPx === b.pageFrameHeightPx;
1553
+ }
1554
+ var RECT_EPS = 0.1;
1555
+ function rectEquals(a, b) {
1556
+ return Math.abs(a.leftPx - b.leftPx) < RECT_EPS && Math.abs(a.topPx - b.topPx) < RECT_EPS && Math.abs(a.widthPx - b.widthPx) < RECT_EPS && Math.abs(a.heightPx - b.heightPx) < RECT_EPS;
1557
+ }
1558
+ function rectIntersects(a, b) {
1559
+ return !(a.leftPx + a.widthPx <= b.leftPx || b.leftPx + b.widthPx <= a.leftPx || a.topPx + a.heightPx <= b.topPx || b.topPx + b.heightPx <= a.topPx);
1560
+ }
1561
+
1562
+ // src/runtime/render/render-frame-types.ts
1563
+ var DEFAULT_PX_PER_TWIP = 96 / 1440;
1564
+ var EMPTY_DECORATION_INDEX = Object.freeze({
1565
+ workflow: Object.freeze([]),
1566
+ comments: Object.freeze([]),
1567
+ revisions: Object.freeze([]),
1568
+ search: Object.freeze([]),
1569
+ locked: Object.freeze([])
1570
+ });
1571
+
1205
1572
  // src/core/schema/text-schema.ts
1206
1573
  function parseTextStory(content) {
1207
1574
  const root = normalizeDocumentRoot(content);
@@ -2084,132 +2451,6 @@ function truncate(s) {
2084
2451
  // src/api/public-types.ts
2085
2452
  init_measurement_backend_canvas();
2086
2453
 
2087
- // src/runtime/story-context.ts
2088
- function collectSectionContexts(document2) {
2089
- const sections = [];
2090
- let sectionIndex = 0;
2091
- for (const block of document2.content.children) {
2092
- if (block.type !== "section_break") {
2093
- continue;
2094
- }
2095
- sections.push({
2096
- index: sectionIndex,
2097
- properties: block.sectionProperties
2098
- });
2099
- sectionIndex += 1;
2100
- }
2101
- sections.push({
2102
- index: sectionIndex,
2103
- properties: document2.subParts?.finalSectionProperties
2104
- });
2105
- return sections;
2106
- }
2107
- function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
2108
- if (explicitReferences && explicitReferences.length > 0) {
2109
- return explicitReferences.map((ref) => ({
2110
- variant: ref.variant,
2111
- relationshipId: ref.relationshipId
2112
- }));
2113
- }
2114
- return documents.filter(
2115
- (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
2116
- ).map((entry) => ({
2117
- variant: entry.variant,
2118
- relationshipId: entry.relationshipId
2119
- }));
2120
- }
2121
- function findHeaderFooterDocumentEntry(document2, target) {
2122
- const documents = target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? [];
2123
- const matches = documents.filter(
2124
- (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
2125
- );
2126
- if (matches.length === 0) {
2127
- return void 0;
2128
- }
2129
- if (target.sectionIndex !== void 0) {
2130
- return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
2131
- }
2132
- return matches[0];
2133
- }
2134
- function sectionSupportsStoryTarget(document2, sectionIndex, target) {
2135
- if (!findHeaderFooterDocumentEntry(document2, target)) {
2136
- return false;
2137
- }
2138
- const section = collectSectionContexts(document2).find(
2139
- (candidate) => candidate.index === sectionIndex
2140
- );
2141
- if (!section) {
2142
- return false;
2143
- }
2144
- const variants = resolveSectionVariants(
2145
- target.kind,
2146
- sectionIndex,
2147
- target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
2148
- target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? []
2149
- );
2150
- return variants.some(
2151
- (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
2152
- );
2153
- }
2154
- function normalizeHeaderFooterTarget(document2, target, preferredSectionIndex) {
2155
- if (!findHeaderFooterDocumentEntry(document2, target)) {
2156
- return void 0;
2157
- }
2158
- if (target.sectionIndex !== void 0) {
2159
- return sectionSupportsStoryTarget(document2, target.sectionIndex, target) ? target : void 0;
2160
- }
2161
- const candidateIndexes = collectSectionContexts(document2).map((section) => section.index).filter(
2162
- (sectionIndex) => sectionSupportsStoryTarget(document2, sectionIndex, target)
2163
- );
2164
- if (candidateIndexes.length === 0) {
2165
- return void 0;
2166
- }
2167
- const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
2168
- return {
2169
- ...target,
2170
- sectionIndex: resolvedSectionIndex
2171
- };
2172
- }
2173
-
2174
- // src/runtime/story-targeting.ts
2175
- function storyTargetKey(target) {
2176
- switch (target.kind) {
2177
- case "main":
2178
- return "main";
2179
- case "header":
2180
- return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
2181
- case "footer":
2182
- return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
2183
- case "footnote":
2184
- return `footnote:${target.noteId}`;
2185
- case "endnote":
2186
- return `endnote:${target.noteId}`;
2187
- }
2188
- }
2189
- function getStoryBlocks(document2, target) {
2190
- if (target.kind === "main") {
2191
- return document2.content.children;
2192
- }
2193
- const subParts = document2.subParts;
2194
- if (!subParts) {
2195
- return [];
2196
- }
2197
- switch (target.kind) {
2198
- case "header": {
2199
- const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
2200
- return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
2201
- }
2202
- case "footer": {
2203
- const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
2204
- return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
2205
- }
2206
- case "footnote":
2207
- return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
2208
- case "endnote":
2209
- return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
2210
- }
2211
- }
2212
-
2213
2454
  // src/core/selection/anchor-conversion.ts
2214
2455
  var DEFAULT_PUBLIC_ASSOC = {
2215
2456
  start: -1,
@@ -2710,11 +2951,14 @@ function collectEditableTargetRefs(doc, cache) {
2710
2951
  collectEditableTargetsInBlocks(
2711
2952
  context.blocks,
2712
2953
  {
2954
+ doc,
2713
2955
  storyKey: context.storyKey,
2714
2956
  basePath: context.basePath,
2715
2957
  insideSdt: false,
2716
2958
  insideTextBox: false,
2717
- tableDepth: 0
2959
+ tableDepth: 0,
2960
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
2961
+ numberingTargetRevisionHash: createNumberingTargetRevisionHash(doc)
2718
2962
  },
2719
2963
  targets,
2720
2964
  cache
@@ -2731,6 +2975,7 @@ function buildBlockCacheSignature(context, blockIndex) {
2731
2975
  const owner = tt?.editableOwnersByChildIndex?.get(blockIndex);
2732
2976
  return [
2733
2977
  context.storyKey,
2978
+ context.numberingTargetRevisionHash,
2734
2979
  context.insideSdt ? "1" : "0",
2735
2980
  context.insideTextBox ? "1" : "0",
2736
2981
  String(context.tableDepth),
@@ -2776,7 +3021,8 @@ function collectEditableTargetsInBlocks(blocks, context, targets, cache, blockIn
2776
3021
  editableParagraphTargetPosture(targetKind),
2777
3022
  context.contentControl,
2778
3023
  context.tableTarget,
2779
- context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex)
3024
+ context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex),
3025
+ resolveEditableParagraphListIdentity(block, context)
2780
3026
  )
2781
3027
  );
2782
3028
  }
@@ -3305,7 +3551,7 @@ function collectEditableTargetsInInlines(inlines, basePath, context, targets) {
3305
3551
  }
3306
3552
  }
3307
3553
  }
3308
- function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner) {
3554
+ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner, listIdentity) {
3309
3555
  const paragraphText = collectParagraphText(paragraph);
3310
3556
  const paragraphTextHash = hashText(paragraphText);
3311
3557
  const sourceRef = paragraph.sourceRef;
@@ -3316,19 +3562,39 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
3316
3562
  context: { storyKey, insideSdt: contentControl !== void 0 },
3317
3563
  ...tableTarget
3318
3564
  }) : void 0;
3319
- const listAddress = paragraph.numbering !== void 0 ? createCanonicalAddress({
3565
+ const listAddress = listIdentity !== void 0 ? createCanonicalAddress({
3320
3566
  addressKind: "list-item-text",
3321
3567
  storyKey,
3322
3568
  staleCheckKind: "paragraph",
3323
3569
  operationScope: "list-text",
3324
- sourceRefs: [sourceRef],
3570
+ sourceRefs: [
3571
+ sourceRef,
3572
+ listIdentity.paragraphNumberingSourceRef,
3573
+ listIdentity.instanceSourceRef,
3574
+ listIdentity.abstractSourceRef
3575
+ ],
3325
3576
  staleHash: paragraphTextHash,
3326
3577
  rangeBoundary: { boundaryKind: "list-item-text" },
3578
+ list: {
3579
+ numberingOrigin: listIdentity.numberingOrigin,
3580
+ numberingInstanceId: listIdentity.numberingInstanceId,
3581
+ ...listIdentity.abstractNumberingId !== void 0 ? { abstractNumberingId: listIdentity.abstractNumberingId } : {},
3582
+ level: listIdentity.level,
3583
+ ...listIdentity.overrideHash !== void 0 ? { overrideHash: listIdentity.overrideHash } : {},
3584
+ numberingCatalogHash: listIdentity.numberingCatalogHash
3585
+ },
3327
3586
  discriminator: {
3328
3587
  blockPath,
3329
- numberingInstanceId: paragraph.numbering.numberingInstanceId,
3330
- level: paragraph.numbering.level,
3588
+ numberingOrigin: listIdentity.numberingOrigin,
3589
+ numberingInstanceId: listIdentity.numberingInstanceId,
3590
+ abstractNumberingId: listIdentity.abstractNumberingId ?? null,
3591
+ level: listIdentity.level,
3592
+ overrideHash: listIdentity.overrideHash ?? null,
3593
+ numberingCatalogHash: listIdentity.numberingCatalogHash,
3331
3594
  sourceId: sourceRef?.sourceId ?? null,
3595
+ numberingSourceId: listIdentity.paragraphNumberingSourceRef?.sourceId ?? null,
3596
+ numberingInstanceSourceId: listIdentity.instanceSourceRef?.sourceId ?? null,
3597
+ abstractNumberingSourceId: listIdentity.abstractSourceRef?.sourceId ?? null,
3332
3598
  paraId: paragraph.wordExtensionIds?.paraId ?? null,
3333
3599
  textId: paragraph.wordExtensionIds?.textId ?? null
3334
3600
  }
@@ -3369,11 +3635,62 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
3369
3635
  blockType: "paragraph",
3370
3636
  ...paragraph.wordExtensionIds?.paraId !== void 0 ? { wordParaId: paragraph.wordExtensionIds.paraId } : {},
3371
3637
  ...paragraph.wordExtensionIds?.textId !== void 0 ? { wordTextId: paragraph.wordExtensionIds.textId } : {},
3372
- ...sourceRef !== void 0 ? { sourceRef } : {}
3638
+ ...sourceRef !== void 0 ? { sourceRef } : {},
3639
+ ...listIdentity !== void 0 ? {
3640
+ listNumberingOrigin: listIdentity.numberingOrigin,
3641
+ listNumberingInstanceId: listIdentity.numberingInstanceId,
3642
+ ...listIdentity.abstractNumberingId !== void 0 ? { listAbstractNumberingId: listIdentity.abstractNumberingId } : {},
3643
+ listLevel: listIdentity.level,
3644
+ ...listIdentity.overrideHash !== void 0 ? { listOverrideHash: listIdentity.overrideHash } : {},
3645
+ numberingCatalogHash: listIdentity.numberingCatalogHash
3646
+ } : {}
3373
3647
  },
3374
3648
  posture
3375
3649
  };
3376
3650
  }
3651
+ function resolveEditableParagraphListIdentity(paragraph, context) {
3652
+ const directNumbering = paragraph.numbering;
3653
+ const styleNumbering = directNumbering === void 0 && paragraph.styleId !== void 0 ? resolveParagraphStyleNumbering(context.doc, paragraph.styleId) : void 0;
3654
+ const numbering = directNumbering ?? styleNumbering;
3655
+ if (numbering === void 0) return void 0;
3656
+ const numberingCatalog = context.doc.numbering ?? { abstractDefinitions: {}, instances: {} };
3657
+ const instances = numberingCatalog.instances ?? {};
3658
+ const abstractDefinitions = numberingCatalog.abstractDefinitions ?? {};
3659
+ const instance = instances[numbering.numberingInstanceId];
3660
+ const abstractDefinition = instance !== void 0 ? abstractDefinitions[instance.abstractNumberingId] : void 0;
3661
+ const level = numbering.level ?? 0;
3662
+ const override = instance?.overrides.find((entry) => entry.level === level);
3663
+ const overrideHash = override !== void 0 ? hashText(JSON.stringify(numberingOverrideDiscriminator(override))) : void 0;
3664
+ return {
3665
+ numberingOrigin: directNumbering !== void 0 ? "paragraph" : "paragraph-style",
3666
+ numberingInstanceId: numbering.numberingInstanceId,
3667
+ ...instance?.abstractNumberingId !== void 0 ? { abstractNumberingId: instance.abstractNumberingId } : {},
3668
+ level,
3669
+ ...overrideHash !== void 0 ? { overrideHash } : {},
3670
+ numberingCatalogHash: context.numberingCatalogHash,
3671
+ ...directNumbering?.sourceRef !== void 0 ? { paragraphNumberingSourceRef: directNumbering.sourceRef } : {},
3672
+ ...instance?.sourceRef !== void 0 ? { instanceSourceRef: instance.sourceRef } : {},
3673
+ ...abstractDefinition?.sourceRef !== void 0 ? { abstractSourceRef: abstractDefinition.sourceRef } : {}
3674
+ };
3675
+ }
3676
+ function numberingOverrideDiscriminator(override) {
3677
+ return {
3678
+ level: override.level,
3679
+ startAt: override.startAt ?? null,
3680
+ sourceId: override.sourceRef?.sourceId ?? null,
3681
+ levelDefinition: override.levelDefinition === void 0 ? null : {
3682
+ sourceId: override.levelDefinition.sourceRef?.sourceId ?? null,
3683
+ format: override.levelDefinition.format ?? null,
3684
+ text: override.levelDefinition.text ?? null,
3685
+ startAt: override.levelDefinition.startAt ?? null,
3686
+ paragraphStyleId: override.levelDefinition.paragraphStyleId ?? null,
3687
+ isLegalNumbering: override.levelDefinition.isLegalNumbering ?? null,
3688
+ suffix: override.levelDefinition.suffix ?? null,
3689
+ restartAfterLevel: override.levelDefinition.restartAfterLevel ?? null,
3690
+ picBulletId: override.levelDefinition.picBulletId ?? null
3691
+ }
3692
+ };
3693
+ }
3377
3694
  function contentControlLocksContent(contentControl) {
3378
3695
  return contentControl?.lock !== void 0 && contentControl.lock !== "unlocked" && contentControl.lock !== "none";
3379
3696
  }
@@ -4142,6 +4459,7 @@ function createCanonicalAddress(input) {
4142
4459
  ...input.rowRange !== void 0 ? { rowRange: input.rowRange } : {},
4143
4460
  ...input.columnRange !== void 0 ? { columnRange: input.columnRange } : {},
4144
4461
  ...sourceHash !== void 0 ? { sourceJoinHash: sourceHash } : {},
4462
+ ...input.list !== void 0 ? { list: input.list } : {},
4145
4463
  ...input.secondaryStory === true ? { secondaryStory: true } : {},
4146
4464
  ...input.nestedTable === true ? { nestedTable: true } : {},
4147
4465
  ...input.insideSdt === true ? { insideSdt: true } : {},
@@ -4176,6 +4494,71 @@ function sourceJoinHash(refs) {
4176
4494
  if (sourceIds.length === 0) return void 0;
4177
4495
  return hashText(sourceIds.join("\0"));
4178
4496
  }
4497
+ function createNumberingCatalogRevisionHash(doc) {
4498
+ const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
4499
+ const abstractDefinitions = catalog.abstractDefinitions ?? {};
4500
+ const instances = catalog.instances ?? {};
4501
+ const numPicBullets = catalog.numPicBullets ?? {};
4502
+ return hashText(JSON.stringify({
4503
+ abstractDefinitions: Object.keys(abstractDefinitions).sort().map((abstractNumberingId) => {
4504
+ const definition = abstractDefinitions[abstractNumberingId];
4505
+ return {
4506
+ abstractNumberingId,
4507
+ sourceId: definition.sourceRef?.sourceId ?? null,
4508
+ nsid: definition.nsid ?? null,
4509
+ tplc: definition.tplc ?? null,
4510
+ styleLink: definition.styleLink ?? null,
4511
+ numStyleLink: definition.numStyleLink ?? null,
4512
+ levels: definition.levels.map((level) => ({
4513
+ sourceId: level.sourceRef?.sourceId ?? null,
4514
+ level: level.level,
4515
+ format: level.format,
4516
+ text: level.text,
4517
+ startAt: level.startAt ?? null,
4518
+ paragraphStyleId: level.paragraphStyleId ?? null,
4519
+ isLegalNumbering: level.isLegalNumbering ?? null,
4520
+ suffix: level.suffix ?? null,
4521
+ restartAfterLevel: level.restartAfterLevel ?? null,
4522
+ picBulletId: level.picBulletId ?? null
4523
+ }))
4524
+ };
4525
+ }),
4526
+ instances: Object.keys(instances).sort().map((numberingInstanceId) => {
4527
+ const instance = instances[numberingInstanceId];
4528
+ return {
4529
+ numberingInstanceId,
4530
+ sourceId: instance.sourceRef?.sourceId ?? null,
4531
+ abstractNumberingId: instance.abstractNumberingId,
4532
+ overrides: instance.overrides.map(numberingOverrideDiscriminator)
4533
+ };
4534
+ }),
4535
+ numPicBullets: Object.keys(numPicBullets).sort().map((numPicBulletId) => {
4536
+ const picBullet = numPicBullets[numPicBulletId];
4537
+ return {
4538
+ numPicBulletId,
4539
+ sourceId: picBullet.sourceRef?.sourceId ?? null,
4540
+ mediaId: picBullet.mediaId ?? null,
4541
+ widthEmu: picBullet.widthEmu ?? null,
4542
+ heightEmu: picBullet.heightEmu ?? null
4543
+ };
4544
+ })
4545
+ }));
4546
+ }
4547
+ function createNumberingTargetRevisionHash(doc) {
4548
+ const paragraphStyles = doc.styles?.paragraphs ?? {};
4549
+ return hashText(JSON.stringify({
4550
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
4551
+ paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
4552
+ const style = paragraphStyles[styleId];
4553
+ return {
4554
+ styleId,
4555
+ basedOn: style.basedOn ?? null,
4556
+ numberingInstanceId: style.numbering?.numberingInstanceId ?? null,
4557
+ level: style.numbering?.level ?? null
4558
+ };
4559
+ })
4560
+ }));
4561
+ }
4179
4562
  function collectCanonicalStoryIdentities(doc) {
4180
4563
  const stories = [
4181
4564
  {
@@ -4307,7 +4690,7 @@ function resolveParagraphStyleNumbering(doc, styleId) {
4307
4690
  let currentStyleId = styleId;
4308
4691
  while (currentStyleId !== void 0 && !visited.has(currentStyleId)) {
4309
4692
  visited.add(currentStyleId);
4310
- const style = doc.styles.paragraphs[currentStyleId];
4693
+ const style = doc.styles?.paragraphs?.[currentStyleId];
4311
4694
  if (style === void 0) {
4312
4695
  return void 0;
4313
4696
  }
@@ -5863,6 +6246,10 @@ function createNumberingPrefixResolver(catalog) {
5863
6246
  ])
5864
6247
  ) : resolved.effectiveLevels;
5865
6248
  const picBulletId = resolved.effectiveLevel.picBulletId;
6249
+ const pictureBulletPosture = resolvePictureBulletRenderPosture(
6250
+ picBulletId,
6251
+ picBulletId != null ? catalog.numPicBullets?.[picBulletId] : void 0
6252
+ );
5866
6253
  const text = renderLevelText(
5867
6254
  resolved.effectiveLevel.text,
5868
6255
  workingState.counters,
@@ -5871,14 +6258,20 @@ function createNumberingPrefixResolver(catalog) {
5871
6258
  if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
5872
6259
  return null;
5873
6260
  }
5874
- const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
6261
+ const visibleText = resolved.effectiveLevel.format === "none" ? null : text ?? pictureBulletPosture?.fallbackGlyph ?? null;
6262
+ const normalizedMarkerText = normalizeMarkerText(
6263
+ visibleText,
6264
+ resolved.effectiveLevel.format,
6265
+ resolved.geometry.markerRunProperties
6266
+ );
5875
6267
  const formatPosture = getNumberingFormatPosture(
5876
6268
  resolved.effectiveLevel.format,
5877
6269
  currentCounter
5878
6270
  );
5879
- const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
6271
+ const picBulletMediaId = pictureBulletPosture?.mediaId;
5880
6272
  return {
5881
- text: visibleText,
6273
+ text: normalizedMarkerText.text,
6274
+ ...normalizedMarkerText.posture !== void 0 ? { markerTextPosture: normalizedMarkerText.posture } : {},
5882
6275
  level: resolved.effectiveLevel.level,
5883
6276
  format: resolved.effectiveLevel.format,
5884
6277
  ...formatPosture !== void 0 ? { formatPosture } : {},
@@ -5888,7 +6281,9 @@ function createNumberingPrefixResolver(catalog) {
5888
6281
  ...resolved.effectiveLevel.isLegalNumbering ? { isLegalNumbering: true } : {},
5889
6282
  ...resolved.geometry.markerRunProperties ? { markerRunProperties: resolved.geometry.markerRunProperties } : {},
5890
6283
  geometry: resolved.geometry,
5891
- ...picBulletMediaId != null ? { picBulletMediaId } : {}
6284
+ ...picBulletId != null ? { picBulletId } : {},
6285
+ ...picBulletMediaId != null ? { picBulletMediaId } : {},
6286
+ ...pictureBulletPosture !== void 0 ? { pictureBulletPosture } : {}
5892
6287
  };
5893
6288
  }
5894
6289
  return {
@@ -5904,6 +6299,69 @@ function createNumberingPrefixResolver(catalog) {
5904
6299
  }
5905
6300
  };
5906
6301
  }
6302
+ function normalizeMarkerText(text, format, markerRunProperties) {
6303
+ if (text === null || format !== "bullet") {
6304
+ return { text };
6305
+ }
6306
+ const fontFamily = getMarkerFontFamily(markerRunProperties);
6307
+ if (!isKnownSymbolBulletFont(fontFamily)) {
6308
+ return { text };
6309
+ }
6310
+ const renderedText = Array.from(text, (char) => SYMBOL_BULLET_GLYPH_MAP.get(char) ?? char).join("");
6311
+ if (renderedText === text) {
6312
+ return { text };
6313
+ }
6314
+ return {
6315
+ text: renderedText,
6316
+ posture: {
6317
+ status: "normalized",
6318
+ sourceText: text,
6319
+ renderedText,
6320
+ reason: "symbol-font-bullet-normalized",
6321
+ ...fontFamily ? { fontFamily } : {}
6322
+ }
6323
+ };
6324
+ }
6325
+ function getMarkerFontFamily(markerRunProperties) {
6326
+ return markerRunProperties?.fontFamilyAscii ?? markerRunProperties?.fontFamilyHAnsi ?? markerRunProperties?.fontFamilyEastAsia ?? markerRunProperties?.fontFamilyCs ?? markerRunProperties?.fontFamily;
6327
+ }
6328
+ function isKnownSymbolBulletFont(fontFamily) {
6329
+ return fontFamily !== void 0 && /^(?:symbol|wingdings|wingdings 2|wingdings 3|webdings)$/iu.test(
6330
+ fontFamily.trim()
6331
+ );
6332
+ }
6333
+ var SYMBOL_BULLET_GLYPH_MAP = /* @__PURE__ */ new Map([
6334
+ ["\uF0B7", "\u2022"],
6335
+ ["\uF0A7", "\u25AA"],
6336
+ ["\uF0FC", "\u2713"]
6337
+ ]);
6338
+ function resolvePictureBulletRenderPosture(picBulletId, picBullet) {
6339
+ if (picBulletId == null) return void 0;
6340
+ if (!picBullet) {
6341
+ return {
6342
+ status: "preserve-only",
6343
+ picBulletId,
6344
+ fallbackGlyph: "\u2022",
6345
+ reason: "picture-bullet-catalog-entry-missing"
6346
+ };
6347
+ }
6348
+ if (picBullet.mediaId) {
6349
+ return {
6350
+ status: "media-rendered",
6351
+ picBulletId,
6352
+ mediaId: picBullet.mediaId,
6353
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
6354
+ reason: "picture-bullet-media-rendered"
6355
+ };
6356
+ }
6357
+ return {
6358
+ status: "glyph-fallback",
6359
+ picBulletId,
6360
+ fallbackGlyph: "\u2022",
6361
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
6362
+ reason: "picture-bullet-media-unavailable"
6363
+ };
6364
+ }
5907
6365
  function getSequenceState(states, numberingInstanceId, options = { create: true }) {
5908
6366
  const existing = states.get(numberingInstanceId);
5909
6367
  if (existing) {
@@ -5966,7 +6424,7 @@ function getNumberingFormatPosture(format, value) {
5966
6424
  reason: registryEntry?.fallbackReason ?? "unsupported-numbering-format-decimal-fallback"
5967
6425
  };
5968
6426
  }
5969
- if (value !== void 0 && ((format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
6427
+ if (value !== void 0 && (registryEntry.isInRange !== void 0 && !registryEntry.isInRange(value) || (format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
5970
6428
  return {
5971
6429
  status: "approximated",
5972
6430
  requestedFormat: format,
@@ -6060,6 +6518,37 @@ var exactNumberingFormatEntries = [
6060
6518
  supportsMutation: true,
6061
6519
  render: toOrdinal2
6062
6520
  },
6521
+ {
6522
+ format: "decimalFullWidth",
6523
+ renderSupport: "supported",
6524
+ renderedFormat: "decimalFullWidth",
6525
+ supportsMutation: false,
6526
+ render: toFullWidthDecimal
6527
+ },
6528
+ {
6529
+ format: "decimalEnclosedCircle",
6530
+ renderSupport: "supported",
6531
+ renderedFormat: "decimalEnclosedCircle",
6532
+ supportsMutation: false,
6533
+ render: toCircledDecimal,
6534
+ isInRange: (value) => Number.isInteger(value) && value >= 0 && value <= 50
6535
+ },
6536
+ {
6537
+ format: "decimalEnclosedParen",
6538
+ renderSupport: "supported",
6539
+ renderedFormat: "decimalEnclosedParen",
6540
+ supportsMutation: false,
6541
+ render: (value) => Number.isInteger(value) && value > 0 ? `(${value})` : String(value),
6542
+ isInRange: (value) => Number.isInteger(value) && value > 0
6543
+ },
6544
+ {
6545
+ format: "decimalEnclosedFullstop",
6546
+ renderSupport: "supported",
6547
+ renderedFormat: "decimalEnclosedFullstop",
6548
+ supportsMutation: false,
6549
+ render: (value) => Number.isInteger(value) && value > 0 ? `${value}.` : String(value),
6550
+ isInRange: (value) => Number.isInteger(value) && value > 0
6551
+ },
6063
6552
  {
6064
6553
  format: "cardinalText",
6065
6554
  renderSupport: "supported",
@@ -6097,10 +6586,6 @@ var exactNumberingFormatEntries = [
6097
6586
  }
6098
6587
  ];
6099
6588
  var approximatedDecimalFormats = [
6100
- "decimalEnclosedCircle",
6101
- "decimalEnclosedFullstop",
6102
- "decimalEnclosedParen",
6103
- "decimalFullWidth",
6104
6589
  "decimalHalfWidth",
6105
6590
  "aiueo",
6106
6591
  "iroha",
@@ -6152,6 +6637,30 @@ function toOrdinal2(value) {
6152
6637
  return `${value}th`;
6153
6638
  }
6154
6639
  }
6640
+ function toFullWidthDecimal(value) {
6641
+ return String(value).replace(
6642
+ /[0-9]/g,
6643
+ (digit) => String.fromCharCode(65296 + Number.parseInt(digit, 10))
6644
+ );
6645
+ }
6646
+ var CIRCLED_DECIMAL_BY_VALUE = new Map([
6647
+ [0, "\u24EA"],
6648
+ ...Array.from({ length: 20 }, (_, index) => [
6649
+ index + 1,
6650
+ String.fromCodePoint(9312 + index)
6651
+ ]),
6652
+ ...Array.from({ length: 15 }, (_, index) => [
6653
+ index + 21,
6654
+ String.fromCodePoint(12881 + index)
6655
+ ]),
6656
+ ...Array.from({ length: 15 }, (_, index) => [
6657
+ index + 36,
6658
+ String.fromCodePoint(12977 + index)
6659
+ ])
6660
+ ]);
6661
+ function toCircledDecimal(value) {
6662
+ return CIRCLED_DECIMAL_BY_VALUE.get(value) ?? String(value);
6663
+ }
6155
6664
  function toAlphabetic2(value) {
6156
6665
  if (value <= 0) {
6157
6666
  return String(value);
@@ -6925,6 +7434,7 @@ function toNumberingLayoutInput(numbering) {
6925
7434
  const hangingTwips = textColumn?.hanging ?? numbering.geometry.indentation?.hanging ?? (typeof numbering.geometry.indentation?.firstLine === "number" && numbering.geometry.indentation.firstLine < 0 ? Math.abs(numbering.geometry.indentation.firstLine) : void 0);
6926
7435
  return {
6927
7436
  markerText: numbering.text,
7437
+ ...numbering.markerTextPosture ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
6928
7438
  ...numbering.markerRunProperties ? { markerRunFormatting: numbering.markerRunProperties } : {},
6929
7439
  markerSuffix: normalizeNumberingMarkerSuffix(numbering.suffix),
6930
7440
  ...markerLane ? { markerLaneStartTwips: markerLane.start } : {},
@@ -6937,7 +7447,9 @@ function toNumberingLayoutInput(numbering) {
6937
7447
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
6938
7448
  startAt: numbering.startAt,
6939
7449
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
6940
- ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
7450
+ ...numbering.picBulletId ? { pictureBulletId: numbering.picBulletId } : {},
7451
+ ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {},
7452
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
6941
7453
  };
6942
7454
  }
6943
7455
  function toFieldLayoutInput(entry, resolved, region) {
@@ -7449,6 +7961,7 @@ function buildEffectiveNumbering(detail) {
7449
7961
  const result = {
7450
7962
  level: detail.level,
7451
7963
  ...detail.text !== null ? { marker: detail.text } : {},
7964
+ ...detail.markerTextPosture ? { markerTextPosture: { ...detail.markerTextPosture } } : {},
7452
7965
  ...detail.markerRunProperties ? { markerRunFormatting: detail.markerRunProperties } : {},
7453
7966
  ...detail.geometry ? {
7454
7967
  indentation: {
@@ -7458,7 +7971,8 @@ function buildEffectiveNumbering(detail) {
7458
7971
  ...detail.geometry.tabStops && detail.geometry.tabStops.length > 0 ? { tab: detail.geometry.tabStops[0].position } : {}
7459
7972
  }
7460
7973
  } : {},
7461
- ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {}
7974
+ ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {},
7975
+ ...detail.pictureBulletPosture ? { pictureBulletPosture: { ...detail.pictureBulletPosture } } : {}
7462
7976
  };
7463
7977
  return result;
7464
7978
  }
@@ -9374,6 +9888,7 @@ function toSurfaceResolvedNumbering(numbering) {
9374
9888
  format: numbering.format,
9375
9889
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
9376
9890
  ...numbering.text !== null ? { text: numbering.text } : {},
9891
+ ...numbering.markerTextPosture !== void 0 ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
9377
9892
  startAt: numbering.startAt,
9378
9893
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
9379
9894
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
@@ -9386,7 +9901,9 @@ function toSurfaceResolvedNumbering(numbering) {
9386
9901
  ...numbering.geometry.markerLane ? { markerLane: { ...numbering.geometry.markerLane } } : {},
9387
9902
  ...numbering.geometry.textColumn ? { textColumn: { ...numbering.geometry.textColumn } } : {}
9388
9903
  },
9389
- ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {}
9904
+ ...numbering.picBulletId ? { picBulletId: numbering.picBulletId } : {},
9905
+ ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {},
9906
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
9390
9907
  };
9391
9908
  }
9392
9909
  function describePreservedInlinePreview(payloadReference) {
@@ -13458,6 +13975,11 @@ function freezeNumberingLayoutFacts(numbering) {
13458
13975
  if (numbering.numberingSourceRef) Object.freeze(numbering.numberingSourceRef);
13459
13976
  if (numbering.numberingInstanceSourceRef) Object.freeze(numbering.numberingInstanceSourceRef);
13460
13977
  if (numbering.abstractNumberingSourceRef) Object.freeze(numbering.abstractNumberingSourceRef);
13978
+ if (numbering.markerTextPosture) Object.freeze(numbering.markerTextPosture);
13979
+ if (numbering.pictureBulletPosture) {
13980
+ if (numbering.pictureBulletPosture.sourceRef) Object.freeze(numbering.pictureBulletPosture.sourceRef);
13981
+ Object.freeze(numbering.pictureBulletPosture);
13982
+ }
13461
13983
  if (numbering.markerLane) Object.freeze(numbering.markerLane);
13462
13984
  if (numbering.textColumn) Object.freeze(numbering.textColumn);
13463
13985
  if (numbering.tabStops) {
@@ -14410,8 +14932,17 @@ function collectNumberingLayoutFacts(block) {
14410
14932
  ...block.resolvedNumbering?.format !== void 0 ? { format: block.resolvedNumbering.format } : {},
14411
14933
  ...block.resolvedNumbering?.formatPosture !== void 0 ? { formatPosture: { ...block.resolvedNumbering.formatPosture } } : {},
14412
14934
  ...block.numberingPrefix !== void 0 ? { markerText: block.numberingPrefix } : {},
14935
+ ...block.resolvedNumbering?.markerTextPosture !== void 0 ? { markerTextPosture: { ...block.resolvedNumbering.markerTextPosture } } : {},
14413
14936
  ...block.numberingSuffix !== void 0 ? { markerSuffix: block.numberingSuffix } : {},
14414
14937
  ...block.resolvedNumbering?.geometry.markerJustification !== void 0 ? { markerJustification: block.resolvedNumbering.geometry.markerJustification } : {},
14938
+ ...block.resolvedNumbering?.picBulletId !== void 0 ? { picBulletId: block.resolvedNumbering.picBulletId } : {},
14939
+ ...block.resolvedNumbering?.picBulletMediaId !== void 0 ? { picBulletMediaId: block.resolvedNumbering.picBulletMediaId } : {},
14940
+ ...block.resolvedNumbering?.pictureBulletPosture !== void 0 ? {
14941
+ pictureBulletPosture: {
14942
+ ...block.resolvedNumbering.pictureBulletPosture,
14943
+ ...block.resolvedNumbering.pictureBulletPosture.sourceRef !== void 0 ? { sourceRef: { ...block.resolvedNumbering.pictureBulletPosture.sourceRef } } : {}
14944
+ }
14945
+ } : {},
14415
14946
  ...markerLane ? {
14416
14947
  markerLane: {
14417
14948
  startTwips: markerLane.start,
@@ -16231,16 +16762,6 @@ function resolveProjectedRuntimeRange(offsetMap, from, to) {
16231
16762
  return { from: runtimeFrom, to: runtimeTo };
16232
16763
  }
16233
16764
 
16234
- // src/runtime/render/render-frame-types.ts
16235
- var DEFAULT_PX_PER_TWIP = 96 / 1440;
16236
- var EMPTY_DECORATION_INDEX = Object.freeze({
16237
- workflow: Object.freeze([]),
16238
- comments: Object.freeze([]),
16239
- revisions: Object.freeze([]),
16240
- search: Object.freeze([]),
16241
- locked: Object.freeze([])
16242
- });
16243
-
16244
16765
  // src/runtime/markdown-sanitizer.ts
16245
16766
  function sanitizeMarkdown(raw) {
16246
16767
  let sanitized = false;
@@ -16361,6 +16882,7 @@ var MetadataResolverMissingError = class extends Error {
16361
16882
  buildPagePreviewMaps,
16362
16883
  buildSearchPattern,
16363
16884
  createCanvasBackend,
16885
+ createPagePatchPlan,
16364
16886
  createPublicNodeAnchor,
16365
16887
  createPublicRangeAnchor,
16366
16888
  createScopeTagRegistry,