@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
@@ -4,14 +4,9 @@
4
4
 
5
5
  import { Extension } from '../../utils/extensions.js';
6
6
  import { TextBehavior } from './text.behavior.svelte.js';
7
-
8
- /** @type {Record<string, string>} */
9
- const MARK_SHORTCUTS = {
10
- b: 'bold',
11
- i: 'italic',
12
- u: 'underline',
13
- e: 'code',
14
- };
7
+ import { sanitizeUrl } from '../../utils/html.js';
8
+ import { livePoints, placePoints } from '../../blocks/undo-selection.js';
9
+ import { tick } from 'svelte';
15
10
 
16
11
  /**
17
12
  * Collect all selected blocks with a TextBehavior and a non-collapsed selection.
@@ -22,6 +17,7 @@ function collectMarkTargets(nabu) {
22
17
  const targets = [];
23
18
  for (const [, block] of nabu.blocks) {
24
19
  if (!block.selected) continue;
20
+ if (block.marksEnabled === false) continue;
25
21
  const behavior = block.behaviors?.get('text');
26
22
  if (!(behavior instanceof TextBehavior)) continue;
27
23
  const sel = behavior.selection;
@@ -31,36 +27,45 @@ function collectMarkTargets(nabu) {
31
27
  return targets;
32
28
  }
33
29
 
30
+ /**
31
+ * Run a mark mutation as one transaction and leave the selection EXACTLY on the same characters (anchor, focus and so the
32
+ * direction). A mark rewrites the spans of the text, so the DOM point of an offset changes (a plain text node becomes
33
+ * text / `<strong>` / text): the selection is kept as MODEL points (block + text offset) and put back on the new DOM once it
34
+ * is rendered. Never derive a model offset from a DOM point.
35
+ * @param {Nabu} nabu
36
+ * @param {() => void} mutate
37
+ */
38
+ async function markTransaction(nabu, mutate) {
39
+ const kept = livePoints(nabu);
40
+ await nabu.transact(mutate);
41
+ if (!kept) return;
42
+ await tick();
43
+ placePoints(nabu, kept);
44
+ }
45
+
34
46
  /**
35
47
  * Toggle a mark on all selected text targets.
36
48
  * @param {Nabu} nabu
37
49
  * @param {string} markName
38
50
  */
