@aionbuilders/nabu 0.1.0-beta.0 → 0.1.1

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 (308) hide show
  1. package/CHANGELOG.md +531 -0
  2. package/LICENSE +21 -0
  3. package/README.md +72 -341
  4. package/dist/behaviors/text/RichText.svelte +24 -4
  5. package/dist/behaviors/text/markdown-shortcuts.extension.d.ts +3 -0
  6. package/dist/behaviors/text/markdown-shortcuts.extension.js +35 -10
  7. package/dist/behaviors/text/markdown-syntax.d.ts +42 -0
  8. package/dist/behaviors/text/markdown-syntax.js +81 -0
  9. package/dist/behaviors/text/rich-text.extension.d.ts +3 -0
  10. package/dist/behaviors/text/rich-text.extension.js +95 -38
  11. package/dist/behaviors/text/text.behavior.svelte.d.ts +195 -55
  12. package/dist/behaviors/text/text.behavior.svelte.js +531 -103
  13. package/dist/behaviors/text/typography.extension.d.ts +2 -1
  14. package/dist/behaviors/text/typography.extension.js +3 -2
  15. package/dist/blocks/BlockList.svelte +48 -0
  16. package/dist/blocks/BlockList.svelte.d.ts +17 -0
  17. package/dist/blocks/Nabu.svelte +169 -25
  18. package/dist/blocks/Nabu.svelte.d.ts +13 -0
  19. package/dist/blocks/block.extension.d.ts +3 -0
  20. package/dist/blocks/block.extension.js +4 -7
  21. package/dist/blocks/block.svelte.d.ts +350 -86
  22. package/dist/blocks/block.svelte.js +370 -59
  23. package/dist/blocks/blockquote/Blockquote.svelte +1 -2
  24. package/dist/blocks/blockquote/blockquote.extension.d.ts +4 -1
  25. package/dist/blocks/blockquote/blockquote.extension.js +14 -5
  26. package/dist/blocks/blockquote/blockquote.svelte.d.ts +19 -11
  27. package/dist/blocks/blockquote/blockquote.svelte.js +58 -13
  28. package/dist/blocks/callout/Callout.svelte +6 -8
  29. package/dist/blocks/callout/callout.extension.d.ts +4 -1
  30. package/dist/blocks/callout/callout.extension.js +19 -3
  31. package/dist/blocks/callout/callout.svelte.d.ts +5 -3
  32. package/dist/blocks/callout/callout.svelte.js +11 -6
  33. package/dist/blocks/chunks.d.ts +49 -0
  34. package/dist/blocks/chunks.js +90 -0
  35. package/dist/blocks/code/Code.svelte +7 -8
  36. package/dist/blocks/code/code.extension.d.ts +4 -1
  37. package/dist/blocks/code/code.extension.js +22 -2
  38. package/dist/blocks/code/code.svelte.d.ts +9 -2
  39. package/dist/blocks/code/code.svelte.js +49 -25
  40. package/dist/blocks/container.utils.d.ts +85 -13
  41. package/dist/blocks/container.utils.js +338 -178
  42. package/dist/blocks/dialogue/Dialogue.svelte +8 -4
  43. package/dist/blocks/dialogue/dialogue.svelte.d.ts +33 -2
  44. package/dist/blocks/dialogue/dialogue.svelte.js +58 -4
  45. package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +2 -2
  46. package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +6 -4
  47. package/dist/blocks/dialogue/index.d.ts +12 -1
  48. package/dist/blocks/dialogue/index.js +51 -35
  49. package/dist/blocks/divider/divider.extension.d.ts +23 -1
  50. package/dist/blocks/divider/divider.extension.js +85 -19
  51. package/dist/blocks/divider/divider.svelte.d.ts +7 -2
  52. package/dist/blocks/divider/divider.svelte.js +9 -4
  53. package/dist/blocks/file/File.svelte +13 -6
  54. package/dist/blocks/file/file.extension.d.ts +4 -1
  55. package/dist/blocks/file/file.extension.js +9 -1
  56. package/dist/blocks/file/file.svelte.d.ts +3 -3
  57. package/dist/blocks/file/file.svelte.js +20 -14
  58. package/dist/blocks/heading/Heading.svelte +1 -2
  59. package/dist/blocks/heading/heading.svelte.d.ts +23 -11
  60. package/dist/blocks/heading/heading.svelte.js +68 -13
  61. package/dist/blocks/heading/hooks/onBeforeInput.hook.js +7 -5
  62. package/dist/blocks/heading/index.d.ts +2 -2
  63. package/dist/blocks/heading/index.js +33 -8
  64. package/dist/blocks/image/Image.svelte +5 -2
  65. package/dist/blocks/image/image.extension.d.ts +4 -1
  66. package/dist/blocks/image/image.extension.js +9 -1
  67. package/dist/blocks/image/image.svelte.d.ts +17 -6
  68. package/dist/blocks/image/image.svelte.js +33 -11
  69. package/dist/blocks/index.d.ts +1 -1
  70. package/dist/blocks/index.js +1 -1
  71. package/dist/blocks/list/List.svelte +1 -0
  72. package/dist/blocks/list/ListItem.svelte +1 -0
  73. package/dist/blocks/list/convert.d.ts +20 -0
  74. package/dist/blocks/list/convert.js +92 -0
  75. package/dist/blocks/list/hooks/onBeforeInput.hook.js +49 -28
  76. package/dist/blocks/list/html-flat.d.ts +78 -0
  77. package/dist/blocks/list/html-flat.js +244 -0
  78. package/dist/blocks/list/indent.d.ts +86 -0
  79. package/dist/blocks/list/indent.js +205 -0
  80. package/dist/blocks/list/index.d.ts +6 -3
  81. package/dist/blocks/list/index.js +42 -31
  82. package/dist/blocks/list/list-item.svelte.d.ts +32 -18
  83. package/dist/blocks/list/list-item.svelte.js +99 -100
  84. package/dist/blocks/list/list.behavior.svelte.d.ts +4 -1
  85. package/dist/blocks/list/list.behavior.svelte.js +6 -1
  86. package/dist/blocks/list/list.svelte.d.ts +89 -18
  87. package/dist/blocks/list/list.svelte.js +129 -125
  88. package/dist/blocks/list/markdown.d.ts +149 -0
  89. package/dist/blocks/list/markdown.js +442 -0
  90. package/dist/blocks/list/normalize.d.ts +11 -0
  91. package/dist/blocks/list/normalize.js +396 -0
  92. package/dist/blocks/list/paste.d.ts +45 -0
  93. package/dist/blocks/list/paste.js +242 -0
  94. package/dist/blocks/list/step-back.d.ts +24 -0
  95. package/dist/blocks/list/step-back.js +87 -0
  96. package/dist/blocks/list/to-list.d.ts +7 -0
  97. package/dist/blocks/list/to-list.js +44 -0
  98. package/dist/blocks/list/todos-toggle.d.ts +20 -0
  99. package/dist/blocks/list/todos-toggle.js +48 -0
  100. package/dist/blocks/media/markdown.d.ts +12 -0
  101. package/dist/blocks/media/markdown.js +26 -0
  102. package/dist/blocks/media/media-block.svelte.d.ts +77 -2
  103. package/dist/blocks/media/media-block.svelte.js +124 -12
  104. package/dist/blocks/media/media.helpers.d.ts +6 -1
  105. package/dist/blocks/media/media.helpers.js +43 -6
  106. package/dist/blocks/megablock.svelte.d.ts +50 -19
  107. package/dist/blocks/megablock.svelte.js +114 -74
  108. package/dist/blocks/move.d.ts +23 -0
  109. package/dist/blocks/move.js +92 -0
  110. package/dist/blocks/nabu.svelte.d.ts +764 -71
  111. package/dist/blocks/nabu.svelte.js +1753 -189
  112. package/dist/blocks/paragraph/Paragraph.svelte +1 -2
  113. package/dist/blocks/paragraph/index.d.ts +2 -2
  114. package/dist/blocks/paragraph/index.js +35 -13
  115. package/dist/blocks/paragraph/paragraph.svelte.d.ts +46 -14
  116. package/dist/blocks/paragraph/paragraph.svelte.js +77 -16
  117. package/dist/blocks/paragraph/table.html.d.ts +9 -0
  118. package/dist/blocks/paragraph/table.html.js +111 -0
  119. package/dist/blocks/paragraph/table.markdown.d.ts +32 -0
  120. package/dist/blocks/paragraph/table.markdown.js +90 -0
  121. package/dist/blocks/region/Region.svelte +264 -0
  122. package/dist/blocks/region/Region.svelte.d.ts +11 -0
  123. package/dist/blocks/region/actions.d.ts +135 -0
  124. package/dist/blocks/region/actions.js +402 -0
  125. package/dist/blocks/region/close.d.ts +35 -0
  126. package/dist/blocks/region/close.js +130 -0
  127. package/dist/blocks/region/commands.d.ts +6 -0
  128. package/dist/blocks/region/commands.js +277 -0
  129. package/dist/blocks/region/create.d.ts +72 -0
  130. package/dist/blocks/region/create.js +208 -0
  131. package/dist/blocks/region/end-marker.d.ts +35 -0
  132. package/dist/blocks/region/end-marker.js +51 -0
  133. package/dist/blocks/region/facts.d.ts +69 -0
  134. package/dist/blocks/region/facts.js +152 -0
  135. package/dist/blocks/region/format.d.ts +91 -0
  136. package/dist/blocks/region/format.js +260 -0
  137. package/dist/blocks/region/index.d.ts +14 -0
  138. package/dist/blocks/region/index.js +14 -0
  139. package/dist/blocks/region/insert.d.ts +59 -0
  140. package/dist/blocks/region/insert.js +102 -0
  141. package/dist/blocks/region/messages.d.ts +254 -0
  142. package/dist/blocks/region/messages.js +131 -0
  143. package/dist/blocks/region/normalize.d.ts +7 -0
  144. package/dist/blocks/region/normalize.js +170 -0
  145. package/dist/blocks/region/region.extension.d.ts +58 -0
  146. package/dist/blocks/region/region.extension.js +119 -0
  147. package/dist/blocks/region/region.svelte.d.ts +221 -0
  148. package/dist/blocks/region/region.svelte.js +582 -0
  149. package/dist/blocks/region/regions.svelte.d.ts +141 -0
  150. package/dist/blocks/region/regions.svelte.js +276 -0
  151. package/dist/blocks/region/serialize.d.ts +57 -0
  152. package/dist/blocks/region/serialize.js +112 -0
  153. package/dist/blocks/region/types.d.ts +255 -0
  154. package/dist/blocks/region/types.js +204 -0
  155. package/dist/blocks/selection.svelte.d.ts +106 -8
  156. package/dist/blocks/selection.svelte.js +622 -74
  157. package/dist/blocks/subthread.d.ts +80 -0
  158. package/dist/blocks/subthread.js +167 -0
  159. package/dist/blocks/text-block.svelte.d.ts +35 -14
  160. package/dist/blocks/text-block.svelte.js +42 -8
  161. package/dist/blocks/toggle/Toggle.svelte +4 -15
  162. package/dist/blocks/toggle/markdown.d.ts +20 -0
  163. package/dist/blocks/toggle/markdown.js +112 -0
  164. package/dist/blocks/toggle/toggle.extension.d.ts +4 -1
  165. package/dist/blocks/toggle/toggle.extension.js +6 -0
  166. package/dist/blocks/toggle/toggle.svelte.d.ts +55 -8
  167. package/dist/blocks/toggle/toggle.svelte.js +134 -34
  168. package/dist/blocks/undo-selection.d.ts +175 -0
  169. package/dist/blocks/undo-selection.js +360 -0
  170. package/dist/blocks/video/Video.svelte +5 -2
  171. package/dist/blocks/video/video.extension.d.ts +4 -1
  172. package/dist/blocks/video/video.extension.js +9 -1
  173. package/dist/blocks/video/video.svelte.d.ts +6 -5
  174. package/dist/blocks/video/video.svelte.js +18 -9
  175. package/dist/extend.d.ts +55 -0
  176. package/dist/extend.js +88 -0
  177. package/dist/files/assets.clipboard.d.ts +77 -0
  178. package/dist/files/assets.clipboard.js +152 -0
  179. package/dist/files/files.svelte.d.ts +321 -19
  180. package/dist/files/files.svelte.js +847 -43
  181. package/dist/files/index.d.ts +3 -1
  182. package/dist/files/index.js +3 -1
  183. package/dist/files/outbox.d.ts +69 -0
  184. package/dist/files/outbox.js +48 -0
  185. package/dist/files/status.d.ts +65 -0
  186. package/dist/files/status.js +87 -0
  187. package/dist/files/store.d.ts +97 -0
  188. package/dist/files/store.js +65 -0
  189. package/dist/files/uploads.svelte.d.ts +174 -0
  190. package/dist/files/uploads.svelte.js +504 -0
  191. package/dist/index.d.ts +68 -9
  192. package/dist/index.js +117 -10
  193. package/dist/nabu-theme.css +21 -1
  194. package/dist/paste/html.paste.d.ts +74 -3
  195. package/dist/paste/html.paste.js +550 -86
  196. package/dist/paste/markdown-inline.d.ts +86 -0
  197. package/dist/paste/markdown-inline.js +528 -0
  198. package/dist/paste/markdown.paste.d.ts +2 -8
  199. package/dist/paste/markdown.paste.js +78 -94
  200. package/dist/paste/nabu.paste.d.ts +3 -0
  201. package/dist/paste/nabu.paste.js +29 -3
  202. package/dist/paste/plain-text.paste.d.ts +2 -2
  203. package/dist/paste/plain-text.paste.js +3 -3
  204. package/dist/persistence/asset-store.d.ts +51 -0
  205. package/dist/persistence/asset-store.js +103 -0
  206. package/dist/persistence/autosave.d.ts +53 -0
  207. package/dist/persistence/autosave.js +62 -0
  208. package/dist/persistence/compact.d.ts +162 -0
  209. package/dist/persistence/compact.js +141 -0
  210. package/dist/persistence/history.d.ts +77 -0
  211. package/dist/persistence/history.js +176 -0
  212. package/dist/persistence/indexeddb.d.ts +190 -4
  213. package/dist/persistence/indexeddb.js +333 -29
  214. package/dist/persistence/merge.d.ts +38 -0
  215. package/dist/persistence/merge.js +36 -0
  216. package/dist/persistence/outbox.d.ts +25 -0
  217. package/dist/persistence/outbox.js +40 -0
  218. package/dist/persistence/persistence.d.ts +70 -9
  219. package/dist/persistence/persistence.js +507 -35
  220. package/dist/persistence/recovery.d.ts +79 -0
  221. package/dist/persistence/recovery.js +79 -0
  222. package/dist/persistence/release.d.ts +34 -0
  223. package/dist/persistence/release.js +64 -0
  224. package/dist/persistence/state.svelte.d.ts +53 -0
  225. package/dist/persistence/state.svelte.js +48 -0
  226. package/dist/persistence/sync.d.ts +39 -0
  227. package/dist/persistence/sync.js +138 -0
  228. package/dist/persistence/tail.d.ts +42 -0
  229. package/dist/persistence/tail.js +103 -0
  230. package/dist/presets.d.ts +29 -26
  231. package/dist/presets.js +35 -13
  232. package/dist/themes/atelier.css +318 -0
  233. package/dist/ui/CommandChooser.svelte +153 -0
  234. package/dist/ui/CommandChooser.svelte.d.ts +13 -0
  235. package/dist/ui/CommandInvite.svelte +99 -0
  236. package/dist/ui/CommandInvite.svelte.d.ts +12 -0
  237. package/dist/ui/DragHandle.svelte +97 -21
  238. package/dist/ui/FloatingToolbar.svelte +75 -27
  239. package/dist/ui/FloatingToolbar.svelte.d.ts +10 -0
  240. package/dist/ui/SlashMenu.svelte +147 -15
  241. package/dist/ui/SlashMenu.svelte.d.ts +20 -0
  242. package/dist/ui/anchor.d.ts +112 -0
  243. package/dist/ui/anchor.js +136 -0
  244. package/dist/ui/index.d.ts +7 -1
  245. package/dist/ui/index.js +12 -1
  246. package/dist/ui/slash-menu.svelte.d.ts +79 -7
  247. package/dist/ui/slash-menu.svelte.js +85 -51
  248. package/dist/utils/command-confirm.svelte.d.ts +349 -0
  249. package/dist/utils/command-confirm.svelte.js +673 -0
  250. package/dist/utils/commands.d.ts +328 -0
  251. package/dist/utils/commands.js +416 -0
  252. package/dist/utils/composition.d.ts +28 -0
  253. package/dist/utils/composition.js +51 -0
  254. package/dist/utils/dom-scope.d.ts +14 -0
  255. package/dist/utils/dom-scope.js +20 -0
  256. package/dist/utils/drop.d.ts +160 -0
  257. package/dist/utils/drop.js +305 -0
  258. package/dist/utils/extensions.d.ts +439 -45
  259. package/dist/utils/extensions.js +271 -29
  260. package/dist/utils/html.d.ts +44 -0
  261. package/dist/utils/html.js +183 -0
  262. package/dist/utils/index.d.ts +3 -0
  263. package/dist/utils/index.js +3 -0
  264. package/dist/utils/keys.d.ts +120 -0
  265. package/dist/utils/keys.js +248 -0
  266. package/dist/utils/links.d.ts +22 -0
  267. package/dist/utils/links.js +34 -0
  268. package/dist/utils/placeholders.d.ts +81 -3
  269. package/dist/utils/placeholders.js +73 -3
  270. package/dist/utils/selection.svelte.d.ts +48 -20
  271. package/dist/utils/selection.svelte.js +60 -10
  272. package/dist/utils/spellcheck.d.ts +9 -0
  273. package/dist/utils/spellcheck.js +17 -0
  274. package/dist/utils/tab.d.ts +31 -0
  275. package/dist/utils/tab.js +117 -0
  276. package/dist/utils/words.d.ts +42 -0
  277. package/dist/utils/words.js +147 -0
  278. package/dist/vite.d.ts +9 -3
  279. package/dist/vite.js +19 -8
  280. package/package.json +56 -20
  281. package/dist/blocks/variable.svelte.d.ts +0 -47
  282. package/dist/blocks/variable.svelte.js +0 -51
  283. package/dist/blocks/zone/TemplateEditor.svelte +0 -308
  284. package/dist/blocks/zone/TemplateEditor.svelte.d.ts +0 -11
  285. package/dist/blocks/zone/Zone.svelte +0 -272
  286. package/dist/blocks/zone/Zone.svelte.d.ts +0 -11
  287. package/dist/blocks/zone/ZoneEditor.svelte +0 -289
  288. package/dist/blocks/zone/ZoneEditor.svelte.d.ts +0 -11
  289. package/dist/blocks/zone/ZoneTemplatesList.svelte +0 -188
  290. package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +0 -11
  291. package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +0 -3
  292. package/dist/blocks/zone/hooks/onBeforeInput.hook.js +0 -30
  293. package/dist/blocks/zone/index.d.ts +0 -2
  294. package/dist/blocks/zone/index.js +0 -2
  295. package/dist/blocks/zone/zone.extension.d.ts +0 -2
  296. package/dist/blocks/zone/zone.extension.js +0 -237
  297. package/dist/blocks/zone/zone.svelte.d.ts +0 -221
  298. package/dist/blocks/zone/zone.svelte.js +0 -608
  299. package/dist/overlays/context/Context.svelte +0 -182
  300. package/dist/overlays/context/Context.svelte.d.ts +0 -17
  301. package/dist/overlays/context/collect.d.ts +0 -17
  302. package/dist/overlays/context/collect.js +0 -33
  303. package/dist/overlays/context/context.extension.d.ts +0 -2
  304. package/dist/overlays/context/context.extension.js +0 -8
  305. package/dist/overlays/context/context.svelte.d.ts +0 -82
  306. package/dist/overlays/context/context.svelte.js +0 -159
  307. package/dist/overlays/context/index.d.ts +0 -3
  308. package/dist/overlays/context/index.js +0 -3
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Undo / redo restore the SELECTION (ADR 015): what is stored with each undo step, how it is captured, and how it comes back.
3
+ *
4
+ * Each endpoint of a selection (anchor, focus) is remembered as Loro stable cursors on the block's text, so concurrent remote
5
+ * edits shift it correctly, plus the block id, its tree path and the plain offset as fallbacks. Pure helpers: they know the
6
+ * `text` behavior (container + `getDOMPoint`) and nothing about any concrete block type.
7
+ *
8
+ * Two cursors per endpoint, because a Loro cursor is bound to ONE character and a character deleted by the very action being
9
+ * undone (and re-created under a new id by the undo) is no anchor any more:
10
+ * - `next`: bound to the character right AFTER the endpoint (an insertion at the endpoint lands before it);
11
+ * - `prev`: bound to the character right BEFORE the endpoint (resolved +1).
12
+ * Whichever one still points at a live character wins (see {@link resolveOffset}).
13
+ */
14
+
15
+ import { tick } from 'svelte';
16
+ import { Cursor } from 'loro-crdt';
17
+
18
+ /**
19
+ * @import { LoroDoc } from 'loro-crdt';
20
+ * @import { Nabu } from './nabu.svelte.js';
21
+ * @import { Block } from './block.svelte.js';
22
+ */
23
+
24
+ /**
25
+ * @typedef {Object} Endpoint One end of a stored selection.
26
+ * @property {string} blockId
27
+ * @property {number[]} path child index at each level, root first (see {@link blockPath})
28
+ * @property {number} offset model offset when captured: the fallback when no cursor can be used
29
+ * @property {number} [length] length of the block's text when captured (see {@link resolveOffset}: both cursors dead)
30
+ * @property {string | null} container id of the block's text container the cursors belong to
31
+ * @property {'start' | 'end'} role the first end of a range sticks to the character before it, every other end to the one after
32
+ * @property {Uint8Array | null} next encoded Loro cursor (the UndoManager serializes what it stores: a live Cursor would not survive)
33
+ * @property {Uint8Array | null} prev
34
+ */
35
+
36
+ /**
37
+ * @typedef {Object} UndoSelection The selection stored with an undo / redo step.
38
+ * @property {Endpoint} anchor
39
+ * @property {Endpoint} focus Equal to `anchor` for a caret. The direction of a backward selection is kept by which end is which.
40
+ */
41
+
42
+ /**
43
+ * Tree path of a block: the child index at each level, root first. Read from the Block's own
44
+ * `parent` / `index` — still valid for a block destroyed in the very transaction being recorded,
45
+ * whose Loro node can no longer tell (a deleted node has no index).
46
+ * @param {Block} block
47
+ * @returns {number[]}
48
+ */
49
+ export function blockPath(block) {
50
+ /** @type {number[]} */
51
+ const path = [];
52
+ for (let b = /** @type {any} */ (block); b; b = b.parent) path.unshift(b.index);
53
+ return path;
54
+ }
55
+
56
+ /**
57
+ * @param {Block} block
58
+ * @param {number} offset
59
+ * @param {'start' | 'end'} role
60
+ * @param {boolean} [withCursors] false for a caret known only after the fact (no pre-change text to bind to)
61
+ * @returns {Endpoint}
62
+ */
63
+ export function makeEndpoint(block, offset, role, withCursors = true) {
64
+ const container = /** @type {any} */ (block.behaviors?.get('text'))?.container ?? null;
65
+ /** @type {Uint8Array | null} */
66
+ let next = null;
67
+ /** @type {Uint8Array | null} */
68
+ let prev = null;
69
+ if (container && withCursors) {
70
+ try {
71
+ next = container.getCursor(offset, 0)?.encode() ?? null;
72
+ prev = offset > 0 ? container.getCursor(offset - 1, 0)?.encode() ?? null : null;
73
+ } catch { /* a container without cursor support: the plain offset remains */ }
74
+ }
75
+ const length = container ? container.length : undefined;
76
+ return { blockId: block.id, path: blockPath(block), offset, length, container: container?.id ?? null, role, next, prev };
77
+ }
78
+
79
+ /**
80
+ * Where a DOM point is in the model: the text block holding it and the offset in its text.
81
+ * @param {Nabu} nabu
82
+ * @param {Node} node
83
+ * @param {number} offset
84
+ * @returns {{ block: Block, offset: number } | null}
85
+ */
86
+ function locate(nabu, node, offset) {
87
+ const el = /** @type {Element | null} */ (node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement);
88
+ if (!el || nabu.selection.closestOwn(el, '[data-nabu-ui]')) return null;
89
+ if (!nabu.selection.owns(node)) return null; // a point of another editor (or of none) is not a position in THIS model
90
+ const id = el.closest('[data-block-id]')?.getAttribute('data-block-id');
91
+ const block = id ? nabu.blocks.get(id) : null;
92
+ if (!block) return null;
93
+ const text = /** @type {any} */ (block.behaviors?.get('text'));
94
+ if (!text) return { block, offset: 0 };
95
+ const at = block.element ? text.calculateOffset(node, offset, block.element) : 0;
96
+ return { block, offset: Math.max(0, Math.min(at, text.text.length)) };
97
+ }
98
+
99
+ /**
100
+ * The live DOM selection as MODEL points (block + text offset), anchor and focus kept apart so the direction survives.
101
+ * The only reliable way to carry a selection across a change that rewrites the DOM of its blocks (a mark toggled, a text
102
+ * rewritten): DOM offsets are relative to a text node, and the text nodes change with the spans.
103
+ * @param {Nabu} nabu
104
+ * @returns {{ anchor: { block: Block, offset: number }, focus: { block: Block, offset: number } } | null}
105
+ */
106
+ export function livePoints(nabu) {
107
+ if (typeof window === 'undefined' || !window.getSelection) return null;
108
+ const live = window.getSelection();
109
+ if (!live || live.rangeCount === 0 || !live.anchorNode || !live.focusNode) return null;
110
+ if (nabu.selection.scope(live) !== 'mine') return null;
111
+ const anchor = locate(nabu, live.anchorNode, live.anchorOffset);
112
+ const focus = locate(nabu, live.focusNode, live.focusOffset);
113
+ return anchor && focus ? { anchor, focus } : null;
114
+ }
115
+
116
+ /**
117
+ * Put a selection given as model points (see {@link livePoints}) on the rendered DOM, direction included. Offsets are clamped to
118
+ * the text. Does nothing when a block has no DOM point (not rendered).
119
+ * @param {Nabu} nabu
120
+ * @param {{ anchor: { block: Block, offset: number }, focus: { block: Block, offset: number } }} points
121
+ * @returns {boolean} whether the selection was placed
122
+ */
123
+ export function placePoints(nabu, { anchor, focus }) {
124
+ /** @param {{ block: Block, offset: number }} p */
125
+ const point = (p) => {
126
+ const len = /** @type {any} */ (p.block.behaviors?.get('text'))?.text?.length ?? p.offset;
127
+ return /** @type {any} */ (p.block).getDOMPoint?.(Math.max(0, Math.min(p.offset, len))) ?? null;
128
+ };
129
+ const a = point(anchor);
130
+ const f = point(focus);
131
+ if (!a || !f) return false;
132
+ nabu.selection.setBaseAndExtent(a.node, a.offset, f.node, f.offset);
133
+ return true;
134
+ }
135
+
136
+ /**
137
+ * Capture the live DOM selection as an {@link UndoSelection}. The cursors are created on the CURRENT text, so call it while the
138
+ * model and the DOM agree and before the change to be undone is applied (see `Nabu#captureUndoSelection`).
139
+ * @param {Nabu} nabu
140
+ * @returns {UndoSelection | null} null when the selection is not in this editor
141
+ */
142
+ export function captureSelection(nabu) {
143
+ if (typeof window === 'undefined' || !window.getSelection) return null;
144
+ const live = window.getSelection();
145
+ if (!live || live.rangeCount === 0 || !live.anchorNode || !live.focusNode) return null;
146
+ if (nabu.selection.scope(live) !== 'mine') return null;
147
+ const a = locate(nabu, live.anchorNode, live.anchorOffset);
148
+ const f = locate(nabu, live.focusNode, live.focusOffset);
149
+ if (!a || !f) return null;
150
+
151
+ const collapsed = a.block === f.block && a.offset === f.offset;
152
+ if (collapsed) {
153
+ const ep = makeEndpoint(a.block, a.offset, 'end');
154
+ return { anchor: ep, focus: ep };
155
+ }
156
+ // Which end comes first in the document decides the roles; the anchor / focus order (the direction) is kept as is.
157
+ let anchorFirst = a.offset <= f.offset;
158
+ if (a.block !== f.block) {
159
+ try {
160
+ const probe = document.createRange();
161
+ probe.setStart(live.anchorNode, live.anchorOffset);
162
+ probe.collapse(true);
163
+ anchorFirst = probe.comparePoint(live.focusNode, live.focusOffset) >= 0;
164
+ } catch { /* keep the offset order */ }
165
+ }
166
+ return {
167
+ anchor: makeEndpoint(a.block, a.offset, anchorFirst ? 'start' : 'end'),
168
+ focus: makeEndpoint(f.block, f.offset, anchorFirst ? 'end' : 'start'),
169
+ };
170
+ }
171
+
172
+ /**
173
+ * A caret decided by a caller (a block shortcut puts it right after the typed trigger): plain block + offset, no cursors
174
+ * (the text it refers to is not the one the change is applied on).
175
+ * @param {Block} block
176
+ * @param {number} offset
177
+ * @returns {UndoSelection}
178
+ */
179
+ export function explicitSelection(block, offset) {
180
+ const ep = makeEndpoint(block, offset, 'end', false);
181
+ return { anchor: ep, focus: ep };
182
+ }
183
+
184
+ /**
185
+ * The caret the selection state reports, when the DOM selection could not be captured (no DOM selection: a blurred editor, a
186
+ * test environment). No cursors.
187
+ * @param {Nabu} nabu
188
+ * @returns {UndoSelection | null}
189
+ */
190
+ export function legacySelection(nabu) {
191
+ const sel = /** @type {any} */ (nabu.selection);
192
+ const block = sel?.anchorBlock;
193
+ if (!block) return null;
194
+ const ep = makeEndpoint(block, sel.startOffset ?? 0, 'end', false);
195
+ return { anchor: ep, focus: ep };
196
+ }
197
+
198
+ /**
199
+ * Offset an endpoint stands at NOW. A cursor whose character was deleted (`update` set) is the one to distrust; of the
200
+ * two cursors, the live one wins — for two live ones the role decides (a range start sticks to the character before it).
201
+ * Both dead: the position of the tombstones, unless the text has the very length it had when the endpoint was captured — the
202
+ * characters around it were then deleted and re-created by an undo / redo of the action (typing over a range: the caret between
203
+ * the typed character and the merged tail, and both are new characters after the redo), and the stored offset is the right one.
204
+ * @param {LoroDoc} doc
205
+ * @param {Endpoint} ep
206
+ * @param {number} length current length of the text
207
+ * @returns {number | null} null when no cursor resolves (use the stored offset)
208
+ */
209
+ export function resolveOffset(doc, ep, length) {
210
+ /** @param {Uint8Array | null} encoded @param {number} shift @returns {{ offset: number, deleted: boolean } | null} */
211
+ const at = (encoded, shift) => {
212
+ if (!encoded) return null;
213
+ try {
214
+ const r = doc.getCursorPos(Cursor.decode(encoded));
215
+ return r ? { offset: r.offset + shift, deleted: !!r.update } : null;
216
+ } catch { return null; }
217
+ };
218
+ const next = at(ep.next, 0);
219
+ // No `prev` cursor at offset 0: the start of the text is a position that cannot be deleted.
220
+ const prev = ep.prev ? at(ep.prev, 1) : (ep.offset === 0 ? { offset: 0, deleted: false } : null);
221
+ /** @type {{ offset: number, deleted: boolean } | null} */
222
+ let chosen;
223
+ if (next && prev) {
224
+ if (next.deleted !== prev.deleted) chosen = next.deleted ? prev : next;
225
+ else if (next.deleted && prev.deleted && ep.length === length) chosen = { offset: ep.offset, deleted: true };
226
+ else chosen = ep.role === 'start' && !prev.deleted ? prev : next;
227
+ } else chosen = next ?? prev;
228
+ return chosen ? Math.max(0, Math.min(chosen.offset, length)) : null;
229
+ }
230
+
231
+ /**
232
+ * The block and offset an endpoint stands at now. The block is found by id when it is still alive; Loro gives a block RESTORED
233
+ * by an undo (after a delete) a new id and a new text container, so otherwise by its tree path (walked as far as it still
234
+ * exists, then the nearest text block); the offset is the cursors' answer when they belong to the block's current text, else
235
+ * the stored one clamped to the text.
236
+ * @param {Nabu} nabu
237
+ * @param {Endpoint} ep
238
+ * @param {boolean} [strict] only the block of that very id, still alive (no fallback by tree path): null otherwise
239
+ * @returns {{ block: Block, offset: number } | null}
240
+ */
241
+ function resolveEndpoint(nabu, ep, strict = false) {
242
+ /** @param {Block | undefined | null} b */
243
+ const alive = (b) => !!b && !b.node.isDeleted?.() && nabu.tree.has(b.node.id);
244
+ /** @param {Block} b */
245
+ const withText = (b) => !!b.behaviors?.has('text');
246
+ /** @param {Block} b */
247
+ const length = (b) => /** @type {any} */ (b.behaviors.get('text'))?.text?.length ?? 0;
248
+ /** @param {Block} b */
249
+ const resolve = (b) => {
250
+ const container = /** @type {any} */ (b.behaviors.get('text'))?.container;
251
+ const fromCursors = container && ep.container === container.id ? resolveOffset(nabu.doc, ep, length(b)) : null;
252
+ return { block: b, offset: fromCursors ?? Math.max(0, Math.min(ep.offset, length(b))) };
253
+ };
254
+
255
+ const byId = nabu.blocks.get(ep.blockId);
256
+ if (byId && alive(byId) && withText(byId)) return resolve(byId);
257
+ if (strict) return null;
258
+
259
+ /** @type {Block | null} */
260
+ let found = null;
261
+ /** @type {any} */
262
+ let level = nabu;
263
+ for (const i of ep.path ?? []) {
264
+ const next = level.children?.[i];
265
+ if (!next) break;
266
+ found = next;
267
+ level = next;
268
+ }
269
+ if (found && !withText(found)) found = found.findForward(withText);
270
+ if (!found) found = nabu.children.find(withText) ?? nabu.children[0]?.findForward(withText) ?? null;
271
+ return found ? resolve(found) : null;
272
+ }
273
+
274
+ /**
275
+ * Put the stored selection back, after the undo / redo has re-rendered, then scroll it into view. A block recreated by the undo
276
+ * may not be rendered yet: retried a few ticks.
277
+ * @param {Nabu} nabu
278
+ * @param {UndoSelection} snap
279
+ * @param {number} [attempt]
280
+ * @param {boolean} [reveal] scroll the focus end into view (default); `false` for a change the user did not make (a remote import)
281
+ */
282
+ export function restoreSelection(nabu, snap, attempt = 0, reveal = true) {
283
+ tick().then(() => {
284
+ const a = resolveEndpoint(nabu, snap.anchor);
285
+ const f = resolveEndpoint(nabu, snap.focus);
286
+ if (!a && !f) return;
287
+ const anchor = /** @type {NonNullable<typeof a>} */ (a ?? f);
288
+ const focus = /** @type {NonNullable<typeof f>} */ (f ?? a);
289
+ if ((!anchor.block.element || !focus.block.element) && attempt < 3) return restoreSelection(nabu, snap, attempt + 1, reveal);
290
+
291
+ if (anchor.block === focus.block && anchor.offset === focus.offset) {
292
+ nabu.selection.setCursor(anchor.block, anchor.offset);
293
+ } else {
294
+ const from = /** @type {any} */ (anchor.block).getDOMPoint?.(anchor.offset);
295
+ const to = /** @type {any} */ (focus.block).getDOMPoint?.(focus.offset);
296
+ if (from && to) nabu.selection.setBaseAndExtent(from.node, from.offset, to.node, to.offset);
297
+ else nabu.selection.setCursor(focus.block, focus.offset);
298
+ }
299
+ if (reveal) revealFocus(focus.block);
300
+ });
301
+ }
302
+
303
+ /**
304
+ * Keep the live selection on the characters it was on: after a change the user did not make in a block holding one of its ends
305
+ * (a programmatic edit, a collaborator's), the DOM selection is put back where the stored endpoints (Loro cursors) now stand,
306
+ * if it is anywhere else. Svelte rewrites the text node of an edited block, which sends the end of a DOM range to offset 0 of it
307
+ * (P-109). Does nothing when there is no live selection in the editor, when a block of the snapshot is gone, or when the
308
+ * selection is already right. Never scrolls.
309
+ * @param {Nabu} nabu
310
+ * @param {UndoSelection} snap the selection BEFORE the change
311
+ * @returns {boolean} whether the selection was moved
312
+ */
313
+ export function keepSelection(nabu, snap) {
314
+ const live = livePoints(nabu);
315
+ if (!live) return false;
316
+ const a = resolveEndpoint(nabu, snap.anchor, true);
317
+ const f = resolveEndpoint(nabu, snap.focus, true);
318
+ if (!a || !f) return false;
319
+ if (a.block === live.anchor.block && a.offset === live.anchor.offset && f.block === live.focus.block && f.offset === live.focus.offset) return false;
320
+ return placePoints(nabu, { anchor: a, focus: f });
321
+ }
322
+
323
+ /**
324
+ * Scroll the moving end of the selection into view, "nearest": nothing moves when it is already visible (in the window and in
325
+ * the scroll container that holds the editor).
326
+ * @param {Block} block the block holding the focus end (its element is the fallback target)
327
+ */
328
+ export function revealFocus(block) {
329
+ if (typeof window === 'undefined') return;
330
+ const live = window.getSelection();
331
+ if (!live || live.rangeCount === 0 || !live.focusNode) return;
332
+ const holder = /** @type {Element | null} */ (live.focusNode.nodeType === Node.ELEMENT_NODE ? live.focusNode : live.focusNode.parentElement);
333
+ const target = holder?.closest('[data-block-id]') ?? block.element;
334
+ if (!target) return;
335
+
336
+ /** @type {{ top: number, bottom: number } | null} */
337
+ let rect = null;
338
+ try {
339
+ const caret = document.createRange();
340
+ caret.setStart(live.focusNode, live.focusOffset);
341
+ caret.collapse(true);
342
+ const r = caret.getClientRects()[0] ?? caret.getBoundingClientRect();
343
+ if (r && (r.height > 0 || r.top !== 0)) rect = r;
344
+ } catch { /* fall back to the block */ }
345
+ rect ??= target.getBoundingClientRect();
346
+
347
+ // Visible band: the window, narrowed by every scrollable ancestor.
348
+ let top = 0;
349
+ let bottom = window.innerHeight;
350
+ for (let el = target.parentElement; el; el = el.parentElement) {
351
+ const overflow = getComputedStyle(el).overflowY;
352
+ if ((overflow === 'auto' || overflow === 'scroll' || overflow === 'overlay') && el.scrollHeight > el.clientHeight) {
353
+ const box = el.getBoundingClientRect();
354
+ top = Math.max(top, box.top);
355
+ bottom = Math.min(bottom, box.bottom);
356
+ }
357
+ }
358
+ if (rect.top >= top && rect.bottom <= bottom) return;
359
+ target.scrollIntoView({ block: 'nearest', inline: 'nearest' });
360
+ }
@@ -1,6 +1,7 @@
1
1
  <script>
