@beyondwork/docx-react-component 1.0.29 → 1.0.31

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 (383) hide show
  1. package/package.json +65 -96
  2. package/src/README.md +85 -0
  3. package/src/api/README.md +26 -0
  4. package/src/api/public-types.ts +1952 -0
  5. package/src/api/session-state.ts +62 -0
  6. package/src/compare/diff-engine.ts +623 -0
  7. package/src/compare/export-redlines.ts +280 -0
  8. package/src/compare/index.ts +25 -0
  9. package/src/compare/snapshot.ts +97 -0
  10. package/src/component-inventory.md +99 -0
  11. package/src/core/README.md +10 -0
  12. package/src/core/commands/README.md +3 -0
  13. package/{dist/chunk-TJBP2K4T.js → src/core/commands/formatting-commands.ts} +536 -196
  14. package/src/core/commands/image-commands.ts +373 -0
  15. package/src/core/commands/index.ts +1879 -0
  16. package/src/core/commands/list-commands.ts +565 -0
  17. package/src/core/commands/paragraph-layout-commands.ts +339 -0
  18. package/src/core/commands/review-commands.ts +108 -0
  19. package/{dist/core/commands/section-layout-commands.cjs → src/core/commands/section-layout-commands.ts} +340 -137
  20. package/src/core/commands/structural-helpers.ts +309 -0
  21. package/{dist/core/commands/style-commands.cjs → src/core/commands/style-commands.ts} +113 -65
  22. package/src/core/commands/table-structure-commands.ts +854 -0
  23. package/{dist/chunk-UZXBISGO.js → src/core/commands/text-commands.ts} +142 -86
  24. package/src/core/schema/README.md +3 -0
  25. package/src/core/schema/text-schema.ts +516 -0
  26. package/src/core/search/search-text.ts +357 -0
  27. package/src/core/selection/README.md +3 -0
  28. package/src/core/selection/mapping.ts +289 -0
  29. package/src/core/selection/review-anchors.ts +183 -0
  30. package/src/core/state/README.md +3 -0
  31. package/src/core/state/editor-state.ts +892 -0
  32. package/src/core/state/text-transaction.ts +869 -0
  33. package/src/formats/xlsx/io/parse-shared-strings.ts +41 -0
  34. package/src/formats/xlsx/io/parse-sheet.ts +459 -0
  35. package/src/formats/xlsx/io/parse-styles.ts +59 -0
  36. package/src/formats/xlsx/io/parse-workbook.ts +75 -0
  37. package/src/formats/xlsx/io/serialize-shared-strings.ts +72 -0
  38. package/src/formats/xlsx/io/serialize-sheet.ts +333 -0
  39. package/src/formats/xlsx/io/serialize-styles.ts +98 -0
  40. package/src/formats/xlsx/io/serialize-workbook.ts +429 -0
  41. package/src/formats/xlsx/io/xlsx-session.ts +314 -0
  42. package/src/formats/xlsx/model/cell.ts +189 -0
  43. package/src/formats/xlsx/model/sheet.ts +326 -0
  44. package/src/formats/xlsx/model/styles.ts +118 -0
  45. package/src/formats/xlsx/model/workbook.ts +453 -0
  46. package/src/formats/xlsx/runtime/cell-commands.ts +567 -0
  47. package/src/formats/xlsx/runtime/sheet-commands.ts +206 -0
  48. package/src/formats/xlsx/runtime/workbook-runtime.ts +177 -0
  49. package/src/formats/xlsx/runtime/workbook-transaction.ts +822 -0
  50. package/src/index.ts +142 -0
  51. package/src/io/README.md +10 -0
  52. package/src/io/docx-session.ts +3175 -0
  53. package/src/io/export/README.md +3 -0
  54. package/src/io/export/export-session.ts +220 -0
  55. package/src/io/export/minimal-docx.ts +115 -0
  56. package/src/io/export/reattach-preserved-parts.ts +54 -0
  57. package/src/io/export/serialize-comments.ts +947 -0
  58. package/src/io/export/serialize-footnotes.ts +394 -0
  59. package/src/io/export/serialize-headers-footers.ts +368 -0
  60. package/src/io/export/serialize-main-document.ts +1342 -0
  61. package/src/io/export/serialize-numbering.ts +218 -0
  62. package/src/io/export/serialize-revisions.ts +389 -0
  63. package/src/io/export/serialize-runtime-revisions.ts +463 -0
  64. package/src/io/export/serialize-tables.ts +174 -0
  65. package/src/io/export/split-review-boundaries.ts +356 -0
  66. package/src/io/export/split-story-blocks-for-runtime-revisions.ts +252 -0
  67. package/src/io/export/table-properties-xml.ts +318 -0
  68. package/src/io/normalize/README.md +3 -0
  69. package/src/io/normalize/normalize-text.ts +670 -0
  70. package/src/io/ooxml/README.md +3 -0
  71. package/src/io/ooxml/highlight-colors.ts +39 -0
  72. package/src/io/ooxml/numbering-sentinels.ts +44 -0
  73. package/src/io/ooxml/parse-comments.ts +852 -0
  74. package/src/io/ooxml/parse-complex-content.ts +287 -0
  75. package/src/io/ooxml/parse-fields.ts +834 -0
  76. package/src/io/ooxml/parse-footnotes.ts +952 -0
  77. package/src/io/ooxml/parse-headers-footers.ts +1212 -0
  78. package/src/io/ooxml/parse-inline-media.ts +461 -0
  79. package/src/io/ooxml/parse-main-document.ts +2947 -0
  80. package/src/io/ooxml/parse-numbering.ts +747 -0
  81. package/src/io/ooxml/parse-revisions.ts +1045 -0
  82. package/src/io/ooxml/parse-settings.ts +184 -0
  83. package/src/io/ooxml/parse-shapes.ts +296 -0
  84. package/src/io/ooxml/parse-styles.ts +639 -0
  85. package/src/io/ooxml/parse-tables.ts +627 -0
  86. package/src/io/ooxml/parse-theme.ts +346 -0
  87. package/src/io/ooxml/part-manifest.ts +136 -0
  88. package/src/io/ooxml/revision-boundaries.ts +475 -0
  89. package/src/io/ooxml/workflow-payload.ts +544 -0
  90. package/src/io/opc/README.md +3 -0
  91. package/src/io/opc/corrupt-package.ts +166 -0
  92. package/src/io/opc/docx-package.ts +74 -0
  93. package/src/io/opc/package-reader.ts +325 -0
  94. package/src/io/opc/package-writer.ts +273 -0
  95. package/src/io/source-package-provenance.ts +241 -0
  96. package/{dist/chunk-RMH72RZI.js → src/legal/bookmarks.ts} +130 -44
  97. package/src/legal/cross-references.ts +414 -0
  98. package/src/legal/defined-terms.ts +203 -0
  99. package/src/legal/index.ts +32 -0
  100. package/src/legal/signature-blocks.ts +259 -0
  101. package/src/model/README.md +3 -0
  102. package/src/model/canonical-document.ts +2722 -0
  103. package/src/model/cds-1.0.0.ts +212 -0
  104. package/src/model/snapshot.ts +760 -0
  105. package/src/preservation/README.md +3 -0
  106. package/src/preservation/markup-compatibility.ts +48 -0
  107. package/src/preservation/opaque-fragment-store.ts +89 -0
  108. package/src/preservation/opaque-region.ts +233 -0
  109. package/src/preservation/package-preservation.ts +113 -0
  110. package/src/preservation/preserved-part-manifest.ts +56 -0
  111. package/src/preservation/relationship-retention.ts +57 -0
  112. package/src/preservation/store.ts +255 -0
  113. package/src/review/README.md +16 -0
  114. package/src/review/store/README.md +3 -0
  115. package/src/review/store/comment-anchors.ts +70 -0
  116. package/src/review/store/comment-remapping.ts +154 -0
  117. package/src/review/store/comment-store.ts +349 -0
  118. package/src/review/store/comment-thread.ts +109 -0
  119. package/src/review/store/revision-actions.ts +423 -0
  120. package/src/review/store/revision-store.ts +323 -0
  121. package/src/review/store/revision-types.ts +182 -0
  122. package/src/review/store/runtime-comment-store.ts +43 -0
  123. package/src/runtime/README.md +3 -0
  124. package/src/runtime/ai-action-policy.ts +764 -0
  125. package/src/runtime/context-analytics.ts +824 -0
  126. package/src/runtime/document-layout.ts +332 -0
  127. package/src/runtime/document-locations.ts +521 -0
  128. package/src/runtime/document-navigation.ts +616 -0
  129. package/src/runtime/document-outline.ts +440 -0
  130. package/src/runtime/document-runtime.ts +4055 -0
  131. package/src/runtime/document-search.ts +145 -0
  132. package/src/runtime/event-refresh-hints.ts +137 -0
  133. package/src/runtime/numbering-prefix.ts +244 -0
  134. package/src/runtime/page-layout-estimation.ts +305 -0
  135. package/src/runtime/read-only-diagnostics-runtime.ts +241 -0
  136. package/src/runtime/resolved-numbering-geometry.ts +293 -0
  137. package/src/runtime/review-runtime.ts +44 -0
  138. package/src/runtime/revision-runtime.ts +107 -0
  139. package/src/runtime/session-capabilities.ts +192 -0
  140. package/src/runtime/story-context.ts +164 -0
  141. package/src/runtime/story-targeting.ts +162 -0
  142. package/src/runtime/suggestions-snapshot.ts +137 -0
  143. package/src/runtime/surface-projection.ts +1553 -0
  144. package/src/runtime/table-commands.ts +173 -0
  145. package/src/runtime/table-schema.ts +309 -0
  146. package/src/runtime/table-style-resolver.ts +409 -0
  147. package/src/runtime/view-state.ts +493 -0
  148. package/src/runtime/virtualized-rendering.ts +258 -0
  149. package/src/runtime/workflow-markup.ts +393 -0
  150. package/src/ui/README.md +30 -0
  151. package/src/ui/WordReviewEditor.tsx +5268 -0
  152. package/src/ui/browser-export.ts +52 -0
  153. package/src/ui/comments/README.md +3 -0
  154. package/src/ui/compatibility/README.md +3 -0
  155. package/src/ui/editor-command-bag.ts +127 -0
  156. package/src/ui/editor-runtime-boundary.ts +1558 -0
  157. package/src/ui/editor-shell-view.tsx +144 -0
  158. package/src/ui/editor-surface/README.md +3 -0
  159. package/src/ui/editor-surface-controller.tsx +66 -0
  160. package/src/ui/headless/comment-decoration-model.ts +124 -0
  161. package/src/ui/headless/preserve-editor-selection.ts +5 -0
  162. package/src/ui/headless/revision-decoration-model.ts +128 -0
  163. package/src/ui/headless/selection-helpers.ts +54 -0
  164. package/src/ui/headless/selection-tool-context.ts +19 -0
  165. package/src/ui/headless/selection-tool-resolver.ts +752 -0
  166. package/src/ui/headless/selection-tool-types.ts +129 -0
  167. package/src/ui/headless/selection-toolbar-model.ts +11 -0
  168. package/src/ui/headless/use-editor-keyboard.ts +103 -0
  169. package/src/ui/review/README.md +3 -0
  170. package/src/ui/runtime-shortcut-dispatch.ts +365 -0
  171. package/src/ui/runtime-snapshot-selectors.ts +197 -0
  172. package/src/ui/shared/revision-filters.ts +31 -0
  173. package/src/ui/status/README.md +3 -0
  174. package/src/ui/theme/README.md +3 -0
  175. package/src/ui/toolbar/README.md +3 -0
  176. package/src/ui/workflow-surface-blocked-rails.ts +94 -0
  177. package/src/ui-tailwind/chrome/chrome-preset-model.ts +107 -0
  178. package/src/ui-tailwind/chrome/chrome-preset-toolbar.tsx +15 -0
  179. package/src/ui-tailwind/chrome/responsive-chrome.ts +46 -0
  180. package/src/ui-tailwind/chrome/review-queue-bar.tsx +97 -0
  181. package/src/ui-tailwind/chrome/tw-alert-banner.tsx +64 -0
  182. package/src/ui-tailwind/chrome/tw-context-analytics-summary.tsx +122 -0
  183. package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +121 -0
  184. package/src/ui-tailwind/chrome/tw-layout-panel.tsx +114 -0
  185. package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +30 -0
  186. package/src/ui-tailwind/chrome/tw-page-ruler.tsx +365 -0
  187. package/src/ui-tailwind/chrome/tw-selection-tool-blocked.tsx +23 -0
  188. package/src/ui-tailwind/chrome/tw-selection-tool-comment.tsx +35 -0
  189. package/src/ui-tailwind/chrome/tw-selection-tool-formatting.tsx +37 -0
  190. package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +303 -0
  191. package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +116 -0
  192. package/src/ui-tailwind/chrome/tw-selection-tool-suggestion.tsx +29 -0
  193. package/src/ui-tailwind/chrome/tw-selection-tool-workflow.tsx +27 -0
  194. package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +186 -0
  195. package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +139 -0
  196. package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +250 -0
  197. package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +58 -0
  198. package/src/ui-tailwind/chrome/use-before-unload.ts +20 -0
  199. package/src/ui-tailwind/editor-surface/perf-probe.ts +179 -0
  200. package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +189 -0
  201. package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +31 -0
  202. package/src/ui-tailwind/editor-surface/pm-decorations.ts +411 -0
  203. package/src/ui-tailwind/editor-surface/pm-position-map.ts +123 -0
  204. package/src/ui-tailwind/editor-surface/pm-schema.ts +927 -0
  205. package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +567 -0
  206. package/src/ui-tailwind/editor-surface/search-plugin.ts +168 -0
  207. package/src/ui-tailwind/editor-surface/surface-build-keys.ts +63 -0
  208. package/src/ui-tailwind/editor-surface/tw-caret.tsx +12 -0
  209. package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +150 -0
  210. package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +129 -0
  211. package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +58 -0
  212. package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +151 -0
  213. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +1047 -0
  214. package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +111 -0
  215. package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +503 -0
  216. package/src/ui-tailwind/index.ts +62 -0
  217. package/src/ui-tailwind/page-chrome-model.ts +27 -0
  218. package/src/ui-tailwind/review/tw-comment-sidebar.tsx +406 -0
  219. package/src/ui-tailwind/review/tw-health-panel.tsx +149 -0
  220. package/src/ui-tailwind/review/tw-review-rail.tsx +130 -0
  221. package/src/ui-tailwind/review/tw-revision-sidebar.tsx +164 -0
  222. package/src/ui-tailwind/status/tw-status-bar.tsx +65 -0
  223. package/{dist → src}/ui-tailwind/theme/editor-theme.css +58 -40
  224. package/src/ui-tailwind/toolbar/toolbar-layout.ts +47 -0
  225. package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +52 -0
  226. package/src/ui-tailwind/toolbar/tw-toolbar.tsx +1478 -0
  227. package/src/ui-tailwind/tw-review-workspace.tsx +1587 -0
  228. package/src/validation/README.md +3 -0
  229. package/src/validation/compatibility-engine.ts +878 -0
  230. package/src/validation/compatibility-report.ts +161 -0
  231. package/src/validation/diagnostics.ts +204 -0
  232. package/src/validation/docx-comment-proof.ts +720 -0
  233. package/src/validation/import-diagnostics.ts +128 -0
  234. package/src/validation/low-priority-word-surfaces.ts +373 -0
  235. package/dist/canonical-document-BLEbzL2J.d.cts +0 -844
  236. package/dist/canonical-document-BLEbzL2J.d.ts +0 -844
  237. package/dist/chunk-2FJS5GZM.js +0 -763
  238. package/dist/chunk-2FJS5GZM.js.map +0 -1
  239. package/dist/chunk-2OQBZS3F.js +0 -446
  240. package/dist/chunk-2OQBZS3F.js.map +0 -1
  241. package/dist/chunk-2S7W4KFO.js +0 -127
  242. package/dist/chunk-2S7W4KFO.js.map +0 -1
  243. package/dist/chunk-2TG72QSW.js +0 -3874
  244. package/dist/chunk-2TG72QSW.js.map +0 -1
  245. package/dist/chunk-36QNIZBO.js +0 -532
  246. package/dist/chunk-36QNIZBO.js.map +0 -1
  247. package/dist/chunk-4AQOYAW4.js +0 -3069
  248. package/dist/chunk-4AQOYAW4.js.map +0 -1
  249. package/dist/chunk-4D5EWJ3P.js +0 -77
  250. package/dist/chunk-4D5EWJ3P.js.map +0 -1
  251. package/dist/chunk-5FN54NDH.js +0 -2257
  252. package/dist/chunk-5FN54NDH.js.map +0 -1
  253. package/dist/chunk-BOYGQYRQ.js +0 -7306
  254. package/dist/chunk-BOYGQYRQ.js.map +0 -1
  255. package/dist/chunk-CN3XMECL.js +0 -212
  256. package/dist/chunk-CN3XMECL.js.map +0 -1
  257. package/dist/chunk-EBI3BX6U.js +0 -164
  258. package/dist/chunk-EBI3BX6U.js.map +0 -1
  259. package/dist/chunk-EILUG3VB.js +0 -1275
  260. package/dist/chunk-EILUG3VB.js.map +0 -1
  261. package/dist/chunk-FUDY333O.js +0 -70
  262. package/dist/chunk-FUDY333O.js.map +0 -1
  263. package/dist/chunk-GBVOWFIK.js +0 -1237
  264. package/dist/chunk-GBVOWFIK.js.map +0 -1
  265. package/dist/chunk-H4TQ3H3Y.js +0 -262
  266. package/dist/chunk-H4TQ3H3Y.js.map +0 -1
  267. package/dist/chunk-JGB3IXZO.js +0 -189
  268. package/dist/chunk-JGB3IXZO.js.map +0 -1
  269. package/dist/chunk-KD2QRQPY.js +0 -4342
  270. package/dist/chunk-KD2QRQPY.js.map +0 -1
  271. package/dist/chunk-KLMXQVYK.js +0 -369
  272. package/dist/chunk-KLMXQVYK.js.map +0 -1
  273. package/dist/chunk-KZUG5KFQ.js +0 -214
  274. package/dist/chunk-KZUG5KFQ.js.map +0 -1
  275. package/dist/chunk-QDAQ4CJU.js +0 -345
  276. package/dist/chunk-QDAQ4CJU.js.map +0 -1
  277. package/dist/chunk-RMH72RZI.js.map +0 -1
  278. package/dist/chunk-SWKWQZXM.js +0 -117
  279. package/dist/chunk-SWKWQZXM.js.map +0 -1
  280. package/dist/chunk-TJBP2K4T.js.map +0 -1
  281. package/dist/chunk-TLCEAQDQ.js +0 -542
  282. package/dist/chunk-TLCEAQDQ.js.map +0 -1
  283. package/dist/chunk-UZXBISGO.js.map +0 -1
  284. package/dist/chunk-WGBAKP3Q.js +0 -3220
  285. package/dist/chunk-WGBAKP3Q.js.map +0 -1
  286. package/dist/compare/index.cjs +0 -5475
  287. package/dist/compare/index.cjs.map +0 -1
  288. package/dist/compare/index.d.cts +0 -114
  289. package/dist/compare/index.d.ts +0 -114
  290. package/dist/compare/index.js +0 -731
  291. package/dist/compare/index.js.map +0 -1
  292. package/dist/core/commands/formatting-commands.cjs +0 -828
  293. package/dist/core/commands/formatting-commands.cjs.map +0 -1
  294. package/dist/core/commands/formatting-commands.d.cts +0 -63
  295. package/dist/core/commands/formatting-commands.d.ts +0 -63
  296. package/dist/core/commands/formatting-commands.js +0 -37
  297. package/dist/core/commands/formatting-commands.js.map +0 -1
  298. package/dist/core/commands/image-commands.cjs +0 -2023
  299. package/dist/core/commands/image-commands.cjs.map +0 -1
  300. package/dist/core/commands/image-commands.d.cts +0 -58
  301. package/dist/core/commands/image-commands.d.ts +0 -58
  302. package/dist/core/commands/image-commands.js +0 -18
  303. package/dist/core/commands/image-commands.js.map +0 -1
  304. package/dist/core/commands/section-layout-commands.cjs.map +0 -1
  305. package/dist/core/commands/section-layout-commands.d.cts +0 -62
  306. package/dist/core/commands/section-layout-commands.d.ts +0 -62
  307. package/dist/core/commands/section-layout-commands.js +0 -21
  308. package/dist/core/commands/section-layout-commands.js.map +0 -1
  309. package/dist/core/commands/style-commands.cjs.map +0 -1
  310. package/dist/core/commands/style-commands.d.cts +0 -13
  311. package/dist/core/commands/style-commands.d.ts +0 -13
  312. package/dist/core/commands/style-commands.js +0 -9
  313. package/dist/core/commands/style-commands.js.map +0 -1
  314. package/dist/core/commands/table-structure-commands.cjs +0 -1883
  315. package/dist/core/commands/table-structure-commands.cjs.map +0 -1
  316. package/dist/core/commands/table-structure-commands.d.cts +0 -59
  317. package/dist/core/commands/table-structure-commands.d.ts +0 -59
  318. package/dist/core/commands/table-structure-commands.js +0 -12
  319. package/dist/core/commands/table-structure-commands.js.map +0 -1
  320. package/dist/core/commands/text-commands.cjs +0 -2391
  321. package/dist/core/commands/text-commands.cjs.map +0 -1
  322. package/dist/core/commands/text-commands.d.cts +0 -24
  323. package/dist/core/commands/text-commands.d.ts +0 -24
  324. package/dist/core/commands/text-commands.js +0 -28
  325. package/dist/core/commands/text-commands.js.map +0 -1
  326. package/dist/core/selection/mapping.cjs +0 -200
  327. package/dist/core/selection/mapping.cjs.map +0 -1
  328. package/dist/core/selection/mapping.d.cts +0 -2
  329. package/dist/core/selection/mapping.d.ts +0 -2
  330. package/dist/core/selection/mapping.js +0 -31
  331. package/dist/core/selection/mapping.js.map +0 -1
  332. package/dist/core/state/editor-state.cjs +0 -2278
  333. package/dist/core/state/editor-state.cjs.map +0 -1
  334. package/dist/core/state/editor-state.d.cts +0 -2
  335. package/dist/core/state/editor-state.d.ts +0 -2
  336. package/dist/core/state/editor-state.js +0 -26
  337. package/dist/core/state/editor-state.js.map +0 -1
  338. package/dist/index.cjs +0 -38553
  339. package/dist/index.cjs.map +0 -1
  340. package/dist/index.d.cts +0 -15
  341. package/dist/index.d.ts +0 -15
  342. package/dist/index.js +0 -7856
  343. package/dist/index.js.map +0 -1
  344. package/dist/io/docx-session.cjs +0 -16236
  345. package/dist/io/docx-session.cjs.map +0 -1
  346. package/dist/io/docx-session.d.cts +0 -21
  347. package/dist/io/docx-session.d.ts +0 -21
  348. package/dist/io/docx-session.js +0 -18
  349. package/dist/io/docx-session.js.map +0 -1
  350. package/dist/legal/index.cjs +0 -3900
  351. package/dist/legal/index.cjs.map +0 -1
  352. package/dist/legal/index.d.cts +0 -86
  353. package/dist/legal/index.d.ts +0 -86
  354. package/dist/legal/index.js +0 -616
  355. package/dist/legal/index.js.map +0 -1
  356. package/dist/public-types-7ZL_94cz.d.ts +0 -1573
  357. package/dist/public-types-CeMaDueh.d.cts +0 -1573
  358. package/dist/public-types.cjs +0 -19
  359. package/dist/public-types.cjs.map +0 -1
  360. package/dist/public-types.d.cts +0 -2
  361. package/dist/public-types.d.ts +0 -2
  362. package/dist/public-types.js +0 -1
  363. package/dist/public-types.js.map +0 -1
  364. package/dist/runtime/document-runtime.cjs +0 -11140
  365. package/dist/runtime/document-runtime.cjs.map +0 -1
  366. package/dist/runtime/document-runtime.d.cts +0 -231
  367. package/dist/runtime/document-runtime.d.ts +0 -231
  368. package/dist/runtime/document-runtime.js +0 -21
  369. package/dist/runtime/document-runtime.js.map +0 -1
  370. package/dist/structural-helpers-CilgOVhh.d.cts +0 -10
  371. package/dist/structural-helpers-q0Gd-eBN.d.ts +0 -10
  372. package/dist/ui-tailwind/editor-surface/search-plugin.cjs +0 -313
  373. package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +0 -1
  374. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +0 -67
  375. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +0 -67
  376. package/dist/ui-tailwind/editor-surface/search-plugin.js +0 -23
  377. package/dist/ui-tailwind/editor-surface/search-plugin.js.map +0 -1
  378. package/dist/ui-tailwind/index.cjs +0 -4833
  379. package/dist/ui-tailwind/index.cjs.map +0 -1
  380. package/dist/ui-tailwind/index.d.cts +0 -617
  381. package/dist/ui-tailwind/index.d.ts +0 -617
  382. package/dist/ui-tailwind/index.js +0 -575
  383. package/dist/ui-tailwind/index.js.map +0 -1
