@beyondwork/docx-react-component 1.0.28 → 1.0.29

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 (354) hide show
  1. package/dist/canonical-document-BLEbzL2J.d.cts +844 -0
  2. package/dist/canonical-document-BLEbzL2J.d.ts +844 -0
  3. package/dist/chunk-2FJS5GZM.js +763 -0
  4. package/dist/chunk-2FJS5GZM.js.map +1 -0
  5. package/{src/core/commands/section-layout-commands.ts → dist/chunk-2OQBZS3F.js} +106 -340
  6. package/dist/chunk-2OQBZS3F.js.map +1 -0
  7. package/dist/chunk-2S7W4KFO.js +127 -0
  8. package/dist/chunk-2S7W4KFO.js.map +1 -0
  9. package/dist/chunk-2TG72QSW.js +3874 -0
  10. package/dist/chunk-2TG72QSW.js.map +1 -0
  11. package/{src/core/commands/table-structure-commands.ts → dist/chunk-36QNIZBO.js} +126 -315
  12. package/dist/chunk-36QNIZBO.js.map +1 -0
  13. package/dist/chunk-4AQOYAW4.js +3069 -0
  14. package/dist/chunk-4AQOYAW4.js.map +1 -0
  15. package/dist/chunk-4D5EWJ3P.js +77 -0
  16. package/dist/chunk-4D5EWJ3P.js.map +1 -0
  17. package/dist/chunk-5FN54NDH.js +2257 -0
  18. package/dist/chunk-5FN54NDH.js.map +1 -0
  19. package/dist/chunk-BOYGQYRQ.js +7306 -0
  20. package/dist/chunk-BOYGQYRQ.js.map +1 -0
  21. package/dist/chunk-CN3XMECL.js +212 -0
  22. package/dist/chunk-CN3XMECL.js.map +1 -0
  23. package/dist/chunk-EBI3BX6U.js +164 -0
  24. package/dist/chunk-EBI3BX6U.js.map +1 -0
  25. package/dist/chunk-EILUG3VB.js +1275 -0
  26. package/dist/chunk-EILUG3VB.js.map +1 -0
  27. package/dist/chunk-FUDY333O.js +70 -0
  28. package/dist/chunk-FUDY333O.js.map +1 -0
  29. package/dist/chunk-GBVOWFIK.js +1237 -0
  30. package/dist/chunk-GBVOWFIK.js.map +1 -0
  31. package/dist/chunk-H4TQ3H3Y.js +262 -0
  32. package/dist/chunk-H4TQ3H3Y.js.map +1 -0
  33. package/{src/core/commands/style-commands.ts → dist/chunk-JGB3IXZO.js} +40 -113
  34. package/dist/chunk-JGB3IXZO.js.map +1 -0
  35. package/dist/chunk-KD2QRQPY.js +4342 -0
  36. package/dist/chunk-KD2QRQPY.js.map +1 -0
  37. package/dist/chunk-KLMXQVYK.js +369 -0
  38. package/dist/chunk-KLMXQVYK.js.map +1 -0
  39. package/dist/chunk-KZUG5KFQ.js +214 -0
  40. package/dist/chunk-KZUG5KFQ.js.map +1 -0
  41. package/{src/core/state/text-transaction.ts → dist/chunk-QDAQ4CJU.js} +79 -236
  42. package/dist/chunk-QDAQ4CJU.js.map +1 -0
  43. package/{src/legal/bookmarks.ts → dist/chunk-RMH72RZI.js} +44 -130
  44. package/dist/chunk-RMH72RZI.js.map +1 -0
  45. package/dist/chunk-SWKWQZXM.js +117 -0
  46. package/dist/chunk-SWKWQZXM.js.map +1 -0
  47. package/{src/core/commands/formatting-commands.ts → dist/chunk-TJBP2K4T.js} +196 -536
  48. package/dist/chunk-TJBP2K4T.js.map +1 -0
  49. package/dist/chunk-TLCEAQDQ.js +542 -0
  50. package/dist/chunk-TLCEAQDQ.js.map +1 -0
  51. package/{src/core/commands/text-commands.ts → dist/chunk-UZXBISGO.js} +86 -142
  52. package/dist/chunk-UZXBISGO.js.map +1 -0
  53. package/dist/chunk-WGBAKP3Q.js +3220 -0
  54. package/dist/chunk-WGBAKP3Q.js.map +1 -0
  55. package/dist/compare/index.cjs +5475 -0
  56. package/dist/compare/index.cjs.map +1 -0
  57. package/dist/compare/index.d.cts +114 -0
  58. package/dist/compare/index.d.ts +114 -0
  59. package/dist/compare/index.js +731 -0
  60. package/dist/compare/index.js.map +1 -0
  61. package/dist/core/commands/formatting-commands.cjs +828 -0
  62. package/dist/core/commands/formatting-commands.cjs.map +1 -0
  63. package/dist/core/commands/formatting-commands.d.cts +63 -0
  64. package/dist/core/commands/formatting-commands.d.ts +63 -0
  65. package/dist/core/commands/formatting-commands.js +37 -0
  66. package/dist/core/commands/formatting-commands.js.map +1 -0
  67. package/dist/core/commands/image-commands.cjs +2023 -0
  68. package/dist/core/commands/image-commands.cjs.map +1 -0
  69. package/dist/core/commands/image-commands.d.cts +58 -0
  70. package/dist/core/commands/image-commands.d.ts +58 -0
  71. package/dist/core/commands/image-commands.js +18 -0
  72. package/dist/core/commands/image-commands.js.map +1 -0
  73. package/dist/core/commands/section-layout-commands.cjs +477 -0
  74. package/dist/core/commands/section-layout-commands.cjs.map +1 -0
  75. package/dist/core/commands/section-layout-commands.d.cts +62 -0
  76. package/dist/core/commands/section-layout-commands.d.ts +62 -0
  77. package/dist/core/commands/section-layout-commands.js +21 -0
  78. package/dist/core/commands/section-layout-commands.js.map +1 -0
  79. package/dist/core/commands/style-commands.cjs +214 -0
  80. package/dist/core/commands/style-commands.cjs.map +1 -0
  81. package/dist/core/commands/style-commands.d.cts +13 -0
  82. package/dist/core/commands/style-commands.d.ts +13 -0
  83. package/dist/core/commands/style-commands.js +9 -0
  84. package/dist/core/commands/style-commands.js.map +1 -0
  85. package/dist/core/commands/table-structure-commands.cjs +1883 -0
  86. package/dist/core/commands/table-structure-commands.cjs.map +1 -0
  87. package/dist/core/commands/table-structure-commands.d.cts +59 -0
  88. package/dist/core/commands/table-structure-commands.d.ts +59 -0
  89. package/dist/core/commands/table-structure-commands.js +12 -0
  90. package/dist/core/commands/table-structure-commands.js.map +1 -0
  91. package/dist/core/commands/text-commands.cjs +2391 -0
  92. package/dist/core/commands/text-commands.cjs.map +1 -0
  93. package/dist/core/commands/text-commands.d.cts +24 -0
  94. package/dist/core/commands/text-commands.d.ts +24 -0
  95. package/dist/core/commands/text-commands.js +28 -0
  96. package/dist/core/commands/text-commands.js.map +1 -0
  97. package/dist/core/selection/mapping.cjs +200 -0
  98. package/dist/core/selection/mapping.cjs.map +1 -0
  99. package/dist/core/selection/mapping.d.cts +2 -0
  100. package/dist/core/selection/mapping.d.ts +2 -0
  101. package/dist/core/selection/mapping.js +31 -0
  102. package/dist/core/selection/mapping.js.map +1 -0
  103. package/dist/core/state/editor-state.cjs +2278 -0
  104. package/dist/core/state/editor-state.cjs.map +1 -0
  105. package/dist/core/state/editor-state.d.cts +2 -0
  106. package/dist/core/state/editor-state.d.ts +2 -0
  107. package/dist/core/state/editor-state.js +26 -0
  108. package/dist/core/state/editor-state.js.map +1 -0
  109. package/dist/index.cjs +38553 -0
  110. package/dist/index.cjs.map +1 -0
  111. package/dist/index.d.cts +15 -0
  112. package/dist/index.d.ts +15 -0
  113. package/dist/index.js +7856 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/io/docx-session.cjs +16236 -0
  116. package/dist/io/docx-session.cjs.map +1 -0
  117. package/dist/io/docx-session.d.cts +21 -0
  118. package/dist/io/docx-session.d.ts +21 -0
  119. package/dist/io/docx-session.js +18 -0
  120. package/dist/io/docx-session.js.map +1 -0
  121. package/dist/legal/index.cjs +3900 -0
  122. package/dist/legal/index.cjs.map +1 -0
  123. package/dist/legal/index.d.cts +86 -0
  124. package/dist/legal/index.d.ts +86 -0
  125. package/dist/legal/index.js +616 -0
  126. package/dist/legal/index.js.map +1 -0
  127. package/dist/public-types-7ZL_94cz.d.ts +1573 -0
  128. package/dist/public-types-CeMaDueh.d.cts +1573 -0
  129. package/dist/public-types.cjs +19 -0
  130. package/dist/public-types.cjs.map +1 -0
  131. package/dist/public-types.d.cts +2 -0
  132. package/dist/public-types.d.ts +2 -0
  133. package/dist/public-types.js +1 -0
  134. package/dist/public-types.js.map +1 -0
  135. package/dist/runtime/document-runtime.cjs +11140 -0
  136. package/dist/runtime/document-runtime.cjs.map +1 -0
  137. package/dist/runtime/document-runtime.d.cts +231 -0
  138. package/dist/runtime/document-runtime.d.ts +231 -0
  139. package/dist/runtime/document-runtime.js +21 -0
  140. package/dist/runtime/document-runtime.js.map +1 -0
  141. package/dist/structural-helpers-CilgOVhh.d.cts +10 -0
  142. package/dist/structural-helpers-q0Gd-eBN.d.ts +10 -0
  143. package/dist/ui-tailwind/editor-surface/search-plugin.cjs +313 -0
  144. package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +1 -0
  145. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +67 -0
  146. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +67 -0
  147. package/dist/ui-tailwind/editor-surface/search-plugin.js +23 -0
  148. package/dist/ui-tailwind/editor-surface/search-plugin.js.map +1 -0
  149. package/dist/ui-tailwind/index.cjs +4833 -0
  150. package/dist/ui-tailwind/index.cjs.map +1 -0
  151. package/dist/ui-tailwind/index.d.cts +617 -0
  152. package/dist/ui-tailwind/index.d.ts +617 -0
  153. package/dist/ui-tailwind/index.js +575 -0
  154. package/dist/ui-tailwind/index.js.map +1 -0
  155. package/package.json +61 -41
  156. package/src/README.md +0 -85
  157. package/src/api/README.md +0 -26
  158. package/src/api/public-types.ts +0 -1421
  159. package/src/api/session-state.ts +0 -60
  160. package/src/compare/diff-engine.ts +0 -623
  161. package/src/compare/export-redlines.ts +0 -280
  162. package/src/compare/index.ts +0 -25
  163. package/src/compare/snapshot.ts +0 -97
  164. package/src/component-inventory.md +0 -99
  165. package/src/core/README.md +0 -10
  166. package/src/core/commands/README.md +0 -3
  167. package/src/core/commands/image-commands.ts +0 -373
  168. package/src/core/commands/index.ts +0 -1757
  169. package/src/core/commands/list-commands.ts +0 -565
  170. package/src/core/commands/paragraph-layout-commands.ts +0 -339
  171. package/src/core/commands/review-commands.ts +0 -108
  172. package/src/core/commands/structural-helpers.ts +0 -309
  173. package/src/core/schema/README.md +0 -3
  174. package/src/core/schema/text-schema.ts +0 -516
  175. package/src/core/search/search-text.ts +0 -357
  176. package/src/core/selection/README.md +0 -3
  177. package/src/core/selection/mapping.ts +0 -289
  178. package/src/core/selection/review-anchors.ts +0 -183
  179. package/src/core/state/README.md +0 -3
  180. package/src/core/state/editor-state.ts +0 -892
  181. package/src/formats/xlsx/io/parse-shared-strings.ts +0 -41
  182. package/src/formats/xlsx/io/parse-sheet.ts +0 -459
  183. package/src/formats/xlsx/io/parse-styles.ts +0 -59
  184. package/src/formats/xlsx/io/parse-workbook.ts +0 -75
  185. package/src/formats/xlsx/io/serialize-shared-strings.ts +0 -72
  186. package/src/formats/xlsx/io/serialize-sheet.ts +0 -333
  187. package/src/formats/xlsx/io/serialize-styles.ts +0 -98
  188. package/src/formats/xlsx/io/serialize-workbook.ts +0 -429
  189. package/src/formats/xlsx/io/xlsx-session.ts +0 -314
  190. package/src/formats/xlsx/model/cell.ts +0 -189
  191. package/src/formats/xlsx/model/sheet.ts +0 -326
  192. package/src/formats/xlsx/model/styles.ts +0 -118
  193. package/src/formats/xlsx/model/workbook.ts +0 -453
  194. package/src/formats/xlsx/runtime/cell-commands.ts +0 -567
  195. package/src/formats/xlsx/runtime/sheet-commands.ts +0 -206
  196. package/src/formats/xlsx/runtime/workbook-runtime.ts +0 -177
  197. package/src/formats/xlsx/runtime/workbook-transaction.ts +0 -822
  198. package/src/index.ts +0 -101
  199. package/src/io/README.md +0 -10
  200. package/src/io/docx-session.ts +0 -2882
  201. package/src/io/export/README.md +0 -3
  202. package/src/io/export/export-session.ts +0 -220
  203. package/src/io/export/minimal-docx.ts +0 -115
  204. package/src/io/export/reattach-preserved-parts.ts +0 -54
  205. package/src/io/export/serialize-comments.ts +0 -947
  206. package/src/io/export/serialize-footnotes.ts +0 -399
  207. package/src/io/export/serialize-headers-footers.ts +0 -372
  208. package/src/io/export/serialize-main-document.ts +0 -1376
  209. package/src/io/export/serialize-numbering.ts +0 -118
  210. package/src/io/export/serialize-revisions.ts +0 -389
  211. package/src/io/export/serialize-runtime-revisions.ts +0 -269
  212. package/src/io/export/serialize-tables.ts +0 -174
  213. package/src/io/export/split-review-boundaries.ts +0 -356
  214. package/src/io/normalize/README.md +0 -3
  215. package/src/io/normalize/normalize-text.ts +0 -639
  216. package/src/io/ooxml/README.md +0 -3
  217. package/src/io/ooxml/highlight-colors.ts +0 -39
  218. package/src/io/ooxml/numbering-sentinels.ts +0 -44
  219. package/src/io/ooxml/parse-comments.ts +0 -846
  220. package/src/io/ooxml/parse-complex-content.ts +0 -287
  221. package/src/io/ooxml/parse-fields.ts +0 -834
  222. package/src/io/ooxml/parse-footnotes.ts +0 -896
  223. package/src/io/ooxml/parse-headers-footers.ts +0 -1169
  224. package/src/io/ooxml/parse-inline-media.ts +0 -461
  225. package/src/io/ooxml/parse-main-document.ts +0 -2877
  226. package/src/io/ooxml/parse-numbering.ts +0 -432
  227. package/src/io/ooxml/parse-revisions.ts +0 -931
  228. package/src/io/ooxml/parse-settings.ts +0 -184
  229. package/src/io/ooxml/parse-shapes.ts +0 -296
  230. package/src/io/ooxml/parse-styles.ts +0 -463
  231. package/src/io/ooxml/parse-tables.ts +0 -618
  232. package/src/io/ooxml/parse-theme.ts +0 -346
  233. package/src/io/ooxml/part-manifest.ts +0 -136
  234. package/src/io/ooxml/revision-boundaries.ts +0 -351
  235. package/src/io/opc/README.md +0 -3
  236. package/src/io/opc/corrupt-package.ts +0 -166
  237. package/src/io/opc/docx-package.ts +0 -74
  238. package/src/io/opc/package-reader.ts +0 -325
  239. package/src/io/opc/package-writer.ts +0 -273
  240. package/src/io/source-package-provenance.ts +0 -241
  241. package/src/legal/cross-references.ts +0 -414
  242. package/src/legal/defined-terms.ts +0 -203
  243. package/src/legal/index.ts +0 -32
  244. package/src/legal/signature-blocks.ts +0 -259
  245. package/src/model/README.md +0 -3
  246. package/src/model/canonical-document.ts +0 -2632
  247. package/src/model/cds-1.0.0.ts +0 -212
  248. package/src/model/snapshot.ts +0 -649
  249. package/src/preservation/README.md +0 -3
  250. package/src/preservation/markup-compatibility.ts +0 -48
  251. package/src/preservation/opaque-fragment-store.ts +0 -89
  252. package/src/preservation/opaque-region.ts +0 -233
  253. package/src/preservation/package-preservation.ts +0 -113
  254. package/src/preservation/preserved-part-manifest.ts +0 -56
  255. package/src/preservation/relationship-retention.ts +0 -57
  256. package/src/preservation/store.ts +0 -185
  257. package/src/review/README.md +0 -16
  258. package/src/review/store/README.md +0 -3
  259. package/src/review/store/comment-anchors.ts +0 -70
  260. package/src/review/store/comment-remapping.ts +0 -154
  261. package/src/review/store/comment-store.ts +0 -331
  262. package/src/review/store/comment-thread.ts +0 -109
  263. package/src/review/store/revision-actions.ts +0 -394
  264. package/src/review/store/revision-store.ts +0 -312
  265. package/src/review/store/revision-types.ts +0 -171
  266. package/src/review/store/runtime-comment-store.ts +0 -43
  267. package/src/runtime/README.md +0 -3
  268. package/src/runtime/ai-action-policy.ts +0 -764
  269. package/src/runtime/document-layout.ts +0 -332
  270. package/src/runtime/document-navigation.ts +0 -603
  271. package/src/runtime/document-runtime.ts +0 -3159
  272. package/src/runtime/document-search.ts +0 -145
  273. package/src/runtime/numbering-prefix.ts +0 -216
  274. package/src/runtime/page-layout-estimation.ts +0 -212
  275. package/src/runtime/read-only-diagnostics-runtime.ts +0 -241
  276. package/src/runtime/review-runtime.ts +0 -44
  277. package/src/runtime/revision-runtime.ts +0 -107
  278. package/src/runtime/session-capabilities.ts +0 -192
  279. package/src/runtime/story-context.ts +0 -164
  280. package/src/runtime/story-targeting.ts +0 -162
  281. package/src/runtime/surface-projection.ts +0 -1357
  282. package/src/runtime/table-commands.ts +0 -173
  283. package/src/runtime/table-schema.ts +0 -309
  284. package/src/runtime/view-state.ts +0 -477
  285. package/src/runtime/virtualized-rendering.ts +0 -258
  286. package/src/runtime/workflow-markup.ts +0 -353
  287. package/src/ui/README.md +0 -30
  288. package/src/ui/WordReviewEditor.tsx +0 -4086
  289. package/src/ui/browser-export.ts +0 -52
  290. package/src/ui/comments/README.md +0 -3
  291. package/src/ui/compatibility/README.md +0 -3
  292. package/src/ui/editor-command-bag.ts +0 -120
  293. package/src/ui/editor-runtime-boundary.ts +0 -1457
  294. package/src/ui/editor-shell-view.tsx +0 -142
  295. package/src/ui/editor-surface/README.md +0 -3
  296. package/src/ui/editor-surface-controller.tsx +0 -61
  297. package/src/ui/headless/comment-decoration-model.ts +0 -124
  298. package/src/ui/headless/preserve-editor-selection.ts +0 -5
  299. package/src/ui/headless/revision-decoration-model.ts +0 -128
  300. package/src/ui/headless/selection-helpers.ts +0 -54
  301. package/src/ui/headless/selection-toolbar-model.ts +0 -34
  302. package/src/ui/headless/use-editor-keyboard.ts +0 -103
  303. package/src/ui/review/README.md +0 -3
  304. package/src/ui/runtime-snapshot-selectors.ts +0 -197
  305. package/src/ui/shared/revision-filters.ts +0 -31
  306. package/src/ui/status/README.md +0 -3
  307. package/src/ui/theme/README.md +0 -3
  308. package/src/ui/toolbar/README.md +0 -3
  309. package/src/ui/workflow-surface-blocked-rails.ts +0 -94
  310. package/src/ui-tailwind/chrome/tw-alert-banner.tsx +0 -64
  311. package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +0 -129
  312. package/src/ui-tailwind/chrome/tw-layout-panel.tsx +0 -114
  313. package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +0 -34
  314. package/src/ui-tailwind/chrome/tw-page-ruler.tsx +0 -386
  315. package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +0 -186
  316. package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +0 -139
  317. package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +0 -128
  318. package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +0 -58
  319. package/src/ui-tailwind/chrome/use-before-unload.ts +0 -20
  320. package/src/ui-tailwind/editor-surface/perf-probe.ts +0 -179
  321. package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +0 -184
  322. package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +0 -31
  323. package/src/ui-tailwind/editor-surface/pm-decorations.ts +0 -427
  324. package/src/ui-tailwind/editor-surface/pm-position-map.ts +0 -123
  325. package/src/ui-tailwind/editor-surface/pm-schema.ts +0 -876
  326. package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +0 -504
  327. package/src/ui-tailwind/editor-surface/search-plugin.ts +0 -168
  328. package/src/ui-tailwind/editor-surface/surface-build-keys.ts +0 -61
  329. package/src/ui-tailwind/editor-surface/tw-caret.tsx +0 -12
  330. package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +0 -150
  331. package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +0 -129
  332. package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +0 -58
  333. package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +0 -151
  334. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +0 -944
  335. package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +0 -111
  336. package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +0 -436
  337. package/src/ui-tailwind/index.ts +0 -62
  338. package/src/ui-tailwind/page-chrome-model.ts +0 -27
  339. package/src/ui-tailwind/review/tw-comment-sidebar.tsx +0 -406
  340. package/src/ui-tailwind/review/tw-health-panel.tsx +0 -149
  341. package/src/ui-tailwind/review/tw-review-rail.tsx +0 -120
  342. package/src/ui-tailwind/review/tw-revision-sidebar.tsx +0 -164
  343. package/src/ui-tailwind/status/tw-status-bar.tsx +0 -61
  344. package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +0 -52
  345. package/src/ui-tailwind/toolbar/tw-toolbar.tsx +0 -1064
  346. package/src/ui-tailwind/tw-review-workspace.tsx +0 -1417
  347. package/src/validation/README.md +0 -3
  348. package/src/validation/compatibility-engine.ts +0 -634
  349. package/src/validation/compatibility-report.ts +0 -161
  350. package/src/validation/diagnostics.ts +0 -204
  351. package/src/validation/docx-comment-proof.ts +0 -707
  352. package/src/validation/import-diagnostics.ts +0 -128
  353. package/src/validation/low-priority-word-surfaces.ts +0 -373
  354. /package/{src → dist}/ui-tailwind/theme/editor-theme.css +0 -0
