edytor 0.0.11 → 0.1.0-next.16

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 (371) hide show
  1. package/README.md +77 -197
  2. package/dist/block/block.svelte.d.ts +156 -69
  3. package/dist/block/block.svelte.js +324 -355
  4. package/dist/block/block.utils.d.ts +191 -24
  5. package/dist/block/block.utils.js +327 -460
  6. package/dist/block/contentRange.d.ts +4 -0
  7. package/dist/block/contentRange.js +20 -0
  8. package/dist/block/inlineBlock.svelte.d.ts +26 -19
  9. package/dist/block/inlineBlock.svelte.js +91 -39
  10. package/dist/clipboard/clipboard.d.ts +4 -0
  11. package/dist/clipboard/clipboard.js +4 -0
  12. package/dist/clipboard/createClipboardFragment.d.ts +3 -0
  13. package/dist/clipboard/createClipboardFragment.js +103 -0
  14. package/dist/clipboard/fragmentData.d.ts +6 -0
  15. package/dist/clipboard/fragmentData.js +74 -0
  16. package/dist/clipboard/htmlFlow.d.ts +22 -0
  17. package/dist/clipboard/htmlFlow.js +167 -0
  18. package/dist/clipboard/insertClipboardFragment.d.ts +18 -0
  19. package/dist/clipboard/insertClipboardFragment.js +48 -0
  20. package/dist/clipboard/serializeClipboardFragment.d.ts +7 -0
  21. package/dist/clipboard/serializeClipboardFragment.js +53 -0
  22. package/dist/clipboard/textBlocks.d.ts +23 -0
  23. package/dist/clipboard/textBlocks.js +103 -0
  24. package/dist/clipboard/types.d.ts +20 -0
  25. package/dist/clipboard/types.js +2 -0
  26. package/dist/cloudflare/DocumentRoom.d.ts +586 -0
  27. package/dist/cloudflare/DocumentRoom.js +1706 -0
  28. package/dist/cloudflare/index.d.ts +8 -0
  29. package/dist/cloudflare/index.js +8 -0
  30. package/dist/cloudflare/routeDocumentSocket.d.ts +33 -0
  31. package/dist/cloudflare/routeDocumentSocket.js +51 -0
  32. package/dist/collaboration/RemoteSelections.svelte +94 -0
  33. package/dist/collaboration/RemoteSelections.svelte.d.ts +7 -0
  34. package/dist/collaboration/awarenessSelection.d.ts +127 -0
  35. package/dist/collaboration/awarenessSelection.js +199 -0
  36. package/dist/collaboration/documentSync.d.ts +20 -0
  37. package/dist/collaboration/documentSync.js +13 -0
  38. package/dist/collaboration/index.d.ts +3 -0
  39. package/dist/collaboration/index.js +3 -0
  40. package/dist/collaboration/providers.d.ts +13 -0
  41. package/dist/collaboration/providers.js +21 -0
  42. package/dist/collaboration/remoteSelection.d.ts +21 -0
  43. package/dist/collaboration/remoteSelection.js +159 -0
  44. package/dist/components/Block.svelte +223 -15
  45. package/dist/components/Block.svelte.d.ts +4 -2
  46. package/dist/components/Content.svelte +128 -32
  47. package/dist/components/Content.svelte.d.ts +6 -2
  48. package/dist/components/Edytor.svelte +308 -110
  49. package/dist/components/Edytor.svelte.d.ts +64 -20
  50. package/dist/components/InlineBlock.svelte +38 -7
  51. package/dist/components/InlineBlock.svelte.d.ts +5 -2
  52. package/dist/components/Mark.svelte +29 -13
  53. package/dist/components/Mark.svelte.d.ts +4 -4
  54. package/dist/components/Suggestion.svelte +48 -0
  55. package/dist/components/Suggestion.svelte.d.ts +7 -0
  56. package/dist/components/SuggestionRanges.svelte +58 -0
  57. package/dist/components/SuggestionRanges.svelte.d.ts +7 -0
  58. package/dist/components/Text.svelte +107 -14
  59. package/dist/components/Text.svelte.d.ts +8 -1
  60. package/dist/constants.d.ts +0 -2
  61. package/dist/constants.js +0 -2
  62. package/dist/crdt/admission.d.ts +141 -0
  63. package/dist/crdt/admission.js +147 -0
  64. package/dist/crdt/anchors.d.ts +47 -0
  65. package/dist/crdt/anchors.js +42 -0
  66. package/dist/crdt/attribution/attribution.d.ts +169 -0
  67. package/dist/crdt/attribution/attribution.js +136 -0
  68. package/dist/crdt/attribution/block.d.ts +200 -0
  69. package/dist/crdt/attribution/block.js +327 -0
  70. package/dist/crdt/attribution/index.d.ts +9 -0
  71. package/dist/crdt/attribution/index.js +9 -0
  72. package/dist/crdt/data.d.ts +81 -0
  73. package/dist/crdt/data.js +383 -0
  74. package/dist/crdt/document.d.ts +590 -0
  75. package/dist/crdt/document.js +1160 -0
  76. package/dist/crdt/edytor-doc.d.ts +752 -0
  77. package/dist/crdt/edytor-doc.js +2382 -0
  78. package/dist/crdt/engine-api.d.ts +153 -0
  79. package/dist/crdt/engine.d.ts +37 -0
  80. package/dist/crdt/engine.js +50 -0
  81. package/dist/crdt/flow.d.ts +104 -0
  82. package/dist/crdt/flow.js +229 -0
  83. package/dist/crdt/index.d.ts +630 -0
  84. package/dist/crdt/index.js +168 -0
  85. package/dist/crdt/migration/legacy-schema.d.ts +61 -0
  86. package/dist/crdt/migration/legacy-schema.js +149 -0
  87. package/dist/crdt/migration/migrate.d.ts +67 -0
  88. package/dist/crdt/migration/migrate.js +219 -0
  89. package/dist/crdt/nodes.d.ts +120 -0
  90. package/dist/crdt/nodes.js +56 -0
  91. package/dist/crdt/placement/model.d.ts +383 -0
  92. package/dist/crdt/placement/model.js +811 -0
  93. package/dist/crdt/placement/rank.d.ts +57 -0
  94. package/dist/crdt/placement/rank.js +209 -0
  95. package/dist/crdt/protocols/auth.d.ts +28 -0
  96. package/dist/crdt/protocols/auth.js +43 -0
  97. package/dist/crdt/protocols/awareness.d.ts +87 -0
  98. package/dist/crdt/protocols/awareness.js +271 -0
  99. package/dist/crdt/protocols/envelope.d.ts +75 -0
  100. package/dist/crdt/protocols/envelope.js +89 -0
  101. package/dist/crdt/protocols/observable.d.ts +19 -0
  102. package/dist/crdt/protocols/observable.js +26 -0
  103. package/dist/crdt/protocols/sync.d.ts +82 -0
  104. package/dist/crdt/protocols/sync.js +288 -0
  105. package/dist/crdt/providers/container.d.ts +23 -0
  106. package/dist/crdt/providers/container.js +64 -0
  107. package/dist/crdt/providers/index.d.ts +282 -0
  108. package/dist/crdt/providers/index.js +118 -0
  109. package/dist/crdt/providers/indexeddb.d.ts +196 -0
  110. package/dist/crdt/providers/indexeddb.js +332 -0
  111. package/dist/crdt/providers/room.d.ts +193 -0
  112. package/dist/crdt/providers/room.js +444 -0
  113. package/dist/crdt/providers/websocket.d.ts +223 -0
  114. package/dist/crdt/providers/websocket.js +601 -0
  115. package/dist/crdt/rand.d.ts +22 -0
  116. package/dist/crdt/rand.js +22 -0
  117. package/dist/crdt/rangeDelete.d.ts +85 -0
  118. package/dist/crdt/rangeDelete.js +126 -0
  119. package/dist/crdt/schema.d.ts +96 -0
  120. package/dist/crdt/schema.js +79 -0
  121. package/dist/crdt/semantics.d.ts +81 -0
  122. package/dist/crdt/semantics.js +57 -0
  123. package/dist/crdt/structs.d.ts +106 -0
  124. package/dist/crdt/structs.js +119 -0
  125. package/dist/crdt/text/deletes.d.ts +23 -0
  126. package/dist/crdt/text/deletes.js +608 -0
  127. package/dist/crdt/text/model.d.ts +280 -0
  128. package/dist/crdt/text/model.js +554 -0
  129. package/dist/crdt/text/runs.d.ts +212 -0
  130. package/dist/crdt/text/runs.js +1142 -0
  131. package/dist/crdt/vendor/yjs/API-NOTES.md +59 -0
  132. package/dist/crdt/vendor/yjs/LICENSE +23 -0
  133. package/dist/crdt/vendor/yjs/UPSTREAM.md +653 -0
  134. package/dist/crdt/vendor/yjs/dts/global.d.ts +52 -0
  135. package/dist/crdt/vendor/yjs/dts/index.d.ts +25 -0
  136. package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +38 -0
  137. package/dist/crdt/vendor/yjs/dts/structs/GC.d.ts +25 -0
  138. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +748 -0
  139. package/dist/crdt/vendor/yjs/dts/structs/Skip.d.ts +30 -0
  140. package/dist/crdt/vendor/yjs/dts/utils/BlockSet.d.ts +34 -0
  141. package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +198 -0
  142. package/dist/crdt/vendor/yjs/dts/utils/EventHandler.d.ts +17 -0
  143. package/dist/crdt/vendor/yjs/dts/utils/ID.d.ts +20 -0
  144. package/dist/crdt/vendor/yjs/dts/utils/RangeCursor.d.ts +198 -0
  145. package/dist/crdt/vendor/yjs/dts/utils/RelativePosition.d.ts +80 -0
  146. package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +61 -0
  147. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +129 -0
  148. package/dist/crdt/vendor/yjs/dts/utils/UndoManager.d.ts +205 -0
  149. package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +170 -0
  150. package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +164 -0
  151. package/dist/crdt/vendor/yjs/dts/utils/YEvent.d.ts +93 -0
  152. package/dist/crdt/vendor/yjs/dts/utils/content-helper.d.ts +1 -0
  153. package/dist/crdt/vendor/yjs/dts/utils/encoding-helpers.d.ts +5 -0
  154. package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +26 -0
  155. package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +407 -0
  156. package/dist/crdt/vendor/yjs/dts/utils/isParentOf.d.ts +1 -0
  157. package/dist/crdt/vendor/yjs/dts/utils/meta.d.ts +25 -0
  158. package/dist/crdt/vendor/yjs/dts/utils/renderer-helpers.d.ts +98 -0
  159. package/dist/crdt/vendor/yjs/dts/utils/schemas.d.ts +2 -0
  160. package/dist/crdt/vendor/yjs/dts/utils/transaction-helpers.d.ts +15 -0
  161. package/dist/crdt/vendor/yjs/dts/utils/updates.d.ts +70 -0
  162. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +655 -0
  163. package/dist/crdt/vendor/yjs/global.d.ts +52 -0
  164. package/dist/crdt/vendor/yjs/src/index.js +64 -0
  165. package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +64 -0
  166. package/dist/crdt/vendor/yjs/src/structs/GC.js +75 -0
  167. package/dist/crdt/vendor/yjs/src/structs/Item.js +1538 -0
  168. package/dist/crdt/vendor/yjs/src/structs/Skip.js +72 -0
  169. package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +291 -0
  170. package/dist/crdt/vendor/yjs/src/utils/Doc.js +255 -0
  171. package/dist/crdt/vendor/yjs/src/utils/EventHandler.js +75 -0
  172. package/dist/crdt/vendor/yjs/src/utils/ID.js +59 -0
  173. package/dist/crdt/vendor/yjs/src/utils/RangeCursor.js +407 -0
  174. package/dist/crdt/vendor/yjs/src/utils/RelativePosition.js +301 -0
  175. package/dist/crdt/vendor/yjs/src/utils/StructStore.js +134 -0
  176. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +458 -0
  177. package/dist/crdt/vendor/yjs/src/utils/UndoManager.js +554 -0
  178. package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +284 -0
  179. package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +323 -0
  180. package/dist/crdt/vendor/yjs/src/utils/YEvent.js +158 -0
  181. package/dist/crdt/vendor/yjs/src/utils/content-helper.js +0 -0
  182. package/dist/crdt/vendor/yjs/src/utils/encoding-helpers.js +110 -0
  183. package/dist/crdt/vendor/yjs/src/utils/encoding.js +662 -0
  184. package/dist/crdt/vendor/yjs/src/utils/ids.js +1504 -0
  185. package/dist/crdt/vendor/yjs/src/utils/isParentOf.js +19 -0
  186. package/dist/crdt/vendor/yjs/src/utils/meta.js +74 -0
  187. package/dist/crdt/vendor/yjs/src/utils/renderer-helpers.js +186 -0
  188. package/dist/crdt/vendor/yjs/src/utils/schemas.js +3 -0
  189. package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +391 -0
  190. package/dist/crdt/vendor/yjs/src/utils/updates.js +264 -0
  191. package/dist/crdt/vendor/yjs/src/ynode.js +2897 -0
  192. package/dist/dnd/pragmatic.d.ts +22 -0
  193. package/dist/dnd/pragmatic.js +26 -0
  194. package/dist/edytor.svelte.d.ts +323 -54
  195. package/dist/edytor.svelte.js +771 -197
  196. package/dist/edytor.utils.d.ts +49 -2
  197. package/dist/edytor.utils.js +65 -76
  198. package/dist/events/beforeInputCommands.d.ts +21 -0
  199. package/dist/events/beforeInputCommands.js +328 -0
  200. package/dist/events/beforeInputDeleteCommands.d.ts +3 -0
  201. package/dist/events/beforeInputDeleteCommands.js +245 -0
  202. package/dist/events/dataTransferPayload.d.ts +6 -0
  203. package/dist/events/dataTransferPayload.js +9 -0
  204. package/dist/events/domTextOffset.d.ts +12 -0
  205. package/dist/events/domTextOffset.js +52 -0
  206. package/dist/events/events.utils.d.ts +3 -0
  207. package/dist/events/events.utils.js +13 -0
  208. package/dist/events/nativeInteractiveControl.d.ts +31 -0
  209. package/dist/events/nativeInteractiveControl.js +98 -0
  210. package/dist/events/onBeforeInput.d.ts +10 -1
  211. package/dist/events/onBeforeInput.js +449 -330
  212. package/dist/events/onCopy.d.ts +7 -0
  213. package/dist/events/onCopy.js +30 -0
  214. package/dist/events/onCut.d.ts +8 -0
  215. package/dist/events/onCut.js +13 -0
  216. package/dist/events/onDrop.d.ts +16 -0
  217. package/dist/events/onDrop.js +158 -0
  218. package/dist/events/onFocus.d.ts +4 -0
  219. package/dist/events/onFocus.js +166 -0
  220. package/dist/events/onInput.d.ts +20 -0
  221. package/dist/events/onInput.js +249 -0
  222. package/dist/events/onKeyDown.js +191 -11
  223. package/dist/events/onPaste.d.ts +3 -0
  224. package/dist/events/onPaste.js +108 -0
  225. package/dist/events/wordBoundary.d.ts +2 -0
  226. package/dist/events/wordBoundary.js +58 -0
  227. package/dist/index.d.ts +38 -1
  228. package/dist/index.js +36 -1
  229. package/dist/kinds.d.ts +100 -0
  230. package/dist/kinds.js +198 -0
  231. package/dist/plugins/arrowMove/arrowMove.d.ts +1 -1
  232. package/dist/plugins/arrowMove/arrowMove.js +30 -65
  233. package/dist/plugins/blockHandles/BlockHandle.svelte +152 -0
  234. package/dist/plugins/blockHandles/BlockHandle.svelte.d.ts +12 -0
  235. package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +208 -0
  236. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +823 -0
  237. package/dist/plugins/blockHandles/BlockHandles.svelte +151 -0
  238. package/dist/plugins/blockHandles/BlockHandles.svelte.d.ts +20 -0
  239. package/dist/plugins/blockHandles/autoScroll.d.ts +8 -0
  240. package/dist/plugins/blockHandles/autoScroll.js +25 -0
  241. package/dist/plugins/blockHandles/blockHandlesPlugin.d.ts +37 -0
  242. package/dist/plugins/blockHandles/blockHandlesPlugin.js +100 -0
  243. package/dist/plugins/blockHandles/dragPreview.d.ts +33 -0
  244. package/dist/plugins/blockHandles/dragPreview.js +228 -0
  245. package/dist/plugins/blockMenu/BlockMenu.svelte +301 -0
  246. package/dist/plugins/blockMenu/BlockMenu.svelte.d.ts +9 -0
  247. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +102 -0
  248. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +245 -0
  249. package/dist/plugins/blockMenu/blockMenuPlugin.d.ts +11 -0
  250. package/dist/plugins/blockMenu/blockMenuPlugin.js +89 -0
  251. package/dist/plugins/code/CodePlugin.svelte +210 -163
  252. package/dist/plugins/code/CodePlugin.svelte.d.ts +1 -3
  253. package/dist/plugins/code/code.css +92 -0
  254. package/dist/plugins/icons.d.ts +2 -0
  255. package/dist/plugins/icons.js +31 -0
  256. package/dist/plugins/image/ImageEmpty.svelte +69 -0
  257. package/dist/plugins/image/ImageEmpty.svelte.d.ts +8 -0
  258. package/dist/plugins/image/ImagePlugin.svelte +74 -12
  259. package/dist/plugins/image/ImagePlugin.svelte.d.ts +15 -0
  260. package/dist/plugins/image/image.d.ts +2 -0
  261. package/dist/plugins/image/image.js +7 -0
  262. package/dist/plugins/index.d.ts +14 -1
  263. package/dist/plugins/index.js +10 -1
  264. package/dist/plugins/keepInView.d.ts +4 -0
  265. package/dist/plugins/keepInView.js +6 -0
  266. package/dist/plugins/markdownShortcuts.d.ts +3 -0
  267. package/dist/plugins/markdownShortcuts.js +104 -0
  268. package/dist/plugins/mention/MentionPlugin.svelte +28 -31
  269. package/dist/plugins/richtext/RichTextPlugin.svelte +411 -200
  270. package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +8 -7
  271. package/dist/plugins/richtext/richTextOperations.d.ts +53 -0
  272. package/dist/plugins/richtext/richTextOperations.js +200 -0
  273. package/dist/plugins/slashMenu/SlashMenu.svelte +297 -0
  274. package/dist/plugins/slashMenu/SlashMenu.svelte.d.ts +11 -0
  275. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +56 -0
  276. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +275 -0
  277. package/dist/plugins/slashMenu/slashMenuPlugin.d.ts +25 -0
  278. package/dist/plugins/slashMenu/slashMenuPlugin.js +105 -0
  279. package/dist/plugins/suggestions/SuggestionBars.svelte +142 -0
  280. package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +10 -0
  281. package/dist/plugins/suggestions/suggestionsPlugin.d.ts +28 -0
  282. package/dist/plugins/suggestions/suggestionsPlugin.js +53 -0
  283. package/dist/plugins/toolbar/Toolbar.svelte +341 -0
  284. package/dist/plugins/toolbar/Toolbar.svelte.d.ts +9 -0
  285. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +85 -0
  286. package/dist/plugins/toolbar/ToolbarController.svelte.js +150 -0
  287. package/dist/plugins/toolbar/toolbarPlugin.d.ts +16 -0
  288. package/dist/plugins/toolbar/toolbarPlugin.js +40 -0
  289. package/dist/plugins.d.ts +249 -40
  290. package/dist/plugins.js +11 -5
  291. package/dist/selection/domSelection.d.ts +29 -0
  292. package/dist/selection/domSelection.js +230 -0
  293. package/dist/selection/replaceSelection.d.ts +143 -0
  294. package/dist/selection/replaceSelection.js +316 -0
  295. package/dist/selection/selection.svelte.d.ts +275 -37
  296. package/dist/selection/selection.svelte.js +1162 -331
  297. package/dist/selection/selection.utils.d.ts +35 -4
  298. package/dist/selection/selection.utils.js +309 -100
  299. package/dist/selection/visibility.d.ts +88 -0
  300. package/dist/selection/visibility.js +140 -0
  301. package/dist/session/attempt.d.ts +190 -0
  302. package/dist/session/attempt.js +188 -0
  303. package/dist/session/bindings.d.ts +16 -0
  304. package/dist/session/bindings.js +262 -0
  305. package/dist/session/commands.d.ts +158 -0
  306. package/dist/session/commands.js +601 -0
  307. package/dist/session/composition.svelte.d.ts +114 -0
  308. package/dist/session/composition.svelte.js +489 -0
  309. package/dist/session/editing/text.d.ts +33 -0
  310. package/dist/session/editing/text.js +36 -0
  311. package/dist/session/handles.d.ts +63 -0
  312. package/dist/session/handles.js +123 -0
  313. package/dist/session/history.d.ts +49 -0
  314. package/dist/session/history.js +131 -0
  315. package/dist/session/keymap.d.ts +42 -0
  316. package/dist/session/keymap.js +144 -0
  317. package/dist/session/moves.d.ts +32 -0
  318. package/dist/session/moves.js +116 -0
  319. package/dist/session/navigation.d.ts +51 -0
  320. package/dist/session/navigation.js +312 -0
  321. package/dist/session/props.d.ts +28 -0
  322. package/dist/session/props.js +162 -0
  323. package/dist/session/selection.d.ts +126 -0
  324. package/dist/session/selection.js +227 -0
  325. package/dist/session/suggestions.svelte.d.ts +125 -0
  326. package/dist/session/suggestions.svelte.js +329 -0
  327. package/dist/session/virtual.d.ts +33 -0
  328. package/dist/session/virtual.js +182 -0
  329. package/dist/surface/attributes.d.ts +36 -0
  330. package/dist/surface/attributes.js +143 -0
  331. package/dist/surface/cells.d.ts +103 -0
  332. package/dist/surface/cells.js +215 -0
  333. package/dist/surface/observer.svelte.d.ts +70 -0
  334. package/dist/surface/observer.svelte.js +969 -0
  335. package/dist/surface/overlay.d.ts +33 -0
  336. package/dist/surface/overlay.js +91 -0
  337. package/dist/surface/pin.svelte.d.ts +56 -0
  338. package/dist/surface/pin.svelte.js +108 -0
  339. package/dist/surface/projector.svelte.d.ts +69 -0
  340. package/dist/surface/projector.svelte.js +486 -0
  341. package/dist/text/deltas.d.ts +14 -3
  342. package/dist/text/deltas.js +27 -90
  343. package/dist/text/text.svelte.d.ts +43 -31
  344. package/dist/text/text.svelte.js +88 -69
  345. package/dist/text/text.utils.d.ts +7 -2
  346. package/dist/text/text.utils.js +121 -97
  347. package/dist/themes/notion.css +473 -0
  348. package/dist/utils/diffText.d.ts +15 -0
  349. package/dist/utils/diffText.js +26 -0
  350. package/dist/utils/json.d.ts +90 -3
  351. package/dist/utils/json.js +369 -2
  352. package/dist/utils.d.ts +3 -1
  353. package/dist/utils.js +2 -0
  354. package/package.json +112 -50
  355. package/dist/block/content.svelte.d.ts +0 -14
  356. package/dist/block/content.svelte.js +0 -40
  357. package/dist/components/ReadonlyEditor.svelte +0 -46
  358. package/dist/components/ReadonlyEditor.svelte.d.ts +0 -4
  359. package/dist/components/readonlyElements.svelte.d.ts +0 -82
  360. package/dist/components/readonlyElements.svelte.js +0 -144
  361. package/dist/dnd.svelte.d.ts +0 -17
  362. package/dist/dnd.svelte.js +0 -125
  363. package/dist/hotkeys.d.ts +0 -27
  364. package/dist/hotkeys.js +0 -282
  365. package/dist/localProvider.d.ts +0 -82
  366. package/dist/localProvider.js +0 -267
  367. package/dist/plugins/code/prism.css +0 -141
  368. package/dist/utils/jsx.d.ts +0 -25
  369. package/dist/utils/jsx.js +0 -66
  370. package/dist/utils/serialize.js +0 -1
  371. /package/dist/{utils/serialize.d.ts → crdt/engine-api.js} +0 -0
