@aionbuilders/nabu 0.1.0-beta.0 → 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 (306) hide show
  1. package/CHANGELOG.md +523 -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 +199 -48
  12. package/dist/behaviors/text/text.behavior.svelte.js +549 -83
  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 +31 -17
  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 +1746 -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 +34 -13
  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 +54 -7
  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/dom-scope.d.ts +14 -0
  253. package/dist/utils/dom-scope.js +20 -0
  254. package/dist/utils/drop.d.ts +160 -0
  255. package/dist/utils/drop.js +305 -0
  256. package/dist/utils/extensions.d.ts +439 -45
  257. package/dist/utils/extensions.js +271 -29
  258. package/dist/utils/html.d.ts +44 -0
  259. package/dist/utils/html.js +183 -0
  260. package/dist/utils/index.d.ts +3 -0
  261. package/dist/utils/index.js +3 -0
  262. package/dist/utils/keys.d.ts +120 -0
  263. package/dist/utils/keys.js +248 -0
  264. package/dist/utils/links.d.ts +22 -0
  265. package/dist/utils/links.js +34 -0
  266. package/dist/utils/placeholders.d.ts +81 -3
  267. package/dist/utils/placeholders.js +73 -3
  268. package/dist/utils/selection.svelte.d.ts +47 -19
  269. package/dist/utils/selection.svelte.js +60 -10
  270. package/dist/utils/spellcheck.d.ts +9 -0
  271. package/dist/utils/spellcheck.js +17 -0
  272. package/dist/utils/tab.d.ts +31 -0
  273. package/dist/utils/tab.js +117 -0
  274. package/dist/utils/words.d.ts +7 -0
  275. package/dist/utils/words.js +62 -0
  276. package/dist/vite.d.ts +9 -3
  277. package/dist/vite.js +19 -8
  278. package/package.json +54 -20
  279. package/dist/blocks/variable.svelte.d.ts +0 -47
  280. package/dist/blocks/variable.svelte.js +0 -51
  281. package/dist/blocks/zone/TemplateEditor.svelte +0 -308
  282. package/dist/blocks/zone/TemplateEditor.svelte.d.ts +0 -11
  283. package/dist/blocks/zone/Zone.svelte +0 -272
  284. package/dist/blocks/zone/Zone.svelte.d.ts +0 -11
  285. package/dist/blocks/zone/ZoneEditor.svelte +0 -289
  286. package/dist/blocks/zone/ZoneEditor.svelte.d.ts +0 -11
  287. package/dist/blocks/zone/ZoneTemplatesList.svelte +0 -188
  288. package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +0 -11
  289. package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +0 -3
  290. package/dist/blocks/zone/hooks/onBeforeInput.hook.js +0 -30
  291. package/dist/blocks/zone/index.d.ts +0 -2
  292. package/dist/blocks/zone/index.js +0 -2
  293. package/dist/blocks/zone/zone.extension.d.ts +0 -2
  294. package/dist/blocks/zone/zone.extension.js +0 -237
  295. package/dist/blocks/zone/zone.svelte.d.ts +0 -221
  296. package/dist/blocks/zone/zone.svelte.js +0 -608
  297. package/dist/overlays/context/Context.svelte +0 -182
  298. package/dist/overlays/context/Context.svelte.d.ts +0 -17
  299. package/dist/overlays/context/collect.d.ts +0 -17
  300. package/dist/overlays/context/collect.js +0 -33
  301. package/dist/overlays/context/context.extension.d.ts +0 -2
  302. package/dist/overlays/context/context.extension.js +0 -8
  303. package/dist/overlays/context/context.svelte.d.ts +0 -82
  304. package/dist/overlays/context/context.svelte.js +0 -159
  305. package/dist/overlays/context/index.d.ts +0 -3
  306. package/dist/overlays/context/index.js +0 -3