@@ -1,61 +1,30 @@
1
- import type { RuntimeRenderSnapshot as PublicRuntimeRenderSnapshot } from "../../api/public-types";
2
- import type {
3
- DocumentRootNode,
4
- ParagraphNode,
5
- TableCellNode,
6
- TableNode,
7
- TableRowNode,
8
- } from "../../model/canonical-document.ts";
9
- import type { TableSelectionDescriptor } from "../../runtime/table-commands.ts";
10
- import type { CanonicalDocumentEnvelope, SelectionSnapshot } from "../state/editor-state.ts";
11
- import {
12
- createDetachedAnchor,
13
- createNodeAnchor,
14
- createRangeAnchor,
15
- } from "../selection/mapping.ts";
16
1
  import {
17
2
  createEmptyParagraph,
18
3
  createNoopStructuralMutation,
19
4
  findTableCellParagraphSelection,
20
- findTopLevelParagraphSelectionNearBlock,
21
- type StructuralMutationResult,
22
- } from "./structural-helpers.ts";
23
-
24
- type TableStructureOperation =
25
- | { type: "add-row-before" }
26
- | { type: "add-row-after" }
27
- | { type: "add-column-before" }
28
- | { type: "add-column-after" }
29
- | { type: "delete-row" }
30
- | { type: "delete-column" }
31
- | { type: "delete-table" }
32
- | { type: "merge-cells" }
33
- | { type: "split-cell" }
34
- | { type: "set-cell-background"; color: string };
5
+ findTopLevelParagraphSelectionNearBlock
6
+ } from "./chunk-KZUG5KFQ.js";
7
+ import {
8
+ createDetachedAnchor,
9
+ createNodeAnchor,
10
+ createRangeAnchor
11
+ } from "./chunk-EBI3BX6U.js";
35
12
 