@@ -1,11 +1,57 @@
1
- import { Block } from './block.svelte.js';
2
- import { Text } from '../text/text.svelte.js';
3
- import type { JSONBlock, JSONInlineBlock, JSONText } from '../utils/json.js';
1
+ /**
2
+ * View-side command adapter for block operations (U2 delegation contract).
3
+ *
4
+ * These functions are the `BlockOperations` layer bound onto `Block` via
5
+ * `batch()`, which dispatches each call as a command (admission, plugin
6
+ * interception, one transaction: `session/commands.ts`). The functions own
7
+ * path/offset resolution (target paths → parent blocks, a text's `segStart`,
8
+ * sibling lookup for `nestBlock`), the plan of an operation
9
+ * that is one document op (`prepare*`) and its normalization requests.
10
+ *
11
+ * OPERATIONS READ AND WRITE ONLY THE DOCUMENT (R3): `Block`/`Text` are id-only
12
+ * handles whose getters read the index (R4), so what a caller needs after the
13
+ * write (the new block, the text after an inserted atom, the caret a range op
14
+ * decided) is the op's document result as a handle (`batch`'s `resolve`) —
15
+ * inside an outer transaction too.
16
+ *
17
+ * STRUCTURAL PERMISSION IS DOCUMENT-OWNED: every op delegates to
18
+ * `block.model.*` (the facade through `DocBlock`) and treats a `refused` result
19
+ * as "refused" — no view-side re-checks of the rules the document already
20
+ * enforces (island sealing, void/island destinations, own-subtree moves,
21
+ * merges across island boundaries; see `edytor-doc.ts` `canPlace` and
22
+ * `canMerge`, R5). Removing a view-side semantic guard must never
23
+ * change document behavior — if a rule matters here it belongs in the
24
+ * facade, not in this file.
25
+ *
26
+ * Content preparation produces `BlockSpec`/`ContentItem` DIRECTLY from
27
+ * JSON (`jsonBlockToSpec`/`jsonContentToItems` in `utils/json.ts`): specs are
28
+ * data (K5: `new Block({block})` is gone). The live-content invariant
29
+ * (text-first/text-last, no adjacent same-kind parts) is derived by the
30
+ * document's projection on read, so stored content needs no
31
+ * pre-normalization.
32
+ */
33
+ import type { Block } from './block.svelte.js';
34
+ import type { Text } from '../text/text.svelte.js';
35
+ import type { Flow, FlowTarget } from '../crdt/flow.js';
36
+ import type { Plan, Prepared } from '../crdt/edytor-doc.js';
37
+ import type { DataPatch } from '../crdt/data.js';
38
+ import type { ResolvedAt } from '../session/suggestions.svelte.js';
39
+ import { type JSONBlock, type JSONInlineBlock, type JSONText } from '../utils/json.js';
4
40
  import { InlineBlock } from './inlineBlock.svelte.js';