@@ -0,0 +1,264 @@
1
+ <script>
2
+ import BlockList from "../BlockList.svelte";
3
+ import RichText from "../../behaviors/text/RichText.svelte";
4
+ import { LARGE_DOC } from "../chunks.js";
5
+ import { Regions } from "./regions.svelte.js";
6
+ import { createMessages } from "./messages.js";
7
+ import { endMarkerText, needsEndMarker } from "./end-marker.js";
8
+
9
+ /** @type {{block: import('./region.svelte.js').RegionBlock}}*/
10
+ let {block} = $props();
11
+
12
+ // A large document (Nabu.svelte sets `data-nabu-large` on the root): the body is skipped by the browser while off screen, see the style below.
13
+ const large = $derived(block.nabu.blocks.size >= LARGE_DOC);
14
+ const region = $derived(Regions.get(block.nabu).of(block));
15
+ const level = $derived(Math.min(6, Math.max(1, region?.level ?? 1)));
16
+ // The label template applied with an EMPTY title ("1.", "1.1", "Chapter 2"): the editable title follows it.
17
+ const prefix = $derived(region?.prefix ?? '');
18
+
19
+ // The end marker (board 9, "only when needed"): when text of the parent follows this region, a discreet line closes it. Reactive:
20
+ // it appears and goes away as the siblings change. Texts: the `messages` of the extension (`endOf`, `backTo`, `outside`).
21
+ const endText = $derived.by(() => {
22
+ if (!region) return '';
23
+ const siblings = block.parent ? block.parent.children : block.nabu.children;
24
+ if (!needsEndMarker(siblings, block)) return '';
25
+ return endMarkerText(createMessages(/** @type {any} */ (block.constructor).messages), region);
26
+ });
27
+
28
+ // The margin rail (board 9, option C): the DEEPEST region holding the caret, only while the editor has the focus.
29
+ const hasCaret = $derived(!!region && Regions.get(block.nabu).caret === region);
30
+
31
+ // A protected merge asks to be HELD on this seam (ADR 017 `hold`, ADR 016 lot 2): the command's prompt shows above the
32
+ // seam and the hairline drains in the warning tint while the key is down. Nothing remains once the region is gone.
33
+ const pending = $derived.by(() => {
34
+ const p = block.nabu.pendingCommandOn(block);
35
+ return p?.strategy === 'hold' ? p : null;
36
+ });
37
+ </script>
38
+
39
+ <!--
40
+ The default rendering of a region (ADR 018 §3.6): a container whose HEADER is the seam (the label prefix, the editable
41
+ TITLE, a hairline) and whose BODY is its children. Announced as a heading of the region's level so that screen readers
42
+ navigate by division. No editing UI here: the integrator brings its own. The body has no border, indent, background or
43
+ margin: the text flows from a region into the next.
44
+
45
+ Theming: --nb-region-color, --nb-region-title-color, --nb-region-rule-color, --nb-region-label-size,
46
+ --nb-region-label-weight, --nb-region-gap, --nb-region-margin (they default to the host's text colour, so light and dark
47
+ pages both work) and --nb-region-warning (the tint of a pending merge: amber; nabu-theme.css gives it a darker amber for
48
+ light pages and a lighter one for dark pages, so the hint keeps a 4.5:1 contrast on both — the #b45309 fallback assumes
49
+ a light page). Also: --nb-region-font, --nb-region-text-transform, --nb-region-letter-spacing (the whole seam: label and title) and
50
+ --nb-region-mark (a `url(...)` drawn in front of the label; default none).
51
+
52
+ End marker (only when text of the parent follows the region): --nb-region-end-color (default: the text colour at 60%, like the seam), --nb-region-end-size
53
+ (11.5px). Its height is fixed (2.6 × the size, one line, never wraps), which is what lets the rail stop above it.
54
+
55
+ Margin rail of the region that holds the caret (focus only, never printed): --nb-region-rail (nabu-theme.css: indigo, lighter on
56
+ dark pages), --nb-region-rail-offset. It is a pseudo-element of the region, out of the flow: appearing shifts nothing. The default
57
+ offset (24px + 0.4em to the left of the region) puts the rail just LEFT of the drag handle, which lives in the 24px strip flush
58
+ against each block (a rail at the usual -0.9em would pass behind its glyph); on touch screens (no handle) it comes closer
59
+ (-0.9em). A host with no room left of the editor sets --nb-region-rail-offset (e.g. -0.6em).
60
+
61
+ The hold hint (neutral version of the design of the "8b" board): left-aligned above the seam, no bubble, no background,
62
+ no border, in the warning tint; the hairline drains with the progress (0 → 1). It is positioned ABSOLUTELY in the top
63
+ margin of the seam, so showing it shifts nothing; it needs `--nb-region-margin` to leave about one line above the seam
64
+ (the default does).
65
+ -->
66
+ <!-- No whitespace between tags below: the editor preserves whitespace, so any whitespace text node would render as a selectable line. -->
67
+ <div
68
+ class="nabu-region"
69
+ data-region-type={block.regionType}
70
+ data-region-level={level}
71
+ class:debug={block.nabu.debugging}
72
+ class:selected={block.selected}
73
+ class:pending={!!pending}
74
+ class:has-end={!!endText}
75
+ data-region-caret={hasCaret ? '' : undefined}
76
+ data-region-pending={pending ? 'hold' : undefined}
77
+ style:--nb-region-progress={pending ? pending.progress : undefined}
78
+ ><div class="nabu-region-seam" role="heading" aria-level={level}>{#if pending}<!-- Not read as part of the heading (the live region announces the prompt): decorative here. --><span class="nabu-region-hint" data-region-hint data-nabu-ui contenteditable="false" aria-hidden="true">{pending.message}</span>{/if}{#if prefix}<span class="nabu-region-label" data-nabu-ui contenteditable="false" title={prefix}>{prefix}</span>{/if}<div
79
+ bind:this={block.element}
80
+ class="nabu-region-title"
81
+ class:empty={!block.text}
82
+ data-block-id={block.id}
83
+ data-block-type="region"
84
+ data-nabu-isolated
85
+ data-placeholder={block.placeholder}
86
+ ><RichText delta={block.delta} /></div><span class="nabu-region-rule" data-nabu-ui contenteditable="false" aria-hidden="true">{#if pending}<span class="nabu-region-drain"></span>{/if}</span></div><div class="nabu-region-body" style:--nb-region-blocks={large ? block.weight : undefined}><BlockList blocks={block.children} /></div>{#if endText}<!-- Never a caret stop (not editable, not selectable) and not read as text: a separator named by the same sentence. --><div class="nabu-region-end" data-region-end data-nabu-ui contenteditable="false" role="separator" aria-label={endText}><span class="nabu-region-end-rule" aria-hidden="true"></span><span class="nabu-region-end-text" aria-hidden="true">{endText}</span></div>{/if}</div>
87
+
88
+ <style>
89
+ /* ── Large documents ── In a large document (`data-nabu-large`, 800 blocks) the body of a region is skipped by the browser while it is off screen
90
+ (`content-visibility: auto`): its layout, paint and selection bookkeeping no longer grow with the size of the document, which is
91
+ what keeps a keystroke within a frame at 10,000 blocks. Until it has been shown once its height is an estimate (its number of
92
+ blocks times --nb-block-estimate, 72px); `auto` then remembers the real one. A small document is left exactly as it was. */
93
+ :global(.nabu-editor[data-nabu-large]) .nabu-region-body {
94
+ content-visibility: auto;
95
+ contain-intrinsic-block-size: auto calc(var(--nb-region-blocks, 16) * var(--nb-block-estimate, 72px));
96
+ /* ...and what it contains may hang out of its box (the margin rail of a sub-region): paint containment would clip it. */
97
+ overflow-clip-margin: var(--nb-clip-margin, 3rem);
98
+ }
99
+
100
+ @media print {
101
+ :global(.nabu-editor[data-nabu-large]) .nabu-region-body { content-visibility: visible; }
102
+ }
103
+
104
+ /* ── Margin rail: the region that holds the caret (data-region-caret), from its seam to the end of its body ── */
105
+ @media not print {
106
+ .nabu-region[data-region-caret] {
107
+ position: relative;
108
+ }
109
+
110
+ .nabu-region[data-region-caret]::before {
111
+ content: '';
112
+ position: absolute;
113
+ left: var(--nb-region-rail-offset, calc(-24px - 0.4em));
114
+ top: 0;
115
+ bottom: 0;
116
+ width: 2px;
117
+ border-radius: 2px;
118
+ background: var(--nb-region-rail, #4F46E5);
119
+ pointer-events: none;
120
+ user-select: none;
121
+ }
122
+
123
+ /* The end marker is not part of the region's extent: the rail stops above it. */
124
+ .nabu-region[data-region-caret].has-end::before {
125
+ bottom: calc(var(--nb-region-end-size, 11.5px) * 2.6);
126
+ }
127
+
128
+ .nabu-region[data-region-caret] > .nabu-region-seam .nabu-region-label {
129
+ color: var(--nb-region-rail, #4F46E5);
130
+ }
131
+ }
132
+
133
+ @media (hover: none) {
134
+ .nabu-region[data-region-caret]::before {
135
+ left: var(--nb-region-rail-offset, -0.9em);
136
+ }
137
+ }
138
+
139
+ /* ── End marker ── */
140
+ .nabu-region-end {
141
+ display: flex;
142
+ align-items: center;
143
+ gap: 0.6em;
144
+ height: calc(var(--nb-region-end-size, 11.5px) * 2.6);
145
+ margin: 0;
146
+ font-size: var(--nb-region-end-size, 11.5px);
147
+ line-height: 1.2;
148
+ letter-spacing: 0.01em;
149
+ color: var(--nb-region-end-color, color-mix(in srgb, currentColor 60%, transparent));
150
+ user-select: none;
151
+ -webkit-user-select: none;
152
+ pointer-events: none;
153
+ }
154
+
155
+ .nabu-region-end-rule {
156
+ flex: none;
157
+ width: 24px;
158
+ border-top: 1px solid currentColor;
159
+ opacity: 0.55;
160
+ }
161
+
162
+ .nabu-region-end-text {
163
+ min-width: 0;
164
+ overflow: hidden;
165
+ text-overflow: ellipsis;
166
+ white-space: nowrap;
167
+ }
168
+
169
+ .nabu-region-seam {
170
+ display: flex;
171
+ align-items: center;
172
+ gap: var(--nb-region-gap, 0.75em);
173
+ margin: var(--nb-region-margin, 1.75em 0 0.75em);
174
+ color: var(--nb-region-color, color-mix(in srgb, currentColor 62%, transparent));
175
+ font-size: var(--nb-region-label-size, 0.75em);
176
+ font-weight: var(--nb-region-label-weight, 500);
177
+ font-family: var(--nb-region-font, inherit);
178
+ text-transform: var(--nb-region-text-transform, none);
179
+ line-height: 1.2;
180
+ letter-spacing: var(--nb-region-letter-spacing, 0.02em);
181
+ position: relative;
182
+ }
183
+
184
+ /* Optional mark in front of the label: `--nb-region-mark: url("data:image/svg+xml,…")` (default `none`: nothing is drawn). Generated
185
+ content: not in the DOM, not selectable, takes no part in the caret. */
186
+ .nabu-region-seam::before {
187
+ content: var(--nb-region-mark, none);
188
+ flex: none;
189
+ user-select: none;
190
+ }
191
+
192
+ .nabu-region.debug.selected > .nabu-region-seam {
193
+ background-color: rgba(59, 130, 246, 0.25);
194
+ }
195
+
196
+ /* The pending hold is drawn by the hint and the draining hairline only: not by the engine's default target outline
197
+ (the extra attribute outranks it: its rule is as specific as a single attribute + the editor's scoped classes). */
198
+ .nabu-region :global([data-command-target][data-block-type='region']) {
199
+ outline: none;
200
+ background-image: none;
201
+ border-radius: 0;
202
+ }
203
+
204
+ .nabu-region-hint {
205
+ position: absolute;
206
+ left: 0;
207
+ bottom: 100%;
208
+ max-width: 100%;
209
+ padding-bottom: 0.25em;
210
+ overflow: hidden;
211
+ text-overflow: ellipsis;
212
+ white-space: nowrap;
213
+ color: var(--nb-region-warning, #b45309);
214
+ font-weight: var(--nb-region-label-weight, 500);
215
+ pointer-events: none;
216
+ user-select: none;
217
+ }
218
+
219
+ .nabu-region-label {
220
+ flex: none;
221
+ max-width: 40%;
222
+ overflow: hidden;
223
+ text-overflow: ellipsis;
224
+ white-space: nowrap;
225
+ user-select: none;
226
+ }
227
+
228
+ /* The title is the editable text of the seam (the header of the container). */
229
+ .nabu-region-title {
230
+ flex: 0 1 auto;
231
+ min-width: 1ch;
232
+ max-width: 100%;
233
+ outline: none;
234
+ white-space: pre-wrap;
235
+ overflow-wrap: anywhere;
236
+ color: var(--nb-region-title-color, color-mix(in srgb, currentColor 88%, transparent));
237
+ }
238
+
239
+ /* An empty title keeps room for its placeholder, so that focusing it does not move the hairline. */
240
+ .nabu-region-title.empty {
241
+ min-width: 8ch;
242
+ }
243
+
244
+ .nabu-region-rule {
245
+ flex: 1 1 2em;
246
+ min-width: 2em;
247
+ position: relative;
248
+ border-top: 1px solid var(--nb-region-rule-color, color-mix(in srgb, currentColor 18%, transparent));
249
+ user-select: none;
250
+ }
251
+
252
+ /* The hairline in the warning tint, emptying from the right as the hold progresses. */
253
+ .nabu-region-drain {
254
+ position: absolute;
255
+ left: 0;
256
+ right: 0;
257
+ top: -1px;
258
+ height: 1px;
259
+ background: var(--nb-region-warning, #b45309);
260
+ transform: scaleX(calc(1 - var(--nb-region-progress, 0)));
261
+ transform-origin: left center;
262
+ pointer-events: none;
263
+ }
264
+ </style>
@@ -0,0 +1,11 @@
1
+ export default Region;
2
+ type Region = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Region: import("svelte").Component<{
7
+ block: import("./region.svelte.js").RegionBlock;
8
+ }, {}, "">;
9
+ type $$ComponentProps = {
10
+ block: import("./region.svelte.js").RegionBlock;
11
+ };
@@ -0,0 +1,135 @@
1
+ /** The region of a `Region`, of a region block, or of the id of a region block. @param {Nabu} nabu @param {unknown} target @returns {Region | null} */
2
+ export function toRegion(nabu: Nabu, target: unknown): Region | null;
3
+ /**
4
+ * Creates a block of the default text type WITHOUT committing (the caller owns the transaction).
5
+ * @param {Nabu} nabu @param {Record<string, any>} props @param {string | null} parentId @param {number} index @returns {Block}
6
+ */
7
+ export function createDefaultBlock(nabu: Nabu, props: Record<string, any>, parentId: string | null, index: number): Block;
8
+ /** Puts the caret back after a commit (the DOM is re-rendered by then). @param {Nabu} nabu @param {Block | null | undefined} block @param {number} offset */
9
+ export function restoreCaret(nabu: Nabu, block: Block | null | undefined, offset: number): Promise<void>;
10
+ /** The first block holding text, in document order, among `blocks` and their descendants (a sub-region's title counts). @param {Block[]} blocks @returns {Block | null} */
11
+ export function firstTextBlock(blocks: Block[]): Block | null;
12
+ /**
13
+ * "Split here" (ADR 018 §3.5): the region C whose body directly holds the caret block (none at the root) gets a new sibling N
14
+ * of the same type (the default type at the root) right after it. The caret block is cut like Enter does (a heading cut at its
15
+ * end gives a paragraph, mid-text both halves keep their type; at offset 0 there is no cut), then the tail and ALL the blocks
16
+ * that follow it move, in order, into the body of N. At the root N takes the tail and the root blocks that follow it up to
17
+ * (excluding) the next root region. The caret goes to the start of the tail.
18
+ * A block that does not split on Enter (a code block, where Mod-Enter is the user's own) is left alone. One undo step: the
19
+ * block split commits itself (twice), and the engine merges those commits with ours, which follows in the same synchronous turn.
20
+ * @param {Nabu} nabu
21
+ * @param {{ block: Block | null }} ctx
22
+ * @returns {Promise<boolean>} false when the caret is not in a splittable text block
23
+ */
24
+ export function splitRegion(nabu: Nabu, ctx: {
25
+ block: Block | null;
26
+ }): Promise<boolean>;
27
+ /**
28
+ * Inserts an empty region next to a region, or inside its body, as one undo step; the caret stays where it is.
29
+ * - `at: 'after'` (default): right after `region`, in its parent (a sibling; its whole body stays with it); `'before'`: right before it;
30
+ * - `at: 'inside'`: a SUB-region, in the body of `region`, at the end of the body or at `index` (clamped). The nesting rule
31
+ * holds: the type must be strictly deeper than `region`, and without `type` the shallowest declared deeper type is used (the
32
+ * first declared of its level). A warning and `false` when no type is deeper (a region of the deepest level) or `type` is
33
+ * not valid there; `region` is required;
34
+ * - without `region` (the caret is outside any region): at the caret's position among the root blocks (`from` = the caret
35
+ * block): after / before the root block that holds it.
36
+ * @param {Nabu} nabu
37
+ * @param {Region | null} region the region the position is relative to
38
+ * @param {{ type?: string, at?: 'after' | 'before' | 'inside', index?: number, title?: string, fields?: Record<string, any> }} [options]
39
+ * `type` defaults to the type of `region` (`'inside'`: see above), else the default (top-level) type. `index` only counts for `'inside'`.
40
+ * @param {Block | null} [from] the caret block, for the case without region
41
+ * @returns {Promise<boolean>}
42
+ */
43
+ export function insertNearRegion(nabu: Nabu, region: Region | null, { type, at, index: bodyIndex, title, fields }?: {
44
+ type?: string;
45
+ at?: "after" | "before" | "inside";
46
+ index?: number;
47
+ title?: string;
48
+ fields?: Record<string, any>;
49
+ }, from?: Block | null): Promise<boolean>;
50
+ /**
51
+ * Merges a region with what is before it (ADR 018 §3.5, see `mergePlan`): into its previous sibling when that one is a region
52
+ * of the same level (its body joins the end of that body), else the region is dissolved in place (its body takes its
53
+ * position in its parent). The title goes away in both cases (an undo gives it back). One undo step. The caret, if given,
54
+ * is put back; when it was in the title that went away it goes to the start of the body (else the end of the region joined).
55
+ * @param {Nabu} nabu
56
+ * @param {Region} region
57
+ * @param {Caret | null} [caret]
58
+ * @returns {Promise<boolean>} false when there is nothing to merge with (the first region of the document)
59
+ */
60
+ export function mergeRegion(nabu: Nabu, region: Region, caret?: Caret | null): Promise<boolean>;
61
+ /**
62
+ * Dissolves a region (ADR 018 §3.5): its title, when not empty, becomes a default paragraph at the region's position (delta and
63
+ * marks kept), followed by the children of its body, in order; the region is deleted. One undo step. The caret goes to the
64
+ * same offset in the paragraph if it was in the title, else it is put back.
65
+ * @param {Nabu} nabu
66
+ * @param {Region} region
67
+ * @param {Caret | null} [caret]
68
+ * @returns {Promise<boolean>}
69
+ */
70
+ export function unwrapRegion(nabu: Nabu, region: Region, caret?: Caret | null): Promise<boolean>;
71
+ /**
72
+ * Leaves a region (ADR 018 §3.5, `region:exit`): the caret ends up in an empty default paragraph right after the region, in the
73
+ * region's parent (one level up).
74
+ * - the caret block is an EMPTY default paragraph that is the LAST child of the region's body: that very paragraph moves out,
75
+ * right after the region (so repeating the command climbs scene, chapter, part, root);
76
+ * - otherwise a new empty paragraph is created there.
77
+ * One undo step.
78
+ * @param {Nabu} nabu
79
+ * @param {Region} region
80
+ * @param {Block | null} [from] the block holding the caret
81
+ * @returns {Promise<boolean>}
82
+ */
83
+ export function exitRegion(nabu: Nabu, region: Region, from?: Block | null): Promise<boolean>;
84
+ /**
85
+ * Swaps a region with the previous / next sibling node that is a region of the SAME level, in the same parent: they trade
86
+ * places with their bodies (a region is a container, it moves with its subtree); the text siblings in between stay where
87
+ * they are. At an edge, or when the next sibling region has another level, nothing moves (no commit). One undo step.
88
+ * @param {Nabu} nabu
89
+ * @param {Region} region
90
+ * @param {'up' | 'down'} direction
91
+ * @param {Caret | null} [caret]
92
+ * @returns {Promise<boolean>}
93
+ */
94
+ export function moveRegion(nabu: Nabu, region: Region, direction: "up" | "down", caret?: Caret | null): Promise<boolean>;
95
+ /**
96
+ * Demotes a region (ADR 018 §3.5), structurally like a list indent: it is retyped to the first type of the level below and
97
+ * becomes the LAST child of its previous sibling node, which must be a region shallower than the new type. The sub-regions of
98
+ * its body that are now too shallow for it (level <= its new level) are moved out, in order, right after it (inside the
99
+ * sibling). No-op (no commit) when there is no deeper type or no such sibling. One undo step.
100
+ * @param {Nabu} nabu
101
+ * @param {Region} region
102
+ * @param {Caret | null} [caret]
103
+ * @returns {Promise<boolean>}
104
+ */
105
+ export function demoteRegion(nabu: Nabu, region: Region, caret?: Caret | null): Promise<boolean>;
106
+ /**
107
+ * Promotes a region (ADR 018 §3.5, Q4), the inverse of a demotion: it is retyped to the first type of the level above and
108
+ * leaves its parent region P to sit right after it (in P's parent); every block that FOLLOWED it in P's body, text and
109
+ * regions, follows it into its body, in order, appended after its own. No-op (no commit) when it has no parent region or
110
+ * there is no type one level up. One undo step.
111
+ * @param {Nabu} nabu
112
+ * @param {Region} region
113
+ * @param {Caret | null} [caret]
114
+ * @returns {Promise<boolean>}
115
+ */
116
+ export function promoteRegion(nabu: Nabu, region: Region, caret?: Caret | null): Promise<boolean>;
117
+ /**
118
+ * Puts the caret at the first text position of the BODY of `region` (the first text block after its title, inside it), else
119
+ * at the end of its title, and scrolls it into view.
120
+ * @param {Nabu} nabu
121
+ * @param {Region} region
122
+ * @returns {Promise<boolean>}
123
+ */
124
+ export function goToRegion(nabu: Nabu, region: Region): Promise<boolean>;
125
+ export function kids(node: NabuNode): NabuNode[];
126
+ export function parentIdOf(node: NabuNode): string | null;
127
+ export function defaultType(nabu: Nabu): string;
128
+ export type Caret = {
129
+ block: Block;
130
+ offset: number;
131
+ };
132
+ import type { Nabu } from "../nabu.svelte.js";
133
+ import type { Region } from "./regions.svelte.js";
134
+ import type { Block } from "../block.svelte.js";
135
+ import type { NabuNode } from "../nabu.svelte.js";