edytor 2.0.0 → 4.0.0

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 (346) hide show
  1. package/README.md +19 -4
  2. package/dist/block/block.svelte.js +2 -4
  3. package/dist/clipboard/htmlFlow.d.ts +20 -7
  4. package/dist/clipboard/htmlFlow.js +23 -15
  5. package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
  6. package/dist/clipboard/serializeClipboardFragment.js +6 -4
  7. package/dist/clipboard/textBlocks.d.ts +8 -0
  8. package/dist/clipboard/textBlocks.js +6 -2
  9. package/dist/cloudflare/DocumentRoom.d.ts +13 -9
  10. package/dist/cloudflare/DocumentRoom.js +10 -6
  11. package/dist/cloudflare/room/admission.js +3 -3
  12. package/dist/cloudflare/room/context.d.ts +28 -27
  13. package/dist/cloudflare/room/context.js +2 -2
  14. package/dist/cloudflare/room/purge.d.ts +6 -3
  15. package/dist/cloudflare/room/purge.js +44 -19
  16. package/dist/cloudflare/room/updates.d.ts +3 -4
  17. package/dist/cloudflare/room/updates.js +6 -8
  18. package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
  19. package/dist/cloudflare/routeDocumentSocket.js +53 -0
  20. package/dist/collaboration/comments/client.d.ts +1 -1
  21. package/dist/collaboration/comments/client.js +1 -1
  22. package/dist/collaboration/remoteSelection.js +3 -3
  23. package/dist/components/Edytor.svelte +2 -10
  24. package/dist/components/Edytor.svelte.d.ts +1 -3
  25. package/dist/crdt/admission.d.ts +5 -10
  26. package/dist/crdt/admission.js +5 -11
  27. package/dist/crdt/attribution/attribution.d.ts +31 -12
  28. package/dist/crdt/attribution/attribution.js +56 -18
  29. package/dist/crdt/attribution/block.d.ts +3 -3
  30. package/dist/crdt/attribution/block.js +7 -8
  31. package/dist/crdt/attribution/index.d.ts +1 -1
  32. package/dist/crdt/attribution/index.js +1 -1
  33. package/dist/crdt/data.d.ts +62 -31
  34. package/dist/crdt/data.js +211 -103
  35. package/dist/crdt/doc/delete.d.ts +1 -1
  36. package/dist/crdt/doc/delete.js +13 -30
  37. package/dist/crdt/doc/funnel.d.ts +7 -6
  38. package/dist/crdt/doc/funnel.js +39 -33
  39. package/dist/crdt/doc/gate.d.ts +3 -20
  40. package/dist/crdt/doc/gate.js +2 -41
  41. package/dist/crdt/doc/history.d.ts +25 -9
  42. package/dist/crdt/doc/history.js +152 -42
  43. package/dist/crdt/doc/layout.js +11 -22
  44. package/dist/crdt/doc/meta.js +12 -17
  45. package/dist/crdt/doc/moves.d.ts +1 -1
  46. package/dist/crdt/doc/moves.js +52 -32
  47. package/dist/crdt/doc/reads.js +2 -2
  48. package/dist/crdt/doc/seed.js +2 -2
  49. package/dist/crdt/doc/split-merge.js +12 -15
  50. package/dist/crdt/doc/steps.d.ts +25 -13
  51. package/dist/crdt/doc/steps.js +52 -122
  52. package/dist/crdt/doc/types.d.ts +21 -9
  53. package/dist/crdt/document.d.ts +21 -19
  54. package/dist/crdt/document.js +26 -23
  55. package/dist/crdt/edytor-doc.d.ts +66 -68
  56. package/dist/crdt/edytor-doc.js +21 -20
  57. package/dist/crdt/engine-api.d.ts +33 -1
  58. package/dist/crdt/engine.d.ts +0 -1
  59. package/dist/crdt/engine.js +1 -4
  60. package/dist/crdt/flow.d.ts +1 -1
  61. package/dist/crdt/flow.js +25 -27
  62. package/dist/crdt/index.d.ts +29 -28
  63. package/dist/crdt/index.js +3 -3
  64. package/dist/crdt/placement/display.d.ts +5 -30
  65. package/dist/crdt/placement/display.js +39 -144
  66. package/dist/crdt/placement/keys.d.ts +58 -0
  67. package/dist/crdt/placement/keys.js +90 -0
  68. package/dist/crdt/placement/model.d.ts +119 -118
  69. package/dist/crdt/placement/model.js +242 -142
  70. package/dist/crdt/placement/resolve.d.ts +123 -35
  71. package/dist/crdt/placement/resolve.js +187 -153
  72. package/dist/crdt/placement/slots.d.ts +134 -0
  73. package/dist/crdt/placement/slots.js +152 -0
  74. package/dist/crdt/protocol.d.ts +2 -2
  75. package/dist/crdt/protocol.js +2 -2
  76. package/dist/crdt/providers/index.d.ts +1 -1
  77. package/dist/crdt/providers/room.d.ts +26 -11
  78. package/dist/crdt/providers/room.js +77 -27
  79. package/dist/crdt/providers/websocket.d.ts +1 -1
  80. package/dist/crdt/providers/websocket.js +33 -32
  81. package/dist/crdt/purge.d.ts +17 -8
  82. package/dist/crdt/purge.js +236 -126
  83. package/dist/crdt/restore.d.ts +2 -2
  84. package/dist/crdt/restore.js +18 -34
  85. package/dist/crdt/schema.d.ts +22 -21
  86. package/dist/crdt/schema.js +29 -23
  87. package/dist/crdt/semantics.js +3 -1
  88. package/dist/crdt/storage.d.ts +1 -1
  89. package/dist/crdt/storage.js +1 -1
  90. package/dist/crdt/structs.d.ts +15 -15
  91. package/dist/crdt/structs.js +8 -22
  92. package/dist/crdt/text/index/cache.js +4 -0
  93. package/dist/crdt/text/index/claims.js +12 -0
  94. package/dist/crdt/text/index/fold.d.ts +2 -3
  95. package/dist/crdt/text/index/fold.js +194 -44
  96. package/dist/crdt/text/index/layout.js +5 -8
  97. package/dist/crdt/text/index/placement.d.ts +26 -18
  98. package/dist/crdt/text/index/placement.js +404 -138
  99. package/dist/crdt/text/index/records.d.ts +3 -3
  100. package/dist/crdt/text/index/records.js +24 -31
  101. package/dist/crdt/text/index/shared.d.ts +11 -3
  102. package/dist/crdt/text/index/shared.js +12 -3
  103. package/dist/crdt/text/index/state.d.ts +21 -17
  104. package/dist/crdt/text/index/state.js +15 -17
  105. package/dist/crdt/text/index/streams.d.ts +10 -5
  106. package/dist/crdt/text/index/streams.js +78 -27
  107. package/dist/crdt/text/items.d.ts +10 -3
  108. package/dist/crdt/text/items.js +7 -0
  109. package/dist/crdt/text/model.d.ts +77 -62
  110. package/dist/crdt/text/model.js +84 -169
  111. package/dist/crdt/text/ranges.d.ts +1 -1
  112. package/dist/crdt/text/ranges.js +3 -3
  113. package/dist/crdt/text/rows.d.ts +13 -7
  114. package/dist/crdt/text/rows.js +24 -7
  115. package/dist/crdt/text/runs.d.ts +17 -12
  116. package/dist/crdt/text/runs.js +24 -7
  117. package/dist/crdt/text/streams.d.ts +26 -13
  118. package/dist/crdt/text/streams.js +41 -14
  119. package/dist/crdt/vendor/yjs/UPSTREAM.md +568 -21
  120. package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
  121. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  122. package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
  123. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +194 -10
  124. package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
  125. package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
  126. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
  127. package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
  128. package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
  129. package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
  130. package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
  131. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +43 -7
  132. package/dist/crdt/vendor/yjs/global.d.ts +2 -0
  133. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  134. package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
  135. package/dist/crdt/vendor/yjs/src/structs/Item.js +610 -51
  136. package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
  137. package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
  138. package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
  139. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
  140. package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
  141. package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
  142. package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
  143. package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
  144. package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
  145. package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
  146. package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
  147. package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
  148. package/dist/crdt/vendor/yjs/src/ynode.js +177 -12
  149. package/dist/dnd/autoScroll.d.ts +15 -7
  150. package/dist/dnd/autoScroll.js +10 -15
  151. package/dist/dnd/dropIndicator.js +2 -5
  152. package/dist/dnd/external.d.ts +6 -0
  153. package/dist/dnd/external.js +17 -0
  154. package/dist/dnd/geometry.d.ts +2 -0
  155. package/dist/dnd/geometry.js +3 -4
  156. package/dist/dnd/placement.d.ts +1 -1
  157. package/dist/dnd/pragmatic.d.ts +3 -1
  158. package/dist/dnd/pragmatic.js +12 -2
  159. package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
  160. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
  161. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
  162. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
  163. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
  164. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
  165. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
  166. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
  167. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
  168. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
  169. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
  170. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
  171. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
  172. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
  173. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
  174. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
  175. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
  176. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.d.ts +1 -1
  177. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
  178. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
  179. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
  180. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
  181. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
  182. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
  183. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
  184. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
  185. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
  186. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
  187. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
  188. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
  189. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
  190. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
  191. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
  192. package/dist/edytor.svelte.d.ts +2 -5
  193. package/dist/edytor.svelte.js +21 -32
  194. package/dist/events/beforeInputCommands.js +2 -2
  195. package/dist/events/onBeforeInput.js +1 -1
  196. package/dist/events/onDrop.d.ts +0 -6
  197. package/dist/events/onDrop.js +10 -23
  198. package/dist/events/onInput.d.ts +0 -12
  199. package/dist/events/onInput.js +1 -67
  200. package/dist/events/onPageHide.d.ts +3 -0
  201. package/dist/events/onPageHide.js +16 -0
  202. package/dist/export/forms.d.ts +627 -0
  203. package/dist/export/forms.js +749 -0
  204. package/dist/export/index.d.ts +170 -0
  205. package/dist/export/index.js +161 -0
  206. package/dist/export/markdown.d.ts +41 -0
  207. package/dist/export/markdown.js +585 -0
  208. package/dist/export/markdownWriter.d.ts +9 -0
  209. package/dist/export/markdownWriter.js +133 -0
  210. package/dist/export/mdx.d.ts +15 -0
  211. package/dist/export/mdx.js +33 -0
  212. package/dist/index.d.ts +3 -3
  213. package/dist/index.js +1 -1
  214. package/dist/kinds.js +1 -1
  215. package/dist/plugins/anchored.svelte.d.ts +21 -25
  216. package/dist/plugins/anchored.svelte.js +23 -39
  217. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
  218. package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
  219. package/dist/plugins/blockHandles/dragPreview.js +33 -0
  220. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
  221. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
  222. package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
  223. package/dist/plugins/chrome.d.ts +27 -5
  224. package/dist/plugins/chrome.js +24 -9
  225. package/dist/plugins/code/CodePlugin.svelte +12 -9
  226. package/dist/plugins/code/header.svelte.js +7 -11
  227. package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
  228. package/dist/plugins/code/languageMenu.svelte.js +13 -20
  229. package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
  230. package/dist/plugins/columns/resize.svelte.d.ts +2 -3
  231. package/dist/plugins/columns/resize.svelte.js +2 -5
  232. package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
  233. package/dist/plugins/comments/CommentsController.svelte.js +20 -0
  234. package/dist/plugins/equation/EquationPlugin.svelte +12 -22
  235. package/dist/plugins/equation/equation.svelte.d.ts +7 -15
  236. package/dist/plugins/equation/equation.svelte.js +13 -50
  237. package/dist/plugins/equation/tex.d.ts +17 -0
  238. package/dist/plugins/equation/tex.js +42 -0
  239. package/dist/plugins/fileDrop.d.ts +38 -23
  240. package/dist/plugins/fileDrop.js +82 -76
  241. package/dist/plugins/find/FindController.svelte.d.ts +5 -0
  242. package/dist/plugins/find/FindController.svelte.js +14 -14
  243. package/dist/plugins/find/findPlugin.js +1 -15
  244. package/dist/plugins/image/ImageChrome.svelte +8 -2
  245. package/dist/plugins/image/ImagePlugin.svelte +15 -52
  246. package/dist/plugins/image/controls.svelte.js +16 -2
  247. package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
  248. package/dist/plugins/image/toolbar.svelte.js +21 -31
  249. package/dist/plugins/index.d.ts +1 -1
  250. package/dist/plugins/list.svelte.d.ts +9 -0
  251. package/dist/plugins/list.svelte.js +18 -0
  252. package/dist/plugins/marquee/marqueePlugin.js +0 -4
  253. package/dist/plugins/media/AudioPlugin.svelte +1 -1
  254. package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
  255. package/dist/plugins/media/EmbedPlugin.svelte +5 -90
  256. package/dist/plugins/media/EmptySlot.svelte +36 -20
  257. package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
  258. package/dist/plugins/media/FilePlugin.svelte +1 -19
  259. package/dist/plugins/media/MediaEmpty.svelte +2 -55
  260. package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
  261. package/dist/plugins/media/SourceBlock.svelte +142 -52
  262. package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
  263. package/dist/plugins/media/VideoPlugin.svelte +1 -1
  264. package/dist/plugins/media/empty.svelte.js +2 -7
  265. package/dist/plugins/media/media.d.ts +2 -63
  266. package/dist/plugins/media/media.js +1 -194
  267. package/dist/plugins/media/sources.d.ts +60 -0
  268. package/dist/plugins/media/sources.js +165 -0
  269. package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
  270. package/dist/plugins/media/urlPaste.svelte.js +12 -21
  271. package/dist/plugins/mention/MentionPlugin.svelte +8 -35
  272. package/dist/plugins/page/PagePlugin.svelte +2 -9
  273. package/dist/plugins/page/page.js +1 -1
  274. package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
  275. package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
  276. package/dist/plugins/richtext/body.js +1 -1
  277. package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
  278. package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
  279. package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
  280. package/dist/plugins/richtext/richTextOperations.js +3 -49
  281. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
  282. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
  283. package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
  284. package/dist/plugins/table/TableChrome.svelte +2 -3
  285. package/dist/plugins/table/TablePlugin.svelte +20 -54
  286. package/dist/plugins/table/chrome.svelte.d.ts +5 -2
  287. package/dist/plugins/table/chrome.svelte.js +30 -54
  288. package/dist/plugins/table/table.js +3 -3
  289. package/dist/plugins/toc/TocPlugin.svelte +2 -4
  290. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
  291. package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
  292. package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
  293. package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
  294. package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
  295. package/dist/plugins/triggers/place.js +1 -2
  296. package/dist/plugins/triggers/triggers.d.ts +6 -1
  297. package/dist/plugins/triggers/triggers.js +12 -13
  298. package/dist/plugins/uploads.svelte.d.ts +5 -2
  299. package/dist/plugins/uploads.svelte.js +25 -15
  300. package/dist/plugins.d.ts +26 -0
  301. package/dist/plugins.js +0 -24
  302. package/dist/selection/replaceSelection.js +2 -2
  303. package/dist/selection/selection.svelte.d.ts +4 -10
  304. package/dist/selection/selection.svelte.js +7 -11
  305. package/dist/session/bindings.js +1 -1
  306. package/dist/session/commands.d.ts +7 -11
  307. package/dist/session/commands.js +13 -19
  308. package/dist/session/inputRules.js +1 -1
  309. package/dist/session/navigation.js +1 -1
  310. package/dist/session/suggestions.svelte.d.ts +0 -11
  311. package/dist/session/suggestions.svelte.js +15 -3
  312. package/dist/session/uploads.d.ts +8 -8
  313. package/dist/surface/lines.js +1 -3
  314. package/dist/surface/observer.svelte.d.ts +17 -1
  315. package/dist/surface/observer.svelte.js +74 -19
  316. package/dist/surface/overlay.d.ts +0 -14
  317. package/dist/surface/overlay.js +0 -25
  318. package/dist/surface/projector.svelte.d.ts +15 -3
  319. package/dist/surface/projector.svelte.js +60 -9
  320. package/dist/text/text.svelte.js +3 -13
  321. package/dist/utils/sanitize.d.ts +38 -0
  322. package/dist/utils/sanitize.js +82 -0
  323. package/dist/utils.d.ts +2 -0
  324. package/dist/utils.js +5 -0
  325. package/package.json +19 -2
  326. package/dist/crdt/placement/rank.d.ts +0 -87
  327. package/dist/crdt/placement/rank.js +0 -332
  328. package/dist/crdt/placement/source.d.ts +0 -43
  329. package/dist/crdt/placement/source.js +0 -66
  330. package/dist/crdt/text/delete-index.d.ts +0 -129
  331. package/dist/crdt/text/delete-index.js +0 -365
  332. package/dist/crdt/text/deletes.d.ts +0 -76
  333. package/dist/crdt/text/deletes.js +0 -362
  334. package/dist/crdt/text/index/anchored.d.ts +0 -17
  335. package/dist/crdt/text/index/anchored.js +0 -197
  336. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
  337. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
  338. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
  339. package/dist/plugins/code/LanguageMenu.svelte +0 -25
  340. package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
  341. package/dist/plugins/equation/EquationEditor.svelte +0 -27
  342. package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
  343. package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
  344. package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
  345. package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
  346. package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