5
41
  export type BlockOperations = {
6
42
  removeInlineBlock: {
7
43
  index: number;
8
44
  };
45
+ /**
46
+ * Patch the block's `data` (with `atom`, that inline atom's; on the root,
47
+ * the document's), in order: each patch sets the value at its path, or
48
+ * deletes it when it has no `value`. `block.data`'s proxy, `setData` and
49
+ * `atom.setData` issue it.
50
+ */
51
+ patchData: {
52
+ ops: DataPatch[];
53
+ atom?: string;
54
+ };
9
55
  addChildBlock: {
10
56
  block: JSONBlock;
11
57
  index: number;
@@ -24,15 +70,18 @@ export type BlockOperations = {
24
70
  index: number;
25
71
  text: Text;
26
72
  };
73
+ /** A copy of the block and its subtree right after it, under fresh ids. */
74
+ duplicateBlock: {};
75
+ /** The children take the block's slot unless `keepChildren: false` (the whole subtree). */
27
76
  removeBlock: {
28
- keepChildren: boolean;
77
+ keepChildren?: boolean;
29
78
  };
30
79
  unNestBlock: {};
31
80
  mergeBlockBackward: {};
32
81
  mergeBlockForward: {};
33
82
  nestBlock: {};
34
83
  setBlock: {
35
- value: JSONBlock;
84
+ value: Partial<JSONBlock>;
36
85
  };
37
86
  addInlineBlock: {
38
87
  index: number;
@@ -42,41 +91,159 @@ export type BlockOperations = {
42
91
  moveBlock: {
43
92
  path: number[];
44
93
  };
94
+ moveBlocks: {
95
+ blocks: Block[];
96
+ path: number[];
97
+ };
45
98
  pushContentIntoBlock: {
46
99
  value: (Text | InlineBlock)[];
47
100
  };
48
- deleteContentForward: {
49
- text: Text;
50
- };
51
101
  normalizeContent: {};
102
+ normalizeChildren: {};
103
+ /** @deprecated `edytor.suggestions.add({ end: block.id }, …)`. */
52
104
  suggestText: {
53
105
  value: (JSONText | JSONInlineBlock)[] | string | null;
54
106
  };
107
+ /** @deprecated `suggestion.accept()`; the command hooks see is `acceptSuggestion`. */
55
108
  acceptSuggestedText: {};
109
+ /** A suggestion placed in the document (`edytor.suggestions`, `suggestion.accept()`). */
110
+ acceptSuggestion: {
111
+ suggestion: {
112
+ id: string;
113
+ at: ResolvedAt;
114
+ content: readonly JSONBlock[];
115
+ };
116
+ };
56
117
  deleteContentAtRange: {
57
118
  start: [number, number];
58
119
  end: [number, number];
59
120
  };
60
- deleteContentWithinSelection: {};
121
+ deleteContentWithinSelection: {
122
+ replace?: boolean;
123
+ };
124
+ insertFlow: {
125
+ flow: Flow;
126
+ target: FlowTarget;
127
+ };
128
+ deleteBlocks: {
129
+ blocks: Block[];
130
+ };
131
+ /** A divider at the caret: its steps are the conversion, insertion or split it plans. */
132
+ insertDivider: {};
61
133
  };
62
- export declare function batch<T extends (...args: any[]) => any, O extends keyof BlockOperations>(operation: O, func: T): T;
134
+ /**
135
+ * Bind an operation onto its wrapper: every call is dispatched as a command
136
+ * (`session/commands.ts`): admission, hooks before any write (on the command
137
+ * and, when `prepare` answers one document plan, on each planned step), one
138
+ * transaction, normalization, the result. `func` receives the prepared plan
139
+ * and answers the op's document result; `resolve` turns it into wrappers
140
+ * after the commit patched them.
141
+ */
142
+ export declare function batch<T extends (...args: any[]) => any, O extends keyof BlockOperations, R = ReturnType<T>>(operation: O, func: T, prepare?: (payload: BlockOperations[O]) => Prepared, resolve?: (this: any, out: ReturnType<T> | undefined, payload: Parameters<T>[0]) => R): (...args: Parameters<T>) => R;
143
+ /**
144
+ * The handle of block `id` (null: refused at preparation, or gone; undefined:
145
+ * the command did not run). Inside an outer transaction too: the index shows
146
+ * the block that transaction created.
147
+ */
148
+ export declare function blockOf(this: Block, id: string | null | undefined): Block | null | undefined;
149
+ /**
150
+ * Dispatch `operation` on `block` as the one plan `prepare` answers (a
151
+ * composed command: hooks see it and each planned step, one transaction).
152
+ * `then` runs in that transaction once the plan applied, with the payload
153
+ * hooks left. Answers the applied plan, or null when refused.
154
+ */
155
+ export declare const dispatchPlan: <O extends keyof BlockOperations>(block: Block, operation: O, payload: BlockOperations[O], prepare: (payload: BlockOperations[O]) => Prepared, touched?: (Block | null | undefined)[], then?: (payload: BlockOperations[O]) => void) => Plan | null;
156
+ /** One child at `index` (a default-kind block without `block`); see {@link addChildBlocks}. */
63
157
  export declare function addChildBlock(this: Block, { block, index }: BlockOperations['addChildBlock']): Block;
158
+ /** Children at `index`, clamped to the child list (at its end by default); ids kept or minted. */
64
159
  export declare function addChildBlocks(this: Block, { blocks, index }: BlockOperations['addChildBlocks']): Block[];
65
- export declare function insertBlockAfter(this: Block, { block }: BlockOperations['insertBlockAfter']): Block | null;
66
- export declare function insertBlockBefore(this: Block, { block }: BlockOperations['insertBlockBefore']): Block | null;
67
- export declare function splitBlock(this: Block, { index, text }: BlockOperations['splitBlock']): Block | null;
68
- export declare function removeBlock(this: Block, { keepChildren }?: BlockOperations['removeBlock']): void;
69
- export declare function mergeBlockBackward(this: Block): Block | null;
70
- export declare function mergeBlockForward(this: Block): Block | null;
71
- export declare function moveBlock(this: Block, { path }: BlockOperations['moveBlock']): Block | null;
72
- export declare function unNestBlock(this: Block): Block | null;
73
- export declare function nestBlock(this: Block): Block | null;
74
- export declare function setBlock(this: Block, { value }: BlockOperations['setBlock']): void;
160
+ export declare function prepareInsertAfter(this: Block, { block }: {
161
+ block: JSONBlock;
162
+ }): Prepared;
163
+ export declare function prepareInsertBefore(this: Block, { block }: {
164
+ block: JSONBlock;
165
+ }): Prepared;
166
+ export declare function insertBlockAfter(this: Block, payload: BlockOperations['insertBlockAfter'], plan?: Prepared): string | null;
167
+ export declare function insertBlockBefore(this: Block, payload: BlockOperations['insertBlockBefore'], plan?: Prepared): string | null;
168
+ export declare function prepareDuplicate(this: Block): Prepared;
169
+ export declare function duplicateBlock(this: Block, _?: BlockOperations['duplicateBlock'], plan?: Prepared): string | null;
170
+ export declare function prepareSplit(this: Block, { index, text }: BlockOperations['splitBlock']): Prepared;
171
+ /**
172
+ * A split whose children stay with the block (a container's header): the
173
+ * tail, of `tail`'s kind, becomes the block's first child (`child`) or its
174
+ * next sibling. One plan: the document's split step, placed here, without
175
+ * the move that gives the tail the children.
176
+ */
177
+ export declare function prepareSplitKeepingChildren(this: Block, { index, text }: BlockOperations['splitBlock'], tail: {
178
+ type: string;
179
+ data?: Record<string, unknown>;
180
+ }, child: boolean): Prepared;
181
+ export declare function splitBlock(this: Block, payload: BlockOperations['splitBlock'], plan?: Prepared): string | null;
182
+ export declare function prepareRemove(this: Block, { keepChildren }?: {
183
+ keepChildren?: boolean;
184
+ }): Prepared;
185
+ export declare function removeBlock(this: Block, payload?: BlockOperations['removeBlock'], plan?: Prepared): void;
186
+ export declare function prepareMergeBackward(this: Block): Prepared;
187
+ export declare function prepareMergeForward(this: Block): Prepared;
188
+ export declare function mergeBlockBackward(this: Block, _?: BlockOperations['mergeBlockBackward'], plan?: Prepared): string | null;
189
+ export declare function mergeBlockForward(this: Block, _?: BlockOperations['mergeBlockForward'], plan?: Prepared): string | null;
190
+ export declare function prepareMove(this: Block, { path }: BlockOperations['moveBlock']): Prepared;
191
+ export declare function moveBlock(this: Block, payload: BlockOperations['moveBlock'], plan?: Prepared): Block | null;
192
+ /**
193
+ * Grouped move — the operation-layer counterpart of `moveBlock` for
194
+ * drags/multi-moves (D5). `path` is the same view-tree address shape:
195
+ * the prefix resolves the destination PARENT block, the last element is
196
+ * the FINAL index — already discounted for the moved members by the
197
+ * caller (the `facade.moveBlocks` contract, which counts the
198
+ * destination's children with the moved members excluded). Structural
199
+ * permission stays in the facade.
200
+ */
201
+ export declare function prepareMoves(this: Block, { blocks, path }: BlockOperations['moveBlocks']): Prepared;
202
+ export declare function moveBlocks(this: Block, payload: BlockOperations['moveBlocks'], plan?: Prepared): Block[];
203
+ /**
204
+ * The facade owns the refusal rules (`unNestBlock`: top-level blocks,
205
+ * island-sealed blocks and sealed destinations).
206
+ */
207
+ export declare function prepareUnNest(this: Block): Prepared;
208
+ export declare function unNestBlock(this: Block, _?: BlockOperations['unNestBlock'], plan?: Prepared): Block | null;
209
+ /**
210
+ * Admission resolves the nest target — the previous sibling — and the
211
+ * facade owns permission: `nestBlock` refuses void/island/inside-island
212
+ * targets and island-sealed sources (`canPlace`).
213
+ */
214
+ export declare function prepareNest(this: Block): Prepared;
215
+ export declare function nestBlock(this: Block, _?: BlockOperations['nestBlock'], plan?: Prepared): Block | null;
216
+ export declare function prepareSet(this: Block, { value }: BlockOperations['setBlock']): Prepared;
217
+ export declare function setBlock(this: Block, payload: BlockOperations['setBlock'], plan?: Prepared): void;
75
218
  export declare function pushContentIntoBlock(this: Block, { value }: BlockOperations['pushContentIntoBlock']): void;
76
- export declare function removeInlineBlock(this: Block, { index }: BlockOperations['removeInlineBlock']): void;
77
- export declare const groupContent: (content?: (JSONText | JSONInlineBlock)[]) => (JSONText[] | JSONInlineBlock)[];
78
- export declare function addInlineBlock(this: Block, { index, block, text }: BlockOperations['addInlineBlock']): Text;
219
+ export declare function prepareRemoveInline(this: Block, { index }: {
220
+ index: number;
221
+ }): Prepared;
222
+ export declare function removeInlineBlock(this: Block, payload: BlockOperations['removeInlineBlock'], plan?: Prepared): void;
223
+ export declare function preparePatch(this: Block, { ops, atom }: BlockOperations['patchData']): Prepared;
224
+ export declare function patchData(this: Block, payload: BlockOperations['patchData'], plan?: Prepared): void;
225
+ /**
226
+ * Insert an inline atom at `index` of `text`. Answers the atom's id; the
227
+ * batched operation resolves it to the text after the atom once committed
228
+ * ({@link textAfterAtom}), where the caret's pending marks follow.
229
+ */
230
+ export declare function addInlineBlock(this: Block, { index, block, text }: BlockOperations['addInlineBlock']): string;
231
+ /** The text after atom `atom` of this block; the caret's pending marks follow it there (L4). */
232
+ export declare function textAfterAtom(this: Block, atom: string | undefined): Text | null | undefined;
233
+ /**
234
+ * Normalization runs at the end of the command's transaction
235
+ * (`Dispatcher.drain`): a normalizer reads handles over the index; when a
236
+ * plugin hook answers work, the work runs in the same transaction and the
237
+ * block is requested again (bounded by the dispatcher's pass limit, D25).
238
+ */
79
239
  export declare function normalizeContent(this: Block): void;
240
+ export declare function normalizeChildren(this: Block): void;
241
+ /** @deprecated A thin wrapper over an `{ end: block.id }` suggestion (`edytor.suggestions`). */
80
242
  export declare function suggestText(this: Block, { value }: BlockOperations['suggestText']): void;
243
+ /** @deprecated Accepts this block's latest `{ end }` suggestion (`suggestion.accept()`). */
81
244
  export declare function acceptSuggestedText(this: Block): void;
82
- export declare function deleteContentAtRange(this: Block, { start, end }: BlockOperations['deleteContentAtRange']): void;
245
+ export declare function prepareDeleteRange(this: Block, { start: [startIndex, startOffset], end: [endIndex, endOffset] }: {
246
+ start: number[];
247
+ end: number[];
248
+ }): Prepared;
249
+ export declare function deleteContentAtRange(this: Block, payload: BlockOperations['deleteContentAtRange'], plan?: Prepared): void;