@beyondwork/docx-react-component 1.0.135 → 1.0.137

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 (62) hide show
  1. package/dist/api/public-types.d.cts +2 -2
  2. package/dist/api/public-types.d.ts +2 -2
  3. package/dist/api/v3.cjs +827 -59
  4. package/dist/api/v3.d.cts +3 -3
  5. package/dist/api/v3.d.ts +3 -3
  6. package/dist/api/v3.js +2 -2
  7. package/dist/{canonical-document-CfZIc-fC.d.cts → canonical-document-COmM7v11.d.cts} +1 -1
  8. package/dist/{canonical-document-CfZIc-fC.d.ts → canonical-document-COmM7v11.d.ts} +1 -1
  9. package/dist/{chunk-EPFVMUKF.js → chunk-M3AEVSKU.js} +793 -56
  10. package/dist/{chunk-5CCYF333.js → chunk-NYIMPM3Z.js} +143 -1
  11. package/dist/{chunk-GIFXKIM5.js → chunk-SMBDQV73.js} +688 -57
  12. package/dist/compare.d.cts +1 -1
  13. package/dist/compare.d.ts +1 -1
  14. package/dist/core/commands/formatting-commands.d.cts +2 -2
  15. package/dist/core/commands/formatting-commands.d.ts +2 -2
  16. package/dist/core/commands/image-commands.d.cts +2 -2
  17. package/dist/core/commands/image-commands.d.ts +2 -2
  18. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  19. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  20. package/dist/core/commands/style-commands.d.cts +2 -2
  21. package/dist/core/commands/style-commands.d.ts +2 -2
  22. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  23. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  24. package/dist/core/commands/text-commands.d.cts +2 -2
  25. package/dist/core/commands/text-commands.d.ts +2 -2
  26. package/dist/core/selection/mapping.d.cts +2 -2
  27. package/dist/core/selection/mapping.d.ts +2 -2
  28. package/dist/core/state/editor-state.d.cts +2 -2
  29. package/dist/core/state/editor-state.d.ts +2 -2
  30. package/dist/index.cjs +1808 -190
  31. package/dist/index.d.cts +5 -5
  32. package/dist/index.d.ts +5 -5
  33. package/dist/index.js +144 -32
  34. package/dist/io/docx-session.d.cts +4 -4
  35. package/dist/io/docx-session.d.ts +4 -4
  36. package/dist/legal.d.cts +1 -1
  37. package/dist/legal.d.ts +1 -1
  38. package/dist/{loader-BQ7AB-0v.d.cts → loader-BB7tRkY2.d.cts} +3 -3
  39. package/dist/{loader-Cy6OYBfn.d.ts → loader-DGPbaboy.d.ts} +3 -3
  40. package/dist/{public-types-D31xKNGc.d.cts → public-types-CIvw1GQa.d.cts} +142 -9
  41. package/dist/{public-types-DqYt8GdP.d.ts → public-types-COCDrgVX.d.ts} +142 -9
  42. package/dist/public-types.d.cts +2 -2
  43. package/dist/public-types.d.ts +2 -2
  44. package/dist/runtime/collab.d.cts +3 -3
  45. package/dist/runtime/collab.d.ts +3 -3
  46. package/dist/runtime/document-runtime.cjs +825 -54
  47. package/dist/runtime/document-runtime.d.cts +2 -2
  48. package/dist/runtime/document-runtime.d.ts +2 -2
  49. package/dist/runtime/document-runtime.js +2 -2
  50. package/dist/{session-DA-F2fCw.d.cts → session-CVU-rtCd.d.cts} +3 -3
  51. package/dist/{session-DqL8H0oZ.d.ts → session-DOqy1-Lf.d.ts} +3 -3
  52. package/dist/session.d.cts +5 -5
  53. package/dist/session.d.ts +5 -5
  54. package/dist/tailwind.d.cts +2 -2
  55. package/dist/tailwind.d.ts +2 -2
  56. package/dist/{types-SllbCtGs.d.ts → types-CB_tOnVp.d.ts} +2 -2
  57. package/dist/{types-B2y94n5t.d.cts → types-CZAll7OS.d.cts} +2 -2
  58. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  59. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  60. package/dist/ui-tailwind.d.cts +3 -3
  61. package/dist/ui-tailwind.d.ts +3 -3
  62. package/package.json +1 -1