36
- export function applyTableStructureOperation(
37
- document: CanonicalDocumentEnvelope,
38
- snapshot: PublicRuntimeRenderSnapshot,
39
- selectionDescriptor: TableSelectionDescriptor | null,
40
- operation: TableStructureOperation,
41
- ): StructuralMutationResult {
13
+ // src/core/commands/table-structure-commands.ts
14
+ function applyTableStructureOperation(document, snapshot, selectionDescriptor, operation) {
42
15
  const root = document.content;
43
16
  const fallbackSelection = toInternalSelectionSnapshot(snapshot.selection);
44
17
  if (!root || root.type !== "doc") {
45
18
  return createNoopStructuralMutation(document, fallbackSelection);
46
19
  }
47
-
48
- const effectiveSelection =
49
- selectionDescriptor ?? resolveTableSelectionFromSnapshot(snapshot);
20
+ const effectiveSelection = selectionDescriptor ?? resolveTableSelectionFromSnapshot(snapshot);
50
21
  if (!effectiveSelection) {
51
22
  return createNoopStructuralMutation(document, fallbackSelection);
52
23
  }
53
-
54
24
  const target = root.children[effectiveSelection.tableBlockIndex];
55
25
  if (!target || target.type !== "table") {
56
26
  return createNoopStructuralMutation(document, fallbackSelection);
57
27
  }
58
-
59
28
  switch (operation.type) {
60
29
  case "delete-table":
61
30
  return deleteTableBlock(document, root, effectiveSelection.tableBlockIndex, fallbackSelection);
@@ -81,35 +50,24 @@ export function applyTableStructureOperation(
81
50
  return createNoopStructuralMutation(document, fallbackSelection);
82
51
  }
83
52
  }
84
-
85
- function addRow(
86
- document: CanonicalDocumentEnvelope,
87
- root: DocumentRootNode,
88
- table: TableNode,
89
- selection: TableSelectionDescriptor,
90
- position: "before" | "after",
91
- fallbackSelection: SelectionSnapshot,
92
- ): StructuralMutationResult {
53
+ function addRow(document, root, table, selection, position, fallbackSelection) {
93
54
  if (!isSimpleTable(table)) {
94
55
  return createNoopStructuralMutation(document, fallbackSelection);
95
56
  }
96
-
97
57
  const columnCount = getLogicalColumnCount(table);
98
- const insertIndex =
99
- position === "before" ? selection.anchorCell.rowIndex : selection.anchorCell.rowIndex + 1;
100
- const nextRow: TableRowNode = {
58
+ const insertIndex = position === "before" ? selection.anchorCell.rowIndex : selection.anchorCell.rowIndex + 1;
59
+ const nextRow = {
101
60
  type: "table_row",
102
- cells: Array.from({ length: columnCount }, () => createEmptyCell()),
61
+ cells: Array.from({ length: columnCount }, () => createEmptyCell())
103
62
  };
104
- const nextTable: TableNode = {
63
+ const nextTable = {
105
64
  ...table,
106
65
  rows: [
107
66
  ...table.rows.slice(0, insertIndex),
108
67
  nextRow,
109
- ...table.rows.slice(insertIndex),
110
- ],
68
+ ...table.rows.slice(insertIndex)
69
+ ]
111
70
  };
112
-
113
71
  return commitTableChange(
114
72
  document,
115
73
  root,
@@ -117,29 +75,20 @@ function addRow(
117
75
  nextTable,
118
76
  fallbackSelection,
119
77
  insertIndex,
120
- selection.anchorCell.columnIndex,
78
+ selection.anchorCell.columnIndex
121
79
  );
122
80
  }
123
-
124
- function deleteRow(
125
- document: CanonicalDocumentEnvelope,
126
- root: DocumentRootNode,
127
- table: TableNode,
128
- selection: TableSelectionDescriptor,
129
- fallbackSelection: SelectionSnapshot,
130
- ): StructuralMutationResult {
81
+ function deleteRow(document, root, table, selection, fallbackSelection) {
131
82
  if (!isSimpleTable(table) || table.rows.length <= 1) {
132
83
  return createNoopStructuralMutation(document, fallbackSelection);
133
84
  }
134
-
135
85
  const deleteIndex = selection.anchorCell.rowIndex;
136
86
  const nextRows = table.rows.filter((_, rowIndex) => rowIndex !== deleteIndex);
137
87
  const focusRowIndex = Math.max(0, Math.min(deleteIndex, nextRows.length - 1));
138
- const nextTable: TableNode = {
88
+ const nextTable = {
139
89
  ...table,
140
- rows: nextRows,
90
+ rows: nextRows
141
91
  };
142
-
143
92
  return commitTableChange(
144
93
  document,
145
94
  root,
@@ -147,27 +96,15 @@ function deleteRow(
147
96
  nextTable,
148
97
  fallbackSelection,
149
98
  focusRowIndex,
150
- selection.anchorCell.columnIndex,
99
+ selection.anchorCell.columnIndex
151
100
  );
152
101
  }
153
-
154
- function addColumn(
155
- document: CanonicalDocumentEnvelope,
156
- root: DocumentRootNode,
157
- table: TableNode,
158
- selection: TableSelectionDescriptor,
159
- position: "before" | "after",
160
- fallbackSelection: SelectionSnapshot,
161
- ): StructuralMutationResult {
102
+ function addColumn(document, root, table, selection, position, fallbackSelection) {
162
103
  if (!isSimpleTable(table)) {
163
104
  return createNoopStructuralMutation(document, fallbackSelection);
164
105
  }
165
-
166
- const insertIndex =
167
- position === "before"
168
- ? selection.anchorCell.columnIndex
169
- : selection.anchorCell.columnIndex + 1;
170
- const nextTable: TableNode = {
106
+ const insertIndex = position === "before" ? selection.anchorCell.columnIndex : selection.anchorCell.columnIndex + 1;
107
+ const nextTable = {
171
108
  ...table,
172
109
  gridColumns: insertGridColumn(table.gridColumns, insertIndex),
173
110
  rows: table.rows.map((row) => ({
@@ -175,11 +112,10 @@ function addColumn(
175
112
  cells: [
176
113
  ...row.cells.slice(0, insertIndex),
177
114
  createEmptyCell(),
178
- ...row.cells.slice(insertIndex),
179
- ],
180
- })),
115
+ ...row.cells.slice(insertIndex)
116
+ ]
117
+ }))
181
118
  };
182
-
183
119
  return commitTableChange(
184
120
  document,
185
121
  root,
@@ -187,32 +123,23 @@ function addColumn(
187
123
  nextTable,
188
124
  fallbackSelection,
189
125
  selection.anchorCell.rowIndex,
190
- insertIndex,
126
+ insertIndex
191
127
  );
192
128
  }
193
-
194
- function deleteColumn(
195
- document: CanonicalDocumentEnvelope,
196
- root: DocumentRootNode,
197
- table: TableNode,
198
- selection: TableSelectionDescriptor,
199
- fallbackSelection: SelectionSnapshot,
200
- ): StructuralMutationResult {
129
+ function deleteColumn(document, root, table, selection, fallbackSelection) {
201
130
  if (!isSimpleTable(table) || getLogicalColumnCount(table) <= 1) {
202
131
  return createNoopStructuralMutation(document, fallbackSelection);
203
132
  }
204
-
205
133
  const deleteIndex = selection.anchorCell.columnIndex;
206
- const nextTable: TableNode = {
134
+ const nextTable = {
207
135
  ...table,
208
136
  gridColumns: deleteGridColumn(table.gridColumns, deleteIndex),
209
137
  rows: table.rows.map((row) => ({
210
138
  ...row,
211
- cells: row.cells.filter((_, cellIndex) => cellIndex !== deleteIndex),
212
- })),
139
+ cells: row.cells.filter((_, cellIndex) => cellIndex !== deleteIndex)
140
+ }))
213
141
  };
214
142
  const focusColumnIndex = Math.max(0, Math.min(deleteIndex, getLogicalColumnCount(nextTable) - 1));
215
-
216
143
  return commitTableChange(
217
144
  document,
218
145
  root,
@@ -220,57 +147,39 @@ function deleteColumn(
220
147
  nextTable,
221
148
  fallbackSelection,
222
149
  selection.anchorCell.rowIndex,
223
- focusColumnIndex,
150
+ focusColumnIndex
224
151
  );
225
152
  }
226
-
227
- function mergeSelectedCells(
228
- document: CanonicalDocumentEnvelope,
229
- root: DocumentRootNode,
230
- table: TableNode,
231
- selection: TableSelectionDescriptor,
232
- fallbackSelection: SelectionSnapshot,
233
- ): StructuralMutationResult {
234
- if (
235
- !isSimpleTable(table) ||
236
- selection.selectionKind !== "cell" ||
237
- selection.rect.bottom - selection.rect.top < 1 ||
238
- selection.rect.right - selection.rect.left < 1
239
- ) {
153
+ function mergeSelectedCells(document, root, table, selection, fallbackSelection) {
154
+ if (!isSimpleTable(table) || selection.selectionKind !== "cell" || selection.rect.bottom - selection.rect.top < 1 || selection.rect.right - selection.rect.left < 1) {
240
155
  return createNoopStructuralMutation(document, fallbackSelection);
241
156
  }
242
-
243
157
  const height = selection.rect.bottom - selection.rect.top;
244
158
  const width = selection.rect.right - selection.rect.left;
245
159
  if (height === 1 && width === 1) {
246
160
  return createNoopStructuralMutation(document, fallbackSelection);
247
161
  }
248
-
249
162
  const nextRows = table.rows.map((row) => ({
250
163
  ...row,
251
- cells: row.cells.map((cell) => cloneCell(cell)),
164
+ cells: row.cells.map((cell) => cloneCell(cell))
252
165
  }));
253
- const mergedChildren: ParagraphNode[] = [];
254
-
166
+ const mergedChildren = [];
255
167
  for (let rowIndex = selection.rect.top; rowIndex < selection.rect.bottom; rowIndex += 1) {
256
168
  const row = nextRows[rowIndex];
257
169
  if (!row) {
258
170
  return createNoopStructuralMutation(document, fallbackSelection);
259
171
  }
260
-
261
172
  for (let columnIndex = selection.rect.left; columnIndex < selection.rect.right; columnIndex += 1) {
262
173
  const cellRef = findCellAtColumn(row, columnIndex);
263
174
  if (!cellRef) {
264
175
  return createNoopStructuralMutation(document, fallbackSelection);
265
176
  }
266
-
267
177
  const paragraphs = cellRef.cell.children.filter(
268
- (child): child is ParagraphNode => child.type === "paragraph",
178
+ (child) => child.type === "paragraph"
269
179
  );
270
- mergedChildren.push(...paragraphs.map((paragraph) => structuredClone(paragraph) as ParagraphNode));
180
+ mergedChildren.push(...paragraphs.map((paragraph) => structuredClone(paragraph)));
271
181
  }
272
182
  }
273
-
274
183
  const topRow = nextRows[selection.rect.top];
275
184
  if (!topRow) {
276
185
  return createNoopStructuralMutation(document, fallbackSelection);
@@ -279,36 +188,32 @@ function mergeSelectedCells(
279
188
  if (!topLeftRef) {
280
189
  return createNoopStructuralMutation(document, fallbackSelection);
281
190
  }
282
-
283
191
  topRow.cells[topLeftRef.cellIndex] = {
284
192
  ...topLeftRef.cell,
285
- ...(width > 1 ? { gridSpan: width } : {}),
286
- ...(height > 1 ? { verticalMerge: "restart" as const } : {}),
287
- children: mergedChildren.length > 0 ? mergedChildren : [createEmptyParagraph()],
193
+ ...width > 1 ? { gridSpan: width } : {},
194
+ ...height > 1 ? { verticalMerge: "restart" } : {},
195
+ children: mergedChildren.length > 0 ? mergedChildren : [createEmptyParagraph()]
288
196
  };
289
197
  topRow.cells.splice(topLeftRef.cellIndex + 1, width - 1);
290
-
291
198
  for (let rowIndex = selection.rect.top + 1; rowIndex < selection.rect.bottom; rowIndex += 1) {
292
199
  const row = nextRows[rowIndex];
293
200
  const leftRef = findCellAtColumn(row, selection.rect.left);
294
201
  if (!leftRef) {
295
202
  return createNoopStructuralMutation(document, fallbackSelection);
296
203
  }
297
-
298
204
  row.cells.splice(
299
205
  leftRef.cellIndex,
300
206
  width,
301
207
  {
302
208
  ...createEmptyCell(),
303
- ...(width > 1 ? { gridSpan: width } : {}),
304
- verticalMerge: "continue",
305
- },
209
+ ...width > 1 ? { gridSpan: width } : {},
210
+ verticalMerge: "continue"
211
+ }
306
212
  );
307
213
  }
308
-
309
- const nextTable: TableNode = {
214
+ const nextTable = {
310
215
  ...table,
311
- rows: nextRows,
216
+ rows: nextRows
312
217
  };
313
218
  return commitTableChange(
314
219
  document,
@@ -317,17 +222,10 @@ function mergeSelectedCells(
317
222
  nextTable,
318
223
  fallbackSelection,
319
224
  selection.rect.top,
320
- selection.rect.left,
225
+ selection.rect.left
321
226
  );
322
227
  }
323
-
324
- function splitSelectedCell(
325
- document: CanonicalDocumentEnvelope,
326
- root: DocumentRootNode,
327
- table: TableNode,
328
- selection: TableSelectionDescriptor,
329
- fallbackSelection: SelectionSnapshot,
330
- ): StructuralMutationResult {
228
+ function splitSelectedCell(document, root, table, selection, fallbackSelection) {
331
229
  const row = table.rows[selection.anchorCell.rowIndex];
332
230
  if (!row) {
333
231
  return createNoopStructuralMutation(document, fallbackSelection);
@@ -336,50 +234,44 @@ function splitSelectedCell(
336
234
  if (!cellRef) {
337
235
  return createNoopStructuralMutation(document, fallbackSelection);
338
236
  }
339
-
340
237
  const width = Math.max(1, cellRef.cell.gridSpan ?? 1);
341
238
  const height = Math.max(
342
239
  1,
343
- computeRowSpan(table, selection.anchorCell.rowIndex, selection.anchorCell.columnIndex, width),
240
+ computeRowSpan(table, selection.anchorCell.rowIndex, selection.anchorCell.columnIndex, width)
344
241
  );
345
242
  if (width === 1 && height === 1) {
346
243
  return createNoopStructuralMutation(document, fallbackSelection);
347
244
  }
348
-
349
245
  const nextRows = table.rows.map((currentRow) => ({
350
246
  ...currentRow,
351
- cells: currentRow.cells.map((cell) => cloneCell(cell)),
247
+ cells: currentRow.cells.map((cell) => cloneCell(cell))
352
248
  }));
353
249
  const topRow = nextRows[selection.anchorCell.rowIndex];
354
250
  topRow.cells.splice(
355
251
  cellRef.cellIndex,
356
252
  1,
357
253
  stripCellSpan(cellRef.cell),
358
- ...Array.from({ length: width - 1 }, () => createEmptyCell()),
254
+ ...Array.from({ length: width - 1 }, () => createEmptyCell())
359
255
  );
360
-
361
256
  for (let rowOffset = 1; rowOffset < height; rowOffset += 1) {
362
257
  const rowIndex = selection.anchorCell.rowIndex + rowOffset;
363
258
  const currentRow = nextRows[rowIndex];
364
259
  if (!currentRow) {
365
260
  break;
366
261
  }
367
-
368
262
  const continueRef = findCellAtColumn(currentRow, selection.anchorCell.columnIndex);
369
263
  if (!continueRef) {
370
264
  return createNoopStructuralMutation(document, fallbackSelection);
371
265
  }
372
-
373
266
  currentRow.cells.splice(
374
267
  continueRef.cellIndex,
375
268
  1,
376
- ...Array.from({ length: width }, () => createEmptyCell()),
269
+ ...Array.from({ length: width }, () => createEmptyCell())
377
270
  );
378
271
  }
379
-
380
- const nextTable: TableNode = {
272
+ const nextTable = {
381
273
  ...table,
382
- rows: nextRows,
274
+ rows: nextRows
383
275
  };
384
276
  return commitTableChange(
385
277
  document,
@@ -388,72 +280,54 @@ function splitSelectedCell(
388
280
  nextTable,
389
281
  fallbackSelection,
390
282
  selection.anchorCell.rowIndex,
391
- selection.anchorCell.columnIndex,
283
+ selection.anchorCell.columnIndex
392
284
  );
393
285
  }
394
-
395
- function setCellBackground(
396
- document: CanonicalDocumentEnvelope,
397
- root: DocumentRootNode,
398
- table: TableNode,
399
- selection: TableSelectionDescriptor,
400
- color: string,
401
- fallbackSelection: SelectionSnapshot,
402
- ): StructuralMutationResult {
286
+ function setCellBackground(document, root, table, selection, color, fallbackSelection) {
403
287
  const normalized = normalizeFillColor(color);
404
288
  if (!normalized) {
405
289
  return createNoopStructuralMutation(document, fallbackSelection);
406
290
  }
407
-
408
- const targetRect =
409
- selection.selectionKind === "text"
410
- ? {
411
- top: 0,
412
- left: 0,
413
- bottom: table.rows.length,
414
- right: getLogicalColumnCount(table),
415
- }
416
- : selection.rect;
291
+ const targetRect = selection.selectionKind === "text" ? {
292
+ top: 0,
293
+ left: 0,
294
+ bottom: table.rows.length,
295
+ right: getLogicalColumnCount(table)
296
+ } : selection.rect;
417
297
  let changed = false;
418
298
  const nextRows = table.rows.map((row, rowIndex) => {
419
299
  if (rowIndex < targetRect.top || rowIndex >= targetRect.bottom) {
420
300
  return row;
421
301
  }
422
-
423
302
  let cursor = 0;
424
303
  const cells = row.cells.map((cell) => {
425
304
  const start = cursor;
426
305
  const width = cell.gridSpan ?? 1;
427
306
  const end = start + width;
428
307
  cursor = end;
429
-
430
308
  if (end <= targetRect.left || start >= targetRect.right) {
431
309
  return cell;
432
310
  }
433
-
434
311
  changed = true;
435
312
  return {
436
313
  ...cell,
437
314
  shading: {
438
- ...(cell.shading ?? {}),
439
- fill: normalized,
440
- },
315
+ ...cell.shading ?? {},
316
+ fill: normalized
317
+ }
441
318
  };
442
319
  });
443
-
444
320
  return {
445
321
  ...row,
446
- cells,
322
+ cells
447
323
  };
448
324
  });
449
-
450
325
  if (!changed) {
451
326
  return createNoopStructuralMutation(document, fallbackSelection);
452
327
  }
453
-
454
- const nextTable: TableNode = {
328
+ const nextTable = {
455
329
  ...table,
456
- rows: nextRows,
330
+ rows: nextRows
457
331
  };
458
332
  return commitTableChange(
459
333
  document,
@@ -462,156 +336,115 @@ function setCellBackground(
462
336
  nextTable,
463
337
  fallbackSelection,
464
338
  selection.anchorCell.rowIndex,
465
- selection.anchorCell.columnIndex,
339
+ selection.anchorCell.columnIndex
466
340
  );
467
341
  }
468
-
469
- function deleteTableBlock(
470
- document: CanonicalDocumentEnvelope,
471
- root: DocumentRootNode,
472
- tableBlockIndex: number,
473
- fallbackSelection: SelectionSnapshot,
474
- ): StructuralMutationResult {
342
+ function deleteTableBlock(document, root, tableBlockIndex, fallbackSelection) {
475
343
  const nextChildren = root.children.filter((_, index) => index !== tableBlockIndex);
476
344
  if (nextChildren.length === 0) {
477
345
  nextChildren.push(createEmptyParagraph());
478
346
  }
479
-
480
- const nextDocument: CanonicalDocumentEnvelope = {
347
+ const nextDocument = {
481
348
  ...document,
482
349
  content: {
483
350
  ...root,
484
- children: nextChildren,
485
- },
351
+ children: nextChildren
352
+ }
486
353
  };
487
- const nextSelection =
488
- findTopLevelParagraphSelectionNearBlock(nextDocument, tableBlockIndex) ??
489
- fallbackSelection;
490
-
354
+ const nextSelection = findTopLevelParagraphSelectionNearBlock(nextDocument, tableBlockIndex) ?? fallbackSelection;
491
355
  return {
492
356
  changed: true,
493
357
  document: nextDocument,
494
- selection: nextSelection,
358
+ selection: nextSelection
495
359
  };
496
360
  }
497
-
498
- function commitTableChange(
499
- document: CanonicalDocumentEnvelope,
500
- root: DocumentRootNode,
501
- tableBlockIndex: number,
502
- nextTable: TableNode,
503
- fallbackSelection: SelectionSnapshot,
504
- focusRowIndex: number,
505
- focusColumnIndex: number,
506
- ): StructuralMutationResult {
507
- const nextDocument: CanonicalDocumentEnvelope = {
361
+ function commitTableChange(document, root, tableBlockIndex, nextTable, fallbackSelection, focusRowIndex, focusColumnIndex) {
362
+ const nextDocument = {
508
363
  ...document,
509
364
  content: {
510
365
  ...root,
511
- children: root.children.map((child, index) =>
512
- index === tableBlockIndex ? nextTable : child,
513
- ),
514
- },
366
+ children: root.children.map(
367
+ (child, index) => index === tableBlockIndex ? nextTable : child
368
+ )
369
+ }
515
370
  };
516
- const nextSelection =
517
- findTableCellParagraphSelection(
518
- nextDocument,
519
- tableBlockIndex,
520
- focusRowIndex,
521
- focusColumnIndex,
522
- ) ?? fallbackSelection;
523
-
371
+ const nextSelection = findTableCellParagraphSelection(
372
+ nextDocument,
373
+ tableBlockIndex,
374
+ focusRowIndex,
375
+ focusColumnIndex
376
+ ) ?? fallbackSelection;
524
377
  return {
525
378
  changed: true,
526
379
  document: nextDocument,
527
- selection: nextSelection,
380
+ selection: nextSelection
528
381
  };
529
382
  }
530
-
531
- function resolveTableSelectionFromSnapshot(
532
- snapshot: Pick<PublicRuntimeRenderSnapshot, "selection" | "surface">,
533
- ): TableSelectionDescriptor | null {
383
+ function resolveTableSelectionFromSnapshot(snapshot) {
534
384
  const selectionFrom = Math.min(snapshot.selection.anchor, snapshot.selection.head);
535
385
  const selectionTo = Math.max(snapshot.selection.anchor, snapshot.selection.head);
536
386
  const surface = snapshot.surface;
537
387
  if (!surface) {
538
388
  return null;
539
389
  }
540
-
541
390
  for (let tableBlockIndex = 0; tableBlockIndex < surface.blocks.length; tableBlockIndex += 1) {
542
391
  const block = surface.blocks[tableBlockIndex];
543
392
  if (block.kind !== "table") {
544
393
  continue;
545
394
  }
546
-
547
395
  for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
548
396
  const row = block.rows[rowIndex];
549
397
  for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
550
398
  const cell = row.cells[cellIndex];
551
399
  const hit = cell.content.find(
552
- (child) =>
553
- child.kind === "paragraph" &&
554
- selectionFrom >= child.from &&
555
- selectionTo <= child.to,
400
+ (child) => child.kind === "paragraph" && selectionFrom >= child.from && selectionTo <= child.to
556
401
  );
557
402
  if (!hit) {
558
403
  continue;
559
404
  }
560
-
561
405
  let logicalColumn = 0;
562
406
  for (let currentIndex = 0; currentIndex < cellIndex; currentIndex += 1) {
563
407
  logicalColumn += row.cells[currentIndex]?.gridSpan ?? 1;
564
408
  }
565
-
566
409
  return {
567
410
  tableBlockIndex,
568
411
  selectionKind: "text",
569
412
  anchorCell: {
570
413
  rowIndex,
571
- columnIndex: logicalColumn,
414
+ columnIndex: logicalColumn
572
415
  },
573
416
  headCell: {
574
417
  rowIndex,
575
- columnIndex: logicalColumn,
418
+ columnIndex: logicalColumn
576
419
  },
577
420
  rect: {
578
421
  top: rowIndex,
579
422
  left: logicalColumn,
580
423
  bottom: rowIndex + 1,
581
- right: logicalColumn + (cell.gridSpan ?? 1),
582
- },
424
+ right: logicalColumn + (cell.gridSpan ?? 1)
425
+ }
583
426
  };
584
427
  }
585
428
  }
586
429
  }
587
-
588
430
  return null;
589
431
  }
590
-
591
- function toInternalSelectionSnapshot(
592
- selection: PublicRuntimeRenderSnapshot["selection"],
593
- ): SelectionSnapshot {
432
+ function toInternalSelectionSnapshot(selection) {
594
433
  return {
595
434
  anchor: selection.anchor,
596
435
  head: selection.head,
597
436
  isCollapsed: selection.isCollapsed,
598
- activeRange:
599
- selection.activeRange.kind === "range"
600
- ? createRangeAnchor(
601
- selection.activeRange.from,
602
- selection.activeRange.to,
603
- selection.activeRange.assoc,
604
- )
605
- : selection.activeRange.kind === "node"
606
- ? createNodeAnchor(selection.activeRange.at, selection.activeRange.assoc)
607
- : createDetachedAnchor(
608
- selection.activeRange.lastKnownRange,
609
- selection.activeRange.reason,
610
- ),
437
+ activeRange: selection.activeRange.kind === "range" ? createRangeAnchor(
438
+ selection.activeRange.from,
439
+ selection.activeRange.to,
440
+ selection.activeRange.assoc
441
+ ) : selection.activeRange.kind === "node" ? createNodeAnchor(selection.activeRange.at, selection.activeRange.assoc) : createDetachedAnchor(
442
+ selection.activeRange.lastKnownRange,
443
+ selection.activeRange.reason
444
+ )
611
445
  };
612
446
  }
613
-
614
- function isSimpleTable(table: TableNode): boolean {
447
+ function isSimpleTable(table) {
615
448
  const width = getLogicalColumnCount(table);
616
449
  return table.rows.every((row) => {
617
450
  let rowWidth = 0;
@@ -624,98 +457,76 @@ function isSimpleTable(table: TableNode): boolean {
624
457
  return rowWidth === width;
625
458
  });
626
459
  }
627
-
628
- function getLogicalColumnCount(table: TableNode): number {
460
+ function getLogicalColumnCount(table) {
629
461
  if (table.gridColumns.length > 0) {
630
462
  return table.gridColumns.length;
631
463
  }
632
-
633
464
  return table.rows.reduce((max, row) => {
634
465
  const width = row.cells.reduce((sum, cell) => sum + (cell.gridSpan ?? 1), 0);
635
466
  return Math.max(max, width);
636
467
  }, 0);
637
468
  }
638
-
639
- function computeRowSpan(
640
- table: TableNode,
641
- rowIndex: number,
642
- columnIndex: number,
643
- width: number,
644
- ): number {
469
+ function computeRowSpan(table, rowIndex, columnIndex, width) {
645
470
  let rowspan = 1;
646
-
647
471
  for (let currentRowIndex = rowIndex + 1; currentRowIndex < table.rows.length; currentRowIndex += 1) {
648
472
  const cellRef = findCellAtColumn(table.rows[currentRowIndex], columnIndex);
649
- if (
650
- !cellRef ||
651
- cellRef.cell.verticalMerge !== "continue" ||
652
- (cellRef.cell.gridSpan ?? 1) !== width
653
- ) {
473
+ if (!cellRef || cellRef.cell.verticalMerge !== "continue" || (cellRef.cell.gridSpan ?? 1) !== width) {
654
474
  break;
655
475
  }
656
476
  rowspan += 1;
657
477
  }
658
-
659
478
  return rowspan;
660
479
  }
661
-
662
- function findCellAtColumn(
663
- row: TableRowNode,
664
- logicalColumnIndex: number,
665
- ): { cellIndex: number; cell: TableCellNode } | null {
480
+ function findCellAtColumn(row, logicalColumnIndex) {
666
481
  let cursor = 0;
667
-
668
482
  for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
669
483
  const cell = row.cells[cellIndex];
670
484
  const width = cell.gridSpan ?? 1;
671
485
  if (logicalColumnIndex >= cursor && logicalColumnIndex < cursor + width) {
672
486
  return {
673
487
  cellIndex,
674
- cell,
488
+ cell
675
489
  };
676
490
  }
677
491
  cursor += width;
678
492
  }
679
-
680
493
  return null;
681
494
  }
682
-
683
- function createEmptyCell(): TableCellNode {
495
+ function createEmptyCell() {
684
496
  return {
685
497
  type: "table_cell",
686
- children: [createEmptyParagraph()],
498
+ children: [createEmptyParagraph()]
687
499
  };
688
500
  }
689
-
690
- function cloneCell(cell: TableCellNode): TableCellNode {
691
- return structuredClone(cell) as TableCellNode;
501
+ function cloneCell(cell) {
502
+ return structuredClone(cell);
692
503
  }
693
-
694
- function stripCellSpan(cell: TableCellNode): TableCellNode {
504
+ function stripCellSpan(cell) {
695
505
  return {
696
506
  ...cell,
697
- gridSpan: undefined,
698
- verticalMerge: undefined,
507
+ gridSpan: void 0,
508
+ verticalMerge: void 0
699
509
  };
700
510
  }
701
-
702
- function insertGridColumn(columns: number[], index: number): number[] {
511
+ function insertGridColumn(columns, index) {
703
512
  if (columns.length === 0) {
704
513
  return columns;
705
514
  }
706
-
707
515
  const current = columns[index] ?? columns[index - 1] ?? columns[columns.length - 1] ?? 2400;
708
516
  return [...columns.slice(0, index), current, ...columns.slice(index)];
709
517
  }
710
-
711
- function deleteGridColumn(columns: number[], index: number): number[] {
518
+ function deleteGridColumn(columns, index) {
712
519
  if (columns.length <= 1) {
713
520
  return columns;
714
521
  }
715
522
  return columns.filter((_, columnIndex) => columnIndex !== index);
716
523
  }
717
-
718
- function normalizeFillColor(color: string): string | null {
524
+ function normalizeFillColor(color) {
719
525
  const normalized = color.trim().replace(/^#/, "");
720
526
  return /^[0-9A-Fa-f]{3,8}$/.test(normalized) ? normalized.toUpperCase() : null;
721
527
  }
528
+
529
+ export {
530
+ applyTableStructureOperation
531
+ };
532
+ //# sourceMappingURL=chunk-36QNIZBO.js.map