@@ -1,369 +0,0 @@
1
- // src/core/schema/text-schema.ts
2
- function parseTextStory(content) {
3
- const root = normalizeDocumentRoot(content);
4
- const firstParagraphNode = root.children.find(isParagraphNode);
5
- const firstParagraph = firstParagraphNode ? extractParagraphProperties(firstParagraphNode) : cloneParagraphProperties(EMPTY_PARAGRAPH_PROPERTIES);
6
- const units = [];
7
- for (let index = 0; index < root.children.length; index += 1) {
8
- const block = root.children[index];
9
- const nextBlock = root.children[index + 1];
10
- if (isParagraphNode(block)) {
11
- units.push(...flattenInlineNodes(block.children));
12
- if (isParagraphNode(nextBlock)) {
13
- units.push({
14
- kind: "paragraph_break",
15
- nextParagraph: extractParagraphProperties(nextBlock)
16
- });
17
- }
18
- continue;
19
- }
20
- if (block.type !== "opaque_block") {
21
- continue;
22
- }
23
- units.push({
24
- kind: "opaque_block",
25
- fragmentId: block.fragmentId,
26
- warningId: block.warningId,
27
- ...isParagraphNode(nextBlock) ? { nextParagraph: extractParagraphProperties(nextBlock) } : {}
28
- });
29
- }
30
- return {
31
- firstParagraph,
32
- units,
33
- size: units.length
34
- };
35
- }
36
- function serializeTextStory(story) {
37
- const blocks = [];
38
- let currentParagraph = createParagraph(story.firstParagraph);
39
- let currentHyperlink;
40
- let activeTextBuffer;
41
- const ensureCurrentParagraph = () => {
42
- if (!currentParagraph) {
43
- currentParagraph = createParagraph(EMPTY_PARAGRAPH_PROPERTIES);
44
- }
45
- };
46
- const flushTextBuffer = () => {
47
- if (!activeTextBuffer || activeTextBuffer.text.length === 0) {
48
- activeTextBuffer = void 0;
49
- return;
50
- }
51
- const textNode = {
52
- type: "text",
53
- text: activeTextBuffer.text,
54
- ...activeTextBuffer.marks ? { marks: cloneMarks(activeTextBuffer.marks) } : {}
55
- };
56
- ensureCurrentParagraph();
57
- if (activeTextBuffer.hyperlinkHref) {
58
- if (!currentHyperlink || currentHyperlink.href !== activeTextBuffer.hyperlinkHref) {
59
- flushHyperlink();
60
- currentHyperlink = {
61
- type: "hyperlink",
62
- href: activeTextBuffer.hyperlinkHref,
63
- children: []
64
- };
65
- }
66
- currentHyperlink.children.push(textNode);
67
- } else {
68
- flushHyperlink();
69
- currentParagraph.children.push(textNode);
70
- }
71
- activeTextBuffer = void 0;
72
- };
73
- const flushHyperlink = () => {
74
- if (currentHyperlink) {
75
- ensureCurrentParagraph();
76
- currentParagraph.children.push(currentHyperlink);
77
- currentHyperlink = void 0;
78
- }
79
- };
80
- const flushParagraph = () => {
81
- flushTextBuffer();
82
- flushHyperlink();
83
- if (!currentParagraph) {
84
- return;
85
- }
86
- blocks.push(currentParagraph);
87
- currentParagraph = void 0;
88
- };
89
- const pushInlineNode = (node, hyperlinkHref) => {
90
- flushTextBuffer();
91
- ensureCurrentParagraph();
92
- if (hyperlinkHref) {
93
- if (!currentHyperlink || currentHyperlink.href !== hyperlinkHref) {
94
- flushHyperlink();
95
- currentHyperlink = {
96
- type: "hyperlink",
97
- href: hyperlinkHref,
98
- children: []
99
- };
100
- }
101
- currentHyperlink.children.push(node);
102
- return;
103
- }
104
- flushHyperlink();
105
- currentParagraph.children.push(node);
106
- };
107
- for (const unit of story.units) {
108
- if (unit.kind === "paragraph_break") {
109
- flushParagraph();
110
- currentParagraph = createParagraph(unit.nextParagraph);
111
- continue;
112
- }
113
- if (unit.kind === "opaque_block") {
114
- flushParagraph();
115
- blocks.push({
116
- type: "opaque_block",
117
- fragmentId: unit.fragmentId,
118
- warningId: unit.warningId
119
- });
120
- currentParagraph = unit.nextParagraph ? createParagraph(unit.nextParagraph) : void 0;
121
- continue;
122
- }
123
- if (unit.kind === "text") {
124
- const shouldExtendBuffer = activeTextBuffer && activeTextBuffer.hyperlinkHref === unit.hyperlinkHref && haveEqualMarks(activeTextBuffer.marks, unit.marks);
125
- if (shouldExtendBuffer && activeTextBuffer) {
126
- activeTextBuffer.text += unit.value;
127
- } else {
128
- flushTextBuffer();
129
- activeTextBuffer = {
130
- text: unit.value,
131
- ...unit.marks ? { marks: cloneMarks(unit.marks) } : {},
132
- ...unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}
133
- };
134
- }
135
- continue;
136
- }
137
- switch (unit.kind) {
138
- case "tab":
139
- pushInlineNode({ type: "tab" }, unit.hyperlinkHref);
140
- break;
141
- case "hard_break":
142
- pushInlineNode({ type: "hard_break" }, unit.hyperlinkHref);
143
- break;
144
- case "image":
145
- pushInlineNode({
146
- type: "image",
147
- mediaId: unit.mediaId,
148
- ...unit.altText ? { altText: unit.altText } : {}
149
- });
150
- break;
151
- case "opaque_inline":
152
- pushInlineNode({
153
- type: "opaque_inline",
154
- fragmentId: unit.fragmentId,
155
- warningId: unit.warningId
156
- });
157
- break;
158
- }
159
- }
160
- flushParagraph();
161
- if (blocks.length === 0) {
162
- blocks.push(createParagraph(story.firstParagraph));
163
- }
164
- return {
165
- type: "doc",
166
- children: blocks
167
- };
168
- }
169
- function createPlainText(story) {
170
- return story.units.map((unit) => {
171
- switch (unit.kind) {
172
- case "text":
173
- return unit.value;
174
- case "tab":
175
- return " ";
176
- case "hard_break":
177
- return "\n";
178
- case "paragraph_break":
179
- return "\n";
180
- case "image":
181
- return "\uFFFC";
182
- case "opaque_inline":
183
- return "\uFFF9";
184
- case "opaque_block":
185
- return "\uFFFA";
186
- }
187
- }).join("");
188
- }
189
- function cloneStoryUnit(unit) {
190
- switch (unit.kind) {
191
- case "text":
192
- return {
193
- kind: "text",
194
- value: unit.value,
195
- ...unit.marks ? { marks: cloneMarks(unit.marks) } : {},
196
- ...unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}
197
- };
198
- case "tab":
199
- return {
200
- kind: "tab",
201
- ...unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}
202
- };
203
- case "hard_break":
204
- return {
205
- kind: "hard_break",
206
- ...unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}
207
- };
208
- case "image":
209
- return {
210
- kind: "image",
211
- mediaId: unit.mediaId,
212
- ...unit.altText ? { altText: unit.altText } : {}
213
- };
214
- case "opaque_inline":
215
- return {
216
- kind: "opaque_inline",
217
- fragmentId: unit.fragmentId,
218
- warningId: unit.warningId
219
- };
220
- case "opaque_block":
221
- return {
222
- kind: "opaque_block",
223
- fragmentId: unit.fragmentId,
224
- warningId: unit.warningId,
225
- ...unit.nextParagraph ? { nextParagraph: cloneParagraphProperties(unit.nextParagraph) } : {}
226
- };
227
- case "paragraph_break":
228
- return {
229
- kind: "paragraph_break",
230
- nextParagraph: cloneParagraphProperties(unit.nextParagraph)
231
- };
232
- }
233
- }
234
- function cloneParagraphProperties(properties) {
235
- return {
236
- ...properties.styleId ? { styleId: properties.styleId } : {},
237
- ...properties.numbering ? {
238
- numbering: {
239
- numberingInstanceId: properties.numbering.numberingInstanceId,
240
- level: properties.numbering.level
241
- }
242
- } : {}
243
- };
244
- }
245
- function normalizeDocumentRoot(content) {
246
- if (isDocumentRootNode(content)) {
247
- return content;
248
- }
249
- if (Array.isArray(content)) {
250
- return {
251
- type: "doc",
252
- children: content.filter(
253
- (block) => isParagraphNode(block) || isOpaqueBlockNode(block)
254
- )
255
- };
256
- }
257
- return {
258
- type: "doc",
259
- children: [createEmptyParagraph()]
260
- };
261
- }
262
- function flattenInlineNodes(nodes, hyperlinkHref) {
263
- const units = [];
264
- for (const node of nodes) {
265
- switch (node.type) {
266
- case "text":
267
- for (const character of Array.from(node.text)) {
268
- units.push({
269
- kind: "text",
270
- value: character,
271
- ...node.marks ? { marks: cloneMarks(node.marks) } : {},
272
- ...hyperlinkHref ? { hyperlinkHref } : {}
273
- });
274
- }
275
- break;
276
- case "tab":
277
- units.push({
278
- kind: "tab",
279
- ...hyperlinkHref ? { hyperlinkHref } : {}
280
- });
281
- break;
282
- case "hard_break":
283
- units.push({
284
- kind: "hard_break",
285
- ...hyperlinkHref ? { hyperlinkHref } : {}
286
- });
287
- break;
288
- case "hyperlink":
289
- units.push(...flattenInlineNodes(node.children, node.href));
290
- break;
291
- case "image":
292
- units.push({
293
- kind: "image",
294
- mediaId: node.mediaId,
295
- ...node.altText ? { altText: node.altText } : {}
296
- });
297
- break;
298
- case "opaque_inline":
299
- units.push({
300
- kind: "opaque_inline",
301
- fragmentId: node.fragmentId,
302
- warningId: node.warningId
303
- });
304
- break;
305
- }
306
- }
307
- return units;
308
- }
309
- function extractParagraphProperties(paragraph) {
310
- return {
311
- ...paragraph.styleId ? { styleId: paragraph.styleId } : {},
312
- ...paragraph.numbering ? {
313
- numbering: {
314
- numberingInstanceId: paragraph.numbering.numberingInstanceId,
315
- level: paragraph.numbering.level
316
- }
317
- } : {}
318
- };
319
- }
320
- function createParagraph(properties) {
321
- return {
322
- type: "paragraph",
323
- ...properties.styleId ? { styleId: properties.styleId } : {},
324
- ...properties.numbering ? {
325
- numbering: {
326
- numberingInstanceId: properties.numbering.numberingInstanceId,
327
- level: properties.numbering.level
328
- }
329
- } : {},
330
- children: []
331
- };
332
- }
333
- function createEmptyParagraph() {
334
- return {
335
- type: "paragraph",
336
- children: []
337
- };
338
- }
339
- var EMPTY_PARAGRAPH_PROPERTIES = {};
340
- function cloneMarks(marks) {
341
- return marks.map((mark) => ({ ...mark }));
342
- }
343
- function haveEqualMarks(left, right) {
344
- if (!left && !right) {
345
- return true;
346
- }
347
- if (!left || !right || left.length !== right.length) {
348
- return false;
349
- }
350
- return left.every((mark, index) => mark.type === right[index]?.type);
351
- }
352
- function isDocumentRootNode(value) {
353
- return Boolean(value) && typeof value === "object" && value.type === "doc";
354
- }
355
- function isParagraphNode(value) {
356
- return Boolean(value) && typeof value === "object" && value.type === "paragraph";
357
- }
358
- function isOpaqueBlockNode(value) {
359
- return Boolean(value) && typeof value === "object" && value.type === "opaque_block";
360
- }
361
-
362
- export {
363
- parseTextStory,
364
- serializeTextStory,
365
- createPlainText,
366
- cloneStoryUnit,
367
- cloneParagraphProperties
368
- };
369
- //# sourceMappingURL=chunk-KLMXQVYK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/schema/text-schema.ts"],"sourcesContent":["import type {\n DocumentRootNode,\n HyperlinkNode,\n InlineNode,\n OpaqueBlockNode,\n OpaqueInlineNode,\n ParagraphNode,\n TextMark,\n} from \"../../model/canonical-document.ts\";\n\nexport interface ParagraphProperties {\n styleId?: string;\n numbering?: ParagraphNode[\"numbering\"];\n}\n\nexport interface TextStory {\n firstParagraph: ParagraphProperties;\n units: StoryUnit[];\n size: number;\n}\n\nexport type StoryUnit =\n | TextCharacterUnit\n | TabUnit\n | HardBreakUnit\n | ImageUnit\n | OpaqueInlineUnit\n | OpaqueBlockUnit\n | ParagraphBreakUnit;\n\nexport interface TextCharacterUnit {\n kind: \"text\";\n value: string;\n marks?: TextMark[];\n hyperlinkHref?: string;\n}\n\nexport interface TabUnit {\n kind: \"tab\";\n hyperlinkHref?: string;\n}\n\nexport interface HardBreakUnit {\n kind: \"hard_break\";\n hyperlinkHref?: string;\n}\n\nexport interface ImageUnit {\n kind: \"image\";\n mediaId: string;\n altText?: string;\n}\n\nexport interface OpaqueInlineUnit {\n kind: \"opaque_inline\";\n fragmentId: string;\n warningId: string;\n}\n\nexport interface OpaqueBlockUnit {\n kind: \"opaque_block\";\n fragmentId: string;\n warningId: string;\n nextParagraph?: ParagraphProperties;\n}\n\nexport interface ParagraphBreakUnit {\n kind: \"paragraph_break\";\n nextParagraph: ParagraphProperties;\n}\n\nexport function parseTextStory(content: unknown): TextStory {\n const root = normalizeDocumentRoot(content);\n const firstParagraphNode = root.children.find(isParagraphNode);\n const firstParagraph = firstParagraphNode\n ? extractParagraphProperties(firstParagraphNode)\n : cloneParagraphProperties(EMPTY_PARAGRAPH_PROPERTIES);\n const units: StoryUnit[] = [];\n\n for (let index = 0; index < root.children.length; index += 1) {\n const block = root.children[index];\n const nextBlock = root.children[index + 1];\n\n if (isParagraphNode(block)) {\n units.push(...flattenInlineNodes(block.children));\n\n if (isParagraphNode(nextBlock)) {\n units.push({\n kind: \"paragraph_break\",\n nextParagraph: extractParagraphProperties(nextBlock),\n });\n }\n\n continue;\n }\n\n if (block.type !== \"opaque_block\") {\n continue;\n }\n\n units.push({\n kind: \"opaque_block\",\n fragmentId: block.fragmentId,\n warningId: block.warningId,\n ...(isParagraphNode(nextBlock)\n ? { nextParagraph: extractParagraphProperties(nextBlock) }\n : {}),\n });\n }\n\n return {\n firstParagraph,\n units,\n size: units.length,\n };\n}\n\nexport function serializeTextStory(story: TextStory): DocumentRootNode {\n const blocks: Array<ParagraphNode | OpaqueBlockNode> = [];\n let currentParagraph: ParagraphNode | undefined = createParagraph(story.firstParagraph);\n let currentHyperlink: HyperlinkNode | undefined;\n let activeTextBuffer:\n | {\n text: string;\n marks?: TextMark[];\n hyperlinkHref?: string;\n }\n | undefined;\n\n const ensureCurrentParagraph = () => {\n if (!currentParagraph) {\n currentParagraph = createParagraph(EMPTY_PARAGRAPH_PROPERTIES);\n }\n };\n\n const flushTextBuffer = () => {\n if (!activeTextBuffer || activeTextBuffer.text.length === 0) {\n activeTextBuffer = undefined;\n return;\n }\n\n const textNode = {\n type: \"text\" as const,\n text: activeTextBuffer.text,\n ...(activeTextBuffer.marks ? { marks: cloneMarks(activeTextBuffer.marks) } : {}),\n };\n\n ensureCurrentParagraph();\n\n if (activeTextBuffer.hyperlinkHref) {\n if (!currentHyperlink || currentHyperlink.href !== activeTextBuffer.hyperlinkHref) {\n flushHyperlink();\n currentHyperlink = {\n type: \"hyperlink\",\n href: activeTextBuffer.hyperlinkHref,\n children: [],\n };\n }\n\n currentHyperlink.children.push(textNode);\n } else {\n flushHyperlink();\n currentParagraph!.children.push(textNode);\n }\n\n activeTextBuffer = undefined;\n };\n\n const flushHyperlink = () => {\n if (currentHyperlink) {\n ensureCurrentParagraph();\n currentParagraph!.children.push(currentHyperlink);\n currentHyperlink = undefined;\n }\n };\n\n const flushParagraph = () => {\n flushTextBuffer();\n flushHyperlink();\n\n if (!currentParagraph) {\n return;\n }\n\n blocks.push(currentParagraph);\n currentParagraph = undefined;\n };\n\n const pushInlineNode = (\n node: Exclude<InlineNode, { type: \"text\" }>,\n hyperlinkHref?: string,\n ) => {\n flushTextBuffer();\n ensureCurrentParagraph();\n\n if (hyperlinkHref) {\n if (!currentHyperlink || currentHyperlink.href !== hyperlinkHref) {\n flushHyperlink();\n currentHyperlink = {\n type: \"hyperlink\",\n href: hyperlinkHref,\n children: [],\n };\n }\n\n currentHyperlink.children.push(node as HyperlinkNode[\"children\"][number]);\n return;\n }\n\n flushHyperlink();\n currentParagraph!.children.push(node);\n };\n\n for (const unit of story.units) {\n if (unit.kind === \"paragraph_break\") {\n flushParagraph();\n currentParagraph = createParagraph(unit.nextParagraph);\n continue;\n }\n\n if (unit.kind === \"opaque_block\") {\n flushParagraph();\n blocks.push({\n type: \"opaque_block\",\n fragmentId: unit.fragmentId,\n warningId: unit.warningId,\n });\n currentParagraph = unit.nextParagraph\n ? createParagraph(unit.nextParagraph)\n : undefined;\n continue;\n }\n\n if (unit.kind === \"text\") {\n const shouldExtendBuffer =\n activeTextBuffer &&\n activeTextBuffer.hyperlinkHref === unit.hyperlinkHref &&\n haveEqualMarks(activeTextBuffer.marks, unit.marks);\n\n if (shouldExtendBuffer && activeTextBuffer) {\n activeTextBuffer.text += unit.value;\n } else {\n flushTextBuffer();\n activeTextBuffer = {\n text: unit.value,\n ...(unit.marks ? { marks: cloneMarks(unit.marks) } : {}),\n ...(unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}),\n };\n }\n\n continue;\n }\n\n switch (unit.kind) {\n case \"tab\":\n pushInlineNode({ type: \"tab\" }, unit.hyperlinkHref);\n break;\n case \"hard_break\":\n pushInlineNode({ type: \"hard_break\" }, unit.hyperlinkHref);\n break;\n case \"image\":\n pushInlineNode({\n type: \"image\",\n mediaId: unit.mediaId,\n ...(unit.altText ? { altText: unit.altText } : {}),\n });\n break;\n case \"opaque_inline\":\n pushInlineNode({\n type: \"opaque_inline\",\n fragmentId: unit.fragmentId,\n warningId: unit.warningId,\n });\n break;\n }\n }\n\n flushParagraph();\n\n if (blocks.length === 0) {\n blocks.push(createParagraph(story.firstParagraph));\n }\n\n return {\n type: \"doc\",\n children: blocks,\n };\n}\n\nexport function createPlainText(story: TextStory): string {\n return story.units\n .map((unit) => {\n switch (unit.kind) {\n case \"text\":\n return unit.value;\n case \"tab\":\n return \"\\t\";\n case \"hard_break\":\n return \"\\n\";\n case \"paragraph_break\":\n return \"\\n\";\n case \"image\":\n return \"\\uFFFC\";\n case \"opaque_inline\":\n return \"\\uFFF9\";\n case \"opaque_block\":\n return \"\\uFFFA\";\n }\n })\n .join(\"\");\n}\n\nexport function cloneStoryUnit(unit: StoryUnit): StoryUnit {\n switch (unit.kind) {\n case \"text\":\n return {\n kind: \"text\",\n value: unit.value,\n ...(unit.marks ? { marks: cloneMarks(unit.marks) } : {}),\n ...(unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}),\n };\n case \"tab\":\n return {\n kind: \"tab\",\n ...(unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}),\n };\n case \"hard_break\":\n return {\n kind: \"hard_break\",\n ...(unit.hyperlinkHref ? { hyperlinkHref: unit.hyperlinkHref } : {}),\n };\n case \"image\":\n return {\n kind: \"image\",\n mediaId: unit.mediaId,\n ...(unit.altText ? { altText: unit.altText } : {}),\n };\n case \"opaque_inline\":\n return {\n kind: \"opaque_inline\",\n fragmentId: unit.fragmentId,\n warningId: unit.warningId,\n };\n case \"opaque_block\":\n return {\n kind: \"opaque_block\",\n fragmentId: unit.fragmentId,\n warningId: unit.warningId,\n ...(unit.nextParagraph\n ? { nextParagraph: cloneParagraphProperties(unit.nextParagraph) }\n : {}),\n };\n case \"paragraph_break\":\n return {\n kind: \"paragraph_break\",\n nextParagraph: cloneParagraphProperties(unit.nextParagraph),\n };\n }\n}\n\nexport function cloneParagraphProperties(\n properties: ParagraphProperties,\n): ParagraphProperties {\n return {\n ...(properties.styleId ? { styleId: properties.styleId } : {}),\n ...(properties.numbering\n ? {\n numbering: {\n numberingInstanceId: properties.numbering.numberingInstanceId,\n level: properties.numbering.level,\n },\n }\n : {}),\n };\n}\n\nfunction normalizeDocumentRoot(content: unknown): DocumentRootNode {\n if (isDocumentRootNode(content)) {\n return content;\n }\n\n if (Array.isArray(content)) {\n return {\n type: \"doc\",\n children: content.filter(\n (block): block is DocumentRootNode[\"children\"][number] =>\n isParagraphNode(block) || isOpaqueBlockNode(block),\n ),\n };\n }\n\n return {\n type: \"doc\",\n children: [createEmptyParagraph()],\n };\n}\n\nfunction flattenInlineNodes(\n nodes: ParagraphNode[\"children\"],\n hyperlinkHref?: string,\n): StoryUnit[] {\n const units: StoryUnit[] = [];\n\n for (const node of nodes) {\n switch (node.type) {\n case \"text\":\n for (const character of Array.from(node.text)) {\n units.push({\n kind: \"text\",\n value: character,\n ...(node.marks ? { marks: cloneMarks(node.marks) } : {}),\n ...(hyperlinkHref ? { hyperlinkHref } : {}),\n });\n }\n break;\n case \"tab\":\n units.push({\n kind: \"tab\",\n ...(hyperlinkHref ? { hyperlinkHref } : {}),\n });\n break;\n case \"hard_break\":\n units.push({\n kind: \"hard_break\",\n ...(hyperlinkHref ? { hyperlinkHref } : {}),\n });\n break;\n case \"hyperlink\":\n units.push(...flattenInlineNodes(node.children, node.href));\n break;\n case \"image\":\n units.push({\n kind: \"image\",\n mediaId: node.mediaId,\n ...(node.altText ? { altText: node.altText } : {}),\n });\n break;\n case \"opaque_inline\":\n units.push({\n kind: \"opaque_inline\",\n fragmentId: node.fragmentId,\n warningId: node.warningId,\n });\n break;\n }\n }\n\n return units;\n}\n\nfunction extractParagraphProperties(paragraph: ParagraphNode): ParagraphProperties {\n return {\n ...(paragraph.styleId ? { styleId: paragraph.styleId } : {}),\n ...(paragraph.numbering\n ? {\n numbering: {\n numberingInstanceId: paragraph.numbering.numberingInstanceId,\n level: paragraph.numbering.level,\n },\n }\n : {}),\n };\n}\n\nfunction createParagraph(properties: ParagraphProperties): ParagraphNode {\n return {\n type: \"paragraph\",\n ...(properties.styleId ? { styleId: properties.styleId } : {}),\n ...(properties.numbering\n ? {\n numbering: {\n numberingInstanceId: properties.numbering.numberingInstanceId,\n level: properties.numbering.level,\n },\n }\n : {}),\n children: [],\n };\n}\n\nfunction createEmptyParagraph(): ParagraphNode {\n return {\n type: \"paragraph\",\n children: [],\n };\n}\n\nconst EMPTY_PARAGRAPH_PROPERTIES: ParagraphProperties = {};\n\nfunction cloneMarks(marks: TextMark[]): TextMark[] {\n return marks.map((mark) => ({ ...mark }));\n}\n\nfunction haveEqualMarks(left?: TextMark[], right?: TextMark[]): boolean {\n if (!left && !right) {\n return true;\n }\n\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n\n return left.every((mark, index) => mark.type === right[index]?.type);\n}\n\nfunction isDocumentRootNode(value: unknown): value is DocumentRootNode {\n return Boolean(value) && typeof value === \"object\" && (value as { type?: string }).type === \"doc\";\n}\n\nfunction isParagraphNode(value: unknown): value is ParagraphNode {\n return Boolean(value) && typeof value === \"object\" && (value as { type?: string }).type === \"paragraph\";\n}\n\nfunction isOpaqueBlockNode(value: unknown): value is OpaqueBlockNode {\n return Boolean(value) && typeof value === \"object\" && (value as { type?: string }).type === \"opaque_block\";\n}\n"],"mappings":";AAuEO,SAAS,eAAe,SAA6B;AAC1D,QAAM,OAAO,sBAAsB,OAAO;AAC1C,QAAM,qBAAqB,KAAK,SAAS,KAAK,eAAe;AAC7D,QAAM,iBAAiB,qBACnB,2BAA2B,kBAAkB,IAC7C,yBAAyB,0BAA0B;AACvD,QAAM,QAAqB,CAAC;AAE5B,WAAS,QAAQ,GAAG,QAAQ,KAAK,SAAS,QAAQ,SAAS,GAAG;AAC5D,UAAM,QAAQ,KAAK,SAAS,KAAK;AACjC,UAAM,YAAY,KAAK,SAAS,QAAQ,CAAC;AAEzC,QAAI,gBAAgB,KAAK,GAAG;AAC1B,YAAM,KAAK,GAAG,mBAAmB,MAAM,QAAQ,CAAC;AAEhD,UAAI,gBAAgB,SAAS,GAAG;AAC9B,cAAM,KAAK;AAAA,UACT,MAAM;AAAA,UACN,eAAe,2BAA2B,SAAS;AAAA,QACrD,CAAC;AAAA,MACH;AAEA;AAAA,IACF;AAEA,QAAI,MAAM,SAAS,gBAAgB;AACjC;AAAA,IACF;AAEA,UAAM,KAAK;AAAA,MACT,MAAM;AAAA,MACN,YAAY,MAAM;AAAA,MAClB,WAAW,MAAM;AAAA,MACjB,GAAI,gBAAgB,SAAS,IACzB,EAAE,eAAe,2BAA2B,S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AA4B,SAAS;AAC9F;","names":[]}
@@ -1,214 +0,0 @@
1
- import {
2
- createEditorSurfaceSnapshot
3
- } from "./chunk-EILUG3VB.js";
4
- import {
5
- createSelectionSnapshot
6
- } from "./chunk-5FN54NDH.js";
7
-
8
- // src/core/commands/structural-helpers.ts
9
- var DEFAULT_TABLE_COLUMN_WIDTH = 2400;
10
- function createNoopStructuralMutation(document, selection) {
11
- return {
12
- changed: false,
13
- document,
14
- selection
15
- };
16
- }
17
- function resolveParagraphScope(document, selection) {
18
- const root = asDocumentRoot(document);
19
- if (!root) {
20
- return null;
21
- }
22
- const surface = createEditorSurfaceSnapshot(document, selection);
23
- const selectionFrom = Math.min(selection.anchor, selection.head);
24
- const selectionTo = Math.max(selection.anchor, selection.head);
25
- for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
26
- const block = root.children[blockIndex];
27
- const surfaceBlock = surface.blocks[blockIndex];
28
- if (!surfaceBlock) {
29
- continue;
30
- }
31
- if (block.type === "paragraph" && surfaceBlock.kind === "paragraph" && selectionWithinRange(selectionFrom, selectionTo, surfaceBlock.from, surfaceBlock.to)) {
32
- return {
33
- kind: "top-level",
34
- blockIndex,
35
- paragraph: cloneParagraph(block),
36
- paragraphStart: surfaceBlock.from
37
- };
38
- }
39
- if (block.type !== "table" || surfaceBlock.kind !== "table") {
40
- continue;
41
- }
42
- for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
43
- const row = block.rows[rowIndex];
44
- const surfaceRow = surfaceBlock.rows[rowIndex];
45
- if (!surfaceRow) {
46
- continue;
47
- }
48
- for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
49
- const cell = row.cells[cellIndex];
50
- const surfaceCell = surfaceRow.cells[cellIndex];
51
- if (!surfaceCell) {
52
- continue;
53
- }
54
- for (let childIndex = 0; childIndex < cell.children.length; childIndex += 1) {
55
- const child = cell.children[childIndex];
56
- const surfaceChild = surfaceCell.content[childIndex];
57
- if (child?.type === "paragraph" && surfaceChild?.kind === "paragraph" && selectionWithinRange(selectionFrom, selectionTo, surfaceChild.from, surfaceChild.to)) {
58
- return {
59
- kind: "table-cell",
60
- tableBlockIndex: blockIndex,
61
- rowIndex,
62
- cellIndex,
63
- childIndex,
64
- paragraph: cloneParagraph(child),
65
- paragraphStart: surfaceChild.from
66
- };
67
- }
68
- }
69
- }
70
- }
71
- }
72
- return null;
73
- }
74
- function replaceParagraphScope(document, scope, replacementParagraphs) {
75
- const root = asDocumentRoot(document);
76
- if (!root) {
77
- return document;
78
- }
79
- const nextRoot = scope.kind === "top-level" ? {
80
- ...root,
81
- children: [
82
- ...root.children.slice(0, scope.blockIndex),
83
- ...replacementParagraphs,
84
- ...root.children.slice(scope.blockIndex + 1)
85
- ]
86
- } : {
87
- ...root,
88
- children: root.children.map((child, blockIndex) => {
89
- if (blockIndex !== scope.tableBlockIndex || child.type !== "table") {
90
- return child;
91
- }
92
- return {
93
- ...child,
94
- rows: child.rows.map((row, rowIndex) => {
95
- if (rowIndex !== scope.rowIndex) {
96
- return row;
97
- }
98
- return {
99
- ...row,
100
- cells: row.cells.map((cell, cellIndex) => {
101
- if (cellIndex !== scope.cellIndex) {
102
- return cell;
103
- }
104
- return {
105
- ...cell,
106
- children: [
107
- ...cell.children.slice(0, scope.childIndex),
108
- ...replacementParagraphs,
109
- ...cell.children.slice(scope.childIndex + 1)
110
- ]
111
- };
112
- })
113
- };
114
- })
115
- };
116
- })
117
- };
118
- return {
119
- ...document,
120
- content: nextRoot
121
- };
122
- }
123
- function createEmptyParagraph() {
124
- return {
125
- type: "paragraph",
126
- children: []
127
- };
128
- }
129
- function createInsertedTableBlock(rows, columns, styleId) {
130
- const safeRows = Math.max(1, Math.floor(rows));
131
- const safeColumns = Math.max(1, Math.floor(columns));
132
- const nextRows = [];
133
- for (let rowIndex = 0; rowIndex < safeRows; rowIndex += 1) {
134
- const cells = [];
135
- for (let columnIndex = 0; columnIndex < safeColumns; columnIndex += 1) {
136
- cells.push({
137
- type: "table_cell",
138
- children: [createEmptyParagraph()]
139
- });
140
- }
141
- nextRows.push({
142
- type: "table_row",
143
- cells
144
- });
145
- }
146
- return {
147
- type: "table",
148
- ...styleId ? { styleId } : {},
149
- gridColumns: Array.from({ length: safeColumns }, () => DEFAULT_TABLE_COLUMN_WIDTH),
150
- rows: nextRows
151
- };
152
- }
153
- function resolveInsertedTableStyleId(document) {
154
- const styles = document.styles?.tables;
155
- if (!styles || typeof styles !== "object") {
156
- return void 0;
157
- }
158
- return "TableGrid" in styles ? "TableGrid" : void 0;
159
- }
160
- function findTableCellParagraphSelection(document, tableBlockIndex, rowIndex, cellIndex) {
161
- const surface = createEditorSurfaceSnapshot(document, createSelectionSnapshot(0, 0));
162
- const tableBlock = surface.blocks[tableBlockIndex];
163
- if (!tableBlock || tableBlock.kind !== "table") {
164
- return null;
165
- }
166
- const paragraph = tableBlock.rows[rowIndex]?.cells[cellIndex]?.content.find(
167
- (block) => block.kind === "paragraph"
168
- );
169
- if (!paragraph || paragraph.kind !== "paragraph") {
170
- return null;
171
- }
172
- return createSelectionSnapshot(paragraph.from, paragraph.from);
173
- }
174
- function findTopLevelParagraphSelectionNearBlock(document, preferredBlockIndex) {
175
- const surface = createEditorSurfaceSnapshot(document, createSelectionSnapshot(0, 0));
176
- for (let index = preferredBlockIndex; index < surface.blocks.length; index += 1) {
177
- const block = surface.blocks[index];
178
- if (block?.kind === "paragraph") {
179
- return createSelectionSnapshot(block.from, block.from);
180
- }
181
- }
182
- for (let index = Math.min(preferredBlockIndex - 1, surface.blocks.length - 1); index >= 0; index -= 1) {
183
- const block = surface.blocks[index];
184
- if (block?.kind === "paragraph") {
185
- return createSelectionSnapshot(block.from, block.from);
186
- }
187
- }
188
- return null;
189
- }
190
- function asDocumentRoot(document) {
191
- const root = document.content;
192
- if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
193
- return null;
194
- }
195
- return root;
196
- }
197
- function selectionWithinRange(selectionFrom, selectionTo, rangeFrom, rangeTo) {
198
- return selectionFrom >= rangeFrom && selectionTo <= rangeTo;
199
- }
200
- function cloneParagraph(paragraph) {
201
- return structuredClone(paragraph);
202
- }
203
-
204
- export {
205
- createNoopStructuralMutation,
206
- resolveParagraphScope,
207
- replaceParagraphScope,
208
- createEmptyParagraph,
209
- createInsertedTableBlock,
210
- resolveInsertedTableStyleId,
211
- findTableCellParagraphSelection,
212
- findTopLevelParagraphSelectionNearBlock
213
- };
214
- //# sourceMappingURL=chunk-KZUG5KFQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/commands/structural-helpers.ts"],"sourcesContent":["import {\n createSelectionSnapshot,\n type CanonicalDocumentEnvelope,\n type SelectionSnapshot,\n} from \"../state/editor-state.ts\";\nimport type { TransactionMapping } from \"../selection/mapping.ts\";\nimport type {\n DocumentRootNode,\n ParagraphNode,\n TableCellNode,\n TableNode,\n TableRowNode,\n} from \"../../model/canonical-document.ts\";\nimport { createEditorSurfaceSnapshot } from \"../../runtime/surface-projection.ts\";\n\nexport interface TopLevelParagraphScope {\n kind: \"top-level\";\n blockIndex: number;\n paragraph: ParagraphNode;\n paragraphStart: number;\n}\n\nexport interface TableParagraphScope {\n kind: \"table-cell\";\n tableBlockIndex: number;\n rowIndex: number;\n cellIndex: number;\n childIndex: number;\n paragraph: ParagraphNode;\n paragraphStart: number;\n}\n\nexport type ParagraphScope = TopLevelParagraphScope | TableParagraphScope;\n\nexport interface StructuralMutationResult {\n changed: boolean;\n document: CanonicalDocumentEnvelope;\n selection: SelectionSnapshot;\n mapping?: TransactionMapping;\n}\n\nconst DEFAULT_TABLE_COLUMN_WIDTH = 2400;\n\nexport function createNoopStructuralMutation(\n document: CanonicalDocumentEnvelope,\n selection: SelectionSnapshot,\n): StructuralMutationResult {\n return {\n changed: false,\n document,\n selection,\n };\n}\n\nexport function resolveParagraphScope(\n document: CanonicalDocumentEnvelope,\n selection: SelectionSnapshot,\n): ParagraphScope | null {\n const root = asDocumentRoot(document);\n if (!root) {\n return null;\n }\n\n const surface = createEditorSurfaceSnapshot(document, selection);\n const selectionFrom = Math.min(selection.anchor, selection.head);\n const selectionTo = Math.max(selection.anchor, selection.head);\n\n for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {\n const block = root.children[blockIndex];\n const surfaceBlock = surface.blocks[blockIndex];\n\n if (!surfaceBlock) {\n continue;\n }\n\n if (\n block.type === \"paragraph\" &&\n surfaceBlock.kind === \"paragraph\" &&\n selectionWithinRange(selectionFrom, selectionTo, surfaceBlock.from, surfaceBlock.to)\n ) {\n return {\n kind: \"top-level\",\n blockIndex,\n paragraph: cloneParagraph(block),\n paragraphStart: surfaceBlock.from,\n };\n }\n\n if (block.type !== \"table\" || surfaceBlock.kind !== \"table\") {\n continue;\n }\n\n for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {\n const row = block.rows[rowIndex];\n const surfaceRow = surfaceBlock.rows[rowIndex];\n if (!surfaceRow) {\n continue;\n }\n\n for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {\n const cell = row.cells[cellIndex];\n const surfaceCell = surfaceRow.cells[cellIndex];\n if (!surfaceCell) {\n continue;\n }\n\n for (let childIndex = 0; childIndex < cell.children.length; childIndex += 1) {\n const child = cell.children[childIndex];\n const surfaceChild = surfaceCell.content[childIndex];\n if (\n child?.type === \"paragraph\" &&\n surfaceChild?.kind === \"paragraph\" &&\n selectionWithinRange(selectionFrom, selectionTo, surfaceChild.from, surfaceChild.to)\n ) {\n return {\n kind: \"table-cell\",\n tableBlockIndex: blockIndex,\n rowIndex,\n cellIndex,\n childIndex,\n paragraph: cloneParagraph(child),\n paragraphStart: surfaceChild.from,\n };\n }\n }\n }\n }\n }\n\n return null;\n}\n\nexport function replaceParagraphScope(\n document: CanonicalDocumentEnvelope,\n scope: ParagraphScope,\n replacementParagraphs: ParagraphNode[],\n): CanonicalDocumentEnvelope {\n const root = asDocumentRoot(document);\n if (!root) {\n return document;\n }\n\n const nextRoot: DocumentRootNode =\n scope.kind === \"top-level\"\n ? {\n ...root,\n children: [\n ...root.children.slice(0, scope.blockIndex),\n ...replacementParagraphs,\n ...root.children.slice(scope.blockIndex + 1),\n ],\n }\n : {\n ...root,\n children: root.children.map((child, blockIndex) => {\n if (blockIndex !== scope.tableBlockIndex || child.type !== \"table\") {\n return child;\n }\n\n return {\n ...child,\n rows: child.rows.map((row, rowIndex) => {\n if (rowIndex !== scope.rowIndex) {\n return row;\n }\n\n return {\n ...row,\n cells: row.cells.map((cell, cellIndex) => {\n if (cellIndex !== scope.cellIndex) {\n return cell;\n }\n\n return {\n ...cell,\n children: [\n ...cell.children.slice(0, scope.childIndex),\n ...replacementParagraphs,\n ...cell.children.slice(scope.childIndex + 1),\n ],\n };\n }),\n };\n }),\n };\n }),\n };\n\n return {\n ...document,\n content: nextRoot,\n };\n}\n\nexport function createEmptyParagraph(): ParagraphNode {\n return {\n type: \"paragraph\",\n children: [],\n };\n}\n\nexport function createInsertedTableBlock(\n rows: number,\n columns: number,\n styleId?: string,\n): TableNode {\n const safeRows = Math.max(1, Math.floor(rows));\n const safeColumns = Math.max(1, Math.floor(columns));\n const nextRows: TableRowNode[] = [];\n\n for (let rowIndex = 0; rowIndex < safeRows; rowIndex += 1) {\n const cells: TableCellNode[] = [];\n for (let columnIndex = 0; columnIndex < safeColumns; columnIndex += 1) {\n cells.push({\n type: \"table_cell\",\n children: [createEmptyParagraph()],\n });\n }\n nextRows.push({\n type: \"table_row\",\n cells,\n });\n }\n\n return {\n type: \"table\",\n ...(styleId ? { styleId } : {}),\n gridColumns: Array.from({ length: safeColumns }, () => DEFAULT_TABLE_COLUMN_WIDTH),\n rows: nextRows,\n };\n}\n\nexport function resolveInsertedTableStyleId(\n document: CanonicalDocumentEnvelope,\n): string | undefined {\n const styles = document.styles?.tables;\n if (!styles || typeof styles !== \"object\") {\n return undefined;\n }\n return \"TableGrid\" in styles ? \"TableGrid\" : undefined;\n}\n\nexport function findTableCellParagraphSelection(\n document: CanonicalDocumentEnvelope,\n tableBlockIndex: number,\n rowIndex: number,\n cellIndex: number,\n): SelectionSnapshot | null {\n const surface = createEditorSurfaceSnapshot(document, createSelectionSnapshot(0, 0));\n const tableBlock = surface.blocks[tableBlockIndex];\n if (!tableBlock || tableBlock.kind !== \"table\") {\n return null;\n }\n\n const paragraph = tableBlock.rows[rowIndex]?.cells[cellIndex]?.content.find(\n (block) => block.kind === \"paragraph\",\n );\n if (!paragraph || paragraph.kind !== \"paragraph\") {\n return null;\n }\n\n return createSelectionSnapshot(paragraph.from, paragraph.from);\n}\n\nexport function findTopLevelParagraphSelectionNearBlock(\n document: CanonicalDocumentEnvelope,\n preferredBlockIndex: number,\n): SelectionSnapshot | null {\n const surface = createEditorSurfaceSnapshot(document, createSelectionSnapshot(0, 0));\n\n for (let index = preferredBlockIndex; index < surface.blocks.length; index += 1) {\n const block = surface.blocks[index];\n if (block?.kind === \"paragraph\") {\n return createSelectionSnapshot(block.from, block.from);\n }\n }\n\n for (let index = Math.min(preferredBlockIndex - 1, surface.blocks.length - 1); index >= 0; index -= 1) {\n const block = surface.blocks[index];\n if (block?.kind === \"paragraph\") {\n return createSelectionSnapshot(block.from, block.from);\n }\n }\n\n return null;\n}\n\nfunction asDocumentRoot(\n document: CanonicalDocumentEnvelope,\n): DocumentRootNode | null {\n const root = document.content;\n if (!root || root.type !== \"doc\" || !Array.isArray(root.children)) {\n return null;\n }\n return root;\n}\n\nfunction selectionWithinRange(\n selectionFrom: number,\n selectionTo: number,\n rangeFrom: number,\n rangeTo: number,\n): boolean {\n return selectionFrom >= rangeFrom && selectionTo <= rangeTo;\n}\n\nfunction cloneParagraph(paragraph: ParagraphNode): ParagraphNode {\n return structuredClone(paragraph) as ParagraphNode;\n}\n"],"mappings":";;;;;;;;AAyCA,IAAM,6BAA6B;AAE5B,SAAS,6BACd,UACA,WAC0B;AAC1B,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,sBACd,UACA,WACuB;AACvB,QAAM,OA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