@@ -2189,13 +2189,32 @@ function storyKeyFromHandle(handle) {
2189
2189
  function textLeafEditableTargetHint(entry, semanticBlockRange) {
2190
2190
  const storyKey = storyKeyFromHandle(entry.handle);
2191
2191
  if (!storyKey) return void 0;
2192
+ const semanticBlockPath = textLeafBlockPathFromSemanticPath(entry.handle.semanticPath, storyKey);
2192
2193
  return {
2193
2194
  kind: "text-leaf",
2194
2195
  storyKey,
2195
- blockPath: `${storyKey}/block[${entry.blockIndex}]`,
2196
+ blockPath: semanticBlockPath ?? `${storyKey}/block[${entry.blockIndex}]`,
2196
2197
  semanticBlockRange
2197
2198
  };
2198
2199
  }
2200
+ function textLeafBlockPathFromSemanticPath(semanticPath, storyKey) {
2201
+ if (!semanticPath) return null;
2202
+ const tableIndex = semanticPath.indexOf("table");
2203
+ const rowIndex = semanticPath.indexOf("row", tableIndex + 1);
2204
+ const cellIndex = semanticPath.indexOf("cell", rowIndex + 1);
2205
+ const paragraphIndex = semanticPath.indexOf("paragraph", cellIndex + 1);
2206
+ if (tableIndex < 0 || rowIndex < 0 || cellIndex < 0 || paragraphIndex < 0) {
2207
+ return null;
2208
+ }
2209
+ const table = Number(semanticPath[tableIndex + 1]);
2210
+ const row = Number(semanticPath[rowIndex + 1]);
2211
+ const cell = Number(semanticPath[cellIndex + 1]);
2212
+ const paragraph = Number(semanticPath[paragraphIndex + 1]);
2213
+ if (!Number.isInteger(table) || !Number.isInteger(row) || !Number.isInteger(cell) || !Number.isInteger(paragraph)) {
2214
+ return null;
2215
+ }
2216
+ return `${storyKey}/block[${table}]/row[${row}]/cell[${cell}]/block[${paragraph}]`;
2217
+ }
2199
2218
  function compileParagraphReplacement(entry, proposed, options) {
2200
2219
  if (proposed.operation !== "replace" && proposed.operation !== "insert-before" && proposed.operation !== "insert-after") {
2201
2220
  return null;
@@ -9594,6 +9613,106 @@ function setStartOverride(catalog, numberingInstanceId, level, startAt) {
9594
9613
  overrides: mergeOverride(instance.overrides, { level, startAt })
9595
9614
  };
9596
9615
  }
9616
+ function mergeFragmentNumberingCatalog(target, fragment) {
9617
+ const catalog = cloneNumberingCatalog(target);
9618
+ const abstractIdMap = /* @__PURE__ */ new Map();
9619
+ const instanceIdMap = /* @__PURE__ */ new Map();
9620
+ const picBulletIdMap = /* @__PURE__ */ new Map();
9621
+ if (!fragment) {
9622
+ return { catalog, abstractIdMap, instanceIdMap, picBulletIdMap };
9623
+ }
9624
+ for (const [picBulletId, entry] of Object.entries(fragment.numPicBullets ?? {})) {
9625
+ const mappedId = mapPicBulletId(catalog, picBulletId, entry);
9626
+ picBulletIdMap.set(picBulletId, mappedId);
9627
+ }
9628
+ for (const [abstractId, definition] of Object.entries(fragment.abstractDefinitions)) {
9629
+ const mappedId = mapAbstractDefinition(catalog, definition, picBulletIdMap);
9630
+ abstractIdMap.set(abstractId, mappedId);
9631
+ }
9632
+ for (const [instanceId, instance] of Object.entries(fragment.instances)) {
9633
+ const mappedAbstractId = abstractIdMap.get(instance.abstractNumberingId) ?? instance.abstractNumberingId;
9634
+ const mappedId = mapNumberingInstance(
9635
+ catalog,
9636
+ instance,
9637
+ mappedAbstractId,
9638
+ picBulletIdMap
9639
+ );
9640
+ instanceIdMap.set(instanceId, mappedId);
9641
+ }
9642
+ return { catalog, abstractIdMap, instanceIdMap, picBulletIdMap };
9643
+ }
9644
+ function mapPicBulletId(catalog, picBulletId, entry) {
9645
+ const existing = catalog.numPicBullets?.[picBulletId];
9646
+ if (existing && existing.rawXml === entry.rawXml) return picBulletId;
9647
+ const mappedId = existing ? nextNumericString(Object.keys(catalog.numPicBullets ?? {})) : picBulletId;
9648
+ const numPicBullets = { ...catalog.numPicBullets ?? {} };
9649
+ numPicBullets[mappedId] = {
9650
+ ...stripSourceRef(structuredClone(entry)),
9651
+ numPicBulletId: mappedId
9652
+ };
9653
+ catalog.numPicBullets = numPicBullets;
9654
+ return mappedId;
9655
+ }
9656
+ function mapAbstractDefinition(catalog, definition, picBulletIdMap) {
9657
+ const existing = catalog.abstractDefinitions[definition.abstractNumberingId];
9658
+ if (existing && sameJson(comparableAbstract(existing), comparableAbstract(definition))) {
9659
+ return definition.abstractNumberingId;
9660
+ }
9661
+ const mappedId = existing ? nextCanonicalNumericId("abstract-num:", Object.keys(catalog.abstractDefinitions)) : definition.abstractNumberingId;
9662
+ catalog.abstractDefinitions[mappedId] = {
9663
+ ...stripSourceRef(structuredClone(definition)),
9664
+ abstractNumberingId: mappedId,
9665
+ nsid: freshLongHex(catalog, mappedId, "nsid"),
9666
+ tplc: freshLongHex(catalog, mappedId, "tmpl"),
9667
+ levels: definition.levels.map((level) => remapLevelPicBullet(level, picBulletIdMap))
9668
+ };
9669
+ return mappedId;
9670
+ }
9671
+ function mapNumberingInstance(catalog, instance, abstractNumberingId, picBulletIdMap) {
9672
+ const existing = catalog.instances[instance.numberingInstanceId];
9673
+ const candidate = {
9674
+ ...instance,
9675
+ abstractNumberingId,
9676
+ overrides: instance.overrides.map(
9677
+ (override) => remapOverridePicBullet(override, picBulletIdMap)
9678
+ )
9679
+ };
9680
+ if (existing && sameJson(comparableInstance(existing), comparableInstance(candidate))) {
9681
+ return instance.numberingInstanceId;
9682
+ }
9683
+ const mappedId = existing ? nextCanonicalNumericId("num:", Object.keys(catalog.instances)) : instance.numberingInstanceId;
9684
+ catalog.instances[mappedId] = {
9685
+ ...stripSourceRef(structuredClone(instance)),
9686
+ overrides: candidate.overrides.map((override) => stripOverrideSourceRefs(override)),
9687
+ numberingInstanceId: mappedId,
9688
+ abstractNumberingId
9689
+ };
9690
+ return mappedId;
9691
+ }
9692
+ function remapLevelPicBullet(level, picBulletIdMap) {
9693
+ const cloned = stripSourceRef(structuredClone(level));
9694
+ if (!level.picBulletId) return cloned;
9695
+ return {
9696
+ ...cloned,
9697
+ picBulletId: picBulletIdMap.get(level.picBulletId) ?? level.picBulletId
9698
+ };
9699
+ }
9700
+ function remapOverridePicBullet(override, picBulletIdMap) {
9701
+ const cloned = stripOverrideSourceRefs(structuredClone(override));
9702
+ if (!override.levelDefinition) return cloned;
9703
+ return {
9704
+ ...cloned,
9705
+ levelDefinition: remapLevelPicBullet(override.levelDefinition, picBulletIdMap)
9706
+ };
9707
+ }
9708
+ function stripOverrideSourceRefs(override) {
9709
+ const cloned = stripSourceRef(override);
9710
+ if (!override.levelDefinition) return cloned;
9711
+ return {
9712
+ ...cloned,
9713
+ levelDefinition: stripSourceRef(override.levelDefinition)
9714
+ };
9715
+ }
9597
9716
  function mergeOverride(overrides, nextOverride) {
9598
9717
  return [
9599
9718
  ...overrides.filter((override) => override.level !== nextOverride.level),
@@ -9665,6 +9784,28 @@ function hashLongHex(input) {
9665
9784
  }
9666
9785
  return hash.toString(16).toUpperCase().padStart(8, "0").slice(-8);
9667
9786
  }
9787
+ function stripSourceRef(value) {
9788
+ const { sourceRef: _sourceRef, ...rest } = value;
9789
+ return rest;
9790
+ }
9791
+ function comparableAbstract(definition) {
9792
+ return {
9793
+ ...stripSourceRef(definition),
9794
+ levels: definition.levels.map((level) => stripSourceRef(level))
9795
+ };
9796
+ }
9797
+ function comparableInstance(instance) {
9798
+ return {
9799
+ ...stripSourceRef(instance),
9800
+ overrides: instance.overrides.map((override) => ({
9801
+ ...stripSourceRef(override),
9802
+ ...override.levelDefinition ? { levelDefinition: stripSourceRef(override.levelDefinition) } : {}
9803
+ }))
9804
+ };
9805
+ }
9806
+ function sameJson(left, right) {
9807
+ return JSON.stringify(left) === JSON.stringify(right);
9808
+ }
9668
9809
 
9669
9810
  // src/runtime/formatting/projector.ts
9670
9811
  function buildFormattingDebugEntry(inputs) {
@@ -9692,6 +9833,7 @@ export {
9692
9833
  ensureDefaultListInstance,
9693
9834
  allocateNumberingInstance,
9694
9835
  setStartOverride,
9836
+ mergeFragmentNumberingCatalog,
9695
9837
  inlineLengthForScopeCoordinates,
9696
9838
  computeScopeStoryLayout,
9697
9839
  findParagraphSlotAtPosition,