39
- function toggleMark(nabu, markName) {
40
- const startBlock = nabu.selection.startBlock;
41
- const endBlock = nabu.selection.endBlock;
42
- const startFocusData = startBlock?.focus(null, true);
43
- const endFocusData = endBlock?.focus(null, true);
44
-
51
+ async function toggleMark(nabu, markName) {
45
52
  const targets = collectMarkTargets(nabu);
46
- if (!targets.length) return false;
53
+ if (!targets.length) {
54
+ // Collapsed cursor: toggle the pending stored mark for the next typed char.
55
+ if (nabu.selection.anchorBlock?.behaviors?.has('text')) nabu.toggleStoredMark(markName);
56
+ return false;
57
+ }
47
58
 
48
59
  const isFullyActive = targets.every(({ behavior, sel }) => behavior.isMarkActive(markName, sel));
49
- for (const { behavior, sel } of targets) {
50
- if (isFullyActive) {
51
- behavior.removeMark(markName, sel);
52
- } else {
53
- behavior.applyMark(markName, true, sel);
60
+ await markTransaction(nabu, () => {
61
+ for (const { behavior, sel } of targets) {
62
+ if (isFullyActive) {
63
+ behavior.removeMark(markName, sel);
64
+ } else {
65
+ behavior.applyMark(markName, true, sel);
66
+ }
54
67
  }
55
- }
56
-
57
- nabu.commit();
58
- if (startBlock && endBlock) {
59
- nabu.focus({
60
- from: { block: startBlock, offset: startFocusData?.start?.offset ?? 0 },
61
- to: { block: endBlock, offset: endFocusData?.end?.offset ?? 0 }
62
- });
63
- }
68
+ });
64
69
  return true;
65
70
  }
66
71
 
@@ -73,10 +78,11 @@ function toggleMark(nabu, markName) {
73
78
  function applyMark(nabu, markName, value = true) {
74
79
  const targets = collectMarkTargets(nabu);
75
80
  if (!targets.length) return;
76
- for (const { behavior, sel } of targets) {
77
- behavior.applyMark(markName, value, sel);
78
- }
79
- nabu.commit();
81
+ return markTransaction(nabu, () => {
82
+ for (const { behavior, sel } of targets) {
83
+ behavior.applyMark(markName, value, sel);
84
+ }
85
+ });
80
86
  }
81
87
 
82
88
  /**
@@ -87,49 +93,117 @@ function applyMark(nabu, markName, value = true) {
87
93
  function removeMark(nabu, markName) {
88
94
  const targets = collectMarkTargets(nabu);
89
95
  if (!targets.length) return;
90
- for (const { behavior, sel } of targets) {
91
- behavior.removeMark(markName, sel);
92
- }
93
- nabu.commit();
96
+ return markTransaction(nabu, () => {
97
+ for (const { behavior, sel } of targets) {
98
+ behavior.removeMark(markName, sel);
99
+ }
100
+ });
94
101
  }
95
102
 
96
103
  /**
104
+ * The mark shortcuts are COMMANDS (`mark:bold`…, keys below, replaceable through the `keymap` option). This legacy hook only
105
+ * runs when no command took the key: the browser's own Ctrl/Cmd+B / I / U would then format the text natively
106
+ * (`beforeinput` `formatBold`…), so a shortcut a `keymap` removed or moved stays dead instead of coming back through the
107
+ * native path.
97
108
  * @param {Nabu} nabu
98
109
  * @param {KeyboardEvent} event
99
110
  */
100
111
  function onKeyDown(nabu, event) {
101
- const ctrl = event.ctrlKey || event.metaKey;
102
- if (!ctrl) return;
112
+ if (!(event.ctrlKey || event.metaKey) || event.shiftKey || event.altKey) return;
113
+ const key = typeof event.key === 'string' ? event.key.toLowerCase() : '';
114
+ if (key !== 'b' && key !== 'i' && key !== 'u') return;
115
+ event.preventDefault();
116
+ return nabu.BREAK;
117
+ }
103
118
 
104
- let markName = null;
105
- if (!event.shiftKey) {
106
- markName = MARK_SHORTCUTS[event.key.toLowerCase()] ?? null;
107
- } else if (event.key.toLowerCase() === 'x') {
108
- markName = 'strikethrough';
109
- }
119
+ /** `beforeinput` format types (browser / OS formatting commands) -> the mark they toggle. Sub/superscript have no mark here: ignored. */
120
+ const FORMAT_INPUT_MARKS = /** @type {Record<string, string>} */ ({
121
+ formatBold: 'bold',
122
+ formatItalic: 'italic',
123
+ formatUnderline: 'underline',
124
+ formatStrikeThrough: 'strikethrough',
125
+ });
110
126
 
111
- if (!markName) return;
127
+ /** Marks `formatRemove` clears (links are content, not formatting: they stay). */
128
+ const FORMAT_REMOVE_MARKS = ['bold', 'italic', 'underline', 'strikethrough', 'code'];
112
129
 
130
+ /**
131
+ * Native formatting commands (Cmd+B from the OS menu, "Format > Bold", Touch Bar, accessibility APIs…) arrive as
132
+ * `beforeinput` events of type `formatBold` etc. They go through the same actions as the keyboard shortcuts.
133
+ * @param {Nabu} nabu
134
+ * @param {InputEvent} event
135
+ */
136
+ function onBeforeInput(nabu, event) {
137
+ const type = event.inputType;
138
+ if (typeof type !== 'string' || !type.startsWith('format')) return;
113
139
  event.preventDefault();
114
- nabu.exec('mark:toggle', { mark: markName });
140
+ const mark = FORMAT_INPUT_MARKS[type];
141
+ if (mark) {
142
+ nabu.exec('mark:toggle', { mark });
143
+ } else if (type === 'formatRemove') {
144
+ const targets = collectMarkTargets(nabu);
145
+ if (!targets.length) {
146
+ if (nabu.selection.anchorBlock?.behaviors?.has('text')) {
147
+ nabu.storedMarks = Object.fromEntries(FORMAT_REMOVE_MARKS.map((name) => [name, false]));
148
+ }
149
+ } else {
150
+ markTransaction(nabu, () => {
151
+ for (const { behavior, sel } of targets) for (const name of FORMAT_REMOVE_MARKS) behavior.removeMark(name, sel);
152
+ });
153
+ }
154
+ }
115
155
  return nabu.BREAK;
116
156
  }
117
157
 
158
+ /**
159
+ * A link href that may enter the model: http(s), mailto, tel, relative, `#fragment`. Anything else
160
+ * (`javascript:`, `data:`, `vbscript:`…) is refused with a warning. Returns the href, or null.
161
+ * @param {any} nabu @param {unknown} href @returns {string | null}
162
+ */
163
+ function safeHref(nabu, href) {
164
+ if (!href) return null;
165
+ const safe = sanitizeUrl(href, { kind: 'link' });
166
+ if (safe === null) nabu.warn('link: refused unsafe href', href);
167
+ return safe;
168
+ }
169
+
170
+ /**
171
+ * The inline marks (bold, italic, underline, code, strikethrough) and links: the `mark:*` and `link:*` actions and their keyboard shortcuts.
172
+ */
118
173
  export const RichTextExtension = new Extension('rich-text', {
119
174
  // Declare all mark attributes so Loro's applyDelta can handle them correctly.
120
- // 'expand: after' means the style extends when typing at the end of a marked span.
175
+ // Marks are exact (expand: 'none') — they don't auto-extend at boundaries.
176
+ // Continuation of formatting when typing inside a marked span is handled by
177
+ // stored marks (nabu.storedMarks) toggled via Ctrl+B/I/etc. at a collapsed cursor.
121
178
  loroTextStyles: {
122
- bold: { expand: 'after' },
123
- italic: { expand: 'after' },
124
- underline: { expand: 'after' },
179
+ bold: { expand: 'none' },
180
+ italic: { expand: 'none' },
181
+ underline: { expand: 'none' },
125
182
  code: { expand: 'none' }, // code spans don't expand on insert
126
- strikethrough: { expand: 'after' },
183
+ strikethrough: { expand: 'none' },
184
+ link: { expand: 'none' }, // les liens ne s'étendent pas en tapant
127
185
  },
128
186
  actions: {
129
187
  // Full API
130
188
  'mark:toggle': (nabu, data) => toggleMark(nabu, data?.mark),
131
189
  'mark:apply': (nabu, data) => applyMark(nabu, data?.mark, data?.value),
132
190
  'mark:remove': (nabu, data) => removeMark(nabu, data?.mark),
191
+ // Links — the 'link' mark stores the href as its value
192
+ 'link:set': (nabu, data) => {
193
+ const href = safeHref(nabu, data?.href);
194
+ if (!href) return;
195
+ return applyMark(nabu, 'link', href);
196
+ },
197
+ 'link:remove': (nabu) => removeMark(nabu, 'link'),
198
+ 'link:toggle': (nabu, data) => {
199
+ const targets = collectMarkTargets(nabu);
200
+ if (!targets.length) return;
201
+ const allHaveLink = targets.every(({ behavior, sel }) => behavior.isMarkActive('link', sel));
202
+ if (allHaveLink) return removeMark(nabu, 'link');
203
+ const href = safeHref(nabu, data?.href);
204
+ if (!href) return;
205
+ return applyMark(nabu, 'link', href);
206
+ },
133
207
  // Aliases
134
208
  'bold': (nabu) => toggleMark(nabu, 'bold'),
135
209
  'italic': (nabu) => toggleMark(nabu, 'italic'),
@@ -137,5 +211,13 @@ export const RichTextExtension = new Extension('rich-text', {
137
211
  'code': (nabu) => toggleMark(nabu, 'code'),
138
212
  'strikethrough': (nabu) => toggleMark(nabu, 'strikethrough'),
139
213
  },
140
- hooks: { onKeyDown }
214
+ // Keyboard shortcuts (ADR 017). Also actions of the bus: `nabu.exec('mark:bold')`.
215
+ commands: {
216
+ 'mark:bold': { label: 'Bold', keys: ['Mod-b'], run: (nabu) => { toggleMark(nabu, 'bold'); } },
217
+ 'mark:italic': { label: 'Italic', keys: ['Mod-i'], run: (nabu) => { toggleMark(nabu, 'italic'); } },
218
+ 'mark:underline': { label: 'Underline', keys: ['Mod-u'], run: (nabu) => { toggleMark(nabu, 'underline'); } },
219
+ 'mark:code': { label: 'Code', keys: ['Mod-e'], run: (nabu) => { toggleMark(nabu, 'code'); } },
220
+ 'mark:strikethrough': { label: 'Strikethrough', keys: ['Mod-Shift-x'], run: (nabu) => { toggleMark(nabu, 'strikethrough'); } },
221
+ },
222
+ hooks: { onKeyDown, onBeforeInput }
141
223
  });
@@ -7,29 +7,66 @@
7
7
  export function deltaToHtml(delta: import("loro-crdt").Delta<string>[]): string;
8
8
  /**
9
9
  * Converts a Loro text delta to inline Markdown.
10
+ * A line break (`\n` in the text) is exported as a markdown hard break (backslash + newline), unless `rawBreaks`
11
+ * (a block that re-reads its own lines, like a callout body, keeps the plain newline).
10
12
  * @param {import('loro-crdt').Delta<string>[]} delta
13
+ * @param {{ rawBreaks?: boolean }} [options]
11
14
  * @returns {string}
12
15
  */
13
- export function deltaToMarkdown(delta: import("loro-crdt").Delta<string>[]): string;
16
+ export function deltaToMarkdown(delta: import("loro-crdt").Delta<string>[], { rawBreaks }?: {
17
+ rawBreaks?: boolean;
18
+ }): string;
19
+ /** A link destination: raw when plain, `<…>` when it holds whitespace, angle brackets or unbalanced parentheses. */
20
+ export function markdownDestination(href: string): string;
14
21
  /**
15
- * @typedef {NabuNode<{type: "paragraph", text: LoroText}>} TextNode
16
- */
22
+ * Length (UTF-16 units) of the user-perceived character starting at `index` — the unit one Delete press removes.
23
+ * `Intl.Segmenter` handles ZWJ sequences, flags and combining marks; without it a surrogate pair is kept whole.
24
+ * A caret inside a cluster deletes up to the end of that cluster. 0 at the end of the text.
25
+ * @param {string} text @param {number} index
26
+ */
27
+ export function nextGraphemeLength(text: string, index: number): number;
28
+ /**
29
+ * Length (UTF-16 units) of the user-perceived character ENDING at `index` — the unit one Backspace press removes.
30
+ * Mirror of {@link nextGraphemeLength}: `Intl.Segmenter` handles ZWJ sequences, flags and combining marks; without it a
31
+ * surrogate pair is kept whole. A caret inside a cluster deletes back to the start of that cluster. 0 at the start.
32
+ * @param {string} text @param {number} index
33
+ */
34
+ export function prevGraphemeLength(text: string, index: number): number;
35
+ /**
36
+ * The editing of a block's rich text: wraps a Loro text and offers the reactive `text` and `delta`, the selection in that text, and insertion, deletion, splitting, marks and links. Text blocks use it through `TextBlock`; a container with a header (list item, toggle) owns one.
37
+ */
17
38
  export class TextBehavior {
18
39
  /** @param {Block} block @param {LoroText} [container] */
19
40
  constructor(block: Block, container?: LoroText);
20
- block: Block;
21
- nabu: import("../..").Nabu;
22
- /** @type {LoroText} */
23
- container: LoroText;
24
- text: string;
25
- delta: import("loro-crdt").Delta<string>[];
26
- selection: {
41
+ /** @public */
42
+ public block: Block;
43
+ nabu: import("../../blocks").Nabu;
44
+ /**
45
+ * @type {LoroText}
46
+ * @public
47
+ */
48
+ public container: LoroText;
49
+ /** @public */
50
+ public text: string;
51
+ /** @public */
52
+ public delta: import("loro-crdt").Delta<string>[];
53
+ /** @public */
54
+ public selection: {
27
55
  from: number;
28
56
  to: number;
29
57
  isCollapsed: boolean;
30
58
  direction: "forward" | "backward" | "none";
31
59
  } | null;
32
- positions: number;
60
+ /** @public */
61
+ public positions: number;
62
+ /**
63
+ * Number of words in this text: segmented with `Intl.Segmenter` in the language of the editor (`nabu.lang`) when the platform
64
+ * has it, so Chinese or Japanese text counts its words rather than one per sentence; whitespace-separated otherwise. See
65
+ * `utils/words.js`. Reactive in the text and in `nabu.lang`.
66
+ * @returns {number}
67
+ * @public
68
+ */
69
+ public get wordCount(): number;
33
70
  /**
34
71
  * @param {HTMLElement} element
35
72
  * @param {NabuSelection} globalSelection
@@ -47,70 +84,208 @@ export class TextBehavior {
47
84
  * @param {HTMLElement?} [element]
48
85
  */
49
86
  calculateOffset(node: Node, offset: number, element?: HTMLElement | null): number;
87
+ /**
88
+ * {@link TextBehavior#calculateOffset} bounded by the MODEL text: an empty text renders a lone "\n" placeholder, and a caret
89
+ * after it is still offset 0, not 1 (P-108). (Not during an IME composition: the browser's text is ahead of the model then.)
90
+ * @param {Node} node @param {number} offset @param {HTMLElement?} [element]
91
+ */
92
+ modelOffset(node: Node, offset: number, element?: HTMLElement | null): number;
93
+ /**
94
+ * IME composition starts. With a trailing render filler (`<br data-nabu-filler>`, the empty last line after a "\n")
95
+ * the browser puts the composed text in a NEW text node before the filler (and may swap the filler for a `<br>` of
96
+ * its own) — nodes Svelte does not know, which would stay next to the ones it updates once the model catches up
97
+ * (text shown twice). Remember Svelte's nodes so {@link TextBehavior#restoreAfterComposition} can undo the browser's
98
+ * additions at the end. No filler: nothing to do.
99
+ */
100
+ snapshotForComposition(): void;
101
+ /**
102
+ * End of a composition begun next to a filler, BEFORE the composed text reaches the model: remove the text nodes and
103
+ * `<br>` the browser created meanwhile (the composed text is committed to the model, which the next render shows
104
+ * through Svelte's own nodes); a canceled composition (`composedText` empty) gets its filler back.
105
+ * @param {string} composedText
106
+ */
107
+ restoreAfterComposition(composedText: string): void;
108
+ /**
109
+ * @param {InputEvent} event
110
+ * @param {ReturnType<TextBehavior["getSelection"]>} [selection]
111
+ * @public
112
+ */
113
+ public handleBeforeInput(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): any;
50
114
  /** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [selection] */
51
- handleBeforeInput(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): any;
52
- /** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [selection] */
53
- handleInsertText(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): void;
115
+ handleInsertText(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
54
116
  /** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
55
117
  handleInsertLineBreak(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): void;
56
118
  /** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
57
- handleDeleteContentBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): void;
119
+ handleDeleteContentBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
58
120
  /** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
59
- handleDeleteContentForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): void;
121
+ handleDeleteContentForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
122
+ /**
123
+ * Deletes the word before the cursor (Ctrl+Backspace on Win/Linux,
124
+ * Option+Delete on Mac), including the whitespace that precedes it
125
+ * so no orphan space is left behind (issue #4).
126
+ *
127
+ * For a collapsed selection the range is always computed from the model
128
+ * text, never from `event.getTargetRanges()`: browsers disagree on it
129
+ * (Chromium stops right after the previous space, leaving "one two " from
130
+ * "one two three"), so the behavior would differ per engine.
131
+ * Rule: remove `\s* \S+ \s*` ending at the cursor ("one two three|" -> "one two").
132
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
133
+ */
134
+ handleDeleteWordBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
135
+ /**
136
+ * Deletes the word after the cursor (Ctrl+Delete / Option+Fn+Delete).
137
+ *
138
+ * Like backward deletion, a collapsed selection is resolved from the model
139
+ * text only (`getTargetRanges()` is ignored: it is engine-dependent).
140
+ * Rule, so that the result never has a double space nor glued words:
141
+ * - the cursor is right before the word ("one |two three") -> remove the
142
+ * word and its trailing whitespace -> "one three";
143
+ * - whitespace sits between the cursor and the word ("one| two three")
144
+ * -> remove that leading whitespace and the word, keep the trailing
145
+ * whitespace -> "one three";
146
+ * - last word of the text -> remove it with its leading whitespace
147
+ * ("one two| three" -> "one two").
148
+ * If only whitespace remains after the cursor, it is all removed.
149
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
150
+ */
151
+ handleDeleteWordForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
152
+ /**
153
+ * Deletes from the start of the current line to the cursor (Cmd+Backspace on Mac; `deleteHardLineBackward`).
154
+ * A selection inside the block is deleted whole.
155
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
156
+ */
157
+ handleDeleteSoftLineBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
158
+ /**
159
+ * Deletes from the cursor to the end of the current line (Cmd+Fn+Delete, Ctrl+K style; `deleteHardLineForward`).
160
+ * At the end of a line (before a "\n") or of the block nothing is deleted. A selection is deleted whole.
161
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
162
+ */
163
+ handleDeleteSoftLineForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
164
+ /**
165
+ * Deletes the whole line(s) touched by the selection (`deleteEntireSoftLine`): the text between the surrounding "\n"
166
+ * (or block edges), the line breaks themselves are kept. Caret at the start of the emptied line.
167
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
168
+ */
169
+ handleDeleteEntireLine(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
170
+ /**
171
+ * `deleteContent`: delete the selection (no direction). A collapsed caret deletes nothing.
172
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
173
+ */
174
+ handleDeleteContent(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
175
+ /**
176
+ * `insertReplacementText`: a spellcheck / autocorrect replacement. The replacement text comes in
177
+ * `dataTransfer` (`text/plain`) or `data`; the range to replace in `getTargetRanges()` (mapped to model offsets), else
178
+ * the selection. The replaced run's marks are kept on the new text. One edit (one undo step), caret after it.
179
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
180
+ */
181
+ handleInsertReplacementText(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean;
182
+ /**
183
+ * `insertFromYank` (Emacs-style yank on macOS): the text is inserted as plain text at the caret, replacing the selection.
184
+ * No input rule runs (it is a paste, not typing).
185
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
186
+ */
187
+ handleInsertFromYank(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
188
+ /**
189
+ * `insertTranspose` (macOS Ctrl+T): swaps the two graphemes around the caret; at the end of the text, the last two.
190
+ * Marks travel with their character. No-op with a selection, at the start, with a single character or across a line break.
191
+ * @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
192
+ */
193
+ handleInsertTranspose(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean;
60
194
  /** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
61
195
  handleInsertParagraph(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): any;
62
196
  /**
63
197
  * Retrouve le nœud texte et l'offset DOM pour un offset Modèle donné
64
198
  * @param {number} targetOffset
65
199
  * @param {HTMLElement?} [element]
200
+ * @public
66
201
  */
67
- getDOMPoint(targetOffset: number, element?: HTMLElement | null): {
202
+ public getDOMPoint(targetOffset: number, element?: HTMLElement | null): {
68
203
  node: Node;
69
204
  offset: number;
70
205
  } | null;
71
- /** @param {number} index @param {string} text */
72
- insert(index: number, text: string): void;
73
- /** @param {Parameters<Block["delete"]>[0]} [deletion] @param {ReturnType<TextBehavior["getSelection"]>} [selection] */
74
- delete(deletion?: Parameters<Block["delete"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): void;
75
- /** @param {import('loro-crdt').Delta<string>[]} data */
76
- applyDelta(data?: import("loro-crdt").Delta<string>[]): void;
206
+ /**
207
+ * @param {number} index
208
+ * @param {string} text
209
+ * @public
210
+ */
211
+ public insert(index: number, text: string): void;
212
+ /**
213
+ * @param {Parameters<Block["delete"]>[0]} [deletion]
214
+ * @param {ReturnType<TextBehavior["getSelection"]>} [selection]
215
+ * @public
216
+ */
217
+ public delete(deletion?: Parameters<Block["delete"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): void;
218
+ /**
219
+ * @param {import('loro-crdt').Delta<string>[]} data
220
+ * @public
221
+ */
222
+ public applyDelta(data?: import("loro-crdt").Delta<string>[]): void;
77
223
  /**
78
224
  * @param {Parameters<Block["split"]>[0]} [options]
79
225
  * @param {ReturnType<TextBehavior["getSelection"]>} [selection]
80
226
  * @returns {ReturnType<Block["split"]>}
227
+ * @public
81
228
  */
82
- split(options?: Parameters<Block["split"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): ReturnType<Block["split"]>;
83
- /** @param {string} markName @param {any} value @param {ReturnType<TextBehavior["getSelection"]>} sel */
84
- applyMark(markName: string, value: any, sel: ReturnType<TextBehavior["getSelection"]>): void;
85
- /** @param {string} markName @param {ReturnType<TextBehavior["getSelection"]>} sel */
86
- removeMark(markName: string, sel: ReturnType<TextBehavior["getSelection"]>): void;
87
- /** @param {string} markName @param {ReturnType<TextBehavior["getSelection"]>} sel */
88
- isMarkActive(markName: string, sel: ReturnType<TextBehavior["getSelection"]>): boolean;
89
- /** @param {string} markName @param {any} value @param {ReturnType<TextBehavior["getSelection"]>} sel */
90
- toggleMark(markName: string, value: any, sel: ReturnType<TextBehavior["getSelection"]>): void;
91
- /** @returns {string} */
92
- toMarkdown(): string;
229
+ public split(options?: Parameters<Block["split"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): ReturnType<Block["split"]>;
230
+ /**
231
+ * @param {string} markName
232
+ * @param {any} value
233
+ * @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
234
+ * @public
235
+ */
236
+ public applyMark(markName: string, value: any, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): void;
237
+ /**
238
+ * @param {string} markName
239
+ * @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
240
+ * @public
241
+ */
242
+ public removeMark(markName: string, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): void;
243
+ /**
244
+ * @param {string} markName
245
+ * @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
246
+ * @public
247
+ */
248
+ public isMarkActive(markName: string, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): boolean;
249
+ /**
250
+ * @param {string} markName
251
+ * @param {any} value
252
+ * @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
253
+ * @public
254
+ */
255
+ public toggleMark(markName: string, value: any, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): void;
256
+ /** @param {{ rawBreaks?: boolean }} [options] see {@link deltaToMarkdown}
257
+ * @public
258
+ * @returns {string} */
259
+ public toMarkdown(options?: {
260
+ rawBreaks?: boolean;
261
+ }): string;
93
262
  /**
94
263
  * Converts the text delta to a Slate-like JSON format.
95
264
  * @returns {{text: string, [mark: string]: any}[]}
265
+ * @public
96
266
  */
97
- toJSON(): {
267
+ public toJSON(): {
98
268
  text: string;
99
269
  [mark: string]: any;
100
270
  }[];
101
271
  /**
102
272
  * Serializes a (partial) range of this block's text as a PasteBlock.
103
- * @param {{ from?: number, to?: number, partial?: 'start'|'end'|'both'|false, props?: Record<string,any> }} [context]
104
- * @returns {import('../utils/extensions.js').PasteBlock}
273
+ * @param {{ from?: number, to?: number | null, partial?: 'start'|'end'|'both'|false, props?: Record<string,any> }} [context]
274
+ * @returns {import('../../utils/extensions.js').PasteBlock}
275
+ * @public
105
276
  */
106
- toClipboardBlock({ from, to, partial, props }?: {
277
+ public toClipboardBlock({ from, to, partial, props }?: {
107
278
  from?: number;
108
- to?: number;
279
+ to?: number | null;
109
280
  partial?: "start" | "end" | "both" | false;
110
281
  props?: Record<string, any>;
111
- }): any;
112
- /** @param {Block} other */
113
- absorbs(other: Block): boolean;
282
+ }): import("../../utils/extensions.js").PasteBlock;
283
+ /**
284
+ * @param {Block} other
285
+ * @public
286
+ */
287
+ public absorbs(other: Block): boolean;
288
+ #private;
114
289
  }
115
290
  export type TextNode = NabuNode<{
116
291
  type: "paragraph";