@aionbuilders/nabu 0.1.0-alpha.9 → 0.1.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 (319) hide show
  1. package/CHANGELOG.md +523 -0
  2. package/LICENSE +21 -0
  3. package/README.md +82 -144
  4. package/dist/behaviors/text/RichText.svelte +25 -2
  5. package/dist/behaviors/text/index.d.ts +2 -0
  6. package/dist/behaviors/text/index.js +2 -0
  7. package/dist/behaviors/text/markdown-shortcuts.extension.d.ts +5 -0
  8. package/dist/behaviors/text/markdown-shortcuts.extension.js +79 -0
  9. package/dist/behaviors/text/markdown-syntax.d.ts +42 -0
  10. package/dist/behaviors/text/markdown-syntax.js +81 -0
  11. package/dist/behaviors/text/rich-text.extension.d.ts +3 -0
  12. package/dist/behaviors/text/rich-text.extension.js +135 -53
  13. package/dist/behaviors/text/text.behavior.svelte.d.ts +217 -42
  14. package/dist/behaviors/text/text.behavior.svelte.js +657 -55
  15. package/dist/behaviors/text/typography.extension.d.ts +7 -0
  16. package/dist/behaviors/text/typography.extension.js +25 -0
  17. package/dist/blocks/Block.svelte +5 -2
  18. package/dist/blocks/BlockList.svelte +48 -0
  19. package/dist/blocks/BlockList.svelte.d.ts +17 -0
  20. package/dist/blocks/Nabu.svelte +180 -14
  21. package/dist/blocks/Nabu.svelte.d.ts +13 -0
  22. package/dist/blocks/block.extension.d.ts +3 -0
  23. package/dist/blocks/block.extension.js +8 -9
  24. package/dist/blocks/block.svelte.d.ts +356 -68
  25. package/dist/blocks/block.svelte.js +388 -42
  26. package/dist/blocks/blockquote/Blockquote.svelte +39 -0
  27. package/dist/blocks/blockquote/Blockquote.svelte.d.ts +11 -0
  28. package/dist/blocks/blockquote/blockquote.extension.d.ts +4 -0
  29. package/dist/blocks/blockquote/blockquote.extension.js +80 -0
  30. package/dist/blocks/blockquote/blockquote.svelte.d.ts +63 -0
  31. package/dist/blocks/blockquote/blockquote.svelte.js +136 -0
  32. package/dist/blocks/blockquote/index.d.ts +3 -0
  33. package/dist/blocks/blockquote/index.js +3 -0
  34. package/dist/blocks/callout/Callout.svelte +67 -0
  35. package/dist/blocks/callout/Callout.svelte.d.ts +11 -0
  36. package/dist/blocks/callout/callout.extension.d.ts +4 -0
  37. package/dist/blocks/callout/callout.extension.js +84 -0
  38. package/dist/blocks/callout/callout.svelte.d.ts +80 -0
  39. package/dist/blocks/callout/callout.svelte.js +189 -0
  40. package/dist/blocks/callout/index.d.ts +3 -0
  41. package/dist/blocks/callout/index.js +3 -0
  42. package/dist/blocks/chunks.d.ts +49 -0
  43. package/dist/blocks/chunks.js +90 -0
  44. package/dist/blocks/code/Code.svelte +84 -0
  45. package/dist/blocks/code/Code.svelte.d.ts +11 -0
  46. package/dist/blocks/code/code.extension.d.ts +4 -0
  47. package/dist/blocks/code/code.extension.js +88 -0
  48. package/dist/blocks/code/code.svelte.d.ts +68 -0
  49. package/dist/blocks/code/code.svelte.js +245 -0
  50. package/dist/blocks/code/index.d.ts +3 -0
  51. package/dist/blocks/code/index.js +3 -0
  52. package/dist/blocks/container.utils.d.ts +85 -13
  53. package/dist/blocks/container.utils.js +338 -178
  54. package/dist/blocks/dialogue/Dialogue.svelte +8 -2
  55. package/dist/blocks/dialogue/dialogue.svelte.d.ts +36 -23
  56. package/dist/blocks/dialogue/dialogue.svelte.js +51 -45
  57. package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +2 -2
  58. package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +6 -4
  59. package/dist/blocks/dialogue/index.d.ts +12 -1
  60. package/dist/blocks/dialogue/index.js +51 -35
  61. package/dist/blocks/divider/Divider.svelte +28 -0
  62. package/dist/blocks/divider/Divider.svelte.d.ts +11 -0
  63. package/dist/blocks/divider/divider.extension.d.ts +23 -0
  64. package/dist/blocks/divider/divider.extension.js +153 -0
  65. package/dist/blocks/divider/divider.svelte.d.ts +54 -0
  66. package/dist/blocks/divider/divider.svelte.js +89 -0
  67. package/dist/blocks/divider/index.d.ts +3 -0
  68. package/dist/blocks/divider/index.js +3 -0
  69. package/dist/blocks/file/File.svelte +56 -0
  70. package/dist/blocks/file/File.svelte.d.ts +11 -0
  71. package/dist/blocks/file/file.extension.d.ts +4 -0
  72. package/dist/blocks/file/file.extension.js +27 -0
  73. package/dist/blocks/file/file.svelte.d.ts +29 -0
  74. package/dist/blocks/file/file.svelte.js +77 -0
  75. package/dist/blocks/file/index.d.ts +3 -0
  76. package/dist/blocks/file/index.js +3 -0
  77. package/dist/blocks/heading/Heading.svelte +2 -1
  78. package/dist/blocks/heading/heading.svelte.d.ts +27 -34
  79. package/dist/blocks/heading/heading.svelte.js +72 -60
  80. package/dist/blocks/heading/hooks/onBeforeInput.hook.js +7 -5
  81. package/dist/blocks/heading/index.d.ts +2 -2
  82. package/dist/blocks/heading/index.js +33 -8
  83. package/dist/blocks/image/Image.svelte +41 -0
  84. package/dist/blocks/image/Image.svelte.d.ts +11 -0
  85. package/dist/blocks/image/image.extension.d.ts +5 -0
  86. package/dist/blocks/image/image.extension.js +34 -0
  87. package/dist/blocks/image/image.svelte.d.ts +61 -0
  88. package/dist/blocks/image/image.svelte.js +114 -0
  89. package/dist/blocks/image/index.d.ts +3 -0
  90. package/dist/blocks/image/index.js +3 -0
  91. package/dist/blocks/index.d.ts +11 -1
  92. package/dist/blocks/index.js +11 -1
  93. package/dist/blocks/list/List.svelte +9 -2
  94. package/dist/blocks/list/ListItem.svelte +44 -7
  95. package/dist/blocks/list/convert.d.ts +20 -0
  96. package/dist/blocks/list/convert.js +92 -0
  97. package/dist/blocks/list/hooks/onBeforeInput.hook.js +60 -26
  98. package/dist/blocks/list/html-flat.d.ts +78 -0
  99. package/dist/blocks/list/html-flat.js +244 -0
  100. package/dist/blocks/list/indent.d.ts +86 -0
  101. package/dist/blocks/list/indent.js +205 -0
  102. package/dist/blocks/list/index.d.ts +7 -3
  103. package/dist/blocks/list/index.js +43 -31
  104. package/dist/blocks/list/list-item.svelte.d.ts +43 -17
  105. package/dist/blocks/list/list-item.svelte.js +143 -93
  106. package/dist/blocks/list/list.behavior.svelte.d.ts +7 -4
  107. package/dist/blocks/list/list.behavior.svelte.js +10 -5
  108. package/dist/blocks/list/list.svelte.d.ts +101 -23
  109. package/dist/blocks/list/list.svelte.js +136 -114
  110. package/dist/blocks/list/markdown.d.ts +149 -0
  111. package/dist/blocks/list/markdown.js +442 -0
  112. package/dist/blocks/list/normalize.d.ts +11 -0
  113. package/dist/blocks/list/normalize.js +396 -0
  114. package/dist/blocks/list/paste.d.ts +45 -0
  115. package/dist/blocks/list/paste.js +242 -0
  116. package/dist/blocks/list/step-back.d.ts +24 -0
  117. package/dist/blocks/list/step-back.js +87 -0
  118. package/dist/blocks/list/to-list.d.ts +7 -0
  119. package/dist/blocks/list/to-list.js +44 -0
  120. package/dist/blocks/list/todos-toggle.d.ts +20 -0
  121. package/dist/blocks/list/todos-toggle.js +48 -0
  122. package/dist/blocks/list/todos.svelte.d.ts +35 -0
  123. package/dist/blocks/list/todos.svelte.js +76 -0
  124. package/dist/blocks/media/index.d.ts +2 -0
  125. package/dist/blocks/media/index.js +2 -0
  126. package/dist/blocks/media/markdown.d.ts +12 -0
  127. package/dist/blocks/media/markdown.js +26 -0
  128. package/dist/blocks/media/media-block.svelte.d.ts +107 -0
  129. package/dist/blocks/media/media-block.svelte.js +181 -0
  130. package/dist/blocks/media/media.helpers.d.ts +24 -0
  131. package/dist/blocks/media/media.helpers.js +88 -0
  132. package/dist/blocks/megablock.svelte.d.ts +50 -19
  133. package/dist/blocks/megablock.svelte.js +115 -74
  134. package/dist/blocks/move.d.ts +23 -0
  135. package/dist/blocks/move.js +92 -0
  136. package/dist/blocks/nabu.svelte.d.ts +846 -75
  137. package/dist/blocks/nabu.svelte.js +1990 -182
  138. package/dist/blocks/paragraph/Paragraph.svelte +1 -0
  139. package/dist/blocks/paragraph/index.d.ts +2 -2
  140. package/dist/blocks/paragraph/index.js +35 -16
  141. package/dist/blocks/paragraph/paragraph.svelte.d.ts +49 -35
  142. package/dist/blocks/paragraph/paragraph.svelte.js +81 -69
  143. package/dist/blocks/paragraph/table.html.d.ts +9 -0
  144. package/dist/blocks/paragraph/table.html.js +111 -0
  145. package/dist/blocks/paragraph/table.markdown.d.ts +32 -0
  146. package/dist/blocks/paragraph/table.markdown.js +90 -0
  147. package/dist/blocks/region/Region.svelte +264 -0
  148. package/dist/blocks/region/Region.svelte.d.ts +11 -0
  149. package/dist/blocks/region/actions.d.ts +135 -0
  150. package/dist/blocks/region/actions.js +402 -0
  151. package/dist/blocks/region/close.d.ts +35 -0
  152. package/dist/blocks/region/close.js +130 -0
  153. package/dist/blocks/region/commands.d.ts +6 -0
  154. package/dist/blocks/region/commands.js +277 -0
  155. package/dist/blocks/region/create.d.ts +72 -0
  156. package/dist/blocks/region/create.js +208 -0
  157. package/dist/blocks/region/end-marker.d.ts +35 -0
  158. package/dist/blocks/region/end-marker.js +51 -0
  159. package/dist/blocks/region/facts.d.ts +69 -0
  160. package/dist/blocks/region/facts.js +152 -0
  161. package/dist/blocks/region/format.d.ts +91 -0
  162. package/dist/blocks/region/format.js +260 -0
  163. package/dist/blocks/region/index.d.ts +14 -0
  164. package/dist/blocks/region/index.js +14 -0
  165. package/dist/blocks/region/insert.d.ts +59 -0
  166. package/dist/blocks/region/insert.js +102 -0
  167. package/dist/blocks/region/messages.d.ts +254 -0
  168. package/dist/blocks/region/messages.js +131 -0
  169. package/dist/blocks/region/normalize.d.ts +7 -0
  170. package/dist/blocks/region/normalize.js +170 -0
  171. package/dist/blocks/region/region.extension.d.ts +58 -0
  172. package/dist/blocks/region/region.extension.js +119 -0
  173. package/dist/blocks/region/region.svelte.d.ts +221 -0
  174. package/dist/blocks/region/region.svelte.js +582 -0
  175. package/dist/blocks/region/regions.svelte.d.ts +141 -0
  176. package/dist/blocks/region/regions.svelte.js +276 -0
  177. package/dist/blocks/region/serialize.d.ts +57 -0
  178. package/dist/blocks/region/serialize.js +112 -0
  179. package/dist/blocks/region/types.d.ts +255 -0
  180. package/dist/blocks/region/types.js +204 -0
  181. package/dist/blocks/selection.svelte.d.ts +106 -8
  182. package/dist/blocks/selection.svelte.js +632 -74
  183. package/dist/blocks/subthread.d.ts +80 -0
  184. package/dist/blocks/subthread.js +167 -0
  185. package/dist/blocks/text-block.svelte.d.ts +70 -0
  186. package/dist/blocks/text-block.svelte.js +108 -0
  187. package/dist/blocks/toggle/Toggle.svelte +73 -0
  188. package/dist/blocks/toggle/Toggle.svelte.d.ts +11 -0
  189. package/dist/blocks/toggle/index.d.ts +3 -0
  190. package/dist/blocks/toggle/index.js +3 -0
  191. package/dist/blocks/toggle/markdown.d.ts +20 -0
  192. package/dist/blocks/toggle/markdown.js +112 -0
  193. package/dist/blocks/toggle/toggle.extension.d.ts +4 -0
  194. package/dist/blocks/toggle/toggle.extension.js +18 -0
  195. package/dist/blocks/toggle/toggle.svelte.d.ts +135 -0
  196. package/dist/blocks/toggle/toggle.svelte.js +352 -0
  197. package/dist/blocks/undo-selection.d.ts +175 -0
  198. package/dist/blocks/undo-selection.js +360 -0
  199. package/dist/blocks/video/Video.svelte +42 -0
  200. package/dist/blocks/video/Video.svelte.d.ts +11 -0
  201. package/dist/blocks/video/index.d.ts +3 -0
  202. package/dist/blocks/video/index.js +3 -0
  203. package/dist/blocks/video/video.extension.d.ts +4 -0
  204. package/dist/blocks/video/video.extension.js +27 -0
  205. package/dist/blocks/video/video.svelte.d.ts +29 -0
  206. package/dist/blocks/video/video.svelte.js +80 -0
  207. package/dist/extend.d.ts +55 -0
  208. package/dist/extend.js +88 -0
  209. package/dist/files/assets.clipboard.d.ts +77 -0
  210. package/dist/files/assets.clipboard.js +152 -0
  211. package/dist/files/files.svelte.d.ts +363 -0
  212. package/dist/files/files.svelte.js +897 -0
  213. package/dist/files/index.d.ts +3 -0
  214. package/dist/files/index.js +3 -0
  215. package/dist/files/outbox.d.ts +69 -0
  216. package/dist/files/outbox.js +48 -0
  217. package/dist/files/status.d.ts +65 -0
  218. package/dist/files/status.js +87 -0
  219. package/dist/files/store.d.ts +97 -0
  220. package/dist/files/store.js +65 -0
  221. package/dist/files/uploads.svelte.d.ts +174 -0
  222. package/dist/files/uploads.svelte.js +504 -0
  223. package/dist/index.d.ts +68 -6
  224. package/dist/index.js +117 -7
  225. package/dist/nabu-theme.css +112 -0
  226. package/dist/paste/html.paste.d.ts +74 -3
  227. package/dist/paste/html.paste.js +555 -83
  228. package/dist/paste/markdown-inline.d.ts +86 -0
  229. package/dist/paste/markdown-inline.js +528 -0
  230. package/dist/paste/markdown.paste.d.ts +2 -8
  231. package/dist/paste/markdown.paste.js +78 -94
  232. package/dist/paste/nabu.paste.d.ts +3 -0
  233. package/dist/paste/nabu.paste.js +29 -3
  234. package/dist/paste/plain-text.paste.d.ts +2 -2
  235. package/dist/paste/plain-text.paste.js +3 -3
  236. package/dist/persistence/asset-store.d.ts +51 -0
  237. package/dist/persistence/asset-store.js +103 -0
  238. package/dist/persistence/autosave.d.ts +53 -0
  239. package/dist/persistence/autosave.js +62 -0
  240. package/dist/persistence/compact.d.ts +162 -0
  241. package/dist/persistence/compact.js +141 -0
  242. package/dist/persistence/history.d.ts +77 -0
  243. package/dist/persistence/history.js +176 -0
  244. package/dist/persistence/indexeddb.d.ts +190 -4
  245. package/dist/persistence/indexeddb.js +333 -29
  246. package/dist/persistence/merge.d.ts +38 -0
  247. package/dist/persistence/merge.js +36 -0
  248. package/dist/persistence/outbox.d.ts +25 -0
  249. package/dist/persistence/outbox.js +40 -0
  250. package/dist/persistence/persistence.d.ts +70 -9
  251. package/dist/persistence/persistence.js +507 -35
  252. package/dist/persistence/recovery.d.ts +79 -0
  253. package/dist/persistence/recovery.js +79 -0
  254. package/dist/persistence/release.d.ts +34 -0
  255. package/dist/persistence/release.js +64 -0
  256. package/dist/persistence/state.svelte.d.ts +53 -0
  257. package/dist/persistence/state.svelte.js +48 -0
  258. package/dist/persistence/sync.d.ts +39 -0
  259. package/dist/persistence/sync.js +138 -0
  260. package/dist/persistence/tail.d.ts +42 -0
  261. package/dist/persistence/tail.js +103 -0
  262. package/dist/presets.d.ts +29 -24
  263. package/dist/presets.js +51 -14
  264. package/dist/themes/atelier.css +318 -0
  265. package/dist/ui/CommandChooser.svelte +153 -0
  266. package/dist/ui/CommandChooser.svelte.d.ts +13 -0
  267. package/dist/ui/CommandInvite.svelte +99 -0
  268. package/dist/ui/CommandInvite.svelte.d.ts +12 -0
  269. package/dist/ui/DragHandle.svelte +217 -0
  270. package/dist/ui/DragHandle.svelte.d.ts +11 -0
  271. package/dist/ui/FloatingToolbar.svelte +165 -0
  272. package/dist/ui/FloatingToolbar.svelte.d.ts +27 -0
  273. package/dist/ui/SlashMenu.svelte +215 -0
  274. package/dist/ui/SlashMenu.svelte.d.ts +33 -0
  275. package/dist/ui/anchor.d.ts +112 -0
  276. package/dist/ui/anchor.js +136 -0
  277. package/dist/ui/index.d.ts +10 -0
  278. package/dist/ui/index.js +15 -0
  279. package/dist/ui/slash-menu.svelte.d.ts +112 -0
  280. package/dist/ui/slash-menu.svelte.js +150 -0
  281. package/dist/utils/command-confirm.svelte.d.ts +349 -0
  282. package/dist/utils/command-confirm.svelte.js +673 -0
  283. package/dist/utils/commands.d.ts +328 -0
  284. package/dist/utils/commands.js +416 -0
  285. package/dist/utils/dom-scope.d.ts +14 -0
  286. package/dist/utils/dom-scope.js +20 -0
  287. package/dist/utils/drop.d.ts +160 -0
  288. package/dist/utils/drop.js +305 -0
  289. package/dist/utils/extensions.d.ts +488 -40
  290. package/dist/utils/extensions.js +300 -19
  291. package/dist/utils/html.d.ts +44 -0
  292. package/dist/utils/html.js +183 -0
  293. package/dist/utils/index.d.ts +4 -0
  294. package/dist/utils/index.js +4 -0
  295. package/dist/utils/keys.d.ts +120 -0
  296. package/dist/utils/keys.js +248 -0
  297. package/dist/utils/links.d.ts +22 -0
  298. package/dist/utils/links.js +34 -0
  299. package/dist/utils/placeholders.d.ts +88 -0
  300. package/dist/utils/placeholders.js +91 -0
  301. package/dist/utils/selection.svelte.d.ts +47 -19
  302. package/dist/utils/selection.svelte.js +60 -10
  303. package/dist/utils/spellcheck.d.ts +9 -0
  304. package/dist/utils/spellcheck.js +17 -0
  305. package/dist/utils/tab.d.ts +31 -0
  306. package/dist/utils/tab.js +117 -0
  307. package/dist/utils/words.d.ts +7 -0
  308. package/dist/utils/words.js +62 -0
  309. package/dist/vite.d.ts +22 -0
  310. package/dist/vite.js +34 -0
  311. package/package.json +61 -22
  312. package/dist/blocks/zone/Zone.svelte +0 -258
  313. package/dist/blocks/zone/Zone.svelte.d.ts +0 -11
  314. package/dist/blocks/zone/index.d.ts +0 -2
  315. package/dist/blocks/zone/index.js +0 -2
  316. package/dist/blocks/zone/zone.extension.d.ts +0 -2
  317. package/dist/blocks/zone/zone.extension.js +0 -221
  318. package/dist/blocks/zone/zone.svelte.d.ts +0 -112
  319. package/dist/blocks/zone/zone.svelte.js +0 -321