@@ -1,17 +1,27 @@
1
1
  /**
2
- * The step writers every prepared op composes: the plan itself, ranks (a
3
- * move's, a source rank by where blocks come from, a split's pieces), type
4
- * steps and the kind a block shows where it lands (`settle`), the
5
- * containers and layouts a write leaves empty (`emptying`, `dissolving`),
6
- * delete and merge steps, and display spans of a block's content.
2
+ * The step writers every prepared op composes: the plan itself, moves (a
3
+ * move's place and side), type steps and the kind a block shows where it
4
+ * lands (`settle`), the containers and layouts a write leaves empty
5
+ * (`emptying`, `dissolving`), delete and merge steps, and display spans of a
6
+ * block's content.
7
7
  */
8
- import { randOf } from '../rand.js';
9
8
  import { TYPE } from '../schema.js';
10
- import { blockNodeOf, positionInView, promotedRank, ranksAt, SOURCE_SIDE, sourceRank } from '../placement/model.js';
9
+ import { blockNodeOf } from '../placement/model.js';
11
10
  import { REFUSED, effectOf } from './plan.js';
11
+ /** What the step writers read: the reads and the structural capability. */
12
+ /**
13
+ * A record's order among the records standing at one block, for the
14
+ * engine's sort of two records at one origin (fork patch YP22): what a split
15
+ * of a list around a block writes there — a new head list holding the items
16
+ * before it (`head`), new blocks placed after the items before it, which
17
+ * stay (`kept`), a head holding those items and the block (`with`), the
18
+ * block itself leaving (`self`), new blocks after it (`after`) — in the
19
+ * order every serial run of the gestures gives (`del.merge.container`).
20
+ */
21
+ export const PART = { head: 0, kept: 1, with: 2, self: 3, after: 4 };
12
22
  /** The step writers of one facade. */
