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
@@ -63,7 +63,12 @@ export class BlockMenuController {
63
63
  * after). Delete and Turn into act on their `members`, its items too.
64
64
  */
65
65
  blocks = $state([]);
66
- anchor = null;
66
+ /**
67
+ * Where the menu stands: the handle that opened it (a `ChromeAnchor`:
68
+ * your `menu` places itself beside it, its flyout beside the menu);
69
+ * `null` while closed.
70
+ */
71
+ anchor = $state.raw(null);
67
72
  query = $state('');
68
73
  /** The keyboard's row. */
69
74
  index = $state(0);
@@ -473,7 +478,7 @@ export class BlockMenuController {
473
478
  caret(block) {
474
479
  const text = block && shownText(block, 'first');
475
480
  if (text || !block?.isInTree)
476
- this.edytor.dispatcher.caret(text, 0);
481
+ this.edytor.dispatcher.caretIn(text, 0);
477
482
  else
478
483
  this.edytor.selection.select(blockSelection([block.id]));
479
484
  this.focus();
@@ -11,14 +11,9 @@ import { BlockMenuController, colorCommands } from './BlockMenuController.svelte
11
11
  export const createBlockMenuPlugin = (options = {}) => (edytor) => {
12
12
  const controller = new BlockMenuController(edytor, options);
13
13
  /**
14
- * Beside the handle: 8px right of it, top-aligned; left of it when the
15
- * right has no room; flipped up when the space below is short. The Turn
16
- * into flyout opens right of the menu, or left of it when the right has
17
- * no room, top-aligned with it, moved up as far as the viewport needs
18
- * (never above its top edge), and scrolls inside when taller (Notion):
19
- * every row is in the viewport, reachable by the mouse. It follows
20
- * scrolls and resizes, and closes when the handle leaves the view.
21
- * Measured in the overlay's frame; the placement (or the close) is written after.
14
+ * The menu places itself by `controller.anchor` (the handle), its
15
+ * flyout by the menu; measured in the overlay's frame, the menu closes
16
+ * when the handle leaves the page or the view.
22
17
  */
23
18
  const close = () => controller.close(false);
24
19
  const place = (host) => {
@@ -27,50 +22,10 @@ export const createBlockMenuPlugin = (options = {}) => (edytor) => {
27
22
  return;
28
23
  if (!anchor?.isConnected)
29
24
  return close;
30
- const view = host.ownerDocument.defaultView;
31
- const menu = host.querySelector('[data-edytor-block-menu]') ??
32
- host.firstElementChild;
33
- if (!view || !menu)
34
- return;
35
- const [gap, edge, between] = [8, 8, 4];
36
25
  const rect = anchor.getBoundingClientRect();
37
- if (rect.bottom < 0 || rect.top > view.innerHeight)
26
+ const height = host.ownerDocument.defaultView?.innerHeight ?? Infinity;
27
+ if (rect.bottom < 0 || rect.top > height)
38
28
  return close;
39
- // Layout sizes, not the box: the menus open with a scale (0.98 → 1), and a
40
- // box read mid-animation would place them up to 2% short of their size.
41
- const [width, height] = [menu.offsetWidth, menu.offsetHeight];
42
- const right = rect.right + gap;
43
- const left = rect.left - gap - width;
44
- let x = right + width <= view.innerWidth - edge
45
- ? right
46
- : left >= edge
47
- ? left
48
- : Math.max(edge, Math.min(right, view.innerWidth - edge - width));
49
- const y = rect.top + height <= view.innerHeight - edge
50
- ? rect.top
51
- : Math.max(edge, Math.min(rect.bottom, view.innerHeight - edge) - height);
52
- const flyout = host.querySelector('[data-edytor-block-menu-flyout]');
53
- const frame = flyout?.parentElement;
54
- let side = '';
55
- let shift = '';
56
- if (flyout && frame) {
57
- const box = { width: flyout.offsetWidth, height: flyout.offsetHeight };
58
- // Left of the menu when its right has no room (the menu stays where it is).
59
- if (x + width + between + box.width > view.innerWidth - edge &&
60
- x - between - box.width >= edge) {
61
- side = 'row-reverse';
62
- x -= between + box.width;
63
- }
64
- const top = Math.max(edge, Math.min(y, view.innerHeight - edge - box.height));
65
- shift = `${top - y}px`;
66
- }
67
- return () => {
68
- Object.assign(host.style, { left: `${x}px`, top: `${y}px` });
69
- if (frame)
70
- frame.style.flexDirection = side;
71
- if (flyout)
72
- flyout.style.marginTop = shift;
73
- };
74
29
  };
75
30
  return {
76
31
  // Colours by name in the slash menu (`/red`), as in Notion.
@@ -9,17 +9,33 @@ import type { Snippet } from 'svelte';
9
9
  import type { Attachment } from 'svelte/attachments';
10
10
  import type { Edytor } from '../edytor.svelte.js';
11
11
  import { type BlockActivation, type BlockAddition } from './blockHandles/BlockHandleController.svelte.js';
12
+ /**
13
+ * Where a chrome surface stands, for the app's markup to place itself
14
+ * (Floating UI's virtual element: `computePosition(anchor, floating, …)`,
15
+ * or bits-ui's `customAnchor`): its box read now, in client pixels, on
16
+ * every call (the caret, the selection, a block, a grip, a button), and
17
+ * the element whose scrolling ancestors move it. The package places no
18
+ * popup.
19
+ */
20
+ export type ChromeAnchor = {
21
+ getBoundingClientRect: () => DOMRect;
22
+ readonly contextElement?: Element;
23
+ };
24
+ /** A {@link ChromeAnchor} reading `rect` (an empty box while there is none) inside `context`. */
25
+ export declare const virtualAnchor: (rect: () => DOMRect | null | undefined, context: () => Element | null | undefined) => ChromeAnchor;
12
26
  /**
13
27
  * Mount the app's `snippet` for a chrome surface in a fixed host of the
14
- * overlay (`data-<name>`, placed by `measure`), rendered with `payload`
15
- * while `shown` holds and closed (`close`) when the view turns readonly.
16
- * Without a snippet the surface renders nothing (its controller still
17
- * works): nothing is mounted. Answers the teardown.
28
+ * overlay (`data-<name>`), rendered with `payload` while `shown` holds and
29
+ * closed (`close`) when the view turns readonly; the markup places itself
30
+ * by its controller's `anchor`. `measure` runs on the overlay's frames (a
31
+ * surface whose anchor left the page closes there). Without a snippet the
32
+ * surface renders nothing (its controller still works): nothing is
33
+ * mounted. Answers the teardown.
18
34
  */
19
35
  export declare const mountChrome: <T>(edytor: Edytor, snippet: Snippet<[T]> | undefined, payload: T, shown: () => unknown, place: {
20
36
  name: string;
21
37
  zIndex: number;
22
- measure: (host: HTMLElement, origin: DOMRect) => (() => void) | void;
38
+ measure?: (host: HTMLElement, origin: DOMRect) => (() => void) | void;
23
39
  }, close?: () => void) => () => void;
24
40
  /**
25
41
  * One row of a chrome list a controller builds for the app's markup: the
@@ -68,6 +84,12 @@ export declare const identify: (node: HTMLElement, id: string, role?: string) =>
68
84
  export declare const attribute: (node: HTMLElement, name: string, value: string | undefined) => void;
69
85
  /** Whether `node` may name a highlighted row (`aria-activedescendant`): a field, or an element with a role. */
70
86
  export declare const namesRows: (node: HTMLElement) => boolean;
87
+ /**
88
+ * Every press in `document` (capture; WebKit's lone `mousedown` after a
89
+ * drag too, `onPress`) outside the elements `inside` matches: `outside`
90
+ * hears it. Answers the teardown.
91
+ */
92
+ export declare const onPressOutside: (edytor: Edytor, document: Document, inside: string, outside: (event: MouseEvent) => void) => () => void;
71
93
  /**
72
94
  * A handle menu's events on the editor `node` (the block menu, the `+`'s
73
95
  * menu): a grip's activation (`BLOCK_ACTIVATE_EVENT`), a `+`'s offer
@@ -2,15 +2,24 @@ import Chrome from './Chrome.svelte';
2
2
  import { onPress } from '../events/onFocus.js';
3
3
  import { all, listen } from '../utils/listen.js';
4
4
  import { BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT } from './blockHandles/BlockHandleController.svelte.js';
5
+ /** A {@link ChromeAnchor} reading `rect` (an empty box while there is none) inside `context`. */
6
+ export const virtualAnchor = (rect, context) => ({
7
+ getBoundingClientRect: () => rect() ?? new DOMRect(),
8
+ get contextElement() {
9
+ return context() ?? undefined;
10
+ }
11
+ });
5
12
  /**
6
13
  * Mount the app's `snippet` for a chrome surface in a fixed host of the
7
- * overlay (`data-<name>`, placed by `measure`), rendered with `payload`
8
- * while `shown` holds and closed (`close`) when the view turns readonly.
9
- * Without a snippet the surface renders nothing (its controller still
10
- * works): nothing is mounted. Answers the teardown.
14
+ * overlay (`data-<name>`), rendered with `payload` while `shown` holds and
15
+ * closed (`close`) when the view turns readonly; the markup places itself
16
+ * by its controller's `anchor`. `measure` runs on the overlay's frames (a
17
+ * surface whose anchor left the page closes there). Without a snippet the
18
+ * surface renders nothing (its controller still works): nothing is
19
+ * mounted. Answers the teardown.
11
20
  */
12
21
  export const mountChrome = (edytor, snippet, payload, shown, place, close) => snippet
13
- ? edytor.overlay.mount((Chrome), { edytor, snippet, payload, shown, close }, place.name, place.zIndex, place.measure)
22
+ ? edytor.overlay.mount((Chrome), { edytor, snippet, payload, shown, close }, place.name, place.zIndex, place.measure ?? (() => { }))
14
23
  : () => { };
15
24
  /**
16
25
  * Write `value` as `node`'s attribute `name`, only when it changes:
@@ -74,6 +83,15 @@ export const attribute = (node, name, value) => {
74
83
  };
75
84
  /** Whether `node` may name a highlighted row (`aria-activedescendant`): a field, or an element with a role. */
76
85
  export const namesRows = (node) => isField(node) || node.hasAttribute('role');
86
+ /**
87
+ * Every press in `document` (capture; WebKit's lone `mousedown` after a
88
+ * drag too, `onPress`) outside the elements `inside` matches: `outside`
89
+ * hears it. Answers the teardown.
90
+ */
91
+ export const onPressOutside = (edytor, document, inside, outside) => onPress(edytor, document, (event) => {
92
+ if (!event.target?.closest?.(inside))
93
+ outside(event);
94
+ }, true);
77
95
  /**
78
96
  * A handle menu's events on the editor `node` (the block menu, the `+`'s
79
97
  * menu): a grip's activation (`BLOCK_ACTIVATE_EVENT`), a `+`'s offer
@@ -81,7 +99,4 @@ export const namesRows = (node) => isField(node) || node.hasAttribute('role');
81
99
  * matches (WebKit's lone `mousedown` after a drag too, `onPress`). Answers
82
100
  * the teardown.
83
101
  */
84
- export const handleMenuEvents = (edytor, node, activate, add, inside, outside) => all(listen(node, BLOCK_ACTIVATE_EVENT, activate), listen(node, BLOCK_ADD_EVENT, add), onPress(edytor, node.ownerDocument, (event) => {
85
- if (!event.target?.closest?.(inside))
86
- outside();
87
- }, true));
102
+ export const handleMenuEvents = (edytor, node, activate, add, inside, outside) => all(listen(node, BLOCK_ACTIVATE_EVENT, activate), listen(node, BLOCK_ADD_EVENT, add), onPressOutside(edytor, node.ownerDocument, inside, outside));
@@ -1,14 +1,14 @@
1
1
  <script module lang="ts">
2
+ import { codeForms } from '../../export/forms.js';
2
3
  import './code.css';
3
4
  import type { Plugin, MarkSnippetPayload, BlockSnippetPayload } from '../../plugins.js';
4
5
  import { Text } from '../../text/text.svelte.js';
5
6
  import { runIntent } from '../../events/beforeInputCommands.js';
6
- import { codeKinds } from '../../crdt/semantics.js';
7
+
7
8
  import { shown } from '../../selection/visibility.js';
8
9
  import { caretBeside } from '../../selection/replaceSelection.js';
9
10
  import { siblingSlot } from '../../session/handles.js';
10
11
  import CodeHeader from './CodeHeader.svelte';
11
- import LanguageMenuPanel from './LanguageMenu.svelte';
12
12
  import { LanguageMenu, languageMenus } from './languageMenu.svelte.js';
13
13
  import { codeEnglish, keywordsOf, labelsOf } from '../../labels.js';
14
14
  import {
@@ -115,7 +115,7 @@
115
115
  onEdytorAttached: ({ node }) => {
116
116
  const menu = ownMenu();
117
117
  const snippet = menu?.settings.menu;
118
- return snippet && menu.panel.mount(node, LanguageMenuPanel, { menu, snippet });
118
+ return snippet && menu.panel.mount(node, snippet, menu, () => menu.open !== null);
119
119
  },
120
120
  hotkeys: {
121
121
  // Alt+F10 at a caret in a code line: the keys go to its language button
@@ -174,7 +174,7 @@
174
174
  edytor.idToBlock.get(
175
175
  edytor.insertBlocks(siblingSlot(line), [{ type: 'codeLine' }]).ids[0] ?? ''
176
176
  );
177
- return prevent(() => edytor.dispatcher.caret(next()?.firstText, 0));
177
+ return prevent(() => edytor.dispatcher.caretIn(next()?.firstText, 0));
178
178
  }
179
179
  prevent(() => runIntent(edytor, 'insertParagraph'));
180
180
  }
@@ -189,7 +189,10 @@
189
189
  prevent(() => {
190
190
  const before = caretBeside(block, 'blockBefore', new Set([block]));
191
191
  edytor.deleteBlock(block.id);
192
- edytor.dispatcher.caret(before?.text ?? code.firstEditableText, before?.offset ?? 0);
192
+ edytor.dispatcher.caretIn(
193
+ before?.text ?? code.firstEditableText,
194
+ before?.offset ?? 0
195
+ );
193
196
  });
194
197
  }
195
198
  // Backspace in an empty block right after a code block removes it; the
@@ -202,7 +205,7 @@
202
205
  prevent(() => {
203
206
  edytor.deleteBlock(block.id);
204
207
  const text = previous.lastText;
205
- edytor.dispatcher.caret(text, text?.length ?? 0);
208
+ edytor.dispatcher.caretIn(text, text?.length ?? 0);
206
209
  });
207
210
  }
208
211
  if (block.type !== 'codeLine') return;
@@ -213,7 +216,7 @@
213
216
  const [at, line] = [offset - startText.segStart, startText.stringContent];
214
217
  // A closer typed before the same character steps over it.
215
218
  if (CLOSERS.has(value) && line[at] === value) {
216
- prevent(() => edytor.dispatcher.caret(startText, at + 1));
219
+ prevent(() => edytor.dispatcher.caretIn(startText, at + 1));
217
220
  }
218
221
  // Quotes pair only at a word boundary: the apostrophe in `don't` stays single.
219
222
  const inWord = QUOTES.has(value) && /\w/.test((line[at - 1] ?? '') + (line[at] ?? ''));
@@ -230,7 +233,7 @@
230
233
 
231
234
  blocks: {
232
235
  code: {
233
- ...codeKinds.code,
236
+ ...codeForms().code,
234
237
  snippet: code,
235
238
  presets: [
236
239
  {
@@ -244,8 +247,8 @@
244
247
  empty: { content: [], children: [{ type: 'codeLine', content: [{ text: '' }] }] }
245
248
  },
246
249
  codeLine: {
250
+ ...codeForms().codeLine,
247
251
  snippet: codeLine,
248
- html: (_, content) => `<pre><code>${content}</code></pre>`,
249
252
  transformText: ({ text, block }) =>
250
253
  tokenizeCode(text.stringContent, lineLanguage(block.id)),
251
254
  // A line holding newlines keeps its first line; each other becomes a code line after it.
@@ -9,6 +9,7 @@ import { Text } from '../../text/text.svelte.js';
9
9
  import { attribute } from '../chrome.js';
10
10
  import { languageOf } from './languages.js';
11
11
  import { all, listen } from '../../utils/listen.js';
12
+ import { keysOf } from '../list.svelte.js';
12
13
  /** How long Copy reads Copied after a copy, in milliseconds. */
13
14
  const COPIED_FOR = 1200;
14
15
  /** A code block's text: its lines, joined by newlines. */
@@ -112,17 +113,12 @@ export class CodeHeader {
112
113
  const mousedown = (event) => event.preventDefault();
113
114
  // A click from Enter or Space has no pointer (`detail` 0): the keys opened it.
114
115
  const click = (event) => this.toggle(event.detail === 0);
115
- const keydown = (event) => {
116
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
117
- if (!this.expanded)
118
- this.toggle(true);
119
- }
120
- else if (event.key === 'Escape')
121
- this.menu?.release();
122
- else
123
- return;
124
- event.preventDefault();
125
- };
116
+ const open = () => this.expanded || this.toggle(true);
117
+ const keydown = keysOf({
118
+ ArrowDown: open,
119
+ ArrowUp: open,
120
+ Escape: () => this.menu?.release()
121
+ });
126
122
  const off = listen(node, 'mousedown', mousedown);
127
123
  const off2 = listen(node, 'click', click);
128
124
  const off3 = listen(node, 'keydown', keydown);
@@ -41,8 +41,11 @@ export declare class LanguageMenu extends ChromeList {
41
41
  } | null;
42
42
  /** The search field's text. */
43
43
  query: string;
44
- /** The view is readonly (reactive): the list closes. */
45
- get readonly(): boolean;
44
+ /**
45
+ * Where the list stands: the open block's language button
46
+ * (`ChromeAnchor`), which your `menu` places itself under.
47
+ */
48
+ get anchor(): import("../chrome.js").ChromeAnchor;
46
49
  /** The open block's language id. */
47
50
  get current(): string | null;
48
51
  /** The rows the query keeps: a language the plugin does not list first (the block's own), then the list. */
@@ -1,7 +1,7 @@
1
1
  import { untrack } from 'svelte';
2
2
  import { takeKeys } from '../../events/onFocus.js';
3
3
  import { attribute } from '../chrome.js';
4
- import { ChromeList, holdKeys } from '../list.svelte.js';
4
+ import { ChromeList, holdKeys, keysOf } from '../list.svelte.js';
5
5
  import { Anchored } from '../anchored.svelte.js';
6
6
  import { languageOf } from './languages.js';
7
7
  import { all, listen } from '../../utils/listen.js';
@@ -40,9 +40,12 @@ export class LanguageMenu extends ChromeList {
40
40
  this.settings = settings;
41
41
  this.panel = new Anchored(edytor, 'edytor-code-language-host', () => (this.open ? this.#button(this.open.block) : undefined), () => this.close());
42
42
  }
43
- /** The view is readonly (reactive): the list closes. */
44
- get readonly() {
45
- return this.edytor.readonly;
43
+ /**
44
+ * Where the list stands: the open block's language button
45
+ * (`ChromeAnchor`), which your `menu` places itself under.
46
+ */
47
+ get anchor() {
48
+ return this.panel.anchor;
46
49
  }
47
50
  /** The open block's language id. */
48
51
  get current() {
@@ -121,7 +124,6 @@ export class LanguageMenu extends ChromeList {
121
124
  if (!open)
122
125
  return;
123
126
  this.open = null;
124
- this.panel.box = null;
125
127
  this.query = '';
126
128
  this.edytor.overlay.invalidate();
127
129
  if (keys === 'button')
@@ -152,21 +154,12 @@ export class LanguageMenu extends ChromeList {
152
154
  return all(off, off2);
153
155
  });
154
156
  /** The search field's keys (`keys`). */
155
- #keydown = (event) => {
156
- if (event.isComposing)
157
- return;
158
- const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
159
- if (step)
160
- this.move(step);
161
- else if (event.key === 'Enter')
162
- this.pick();
163
- else if (event.key === 'Escape')
164
- this.close(this.open?.keys ? 'button' : 'editor');
165
- else
166
- return;
167
- event.preventDefault();
168
- event.stopPropagation();
169
- };
157
+ #keydown = keysOf({
158
+ ArrowDown: () => this.move(1),
159
+ ArrowUp: () => this.move(-1),
160
+ Enter: () => this.pick(),
161
+ Escape: () => this.close(this.open?.keys ? 'button' : 'editor')
162
+ }, true);
170
163
  /**
171
164
  * The keys back to the editor from a language button (its Escape): the
172
165
  * host takes the focus, the caret shown where the selection is.
@@ -1,16 +1,17 @@
1
1
  <script module lang="ts">
2
+ import { columnsForms } from '../../export/forms.js';
2
3
  import './columns.css';
3
4
  import type { BlockSnippetPayload, BlockView, EditorCommand, Plugin } from '../../plugins.js';
4
5
  import type { Edytor } from '../../edytor.svelte.js';
5
6
  import type { Block } from '../../block/block.svelte.js';
6
- import { layoutKinds } from '../../crdt/semantics.js';
7
+
7
8
  import { convertToKind, wrapBlocks, wrappable, type KindRow } from '../../kinds.js';
8
9
  import {
9
10
  getSelectedBlocksInDocumentOrder,
10
11
  liftLayouts
11
12
  } from '../../selection/replaceSelection.js';
12
13
  import ColumnResizeStrips from './ColumnResize.svelte';
13
- import { ColumnResize, weightOf } from './resize.svelte.js';
14
+ import { ColumnResize } from './resize.svelte.js';
14
15
  import { hoverChrome } from '../bands.svelte.js';
15
16
  import { all, listen } from '../../utils/listen.js';
16
17
  import { columnsEnglish, keywordsOf, labelsOf } from '../../labels.js';
@@ -23,12 +24,6 @@
23
24
  minWidth?: number;
24
25
  };
25
26
 
26
- /** A weight read back from HTML (`data-width`), when it is one. */
27
- const parsedWidth = (element: HTMLElement): Record<string, number> => {
28
- const width = Number(element.getAttribute('data-width'));
29
- return Number.isFinite(width) && width > 0 ? { width } : {};
30
- };
31
-
32
27
  /**
33
28
  * Whether `block` sits in a layout's column, at any depth: no layout goes
34
29
  * there (`layout.nest`). A `+` menu's stand-in (no id yet) answers by
@@ -174,15 +169,12 @@
174
169
  },
175
170
  blocks: {
176
171
  columns: {
177
- ...layoutKinds.columns,
172
+ ...columnsForms().columns,
178
173
  snippet: columns,
179
- element: { tag: 'div', attributes: { 'data-edytor-columns': '' } },
180
- html: (_, __, children) => `<div data-edytor-columns>${children}</div>`,
181
- plain: (_, __, children) => children,
182
- parse: (element) => (element.hasAttribute('data-edytor-columns') ? {} : undefined)
174
+ element: { tag: 'div', attributes: { 'data-edytor-columns': '' } }
183
175
  },
184
176
  column: {
185
- ...layoutKinds.column,
177
+ ...columnsForms().column,
186
178
  snippet: column,
187
179
  // Its weight as shown: a resize drag's preview (this view only), else `data.width`.
188
180
  element: (data, id) => ({
@@ -191,12 +183,7 @@
191
183
  'data-edytor-column': '',
192
184
  style: `flex: ${resize.weight(id, data)} 1 0px`
193
185
  }
194
- }),
195
- html: (block, _, children) =>
196
- `<div data-edytor-column data-width="${weightOf(block.data)}">${children}</div>`,
197
- plain: (_, __, children) => children,
198
- parse: (element) =>
199
- element.hasAttribute('data-edytor-column') ? parsedWidth(element) : undefined
186
+ })
200
187
  }
201
188
  }
202
189
  };
@@ -3,8 +3,8 @@ import type { Edytor } from '../../edytor.svelte.js';
3
3
  import { BandDrag } from '../bands.svelte.js';
4
4
  /** The guide line's width (the hover guide's and the drag's). */
5
5
  export declare const GUIDE = 2;
6
- /** A column's weight: `data.width`, a positive number, else 1. */
7
- export declare const weightOf: (data: Record<string, unknown> | undefined) => number;
6
+ import { weightOf } from '../../export/forms.js';
7
+ export { weightOf };
8
8
  /** The resize band in the gap between the columns `left` and `right` (`bandOf`), layer-relative. */
9
9
  export type Strip = {
10
10
  /** The layout, and the columns on each side. */
@@ -119,4 +119,3 @@ export declare class ColumnResize {
119
119
  /** A band took (`true`) or lost the focus: its layout's bands stay while it holds it. */
120
120
  focus: (strip: Strip, focused: boolean) => void;
121
121
  }
122
- export {};
@@ -5,11 +5,8 @@ import { stacks } from '../../dnd/stacking.js';
5
5
  import { columnsEnglish, labelsOf } from '../../labels.js';
6
6
  /** The guide line's width (the hover guide's and the drag's). */
7
7
  export const GUIDE = 2;
8
- /** A column's weight: `data.width`, a positive number, else 1. */
9
- export const weightOf = (data) => {
10
- const width = data?.width;
11
- return typeof width === 'number' && Number.isFinite(width) && width > 0 ? width : 1;
12
- };
8
+ import { weightOf } from '../../export/forms.js';
9
+ export { weightOf };
13
10
  /** The band's middle in a gap `width` px wide, from the gap's left. */
14
11
  const middleOf = (width) => {
15
12
  const band = bandOf({ left: 0, right: width });
@@ -74,6 +74,12 @@ export declare class CommentsController {
74
74
  readonly resolved: PlacedThread[];
75
75
  /** The threads the sidebar shows: the open ones, the resolved ones on demand, the active one. */
76
76
  readonly shown: PlacedThread[];
77
+ /**
78
+ * Where the thread being written, else the active one, stands
79
+ * (`ChromeAnchor`): the first line of its text, by which a card may
80
+ * place itself (the sidebar places its cards in the margin).
81
+ */
82
+ readonly anchor: import("../chrome.js").ChromeAnchor;
77
83
  /** The view may write: it may start, answer, resolve and delete comments. */
78
84
  get canComment(): boolean;
79
85
  /** One thread, by id. */
@@ -4,6 +4,9 @@ import { showText } from '../planned.js';
4
4
  import { COMMENT_MARK, blockCommentRuns, commentId, joinAnchors } from '../../crdt/protocols/comments.js';
5
5
  import { CommentThreads } from '../../collaboration/comments/threads.js';
6
6
  import { takeKeys } from '../../events/onFocus.js';
7
+ import { rangeRects } from '../../collaboration/remoteSelection.js';
8
+ import { runOf } from '../../components/Ranges.svelte';
9
+ import { virtualAnchor } from '../chrome.js';
7
10
  const avatarColors = ['#e16259', '#d9730d', '#cb912f', '#448361', '#337ea9', '#9065b0', '#c14c8a'];
8
11
  /**
9
12
  * The comments plugin's state and actions (`plugins/comments`): the
@@ -92,6 +95,23 @@ export class CommentsController {
92
95
  /** The threads the sidebar shows: the open ones, the resolved ones on demand, the active one. */
93
96
  shown = $derived(this.threads.filter((thread) => thread.runs.length > 0 &&
94
97
  (!thread.resolved || this.showResolved || thread.id === this.active)));
98
+ /**
99
+ * Where the thread being written, else the active one, stands
100
+ * (`ChromeAnchor`): the first line of its text, by which a card may
101
+ * place itself (the sidebar places its cards in the margin).
102
+ */
103
+ anchor = virtualAnchor(() => {
104
+ const { edytor } = this;
105
+ const run = this.draft
106
+ ? this.draftRuns()[0]
107
+ : this.active
108
+ ? this.anchors.get(this.active)?.[0]
109
+ : undefined;
110
+ const [rect] = run
111
+ ? runOf(edytor, run.block, run.offset, run.length).flatMap(({ start, end }) => rangeRects(edytor, start, end, new DOMRect()))
112
+ : [];
113
+ return rect && new DOMRect(rect.left, rect.top, rect.width, rect.height);
114
+ }, () => this.edytor.node);
95
115
  /** The view may write: it may start, answer, resolve and delete comments. */
96
116
  get canComment() {
97
117
  return this.edytor.dispatcher.permits();
@@ -1,4 +1,5 @@
1
1
  <script module lang="ts">
2
+ import { equationForms } from '../../export/forms.js';
2
3
  import './equation.css';
3
4
  import type {
4
5
  BlockSnippetPayload,
@@ -8,17 +9,15 @@
8
9
  } from '../../plugins.js';
9
10
  import type { Edytor } from '../../edytor.svelte.js';
10
11
  import { InlineBlock } from '../../block/inlineBlock.svelte.js';
11
- import { equationKinds } from '../../crdt/semantics.js';
12
+
12
13
  import { equationEnglish, keywordsOf, labelsOf } from '../../labels.js';
13
14
  import { id } from '../../utils.js';
14
15
  import EquationView from './EquationView.svelte';
15
- import EquationEditorPanel from './EquationEditor.svelte';
16
16
  import {
17
17
  EquationEditor,
18
18
  EquationRenderer,
19
19
  equationViews,
20
20
  expressionOf,
21
- parseEquation,
22
21
  type EquationData,
23
22
  type EquationErrorPayload,
24
23
  type EquationPlaceholderPayload,
@@ -28,7 +27,7 @@
28
27
  type KatexLoader
29
28
  } from './equation.svelte.js';
30
29
  import { katexLoaderOf } from './katex.js';
31
- import { withRulesAndTriggers } from '../triggers/triggers.js';
30
+ import { placeAtom, withRulesAndTriggers } from '../triggers/triggers.js';
32
31
 
33
32
  export type {
34
33
  EquationData,
@@ -101,13 +100,8 @@
101
100
  /** `$$E=mc^2$$` typed in text: an inline equation (Notion). */
102
101
  const dollars: InputRule = {
103
102
  find: /\$\$([^$\n]*[^$\s][^$\n]*)\$\$$/,
104
- replace: ([, tex], { edytor, block, from, caret, remove }) =>
105
- remove(() => {
106
- const atom = { type: INLINE, data: { expression: tex!.trim() } };
107
- const written = edytor.insertInline(block.id, from, atom).status === 'applied';
108
- if (written) caret(from + 1);
109
- return written;
110
- })
103
+ replace: ([, tex], ctx) =>
104
+ ctx.remove(() => placeAtom(ctx, { type: INLINE, data: { expression: tex!.trim() } }))
111
105
  };
112
106
 
113
107
  /** The equation a block selection or an atom selection stands for, if any. */
@@ -143,6 +137,8 @@
143
137
  (edytor) => {
144
138
  const labels = labelsOf(edytor, 'equation', equationEnglish);
145
139
  const renderer = new EquationRenderer(katexLoaderOf(options.katex), options.macros);
140
+ /** The kinds' forms: MathML by KaTeX once it is loaded. */
141
+ const forms = equationForms(renderer.mathml);
146
142
  // The records read with no view (`plugin(undefined)`) keep no state.
147
143
  if (edytor && !equationViews.has(edytor))
148
144
  equationViews.set(edytor, {
@@ -160,7 +156,7 @@
160
156
  if (!view || !owns()) return;
161
157
  const { editor } = view;
162
158
  const { panel } = options;
163
- return panel && editor.panel.mount(node, EquationEditorPanel, { editor, panel });
159
+ return panel && editor.panel.mount(node, panel, editor, () => editor.target !== null);
164
160
  },
165
161
  // A block equation this view just created empty (a slash pick, Turn into) opens its editor.
166
162
  onAfterOperation: (change) => {
@@ -207,7 +203,7 @@
207
203
  ],
208
204
  blocks: {
209
205
  equation: {
210
- ...equationKinds.equation,
206
+ ...forms.blocks.equation,
211
207
  snippet: equation,
212
208
  empty: { content: [], children: [] },
213
209
  presets: [
@@ -224,19 +220,13 @@
224
220
  ]),
225
221
  group: 'Advanced blocks'
226
222
  }
227
- ],
228
- html: (block) =>
229
- `<div data-edytor-equation>${renderer.mathml(expressionOf(block.data), true)}</div>`,
230
- plain: (block) => expressionOf(block.data),
231
- parse: (element) => parseEquation(element, true)
223
+ ]
232
224
  }
233
225
  },
234
226
  inlineBlocks: {
235
227
  [INLINE]: {
236
- snippet: inlineEquation,
237
- plain: (data) => expressionOf(data),
238
- html: (data) => renderer.mathml(expressionOf(data), false),
239
- parse: (element) => parseEquation(element, false)
228
+ ...forms.inlineBlocks.inlineEquation,
229
+ snippet: inlineEquation
240
230
  }
241
231
  }
242
232
  },