@@ -1,86 +1,55 @@
1
1
  import { MegaBlock } from "../megablock.svelte.js";
2
2
  import ListItemComponent from "./ListItem.svelte";
3
+ import { List, listStart } from "./list.svelte.js";
4
+ import { moveItems, handleTab } from "./indent.js";
5
+ import { retypeItem } from "./convert.js";
6
+ import { pasteIntoItem } from "./paste.js";
3
7
  import { LoroText } from "loro-crdt";
4
8
  import { TextBehavior, deltaToHtml, deltaToMarkdown } from "../../behaviors/text";
9
+ import { renderItem, adjacentRun, markerWidth } from "./markdown.js";
5
10
 
6
11
  /**
7
12
  * @import { Nabu, NabuNode, Block } from "..";
8
13
  */
9
14
 
10
15
  /**
11
- * @typedef {NabuNode<{type: "list-item", text: LoroText}>} ListItemNode
16
+ * @typedef {NabuNode<{type: "list-item", text: LoroText, checked?: boolean}>} ListItemNode
12
17
  */
13
18
 
19
+ /** What the list renderers (markdown.js) need from outside: the inline serializer and the `start` normalizer. */
20
+ const markdownEnv = { toMarkdown: (/** @type {any[]} */ delta) => deltaToMarkdown(delta), listStart };
21
+
14
22
  /**
15
- * Indent a list item (Tab behavior): move into previous sibling's sublist, hoist own children.
23
+ * Indent a list item (Tab behavior): move under the previous sibling (into its last sublist when of the same type, else a new one).
24
+ * The selection (collapsed caret or range) is restored afterwards. See indent.js.
16
25
  * @param {ListItem} item
17
26
  * @returns {boolean}
18
27
  */