2
2
  /** @type {{ block: import('./video.svelte.js').VideoBlock }} */
3
3
  let { block } = $props();
4
+ $effect(() => block.holdSource());
4
5
  const src = $derived(block.displaySrc);
5
6
  </script>
6
7
 
@@ -14,13 +15,15 @@
14
15
  class:selected={block.selected}
15
16
  class:pending={block.status === 'pending'}
16
17
  class:error={block.status === 'error'}
18
+ class:missing={block.isMissing}
17
19
  >
18
20
  {#if block.status === 'error'}
19
21
  <div class="nabu-video-error">⚠️ Upload failed</div>
22
+ {:else if block.isMissing}
23
+ <div class="nabu-video-error nabu-video-missing" data-nabu-missing>Missing file{block.alt ? ' — ' + block.alt : ''}</div>
20
24
  {:else if src}
21
25
  <!-- svelte-ignore a11y_media_has_caption -->
22
- <video src={src} controls draggable="false"></video>
23
- {#if block.status === 'pending'}<div class="nabu-video-spinner">Uploading…</div>{/if}
26
+ <video src={src} controls draggable="false"></video>{#if block.status === 'pending'}<div class="nabu-video-spinner">Uploading…</div>{/if}
24
27
  {:else}
25
28
  <div class="nabu-video-empty">No video</div>
26
29
  {/if}
@@ -1 +1,4 @@
1
- export const VideoExtension: import("../..").Extension;
1
+ /**
2
+ * The video block: stored through the `files` option, with the `video:insert` and `video:pick` actions, video file paste and the "Video" slash entry.
3
+ */
4
+ export const VideoExtension: import("../../extend.js").Extension;
@@ -1,12 +1,20 @@
1
1
  import { extension } from "../../utils/extensions";
2
2
  import { VideoBlock } from "./video.svelte.js";
3
3
  import VideoComponent from "./Video.svelte";
4
- import { pickMedia, insertMediaUrl } from "../media/media.helpers.js";
4
+ import { pickMedia, insertMediaUrl, mediaFileHandler } from "../media/media.helpers.js";
5
5
 
6
+ /**
7
+ * The video block: stored through the `files` option, with the `video:insert` and `video:pick` actions, video file paste and the "Video" slash entry.
8
+ */
6
9
  export const VideoExtension = extension("video", {
7
10
  // @ts-ignore — static-side variance on create()
8
11
  block: VideoBlock,
9
12
  component: VideoComponent,
13
+ // A file pasted from the clipboard becomes this block.
14
+ pasteFileHandlers: [mediaFileHandler('video', (file) => /^video\//i.test(file.type), 20)],
15
+ slashCommands: [
16
+ { title: 'Video', icon: '▷', aliases: ['video', 'movie', 'mp4'], group: 'media', order: 10, run: (e) => e.exec('video:pick') },
17
+ ],
10
18
  actions: {
11
19
  'video:pick': (nabu) => pickMedia(nabu, 'video', 'video/*'),
12
20
  /**
@@ -7,19 +7,20 @@
7
7
  */
8
8
  export class VideoBlock extends MediaBlock {
9
9
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
10
- static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock): string;
10
+ static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock): any;
11
11
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
12
12
  static toHtml(pb: import("../../utils/extensions.js").PasteBlock): string;
13
13
  static htmlRules: {
14
14
  selector: string;
15
+ embed: boolean;
15
16
  }[];
16
17
  /**
17
18
  * @param {Element} el
18
- * @returns {import('../../utils/extensions.js').PasteBlock}
19
+ * @returns {import('../../utils/extensions.js').PasteBlock | null}
19
20
  */
20
- static fromHTML(el: Element): import("../../utils/extensions.js").PasteBlock;
21
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
22
- static create(nabu: Nabu, type: string, props?: Object, parentId?: string | null, index?: number | null): VideoBlock;
21
+ static fromHTML(el: Element): import("../../utils/extensions.js").PasteBlock | null;
22
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
23
+ static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): VideoBlock;
23
24
  component: import("svelte").Component<any, any, string> | import("svelte").Component<{
24
25
  block: import("./video.svelte.js").VideoBlock;
25
26
  }, {}, "">;
@@ -1,6 +1,8 @@
1
1
  // @ts-ignore
2
2
  import { MediaBlock } from "../media/media-block.svelte.js";
3
+ import { markdownMediaLink } from "../media/markdown.js";
3
4
  import VideoComponent from "./Video.svelte";
5
+ import { escapeHtml, escapeAttr, sanitizeUrl } from "../../utils/html.js";
4
6
 
5
7
  /**
6
8
  * @import { Nabu, NabuNode } from "../nabu.svelte.js";
@@ -16,15 +18,15 @@ export class VideoBlock extends MediaBlock {
16
18
  constructor(nabu, node) {
17
19
  super(nabu, node);
18
20
 
19
- this.serializers.set('markdown', () => '[' + (this.alt || this.name || 'video') + '](' + this.ref + ')');
21
+ this.serializers.set('markdown', () => VideoBlock.toMarkdown({ type: 'video', partial: false, props: this.exportProps }));
20
22
  this.serializers.set('json', () => ({
21
23
  id: this.id,
22
24
  type: 'video',
23
- props: { ref: this.ref, alt: this.alt, name: this.name },
25
+ props: this.exportProps,
24
26
  }));
25
27
  this.serializers.set('application/x-nabu+json', () => ({
26
28
  type: 'video',
27
- props: { ref: this.ref, alt: this.alt, name: this.name },
29
+ props: { ref: this.ref, alt: this.alt, name: this.name, ...this.clipboardState },
28
30
  partial: false,
29
31
  }));
30
32
  }
@@ -35,34 +37,41 @@ export class VideoBlock extends MediaBlock {
35
37
 
36
38
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
37
39
  static toMarkdown(pb) {
38
- return '[' + (pb.props?.alt || pb.props?.name || 'video') + '](' + (pb.props?.ref || '') + ')';
40
+ if (!pb.props?.ref) return pb.props?.alt || pb.props?.name || ''; // no source: the label only
41
+ return markdownMediaLink(pb.props?.alt || pb.props?.name || 'video', pb.props.ref);
39
42
  }
40
43
 
41
44
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
42
45
  static toHtml(pb) {
43
- return '<video src="' + (pb.props?.ref || '') + '" controls></video>';
46
+ const ref = pb.props?.ref || '';
47
+ const src = sanitizeUrl(ref, { kind: 'media' }); // null for an empty ref too
48
+ const label = pb.props?.alt || pb.props?.name || '';
49
+ if (src === null) return label ? '<p>' + escapeHtml(label) + '</p>' : ''; // no live <video> without a source
50
+ return '<video src="' + escapeAttr(src) + '" controls></video>';
44
51
  }
45
52
 
46
53
  static htmlRules = [
47
- { selector: 'video' },
54
+ { selector: 'video', embed: true },
48
55
  ];
49
56
 
50
57
  /**
51
58
  * @param {Element} el
52
- * @returns {import('../../utils/extensions.js').PasteBlock}
59
+ * @returns {import('../../utils/extensions.js').PasteBlock | null}
53
60
  */
54
61
  static fromHTML(el) {
62
+ const src = el.getAttribute('src') || el.querySelector('source')?.getAttribute('src') || '';
63
+ if (src && sanitizeUrl(src, { kind: 'media' }) === null) return null;
55
64
  return {
56
65
  type: 'video',
57
66
  props: {
58
- ref: el.getAttribute('src') || el.querySelector('source')?.getAttribute('src') || '',
67
+ ref: src,
59
68
  alt: '',
60
69
  },
61
70
  partial: false,
62
71
  };
63
72
  }
64
73
 
65
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
74
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
66
75
  static create(nabu, type, props = {}, parentId = null, index = null) {
67
76
  const node = MediaBlock.createNode(nabu, 'video', props, parentId, index);
68
77
  const block = new VideoBlock(nabu, /** @type {any} */ (node));
@@ -0,0 +1,55 @@
1
+ export { Block } from "./blocks/block.svelte.js";
2
+ export { TextBlock } from "./blocks/text-block.svelte.js";
3
+ export { MegaBlock } from "./blocks/megablock.svelte.js";
4
+ export { default as BlockComponent } from "./blocks/Block.svelte";
5
+ export { TextBehavior } from "./behaviors/text/index.js";
6
+ export { default as RichText } from "./behaviors/text/RichText.svelte";
7
+ /**
8
+ * A node of the document tree: `NabuNode<{ type: 'x', … }>`.
9
+ */
10
+ export type NabuNode<T extends {
11
+ [x: string]: any;
12
+ } = Record<string, any>> = import("./blocks/nabu.svelte.js").NabuNode<T>;
13
+ export type ExtensionInit = import("./utils/extensions.js").ExtensionInit;
14
+ export type ExtensionHooks = import("./utils/extensions.js").ExtensionHooks;
15
+ /**
16
+ * What the `onSplit` hook receives: the caret offset and the tail of the text.
17
+ */
18
+ export type SplitData = import("./utils/extensions.js").SplitData;
19
+ export type InputRule = import("./utils/extensions.js").InputRule;
20
+ export type PasteBlock = import("./utils/extensions.js").PasteBlock;
21
+ export type PasteFragment = import("./utils/extensions.js").PasteFragment;
22
+ export type PasteInterpreter = import("./utils/extensions.js").PasteInterpreter;
23
+ export type PasteInterpretOptions = import("./utils/extensions.js").PasteInterpretOptions;
24
+ export type PasteFileHandler = import("./utils/extensions.js").PasteFileHandler;
25
+ /**
26
+ * A rule of a block's `static htmlRules`.
27
+ */
28
+ export type HtmlRule = import("./utils/extensions.js").HtmlRule;
29
+ /**
30
+ * What a block's `static fromHTML` receives.
31
+ */
32
+ export type HtmlHelpers = import("./utils/extensions.js").HtmlHelpers;
33
+ /**
34
+ * A rule of a block's `static markdownRules`.
35
+ */
36
+ export type MarkdownRule = import("./utils/extensions.js").MarkdownRule;
37
+ /**
38
+ * What a block's `static fromMarkdown` receives.
39
+ */
40
+ export type MarkdownHelpers = import("./utils/extensions.js").MarkdownHelpers;
41
+ /**
42
+ * The second argument of a block's `static toMarkdown` / `toHtml`.
43
+ */
44
+ export type SerializeContext = import("./utils/extensions.js").SerializeContext;
45
+ /**
46
+ * The shape of `nabu.internals`. UNSTABLE: may change in any minor version.
47
+ */
48
+ export type NabuInternals = import("./blocks/nabu.svelte.js").NabuInternals;
49
+ export type CommandDef = import("./utils/commands.js").CommandDef;
50
+ export type CommandContext = import("./utils/commands.js").CommandContext;
51
+ export type Chord = import("./utils/keys.js").Chord;
52
+ export type Platform = import("./utils/keys.js").Platform;
53
+ export { extension, Extension } from "./utils/extensions.js";
54
+ export { parseChord, canonicalChord, chordId, eventChord, eventChordId, isReservedChord, RESERVED_CHORDS, hasCommandModifier, detectPlatform } from "./utils/keys.js";
55
+ export { escapeHtml, escapeAttr } from "./utils/html.js";