13
23
  export const planSteps = (c) => {
14
- const { doc, runsView, roles, rendersContentOf, view, blockTypeOf, childrenIds, positionOf, ancestorsOf, is, isIsland, itemKindOf, isLayout, displayLength, contentItems, live, isContainer, fitted, emptiable, rendersContent, defaultChild } = c;
24
+ const { doc, runsView, roles, rendersContentOf, view, blockTypeOf, childrenIds, positionOf, ancestorsOf, is, isIsland, itemKindOf, isLayout, displayLength, contentItems, live, isContainer, fitted, emptiable, defaultChild } = c;
15
25
  // ── prepared ops ─────────────────────────────────────────────
16
26
  // Every op is `prepare` (pure: `refused`, or a plan of named steps plus
17
27
  // its effect summary, against the current version) then `apply(plan)`;
@@ -19,124 +29,52 @@ export const planSteps = (c) => {
19
29
  // whole command before any write and a refusal refuses before one.
20
30
  // Each prepare normalizes its inputs once, here at ingress: ids
21
31
  // and strings as the wire would deliver them, payloads cloned.
22
- /** `exitRanks` parts, in their order at one block. */
23
- const [HEAD, KEPT, WITH, SELF, AFTER] = [0, 1, 2, 3, 5];
24
32
  const plan = (ids, writes) => ({
25
33
  ids,
26
34
  writes,
27
35
  effect: effectOf(writes),
28
36
  version: runsView.version()
29
37
  });
30
- /** This client's next clock: what its source ranks are tied by (`sourceRank`). */
31
- const clock = () => doc.store?.getClock(doc.clientID) ?? 0;
32
- /**
33
- * `count` ranks at `index` among `parent`'s children, the moving
34
- * `exclude` left out. `run`: new blocks, which extend this client's run
35
- * after a block it ranked (`order.insert.run`); a move never does
36
- * (the rank-growth guard).
37
- */
38
- const ranksFor = (parent, index, count, exclude = [], run = false) => {
39
- const v = view();
40
- const all = v.kids.get(parent) ?? [];
41
- // The moving blocks' own slots left out: index → the list's index past them.
42
- const gone = exclude
43
- .map((id) => positionInView(v, id))
44
- .filter((p) => p !== null && p.parent === parent)
45
- .map((p) => p.index)
46
- .sort((a, b) => a - b);
47
- const raw = (i) => {
48
- for (const g of gone)
49
- if (g <= i)
50
- i++;
51
- return i;
52
- };
53
- const at = Math.max(0, Math.min(index, all.length - gone.length));
54
- const pair = [at > 0 ? all[raw(at - 1)] : undefined, all[raw(at)]];
55
- return ranksAt(pair, 1, count, doc.clientID, randOf(doc), run);
56
- };
57
38
  /**
58
- * Move `ids` to `ranks` under `parent` (`index`: the slot hooks see).
39
+ * Move `ids` to display index `index` among `parent`'s children (the
40
+ * slot hooks see). `side`: the move record's class among the items of
41
+ * its origin (`placement/slots.ts`) — `0`, the blocks stand after what
42
+ * precedes them (a move; blocks leaving a block for the gap after it:
43
+ * its children, a list's last items); `1`, before what follows them
44
+ * (blocks leaving a block for the gap before it: a list's first item
45
+ * lifted out). In one gap every serial order of the gestures puts a
46
+ * split's pieces first, then the after-records, then the before-records
47
+ * (`del.merge.container`), which the engine's sort gives whatever the
48
+ * client ids.
59
49
  * Every planned move carries the type steps that keep what the moved
60
50
  * blocks show: one displayed out of an island as another kind than its
61
51
  * stored one (`displayType`) gets that kind written, so leaving the
62
52
  * island's slot never brings the island's child kind back.
53
+ * `at`, `part`: the block the record stands at and its order among the
54
+ * records standing there, for the engine's sort of two records at one
55
+ * origin (`PART`; by default the first moved block, as itself).
63
56
  */
64
- const moveTo = (ids, parent, index, ranks) => ids.length === 0
57
+ const moveTo = (ids, parent, index, side = 0, at, part) => ids.length === 0
65
58
  ? []
66
59
  : [
67
- { op: 'moveBlocks', ids, parent, index, ranks },
60
+ {
61
+ op: 'moveBlocks',
62
+ ids,
63
+ parent,
64
+ index,
65
+ ...(side === 1 && { side }),
66
+ ...(at !== undefined && { at }),
67
+ ...(part !== undefined && { part })
68
+ },
68
69
  ...ids.flatMap((id) => {
69
70
  const shown = runsView.displayType(id);
70
71
  return shown === undefined ? [] : attr(id, TYPE, shown);
71
72
  })
72
73
  ];
73
74
  /** Move `ids` to `index` among `parent`'s children. */
74
- const move = (ids, parent, index) => moveTo(ids, parent, index, ranksFor(parent, index, ids.length, ids));
75
- /**
76
- * Ranks for blocks leaving `outer` for the gap right before it (`after`:
77
- * right after it), in the order they come from (`sourceRank`):
78
- * two peers that split or lift out of the same list at once keep the
79
- * text in its order, whatever their client ids. Each part names the
80
- * block in `outer` it stands at (`at`; one that shows no text of its
81
- * own, a list, stands at its first item) and its `part` there:
82
- * - `HEAD`: a new list holding the items before `at`;
83
- * - `KEPT`, index: a block placed after the items before `at`, which
84
- * stay (a divider inserted after an item: a peer's head that takes
85
- * them sorts before it);
86
- * - `WITH`: a new list holding the items before `at` and `at` (`keep`);
87
- * - `SELF`: `at` itself leaving (`SELF + 1` when it stands at its first item);
88
- * - `AFTER`, index: a block placed after it.
89
- * A degenerate gap ranks them as any insert.
90
- */
91
- const exitRanks = (outer, after, parts) => {
92
- const { kids } = view();
93
- const { parent, index } = positionOf(outer);
94
- const sibs = kids.get(parent) ?? [];
95
- const gap = after ? index + 1 : index;
96
- const ranks = [];
97
- for (let { at, part } of parts) {
98
- const own = at;
99
- while (!rendersContent(at) && childrenIds(at).length > 0)
100
- at = childrenIds(at)[0];
101
- if (part[0] === SELF && at !== own)
102
- part = [SELF + 1];
103
- const path = [];
104
- for (let c = at; c !== outer; c = positionOf(c).parent) {
105
- const pos = positionOf(c);
106
- path.unshift(kids.get(pos.parent)[pos.index].rank);
107
- }
108
- const side = after ? SOURCE_SIDE.after : SOURCE_SIDE.before;
109
- const rank = sourceRank(sibs[gap - 1]?.rank, sibs[gap]?.rank, side, path, part, doc.clientID, clock());
110
- if (rank === null)
111
- return ranksFor(parent, gap, parts.length);
112
- ranks.push(rank);
113
- }
114
- return ranks;
115
- };
116
- /**
117
- * Ranks for the `count` blocks a split of `id` at `at` puts right after
118
- * it (Enter, a paste of several lines), by where it splits
119
- * (SW12-crdt-1, SW12-crdt-4): two peers splitting one block at once
120
- * keep its pieces in text order, whatever their client ids. Counted
121
- * from the end — the text after the split point, most first — so a
122
- * peer's own edit before its split point (typing, then Enter; a paste
123
- * over a selection) does not move it; an unseen edit after
124
- * it does (the residual, in the delete contract).
125
- */
126
- const pieceRanks = (id, at, count) => {
127
- const { parent, index } = positionOf(id);
128
- const sibs = view().kids.get(parent) ?? [];
129
- const ranks = [];
130
- for (let i = 0; i < count; i++) {
131
- const rank = sourceRank(sibs[index]?.rank, sibs[index + 1]?.rank, SOURCE_SIDE.pieces, [], [at - displayLength(id), i], doc.clientID, clock());
132
- if (rank === null)
133
- return ranksFor(parent, index + 1, count);
134
- ranks.push(rank);
135
- }
136
- return ranks;
137
- };
138
- /** `exitRanks` for `ids` themselves leaving `outer`. */
139
- const leaving = (outer, after, ids) => exitRanks(outer, after, ids.map((at) => ({ at, part: [SELF] })));
75
+ const move = (ids, parent, index) => moveTo(ids, parent, index);
76
+ /** The side of blocks leaving a block for the gap right after it (`after`) or right before it. */
77
+ const leaving = (after) => (after ? 0 : 1);
140
78
  /**
141
79
  * A type step, planned only when the kind differs (the one same-value
142
80
  * guard). A kind counts as the same only when the block is stored and
@@ -241,10 +179,10 @@ export const planSteps = (c) => {
241
179
  * with one item or none — `gone` (blocks the plan removes) and
242
180
  * `leaving` (blocks it moves) no longer count, an item `writes` move or
243
181
  * insert into it does. With one left, the layout and that item are
244
- * deleted and the item's children moved to the layout's slot at the
245
- * rank `layout.single` reads (`promotedRank` of the layout's, then the
246
- * item's), as the kind they show there (`settle`); with none, the
247
- * layout is deleted. One plan with the write that caused it.
182
+ * deleted and the item's children moved right after the layout, where
183
+ * `layout.single` shows them, as the kind they show there (`settle`);
184
+ * with none, the layout is deleted. One plan with the write that caused
185
+ * it.
248
186
  */
249
187
  const dissolving = (gone, leaving, writes) => {
250
188
  const away = new Set([...gone, ...leaving]);
@@ -269,17 +207,17 @@ export const planSteps = (c) => {
269
207
  const items = slots.filter((k) => !away.has(k.id) && blockTypeOf(k.id) === item);
270
208
  if (items.length + arriving > 1)
271
209
  continue;
272
- const { parent, index } = positionOf(layout);
273
- const rank = kids.get(parent)[index].rank;
210
+ const { parent } = positionOf(layout);
274
211
  const last = items[0];
275
212
  if (last === undefined) {
276
213
  out.push(deleting(layout, [layout]));
277
214
  continue;
278
215
  }
216
+ // Its blocks keep their home slots: the read shows them in the layout's
217
+ // slot (`layout.single`), settled for its parent.
279
218
  const moved = (kids.get(last.id) ?? []).filter((k) => !away.has(k.id));
280
219
  const ids = moved.map((k) => k.id);
281
- const ranks = moved.map((k) => promotedRank(rank, promotedRank(last.rank, k.rank)));
282
- out.push(...moveTo(ids, parent, index + 1, ranks), ...settle(last.id, ids, parent), deleting(layout, [layout, last.id]));
220
+ out.push(...settle(last.id, ids, parent), deleting(layout, [layout, last.id]));
283
221
  }
284
222
  return out;
285
223
  };
@@ -349,17 +287,9 @@ export const planSteps = (c) => {
349
287
  const emptied = (leaving, writes, kept) => emptyingAll(leaving.map((id) => positionOf(id).parent), leaving, writes, kept);
350
288
  return {
351
289
  REFUSED,
352
- HEAD,
353
- KEPT,
354
- WITH,
355
- SELF,
356
- AFTER,
357
290
  plan,
358
- ranksFor,
359
291
  moveTo,
360
292
  move,
361
- exitRanks,
362
- pieceRanks,
363
293
  leaving,
364
294
  attr,
365
295
  leavingIsland,
@@ -8,7 +8,7 @@ import type { AttributionActor } from '../attribution/index.js';
8
8
  import type { BlockId, BlockSpec, InlineSpec, ProjectedBlock, SplitTail } from '../placement/model.js';
9
9
  import type { Anchor } from '../text/model.js';
10
10
  import type { ContentRun } from '../text/runs.js';
11
- import type { DataPatch, LeafWrite } from '../data.js';
11
+ import type { DataPatch, DataWrite } from '../data.js';
12
12
  import type { DocPosition } from '../rangeDelete.js';
13
13
  /** Structural role of a block type (plugin-side policy, resolved per op). */
14
14
  export type BlockRole = {
@@ -180,22 +180,34 @@ export type TextRange = {
180
180
  /**
181
181
  * One planned write, named by the document operation that
182
182
  * performs it — the name a hook matches. Steps carry everything
183
- * their write needs (ranks, marks, offsets), decided at prepare time.
183
+ * their write needs (places, marks, offsets), decided at prepare time; a
184
+ * place is a display index among a parent's children, read against the
185
+ * document as the step is written (the steps before it applied).
184
186
  */
185
187
  export type PlanStep =
186
- /** `index`: the destination slot at prepare time, as hooks see it. */
188
+ /** `index`: the destination slot, as hooks see it. */
189
+ /** `split`: the split-born block of this plan whose boundary these blocks' slots take as their sort key (a paste's lines at its split). */
187
190
  {
188
191
  op: 'insertBlocks';
189
192
  parent: BlockId | null;
190
193
  index: number;
191
194
  specs: BlockSpec[];
192
- ranks: string[];
193
- } | {
195
+ split?: BlockId;
196
+ }
197
+ /**
198
+ * `side`: the move record's class among the items of its origin —
199
+ * absent or `0`, the blocks stand after what precedes them; `1`, before
200
+ * what follows them (blocks leaving a block for the gap before it).
201
+ */
202
+ /** `side`: the record's class at its origin (`1`: before); `at`, `part`: the block it stands at and its order there (`moveTo`). */
203
+ | {
194
204
  op: 'moveBlocks';
195
205
  ids: BlockId[];
196
206
  parent: BlockId | null;
197
207
  index: number;
198
- ranks: string[];
208
+ side?: 0 | 1;
209
+ part?: number;
210
+ at?: BlockId;
199
211
  }
200
212
  /** `marks`: the blocks that get this writer's mark; `removes`: those that leave the document. */
201
213
  | {
@@ -212,7 +224,7 @@ export type PlanStep =
212
224
  newId: BlockId;
213
225
  tail: SplitTail;
214
226
  parent: BlockId | null;
215
- rank: string;
227
+ index: number;
216
228
  }
217
229
  /** `at`/`length`: where `from`'s display lands in `into`'s. */
218
230
  | {
@@ -229,7 +241,7 @@ export type PlanStep =
229
241
  /**
230
242
  * A data patch (`crdt/data.ts`): of block `id`, of its atom `inlineId`
231
243
  * (at display `offset`), or of the document (no `id`). `ops` as asked;
232
- * `leaves` the attr writes they plan.
244
+ * `writes` the attr and slot writes they plan.
233
245
  */
234
246
  | {
235
247
  op: 'patchData';
@@ -237,7 +249,7 @@ export type PlanStep =
237
249
  inlineId?: string;
238
250
  offset?: number;
239
251
  ops: DataPatch[];
240
- leaves: LeafWrite[];
252
+ writes: DataWrite[];
241
253
  } | {
242
254
  op: 'insertText';
243
255
  id: BlockId;
@@ -50,10 +50,9 @@
50
50
  * bootstrap-shaped is written or broadcast, so writes made raw against a
51
51
  * pending doc produce unversioned state that `sync()` then refuses (see
52
52
  * below). `local`/`hydrated` — the full surface is legal; the only
53
- * difference is WHO decided the content. (One exception to "nothing
54
- * broadcast": the actor dictionary attach publishes this replica's
55
- * `c/<clientID>`/`u/<actorId>` records on ANY constructed document —
56
- * identity metadata, not content, and outside every admission gate.)
53
+ * difference is WHO decided the content. (The actor dictionary's
54
+ * `c/<clientID>`/`u/<actorId>` records go with the replica's first write,
55
+ * whatever it is: a document that is only read publishes nothing.)
57
56
  *
58
57
  * ── Admission boundary ────────────────────────────────────────────
59
58
  *
@@ -64,7 +63,7 @@
64
63
  * - `createDocument` — the fresh doc is trivially admitted;
65
64
  * - `loadDocument` — the payload is decoded+integrated onto a SCRATCH
66
65
  * doc first (`admitUpdate`) and the gate runs on the merged result; a
67
- * refusal ({@link UndecodableUpdateError}, {@link UnsupportedDocError},
66
+ * refusal ({@link UndecodableUpdateError},
68
67
  * {@link SchemaMismatchError}) leaves nothing composed and never
69
68
  * touches the caller's bytes;
70
69
  * - `attachDocument` — the borrowed doc is gated BEFORE any composition
@@ -144,7 +143,7 @@ import type { MarkEdge } from './text/marks.js';
144
143
  import type { EngineApi, EngineDoc, YDoc, YUndoManager } from './engine-api.js';
145
144
  import { type DocumentOperations } from './operations.js';
146
145
  import { type AttributionBinding, type DocumentAttribution } from './attribution/index.js';
147
- import { type BlockRole, type DocFacade, type EdytorDocConfig } from './edytor-doc.js';
146
+ import { DocumentDestroyedError, type BlockRole, type DocFacade, type EdytorDocConfig } from './edytor-doc.js';
148
147
  import { Awareness } from './protocols/awareness.js';
149
148
  import type { EdytorSync, EdytorSyncCleanup } from './providers/index.js';
150
149
  import { SyncRefusedError } from './providers/room.js';
@@ -243,19 +242,11 @@ export type CreateDocumentOptions = DocumentOptions & {
243
242
  value?: JSONDoc;
244
243
  };
245
244
  export type LoadDocumentOptions = DocumentOptions;
245
+ export { DocumentDestroyedError };
246
246
  /** Raised when a readiness-gated service is used on a pending document. */
247
247
  export declare class DocumentNotReadyError extends Error {
248
248
  constructor(service: string);
249
249
  }
250
- /**
251
- * Raised when an operation runs against a torn-down document — every
252
- * attach reference has been released and the facade/history/awareness
253
- * teardown already ran. Distinct from {@link DocumentNotReadyError}:
254
- * destroyed is terminal, pending may still resolve.
255
- */
256
- export declare class DocumentDestroyedError extends Error {
257
- constructor(service?: string);
258
- }
259
250
  /**
260
251
  * How the document's content state was decided — the distinction the
261
252
  * readiness contract requires:
@@ -332,7 +323,7 @@ export declare class EdytorDocument {
332
323
  * replicated actor dictionary (`u/` profiles, `c/` replica bindings).
333
324
  * Ordinary edits perform no attribution
334
325
  * writes — authorship lands inside the owning op's transaction as the
335
- * block-level `b/<id>` record/`l` stamp. See
326
+ * block-level record (`blockattr` `<id>`)/`l` stamp. See
336
327
  * `src/lib/crdt/attribution/attribution.ts` for the full contract.
337
328
  * Access after teardown throws {@link DocumentDestroyedError} — same
338
329
  * lifecycle contract as {@link history}.
@@ -496,6 +487,18 @@ export declare class EdytorDocument {
496
487
  * on pending).
497
488
  */
498
489
  clearHistory: () => void;
490
+ /**
491
+ * End this session's history: the page it was edited in left for good.
492
+ * Every step is dropped, and what this replica deleted is released: the
493
+ * text its deletes hid is deleted for good now, and the room's purge
494
+ * removes the blocks it deleted at its next run, without waiting for the
495
+ * purge horizon (one small write, sent if the connection still can). A
496
+ * view calls it at a `pagehide` the back/forward cache keeps nothing of;
497
+ * a page kept there, or one that lost its connection, keeps its history.
498
+ * Undo starts empty afterwards. No-op while history has not attached, and
499
+ * on a destroyed document.
500
+ */
501
+ endHistory: () => void;
499
502
  /**
500
503
  * Local document transaction — headless edits, one undo step per call
501
504
  * (`origin`: another origin, which the document's history tracks only
@@ -641,9 +644,8 @@ export declare const bindDocument: (Y: EngineApi) => {
641
644
  * borrowed doc. Content state stays `pending` — the caller (view or
642
645
  * provider path) drives `sync()`.
643
646
  *
644
- * Admission runs BEFORE any composition touches the doc: a
645
- * foreign engine object refuses with {@link UnsupportedDocError}, an
646
- * unversioned/unsupported/foreign schema claim with
647
+ * Admission runs BEFORE any composition touches the doc: an
648
+ * unversioned/unsupported/foreign schema claim refuses with
647
649
  * {@link SchemaMismatchError} — the borrowed doc is left
648
650
  * byte-identical (the gate reads are write-free) and can be
649
651
  * attached once its state heals (e.g. a remote update supplies the
@@ -5,7 +5,7 @@ import { DOCUMENT_OPERATIONS } from './operations.js';
5
5
  import { propsProxy } from './props.js';
6
6
  import { bindAttribution } from './attribution/index.js';
7
7
  import { profileOf } from './attribution/attribution.js';
8
- import { docFacade, DEFAULT_HISTORY_LIMIT, isInitialized } from './edytor-doc.js';
8
+ import { docFacade, DocumentDestroyedError, DEFAULT_HISTORY_LIMIT, isInitialized } from './edytor-doc.js';
9
9
  import { assertAdmission, assertSchema, bindAdmission, checkSchema } from './admission.js';
10
10
  import { Awareness } from './protocols/awareness.js';
11
11
  import { callEach } from './protocols/observable.js';
@@ -18,27 +18,14 @@ const alive = (document, op) => {
18
18
  if (document.destroyed)
19
19
  throw new DocumentDestroyedError(op);
20
20
  };
21
+ export { DocumentDestroyedError };
21
22
  /** Raised when a readiness-gated service is used on a pending document. */
22
23
  export class DocumentNotReadyError extends Error {
23
24
  constructor(service) {
24
- super(`EdytorDocument.${service}: document is not ready — it is still pending ` +
25
- `(created without a value, provider hydration may be in flight). ` +
26
- `Wait for the sync callback / call document.sync() first.`);
25
+ super(`${service}: the document is not ready (call document.sync() first)`);
27
26
  this.name = 'DocumentNotReadyError';
28
27
  }
29
28
  }
30
- /**
31
- * Raised when an operation runs against a torn-down document — every
32
- * attach reference has been released and the facade/history/awareness
33
- * teardown already ran. Distinct from {@link DocumentNotReadyError}:
34
- * destroyed is terminal, pending may still resolve.
35
- */
36
- export class DocumentDestroyedError extends Error {
37
- constructor(service) {
38
- super(`EdytorDocument${service ? `.${service}` : ''}: document is destroyed.`);
39
- this.name = 'DocumentDestroyedError';
40
- }
41
- }
42
29
  /**
43
30
  * How long (ms) an empty document waits for a provider that has not
44
31
  * settled before it decides without it (settle-or-bound) — the bound a
@@ -105,7 +92,7 @@ export class EdytorDocument {
105
92
  * replicated actor dictionary (`u/` profiles, `c/` replica bindings).
106
93
  * Ordinary edits perform no attribution
107
94
  * writes — authorship lands inside the owning op's transaction as the
108
- * block-level `b/<id>` record/`l` stamp. See
95
+ * block-level record (`blockattr` `<id>`)/`l` stamp. See
109
96
  * `src/lib/crdt/attribution/attribution.ts` for the full contract.
110
97
  * Access after teardown throws {@link DocumentDestroyedError} — same
111
98
  * lifecycle contract as {@link history}.
@@ -226,9 +213,10 @@ export class EdytorDocument {
226
213
  this.awareness.setLocalStateField('user', user);
227
214
  // Attribution service — attaches after the facade (which gates
228
215
  // foreign docs) and after the actor is fixed. Publishes this
229
- // replica's actor dictionary entries (`c/`+`u/`) once; ordinary
230
- // edits perform no attribution work and per-block records are
231
- // written inside the owning op's transaction by the facade.
216
+ // replica's actor dictionary entries (`c/`+`u/`) inside its first
217
+ // write's transaction; ordinary edits perform no attribution work
218
+ // and per-block records are written inside the owning op's
219
+ // transaction by the facade.
232
220
  this.#attributionCtl = init.attribution.attach(asEngineDoc(this.doc), {
233
221
  actor: this.actor
234
222
  });
@@ -514,6 +502,22 @@ export class EdytorDocument {
514
502
  alive(this, 'clearHistory');
515
503
  this.#_history?.clear();
516
504
  };
505
+ /**
506
+ * End this session's history: the page it was edited in left for good.
507
+ * Every step is dropped, and what this replica deleted is released: the
508
+ * text its deletes hid is deleted for good now, and the room's purge
509
+ * removes the blocks it deleted at its next run, without waiting for the
510
+ * purge horizon (one small write, sent if the connection still can). A
511
+ * view calls it at a `pagehide` the back/forward cache keeps nothing of;
512
+ * a page kept there, or one that lost its connection, keeps its history.
513
+ * Undo starts empty afterwards. No-op while history has not attached, and
514
+ * on a destroyed document.
515
+ */
516
+ endHistory = () => {
517
+ if (this._destroyed)
518
+ return;
519
+ this.#_history?.end();
520
+ };
517
521
  /**
518
522
  * Local document transaction — headless edits, one undo step per call
519
523
  * (`origin`: another origin, which the document's history tracks only
@@ -926,9 +930,8 @@ export const bindDocument = (Y) => {
926
930
  * borrowed doc. Content state stays `pending` — the caller (view or
927
931
  * provider path) drives `sync()`.
928
932
  *
929
- * Admission runs BEFORE any composition touches the doc: a
930
- * foreign engine object refuses with {@link UnsupportedDocError}, an
931
- * unversioned/unsupported/foreign schema claim with
933
+ * Admission runs BEFORE any composition touches the doc: an
934
+ * unversioned/unsupported/foreign schema claim refuses with
932
935
  * {@link SchemaMismatchError} — the borrowed doc is left
933
936
  * byte-identical (the gate reads are write-free) and can be
934
937
  * attached once its state heals (e.g. a remote update supplies the