19
28
  export function indentListItem(item) {
20
- const currentIndex = item.node.index();
21
- if (currentIndex === 0) return false;
22
-
23
- const parentList = item.node.parent();
24
- if (!parentList) return false;
25
-
26
- const previousNode = parentList.children()?.[currentIndex - 1];
27
- if (!previousNode) return false;
28
- const previousItem = item.nabu.blocks.get(previousNode.id.toString());
29
- if (!previousItem || previousItem.type !== 'list-item') return false;
30
-
31
- // @ts-ignore
32
- const targetSublist = previousItem.getOrCreateSublist();
33
- const targetSublistId = targetSublist.node.id.toString();
34
-
35
- item.nabu.tree.move(item.node.id.toString(), targetSublistId);
36
-
37
- if (item.sublist) {
38
- for (const childNode of item.sublist.node.children()) {
39
- item.nabu.tree.move(childNode.id.toString(), targetSublistId);
40
- }
41
- }
42
-
43
- item.commit().then(() => item.behavior.block.focus());
44
- return true;
29
+ const node = /** @type {import("../nabu.svelte.js").NabuNode} */ (item.node);
30
+ const movable = !!node.index() && node.parent()?.children()?.[/** @type {number} */ (node.index()) - 1]?.data.get('type') === 'list-item';
31
+ if (movable) moveItems(item.nabu, [node], false);
32
+ return movable;
45
33
  }
46
34
 
47
35
  /**
48
36
  * Unindent a list item (Shift+Tab behavior): move out of parent sublist, carry followers.
37
+ * The selection (collapsed caret or range) is restored afterwards. See indent.js.
49
38
  * @param {ListItem} item
50
39
  * @returns {boolean}
51
40
  */
52
41
  export function unindentListItem(item) {
53
- const parentListNode = item.node.parent();
54
- if (!parentListNode) return false;
55
-
56
- const grandParentItemNode = parentListNode.parent();
57
- if (!grandParentItemNode || grandParentItemNode.data.get('type') !== 'list-item') return false;
58
-
59
- const myIndex = item.node.index();
60
- const followers = parentListNode.children().slice(myIndex + 1);
61
-
62
- if (followers.length > 0) {
63
- const mySublist = item.getOrCreateSublist();
64
- for (const follower of followers) {
65
- item.nabu.tree.move(follower.id.toString(), mySublist.node.id.toString());
66
- }
67
- }
68
-
69
- const targetParentListNode = grandParentItemNode.parent();
70
- if (!targetParentListNode) return false;
71
-
72
- const targetIndex = grandParentItemNode.index() + 1;
73
- item.nabu.tree.move(item.node.id.toString(), targetParentListNode.id.toString(), targetIndex);
74
-
75
- item.commit().then(() => item.behavior.block.focus());
76
- return true;
42
+ const node = /** @type {import("../nabu.svelte.js").NabuNode} */ (item.node);
43
+ const movable = node.parent()?.parent()?.data.get('type') === 'list-item';
44
+ if (movable) moveItems(item.nabu, [node], true);
45
+ return movable;
77
46
  }
78
47
 
79
48
  export class ListItem extends MegaBlock {
80
49
  /** @param {Nabu} nabu @param {ListItemNode} node */
81
50
  constructor(nabu, node) {
82
51
  super(nabu, node);
83
-
52
+
84
53
  const data = node.data;
85
54
  this.container = data.get("text") ?? data.setContainer("text", new LoroText());
86
55
 
@@ -88,24 +57,36 @@ export class ListItem extends MegaBlock {
88
57
  this.behavior = new TextBehavior(this, this.container);
89
58
  this.behaviors.set("text", this.behavior);
90
59
 
60
+ // Initialize checked from Loro metadata
61
+ this.checked = !!node.data.get('checked');
62
+ // Subscribe to data changes to keep checked in sync
63
+ this.node.data.subscribe(() => {
64
+ this.checked = !!this.node.data.get('checked');
65
+ });
66
+
67
+ // One item (and its sublists), indented under the items that hold it. A whole list is rendered by the List.
91
68
  this.serializers.set('markdown', () => {
92
- const depth = this.parents.filter(p => p.type === 'list-item').length;
93
- const indent = ' '.repeat(depth);
94
- const listType = /** @type {any} */ (this.parent)?.listType ?? 'bullet';
95
- const prefix = listType === 'ordered' ? `${this.index + 1}.` : '-';
96
- const lines = [`${indent}${prefix} ${this.behavior.toMarkdown()}`];
97
- if (this.sublist) {
98
- const sublistMd = this.sublist.serialize('markdown');
99
- if (sublistMd) lines.push(sublistMd);
69
+ const list = /** @type {any} */ (this.parent);
70
+ let indent = '';
71
+ for (let item = /** @type {any} */ (this); item.parent?.parent?.type === 'list-item'; item = item.parent.parent) {
72
+ const outer = item.parent.parent;
73
+ indent = ' '.repeat(markerWidth(outer.parent?.listType, (outer.parent?.start ?? 1) + outer.index)) + indent;
100
74
  }
101
- return lines.join('\n');
75
+ return renderItem(this.toPasteBlock(), markdownEnv, {
76
+ listType: list?.listType ?? 'bullet',
77
+ index: this.index,
78
+ start: list?.start ?? 1,
79
+ run: list ? adjacentRun(list.listType, list.siblingsBefore()) : 0,
80
+ indent,
81
+ });
102
82
  });
103
83
  this.serializers.set('json', () => {
104
84
  /** @type {Record<string, any>} */
105
85
  const result = {
106
86
  id: this.id,
107
87
  type: 'list-item',
108
- content: this.behavior.toJSON()
88
+ content: this.behavior.toJSON(),
89
+ ...(this.isTodo ? { props: { checked: this.checked } } : {})
109
90
  };
110
91
  const childrenJson = this.children.map(c => c.serialize('json')).filter(Boolean);
111
92
  if (childrenJson.length) result.children = childrenJson;
@@ -115,7 +96,45 @@ export class ListItem extends MegaBlock {
115
96
  }
116
97
 
117
98
  component = $derived(this.nabu.components.get("list-item") || ListItemComponent);
118
-
99
+
100
+ /** @type {boolean} */
101
+ checked = $state(false);
102
+
103
+ isTodo = $derived(/** @type {any} */ (this.parent)?.listType === 'todo');
104
+
105
+ /**
106
+ * This item and its sublists as PasteBlocks (the shape the static serializers read).
107
+ * @returns {import('../../utils/extensions.js').PasteBlock}
108
+ */
109
+ toPasteBlock() {
110
+ const pb = this.behavior.toClipboardBlock({ props: this.clipboardProps });
111
+ const sublists = this.sublists;
112
+ return sublists.length ? { ...pb, children: sublists.map(sub => /** @type {any} */ (sub).toPasteBlock()) } : pb;
113
+ }
114
+
115
+ /** A to-do item carries its `checked` state onto the clipboard. */
116
+ get clipboardProps() {
117
+ return this.isTodo ? { checked: this.checked } : {};
118
+ }
119
+
120
+ /**
121
+ * Set the checked state and persist to Loro.
122
+ * @param {boolean} v
123
+ */
124
+ setChecked(v) {
125
+ this.checked = !!v;
126
+ /** @type {any} */ (this.node.data).set('checked', !!v);
127
+ this.commit();
128
+ }
129
+
130
+ /**
131
+ * Toggle the checked state (the user's gesture: a click on the box, the key). Does nothing in a read-only editor.
132
+ */
133
+ toggleChecked() {
134
+ if (this.nabu.readonly) return;
135
+ this.setChecked(!this.checked);
136
+ }
137
+
119
138
  get text() {
120
139
  return this.behavior.text;
121
140
  }
@@ -126,8 +145,11 @@ export class ListItem extends MegaBlock {
126
145
 
127
146
  selection = $derived(this.behavior.selection);
128
147
 
148
+ // @ts-ignore — `super.positions`: Svelte compiles the parent's `$derived` field to a prototype accessor, which TS sees as a field
129
149
  positions = $derived(this.behavior.positions + super.positions);
130
150
 
151
+ wordCount = $derived((this.behavior?.wordCount ?? 0) + this.children.reduce((sum, c) => sum + (c.wordCount ?? 0), 0));
152
+
131
153
  /**
132
154
  * Mixed block: own text comes first, then children (sublists).
133
155
  * @param {number} localOffset
@@ -147,7 +169,11 @@ export class ListItem extends MegaBlock {
147
169
  return { block: this, offset: this.behavior.text.length };
148
170
  }
149
171
 
150
- sublist = $derived(this.children.find(child => child.node.data.get("type") === "list"));
172
+ /** Every sublist, in order: an item may hold several, of different types (`a > [ul[…], ol[…], ul[…]]`). */
173
+ sublists = $derived(this.children.filter(child => child.node.data.get("type") === "list"));
174
+
175
+ /** The first sublist (see `sublists`). */
176
+ sublist = $derived(this.sublists[0]);
151
177
 
152
178
  /**
153
179
  * A ListItem must always live inside a List.
@@ -167,29 +193,46 @@ export class ListItem extends MegaBlock {
167
193
  }
168
194
 
169
195
  /**
170
- * Retourne la sous-liste existante, ou en crée une nouvelle à la fin des enfants.
171
- * @param {"bullet" | "ordered"} [listType="bullet"]
196
+ * The sublist that receives a child of type `listType`: the LAST sublist when it has that type, otherwise
197
+ * a new one appended after the existing sublists (an item may hold several sublists of different types).
198
+ * @param {"bullet" | "ordered" | "todo"} [listType]
172
199
  */
173
- getOrCreateSublist(listType = "bullet") {
174
- if (this.sublist) return this.sublist;
175
-
176
- // S'il n'y en a pas, on demande à Nabu d'en créer une en tant qu'enfant de ce ListItem
177
- const newList = this.nabu.insert("list", { listType }, this.node.id.toString());
178
- return newList;
200
+ getOrCreateSublist(listType = /** @type {any} */ (this.parent)?.listType || "bullet") {
201
+ const last = this.sublists.at(-1);
202
+ if (last && /** @type {any} */ (last).listType === listType) return last;
203
+
204
+ // No nabu.insert() here: it commits, and the list schema normalizer would delete this still-empty
205
+ // list before the caller had the chance to fill it.
206
+ return List.create(this.nabu, "list", { listType }, this.node.id.toString());
207
+ }
208
+
209
+ /**
210
+ * A list item cannot simply change type where it stands (a list only holds items): it leaves its list,
211
+ * which is split around it, and keeps its text, marks and caret. See convert.js.
212
+ * @param {string} newType
213
+ * @param {Record<string, any>} [props={}]
214
+ */
215
+ retype(newType, props = {}) {
216
+ retypeItem(this.nabu, /** @type {NabuNode} */ (this.node), newType, props);
217
+ }
218
+
219
+ /**
220
+ * A paste landing in a list item: paragraphs and lists are absorbed as items of this list, any block an
221
+ * item cannot hold splits the list. See paste.js.
222
+ * @param {import('../../utils/extensions.js').PasteBlock[]} blocks
223
+ * @param {{ offset: number }} ctx
224
+ */
225
+ acceptPaste(blocks, ctx) {
226
+ return pasteIntoItem(/** @type {any} */ (this), ctx.offset, blocks);
179
227
  }
180
228
 
181
229
  /** @param {KeyboardEvent} event */
182
230
  keydown(event) {
183
- if (event.key === 'Tab') {
184
- event.preventDefault();
185
- if (event.shiftKey) {
186
- unindentListItem(this);
187
- } else {
188
- indentListItem(this);
189
- }
190
- return true;
191
- }
192
- return false;
231
+ if (event.key !== 'Tab') return false;
232
+ // Single item, or a selection spanning several items that landed here (see ListExtension's onKeyDown).
233
+ if (handleTab(this.nabu, event)) return true;
234
+ // Plain Tab inside the item (modifier combos aside): never let the focus leave the editor.
235
+ return !(event.ctrlKey || event.altKey || event.metaKey);
193
236
  }
194
237
 
195
238
  /** @param {InputEvent} event */
@@ -221,20 +264,16 @@ export class ListItem extends MegaBlock {
221
264
  split(options) {
222
265
  return this.ascend("onSplit", null, {
223
266
  offset: options?.offset || 0,
224
- delta: this.behavior.container.sliceDelta(options?.offset || 0, this.text.length)
267
+ delta: this.behavior.container.sliceDelta(options?.offset || 0, this.behavior.container.length)
225
268
  });
226
269
  }
227
270
 
228
271
  /**
229
272
  * @param {import('../../utils/extensions.js').PasteBlock} pb
230
- * @param {{ recurse: (child: import('../../utils/extensions.js').PasteBlock, ctx?: object) => string, listType?: string, index?: number, depth?: number }} helpers
273
+ * @param {Partial<import('../../utils/extensions.js').SerializeContext> & { listType?: string, index?: number, start?: number, run?: number, indent?: string }} helpers `run`: position of the list among adjacent lists (marker alternation), `indent`: what the item is nested under
231
274
  */
232
- static toMarkdown(pb, { recurse, listType = 'bullet', index = 0, depth = 0 }) {
233
- const indent = ' '.repeat(depth);
234
- const prefix = listType === 'ordered' ? `${index + 1}.` : '-';
235
- const text = deltaToMarkdown(pb.delta || []);
236
- const sublists = (pb.children || []).map(sub => recurse(sub, { depth: depth + 1 })).join('\n');
237
- return `${indent}${prefix} ${text}${sublists ? '\n' + sublists : ''}`;
275
+ static toMarkdown(pb, { listType = 'bullet', index = 0, start = 1, run = 0, indent = '' }) {
276
+ return renderItem(pb, markdownEnv, { listType, index, start, run, indent });
238
277
  }
239
278
 
240
279
  /**
@@ -244,6 +283,10 @@ export class ListItem extends MegaBlock {
244
283
  static toHtml(pb, { recurse }) {
245
284
  const text = deltaToHtml(pb.delta || []);
246
285
  const sublists = (pb.children || []).map(recurse).join('');
286
+ if (pb.props?.checked !== undefined) {
287
+ const checkedAttr = pb.props.checked ? ' checked' : '';
288
+ return `<li><input type="checkbox" disabled${checkedAttr}> ${text}${sublists}</li>`;
289
+ }
247
290
  return `<li>${text}${sublists}</li>`;
248
291
  }
249
292
 
@@ -262,20 +305,27 @@ export class ListItem extends MegaBlock {
262
305
  .map(parseBlock)
263
306
  .filter(Boolean)
264
307
  );
308
+ // Detect checkbox: <li><input type="checkbox"> or <li><p><input type="checkbox">
309
+ const cb = el.querySelector(':scope > input[type=checkbox], :scope > p > input[type=checkbox]') ||
310
+ el.querySelector('input[type=checkbox]');
265
311
  /** @type {import('../../utils/extensions.js').PasteBlock} */
266
312
  const result = { type: 'list-item', delta, partial: false };
313
+ if (cb) result.props = { checked: cb.hasAttribute('checked') };
314
+ // Google Docs checklist: `<li role="checkbox" aria-checked="true">`
315
+ else if (el.getAttribute('aria-checked') === 'true' || el.getAttribute('aria-checked') === 'false') result.props = { checked: el.getAttribute('aria-checked') === 'true' };
267
316
  if (childLists.length) result.children = childLists;
268
317
  return result;
269
318
  }
270
319
 
271
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
320
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
272
321
  static create(nabu, type, props = {}, parentId = null, index = null) {
273
- const node = nabu.tree.createNode(parentId || undefined, index || undefined);
322
+ const node = nabu.tree.createNode(/** @type {import('loro-crdt').TreeID | undefined} */ (parentId || undefined), index ?? undefined);
274
323
  node.data.set("type", "list-item");
275
324
  const container = node.data.setContainer("text", new LoroText());
276
325
  if (props.text) container.insert(0, props.text);
277
326
  if (props.delta) container.applyDelta([...props.delta]);
278
- const block = new ListItem(nabu, node);
327
+ if (props.checked !== undefined) /** @type {any} */ (node.data).set('checked', !!props.checked);
328
+ const block = new ListItem(nabu, /** @type {ListItemNode} */ (node));
279
329
  return block;
280
330
  }
281
331
  }
@@ -3,7 +3,7 @@
3
3
  * @import {LoroText} from "loro-crdt";
4
4
  */
5
5
  /**
6
- * @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered"}>} ListNode
6
+ * @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo", start?: number}>} ListNode
7
7
  */
8
8
  export class ListBehavior {
9
9
  /** @param {Block} block */
@@ -11,14 +11,17 @@ export class ListBehavior {
11
11
  block: Block;
12
12
  nabu: import("..").Nabu;
13
13
  node: ListNode;
14
- /** @type {"bullet" | "ordered"} */
15
- listType: "bullet" | "ordered";
14
+ /** @type {"bullet" | "ordered" | "todo"} */
15
+ listType: "bullet" | "ordered" | "todo";
16
+ /** Raw `start` number from the node (null = unset); List.start normalizes it. @type {number | null} */
17
+ start: number | null;
16
18
  /** @param {Block} block */
17
19
  absorbs(block: Block): true | undefined;
18
20
  }
19
21
  export type ListNode = NabuNode<{
20
22
  type: "list";
21
- listType: "bullet" | "ordered";
23
+ listType: "bullet" | "ordered" | "todo";
24
+ start?: number;
22
25
  }>;
23
26
  import type { Block } from "..";
24
27
  import type { NabuNode } from "..";
@@ -1,4 +1,4 @@
1
- import { MegaBlock } from "..";
1
+ import { MegaBlock } from "../megablock.svelte.js";
2
2
 
3
3
  /**
4
4
  * @import {Block, NabuNode} from "..";
@@ -6,7 +6,7 @@ import { MegaBlock } from "..";
6
6
  */
7
7
 
8
8
  /**
9
- * @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered"}>} ListNode
9
+ * @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo", start?: number}>} ListNode
10
10
  */
11
11
 
12
12
  export class ListBehavior {
@@ -15,13 +15,18 @@ export class ListBehavior {
15
15
  this.block = block;
16
16
  this.nabu = block.nabu;
17
17
  this.node = /** @type {ListNode} */ (block.node);
18
- this.listType = /** @type {"bullet" | "ordered"} */ (this.node.data.get("listType") || "bullet");
18
+ this.listType = /** @type {"bullet" | "ordered" | "todo"} */ (this.node.data.get("listType") || "bullet");
19
+ this.start = /** @type {any} */ (this.node.data.get("start")) ?? null;
19
20
  this.node.data.subscribe(() => {
20
- this.listType = /** @type {"bullet" | "ordered"} */ (this.node.data.get("listType") || "bullet");
21
+ this.listType = /** @type {"bullet" | "ordered" | "todo"} */ (this.node.data.get("listType") || "bullet");
22
+ this.start = /** @type {any} */ (this.node.data.get("start")) ?? null;
21
23
  });
22
24
  }
23
25
 
24
- /** @type {"bullet" | "ordered"} */
26
+ /** Raw `start` number from the node (null = unset); List.start normalizes it. @type {number | null} */
27
+ start = $state(null);
28
+
29
+ /** @type {"bullet" | "ordered" | "todo"} */
25
30
  listType = $state("bullet");
26
31
 
27
32
  /** @param {Block} block */
@@ -2,16 +2,24 @@
2
2
  * @import { Nabu, NabuNode } from "../nabu.svelte.js";
3
3
  */
4
4
  /**
5
- * @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered"}>} ListNode
5
+ * @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo", start?: number}>} ListNode
6
6
  */
7
+ /**
8
+ * Normalize a list's `start` number: only meaningful for ORDERED lists, and `1` is the default.
9
+ * @param {string | undefined} listType
10
+ * @param {any} start a number, a numeric string (markdown / `<ol start>`), or nothing
11
+ * @returns {number | null} the number to store / emit, or null = default (omit it)
12
+ */
13
+ export function listStart(listType: string | undefined, start: any): number | null;
7
14
  export class List extends MegaBlock {
8
15
  /**
16
+ * Markdown of a list and its sublists. Adjacent lists alternate their marker (`-` / `*`, `.` / `)`), see `adjacentRun`.
9
17
  * @param {import('../../utils/extensions.js').PasteBlock} pb
10
- * @param {{ recurse: (child: import('../../utils/extensions.js').PasteBlock, ctx?: object) => string, depth?: number }} helpers
18
+ * @param {{ indent?: string, before?: import('../../utils/extensions.js').PasteBlock[] }} helpers `before`: the siblings before the list
11
19
  */
12
- static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock, { recurse, depth }: {
13
- recurse: (child: import("../../utils/extensions.js").PasteBlock, ctx?: object) => string;
14
- depth?: number;
20
+ static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock, { indent, before }: {
21
+ indent?: string;
22
+ before?: import("../../utils/extensions.js").PasteBlock[];
15
23
  }): string;
16
24
  /**
17
25
  * @param {import('../../utils/extensions.js').PasteBlock} pb
@@ -20,49 +28,116 @@ export class List extends MegaBlock {
20
28
  static toHtml(pb: import("../../utils/extensions.js").PasteBlock, { recurse }: {
21
29
  recurse: (child: import("../../utils/extensions.js").PasteBlock) => string;
22
30
  }): string;
31
+ /**
32
+ * Markdown lists, see markdown.js: markers `-` `*` `+` `1.` `1)`, nesting by indentation (2 / 4 spaces, TAB), tasks,
33
+ * loose lists, continuation paragraphs of an item.
34
+ */
23
35
  static markdownRules: {
24
36
  priority: number;
25
- detect: RegExp;
26
- consume(lines: string[], i: number): number;
37
+ interruptsParagraph: (line: string) => boolean;
38
+ detect: (line: string) => boolean;
39
+ consume: (lines: string[], i: number, helpers: any) => number;
27
40
  }[];
28
41
  /**
29
- * Parse markdown list lines into a nested List/ListItem PasteBlock tree.
30
- * Uses indent depth to reconstruct nesting recursively.
42
+ * Parse markdown list lines into a nested List/ListItem PasteBlock tree (an array when the marker type changes at
43
+ * the root: several lists).
31
44
  *
32
45
  * @param {string[]} lines
33
- * @param {{ parseInline: (text: string) => import('loro-crdt').Delta<string>[] }} helpers
34
- * @returns {import('../../utils/extensions.js').PasteBlock | null}
46
+ * @param {{ parseInline: (text: string) => import('loro-crdt').Delta<string>[], joinLines?: boolean, softBreak?: string }} helpers
47
+ * @returns {import('../../utils/extensions.js').PasteBlock | import('../../utils/extensions.js').PasteBlock[] | null}
35
48
  */
36
- static fromMarkdown(lines: string[], { parseInline }: {
49
+ static fromMarkdown(lines: string[], helpers: {
37
50
  parseInline: (text: string) => import("loro-crdt").Delta<string>[];
38
- }): import("../../utils/extensions.js").PasteBlock | null;
39
- static htmlRules: {
51
+ joinLines?: boolean;
52
+ softBreak?: string;
53
+ }): import("../../utils/extensions.js").PasteBlock | import("../../utils/extensions.js").PasteBlock[] | null;
54
+ static htmlRules: ({
40
55
  selector: string;
41
56
  props: {
42
57
  listType: string;
43
58
  };
44
- }[];
59
+ priority: number;
60
+ filter?: undefined;
61
+ } | {
62
+ selector: string;
63
+ filter: (el: Element) => boolean;
64
+ props: {
65
+ listType: string;
66
+ };
67
+ priority: number;
68
+ } | {
69
+ selector: string;
70
+ props: {
71
+ listType: string;
72
+ };
73
+ priority?: undefined;
74
+ filter?: undefined;
75
+ })[];
76
+ /**
77
+ * The elements after `el` that continue its list (the `html` interpreter reads them as part of this list): the `<ul>`
78
+ * per nesting level of Google Docs, the following list paragraphs of Word.
79
+ * @param {Element} el
80
+ * @returns {Element[]}
81
+ */
82
+ static htmlSiblings(el: Element): Element[];
45
83
  /**
46
84
  * @param {Element} el
47
- * @param {{ parseChildren: (el: Element) => import('../../utils/extensions.js').PasteBlock[] }} helpers
85
+ * @param {{ parseChildren: (el: Element) => import('../../utils/extensions.js').PasteBlock[], parseBlock: (el: Element) => import('../../utils/extensions.js').PasteBlock | null, parseInline: (el: Element) => import('loro-crdt').Delta<string>[] }} helpers
48
86
  * @param {{ props?: { listType?: string } }} [rule]
87
+ * @param {Element[]} [siblings] what `htmlSiblings` absorbed
49
88
  * @returns {import('../../utils/extensions.js').PasteBlock | null}
50
89
  */
51
- static fromHTML(el: Element, { parseChildren }: {
90
+ static fromHTML(el: Element, helpers: {
52
91
  parseChildren: (el: Element) => import("../../utils/extensions.js").PasteBlock[];
92
+ parseBlock: (el: Element) => import("../../utils/extensions.js").PasteBlock | null;
93
+ parseInline: (el: Element) => import("loro-crdt").Delta<string>[];
53
94
  }, rule?: {
54
95
  props?: {
55
96
  listType?: string;
56
97
  };
57
- }): import("../../utils/extensions.js").PasteBlock | null;
58
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
59
- static create(nabu: Nabu, type: string, props?: Object, parentId?: string | null, index?: number | null): List;
98
+ }, siblings?: Element[]): import("../../utils/extensions.js").PasteBlock | null;
99
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
100
+ static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): List;
60
101
  /** @param {Nabu} nabu @param {ListNode} node */
61
102
  constructor(nabu: Nabu, node: ListNode);
62
103
  behavior: ListBehavior;
63
- listType: "bullet" | "ordered";
104
+ /**
105
+ * This list, its items and their sublists as PasteBlocks (the shape the static serializers read).
106
+ * @returns {import('../../utils/extensions.js').PasteBlock}
107
+ */
108
+ toPasteBlock(): import("../../utils/extensions.js").PasteBlock;
109
+ /**
110
+ * The siblings before this list (the lists right before it decide its marker, see `adjacentRun`).
111
+ * @returns {Array<{ type: string, props: { listType?: string } }>}
112
+ */
113
+ siblingsBefore(): Array<{
114
+ type: string;
115
+ props: {
116
+ listType?: string;
117
+ };
118
+ }>;
119
+ listType: "bullet" | "ordered" | "todo";
120
+ /** First number of an ORDERED list (`<ol start>`); null = 1, the default. @type {number | null} */
121
+ start: number | null;
122
+ /** `start` is only emitted when it is not the default. */
64
123
  get clipboardProps(): {
65
- listType: "bullet" | "ordered";
124
+ listType: "bullet" | "ordered" | "todo";
125
+ start?: undefined;
126
+ } | {
127
+ listType: "bullet" | "ordered" | "todo";
128
+ start: number;
129
+ };
130
+ /**
131
+ * Copying a slice that starts at item `firstChildIndex` of an ORDERED list: the copy is numbered from that item's
132
+ * visual number (`start + index`), not from the original list start.
133
+ * @param {number} firstChildIndex
134
+ */
135
+ clipboardPropsFrom(firstChildIndex: number): {
136
+ listType: "bullet" | "ordered" | "todo";
137
+ start?: undefined;
138
+ } | {
139
+ listType: "bullet" | "ordered" | "todo";
140
+ start: number;
66
141
  };
67
142
  component: import("svelte").Component<any, any, string> | import("svelte").Component<{
68
143
  block: import("./list.svelte.js").List;
@@ -79,12 +154,15 @@ export class List extends MegaBlock {
79
154
  offset: number;
80
155
  delta: import("loro-crdt").Delta<string>;
81
156
  }): {
157
+ block: import("./list-item.svelte.js").ListItem;
158
+ } | {
82
159
  block: import("../block.svelte.js").Block;
83
160
  };
84
161
  }
85
162
  export type ListNode = NabuNode<{
86
163
  type: "list";
87
- listType: "bullet" | "ordered";
164
+ listType: "bullet" | "ordered" | "todo";
165
+ start?: number;
88
166
  }>;
89
167
  import { MegaBlock } from "../megablock.svelte.js";
90
168
  import { ListBehavior } from "./list.behavior.svelte.js";