@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
@@ -5,10 +5,41 @@
5
5
  * @typedef {NabuNode<{type: "dialogue", text: LoroText}>} DialogueNode
6
6
  */
7
7
  export class Dialogue extends TextBlock {
8
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
9
- static create(nabu: Nabu, type: string, props?: Object, parentId?: string | null, index?: number | null): Dialogue;
8
+ static placeholder: string;
9
+ /**
10
+ * Dialogue marker DISPLAYED in front of the line (CSS `::before`, see `--nb-dialogue-dash`). Purely visual:
11
+ * overridden by `createDialogueExtension({ dash })`, which registers a subclass. It never reaches the markdown.
12
+ */
13
+ static dash: string;
14
+ /**
15
+ * Markdown syntax of a dialogue line: `-- text`. Fixed, independent of the displayed `dash` (an exchange
16
+ * format must not depend on a visual preference); `–` / `—` at the start of a line are NOT dialogue.
17
+ */
18
+ static markdownMarker: string;
19
+ /** @param {import('../../utils/extensions.js').PasteBlock} pb */
20
+ static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock): string;
21
+ /** @param {import('../../utils/extensions.js').PasteBlock} pb */
22
+ static toHtml(pb: import("../../utils/extensions.js").PasteBlock): string;
23
+ static markdownRules: {
24
+ priority: number;
25
+ interruptsParagraph: boolean;
26
+ detect: RegExp;
27
+ consume: () => number;
28
+ }[];
29
+ /**
30
+ * @param {string[]} lines
31
+ * @param {{ parseInline: (text: string) => import('loro-crdt').Delta<string>[] }} helpers
32
+ * @returns {import('../../utils/extensions.js').PasteBlock | null}
33
+ */
34
+ static fromMarkdown(lines: string[], { parseInline }: {
35
+ parseInline: (text: string) => import("loro-crdt").Delta<string>[];
36
+ }): import("../../utils/extensions.js").PasteBlock | null;
37
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
38
+ static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): any;
10
39
  /** @param {Nabu} nabu @param {DialogueNode} node */
11
40
  constructor(nabu: Nabu, node: DialogueNode);
41
+ /** @returns {string} */
42
+ get dash(): string;
12
43
  component: import("svelte").Component<any, any, string> | import("svelte").Component<{
13
44
  block: import("./dialogue.svelte.js").Dialogue;
14
45
  }, {}, "">;
@@ -1,6 +1,7 @@
1
1
  import { TextBlock } from "../text-block.svelte.js";
2
2
  import { LoroText } from "loro-crdt";
3
3
  import DialogueComponent from "./Dialogue.svelte";
4
+ import { deltaToMarkdown, deltaToHtml } from "../../behaviors/text";
4
5
 
5
6
  /**
6
7
  * @import { Nabu, NabuNode } from "../nabu.svelte.js";
@@ -15,7 +16,7 @@ export class Dialogue extends TextBlock {
15
16
  constructor(nabu, node) {
16
17
  super(nabu, node);
17
18
 
18
- this.serializers.set('markdown', () => `— ${this.behavior.toMarkdown()}`);
19
+ this.serializers.set('markdown', () => { const md = this.behavior.toMarkdown(); return md ? `${Dialogue.markdownMarker} ${md}` : ''; }); // an empty line has no markdown
19
20
  this.serializers.set('json', () => ({
20
21
  id: this.id,
21
22
  type: 'dialogue',
@@ -24,16 +25,69 @@ export class Dialogue extends TextBlock {
24
25
  this.serializers.set('application/x-nabu+json', (ctx) => this.behavior.toClipboardBlock(ctx));
25
26
  }
26
27
 
28
+ static placeholder = 'Dialogue...';
29
+
30
+ /**
31
+ * Dialogue marker DISPLAYED in front of the line (CSS `::before`, see `--nb-dialogue-dash`). Purely visual:
32
+ * overridden by `createDialogueExtension({ dash })`, which registers a subclass. It never reaches the markdown.
33
+ */
34
+ static dash = '–';
35
+
36
+ /**
37
+ * Markdown syntax of a dialogue line: `-- text`. Fixed, independent of the displayed `dash` (an exchange
38
+ * format must not depend on a visual preference); `–` / `—` at the start of a line are NOT dialogue.
39
+ */
40
+ static markdownMarker = '--';
41
+
42
+ /** @returns {string} */
43
+ get dash() { return /** @type {typeof Dialogue} */ (this.constructor).dash; }
44
+
45
+ /** @param {import('../../utils/extensions.js').PasteBlock} pb */
46
+ static toMarkdown(pb) {
47
+ const md = deltaToMarkdown(pb.delta || []);
48
+ return md ? `${Dialogue.markdownMarker} ${md}` : ''; // an empty line has no markdown
49
+ }
50
+
51
+ /** @param {import('../../utils/extensions.js').PasteBlock} pb */
52
+ static toHtml(pb) {
53
+ return `<p>${deltaToHtml(pb.delta || [])}</p>`;
54
+ }
55
+
56
+ static markdownRules = [
57
+ {
58
+ priority: 10,
59
+ interruptsParagraph: true,
60
+ detect: /^-- /,
61
+ consume: () => 1,
62
+ }
63
+ ];
64
+
65
+ /**
66
+ * @param {string[]} lines
67
+ * @param {{ parseInline: (text: string) => import('loro-crdt').Delta<string>[] }} helpers
68
+ * @returns {import('../../utils/extensions.js').PasteBlock | null}
69
+ */
70
+ static fromMarkdown(lines, { parseInline }) {
71
+ const m = lines[0].match(/^-- +(.*)/);
72
+ if (!m) return null;
73
+ const delta = parseInline(m[1]);
74
+ if (!delta.length) return null;
75
+ return { type: 'dialogue', delta, partial: false };
76
+ }
77
+
27
78
  component = $derived(this.nabu.components.get("dialogue") || DialogueComponent);
28
79
 
29
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
80
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
30
81
  static create(nabu, type, props = {}, parentId = null, index = null) {
31
- const node = nabu.tree.createNode(parentId || undefined, index || undefined);
82
+ const node = nabu.tree.createNode(/** @type {import('loro-crdt').TreeID | undefined} */ (parentId || undefined), index ?? undefined);
32
83
  node.data.set("type", "dialogue");
33
84
  const container = node.data.setContainer("text", new LoroText());
34
85
  if (props.text) container.insert(0, props.text);
35
86
  if (props.delta) container.applyDelta([...props.delta]);
36
- const block = new Dialogue(nabu, node);
87
+ // The registered class: a configured subclass (see createDialogueExtension) must be the one instantiated.
88
+ /** @type {any} */
89
+ const BlockClass = nabu.registry.get("dialogue") || Dialogue;
90
+ const block = new BlockClass(nabu, node);
37
91
  return block;
38
92
  }
39
93
  }
@@ -1,3 +1,3 @@
1
1
  export function onBeforeInput(nabu: Nabu, event: InputEvent, block: Block): symbol;
2
- import type { Nabu } from "../../..";
3
- import type { Block } from "../../..";
2
+ import type { Nabu } from "../..";
3
+ import type { Block } from "../..";
@@ -3,7 +3,7 @@ import { TextBehavior } from "../../../behaviors/text";
3
3
  import { Dialogue } from "../dialogue.svelte.js";
4
4
 
5
5
  /**
6
- * @import { Nabu, Block } from "../../..";
6
+ * @import { Nabu, Block } from "../..";
7
7
  */
8
8
 
9
9
  /** @param {Nabu} nabu @param {InputEvent} event @param {Block} block */
@@ -38,10 +38,12 @@ export const onBeforeInput = (nabu, event, block) => {
38
38
  const textBeforeCursor = behavior.text.slice(0, sel.from);
39
39
  if (textBeforeCursor !== "--") return CONTINUE;
40
40
 
41
- behavior.delete({ index: 0, length: 2 });
42
-
43
41
  const blockId = block.node.id.toString();
44
- block.transformTo("dialogue");
42
+ // Undo gives back "-- " (trigger space included): see Nabu.shortcut()
43
+ nabu.shortcut(block, " ", (b) => {
44
+ b.delete({ index: 0, length: 3 });
45
+ block.transformTo("dialogue");
46
+ });
45
47
 
46
48
  tick().then(() => {
47
49
  const b = nabu.blocks.get(blockId);
@@ -1,7 +1,18 @@
1
1
  /**
2
2
  * @import { Nabu } from "../nabu.svelte.js";
3
3
  */
4
- export const DialogueExtension: import("../..").Extension;
4
+ /**
5
+ * Dialogue extension factory.
6
+ * @param {{ dash?: string }} [options]
7
+ * `dash` (default `–`, EN dash): the marker DISPLAYED in front of a dialogue line (CSS custom property
8
+ * `--nb-dialogue-dash`, which a host can also override in CSS). Display only: the markdown syntax of a
9
+ * dialogue line is always `-- text`, whatever the dash.
10
+ */
11
+ export function createDialogueExtension({ dash }?: {
12
+ dash?: string;
13
+ }): import("../../extend.js").Extension;
14
+ /** Default instance (dash `–`). */
15
+ export const DialogueExtension: import("../../extend.js").Extension;
5
16
  import DialogueComponent from "./Dialogue.svelte";
6
17
  import { Dialogue } from "./dialogue.svelte.js";
7
18
  export { DialogueComponent, Dialogue };
@@ -8,40 +8,56 @@ import { onBeforeInput } from "./hooks/onBeforeInput.hook.js";
8
8
  * @import { Nabu } from "../nabu.svelte.js";
9
9
  */
10
10
 
11
- const DialogueExtension = extension("dialogue", {
12
- block: Dialogue,
13
- component: DialogueComponent,
14
- hooks: {
15
- /** @param {Nabu} nabu @param {Dialogue} block @param {Event} event @param {{offset: number, delta: import('loro-crdt').Delta<string>}} data */
16
- onSplit: (nabu, block, event, data) => {
17
- const { offset, delta } = data;
18
-
19
- // Bloc dialogue vide + Entrée → sortir du mode dialogue
20
- if (block.text.length === 0) {
21
- const blockId = block.node.id.toString();
22
- block.transformTo("paragraph");
23
- tick().then(() => {
24
- const b = nabu.blocks.get(blockId);
25
- if (b) b.focus({ start: 0, end: 0 });
26
- });
27
- return { block };
28
- }
29
-
30
- // Bloc non vide + Entrée → créer un nouveau bloc dialogue après
31
- block.delete({ from: offset, to: -1 });
32
-
33
- const currentIndex = block.node.index();
34
- const parent = block.node.parent();
35
- const parentId = parent?.id.toString() || null;
36
-
37
- const newBlock = nabu.insert("dialogue", { delta }, parentId, currentIndex + 1);
38
-
39
- block.commit().then(() => nabu.selection.setCursor(newBlock, 0));
40
-
41
- return { block: newBlock };
42
- },
43
- onBeforeInput,
44
- }
45
- });
11
+ /**
12
+ * Dialogue extension factory.
13
+ * @param {{ dash?: string }} [options]
14
+ * `dash` (default `–`, EN dash): the marker DISPLAYED in front of a dialogue line (CSS custom property
15
+ * `--nb-dialogue-dash`, which a host can also override in CSS). Display only: the markdown syntax of a
16
+ * dialogue line is always `-- text`, whatever the dash.
17
+ */
18
+ export function createDialogueExtension({ dash = '–' } = {}) {
19
+ const BlockClass = dash === Dialogue.dash
20
+ ? Dialogue
21
+ : class extends Dialogue { static dash = dash; };
22
+ return extension("dialogue", {
23
+ // @ts-ignore — static-side variance on create() (same pattern as Paragraph/Heading)
24
+ block: BlockClass,
25
+ component: DialogueComponent,
26
+ hooks: {
27
+ /** @param {Nabu} nabu @param {Dialogue} block @param {Event | null} event @param {import('../../utils/extensions.js').SplitData} data */
28
+ onSplit: (nabu, block, event, data) => {
29
+ const { offset, delta } = data;
30
+
31
+ // Bloc dialogue vide + Entrée → sortir du mode dialogue
32
+ if (block.text.length === 0) {
33
+ const blockId = block.node.id.toString();
34
+ block.transformTo("paragraph");
35
+ tick().then(() => {
36
+ const b = nabu.blocks.get(blockId);
37
+ if (b) b.focus({ start: 0, end: 0 });
38
+ });
39
+ return { block };
40
+ }
41
+
42
+ // Bloc non vide + Entrée → créer un nouveau bloc dialogue après
43
+ block.delete({ from: offset, to: -1 });
44
+
45
+ const currentIndex = block.node.index() ?? 0;
46
+ const parent = block.node.parent();
47
+ const parentId = parent?.id.toString() || null;
48
+
49
+ const newBlock = nabu.insert("dialogue", { delta }, parentId, currentIndex + 1);
50
+
51
+ block.commit().then(() => nabu.selection.setCursor(newBlock, 0));
52
+
53
+ return { block: newBlock };
54
+ },
55
+ onBeforeInput,
56
+ }
57
+ });
58
+ }
59
+
60
+ /** Default instance (dash `–`). */
61
+ const DialogueExtension = createDialogueExtension();
46
62
 
47
63
  export { DialogueExtension, DialogueComponent, Dialogue };
@@ -1 +1,23 @@
1
- export const DividerExtension: import("../..").Extension;
1
+ /**
2
+ * @import { Nabu, Block } from "..";
3
+ */
4
+ /**
5
+ * The ONE divider-insertion path, shared by the `--- ` markdown shortcut and the `divider:insert`
6
+ * action (slash menu `/divider`). Mutations only: the caller commits.
7
+ * - `block` is EMPTY (a paragraph; also any other childless text block except a list item, so `--- `
8
+ * still works in a heading / quote…) → it becomes the divider;
9
+ * - otherwise → a divider is inserted right after the block (after its outermost list when the block
10
+ * sits in one: a divider must not become a child of a list).
11
+ * Either way an empty paragraph is created below the divider, ready for the caret.
12
+ *
13
+ * @param {Nabu} nabu
14
+ * @param {Block} block the block the divider is typed / inserted in
15
+ * @returns {Block | null} the new empty paragraph below the divider
16
+ */
17
+ export function insertDivider(nabu: Nabu, block: Block): Block | null;
18
+ /**
19
+ * The divider block (a horizontal rule): the `--- ` shortcut, markdown and HTML paste rules, and the "Divider" slash entry.
20
+ */
21
+ export const DividerExtension: import("../../extend.js").Extension;
22
+ import type { Nabu } from "..";
23
+ import type { Block } from "..";
@@ -7,13 +7,64 @@ import DividerComponent from "./Divider.svelte";
7
7
  * @import { Nabu, Block } from "..";
8
8
  */
9
9
 
10
+ /**
11
+ * The ONE divider-insertion path, shared by the `--- ` markdown shortcut and the `divider:insert`
12
+ * action (slash menu `/divider`). Mutations only: the caller commits.
13
+ * - `block` is EMPTY (a paragraph; also any other childless text block except a list item, so `--- `
14
+ * still works in a heading / quote…) → it becomes the divider;
15
+ * - otherwise → a divider is inserted right after the block (after its outermost list when the block
16
+ * sits in one: a divider must not become a child of a list).
17
+ * Either way an empty paragraph is created below the divider, ready for the caret.
18
+ *
19
+ * @param {Nabu} nabu
20
+ * @param {Block} block the block the divider is typed / inserted in
21
+ * @returns {Block | null} the new empty paragraph below the divider
22
+ */
23
+ export function insertDivider(nabu, block) {
24
+ const behavior = block.behaviors.get("text");
25
+ const isEmpty = behavior instanceof TextBehavior && behavior.container.length === 0
26
+ && block.type !== "list-item" && !(/** @type {any} */ (block).children?.length);
27
+
28
+ /** @type {Block} */
29
+ let anchor = block;
30
+ if (!isEmpty) {
31
+ while (anchor.parent && (anchor.parent.type === "list" || anchor.parent.type === "list-item")) anchor = /** @type {Block} */ (/** @type {unknown} */ (anchor.parent));
32
+ }
33
+ const node = anchor.node;
34
+ const parentId = node.parent()?.id.toString() || null;
35
+ let index = node.index() ?? 0;
36
+
37
+ if (isEmpty) {
38
+ block.node.data.set("type", "divider");
39
+ } else {
40
+ DividerBlock.create(nabu, "divider", {}, parentId, index + 1);
41
+ index += 1;
42
+ }
43
+
44
+ const PClass = nabu.registry.get("paragraph");
45
+ return PClass ? PClass.create(nabu, "paragraph", {}, parentId, index + 1) : null;
46
+ }
47
+
48
+ /**
49
+ * Commit a divider insertion and move the caret into the paragraph below it.
50
+ * @param {Nabu} nabu @param {Block} block @returns {Promise<void>}
51
+ */
52
+ async function commitDivider(nabu, block) {
53
+ const paragraph = insertDivider(nabu, block);
54
+ await nabu.commit();
55
+ if (!paragraph) return;
56
+ const fresh = nabu.blocks.get(paragraph.id);
57
+ if (fresh) nabu.selection.setCursor(fresh, 0);
58
+ }
59
+
10
60
  /**
11
61
  * Divider hooks:
12
62
  * - `---` + space in a block containing only `---` → replace it with a
13
- * divider and insert an empty paragraph after.
63
+ * divider and insert an empty paragraph after (see insertDivider).
14
64
  * - Backspace at the start of a block whose previous sibling is a divider
15
65
  * → delete the divider (otherwise the text merge would skip over it and
16
66
  * leave it orphaned).
67
+ * - Delete at the end of a block whose next sibling is a divider → delete the divider (symmetric).
17
68
  *
18
69
  * @param {Nabu} nabu @param {InputEvent} event @param {Block} block
19
70
  */
@@ -38,23 +89,33 @@ const onBeforeInput = (nabu, event, block) => {
38
89
  return BREAK;
39
90
  }
40
91
 
92
+ // Delete at the END of the block right BEFORE a divider → delete the divider (symmetric with Backspace
93
+ // after it). The text and the caret are kept; one transaction = one undo step.
94
+ if (event.inputType === "deleteContentForward" && sel.from === behavior.text.length) {
95
+ const { next } = block.getAdjacentSiblings();
96
+ if (next?.type !== 'divider') return CONTINUE;
97
+ const blockId = block.id;
98
+ const offset = sel.from;
99
+ nabu.tree.delete(next.node.id);
100
+ nabu.commit().then(() => {
101
+ const fresh = nabu.blocks.get(blockId);
102
+ if (fresh) nabu.selection.setCursor(fresh, offset);
103
+ });
104
+ return BREAK;
105
+ }
106
+
41
107
  // `--- ` markdown shortcut: block contains exactly `---` and a space is typed
42
108
  if (event.inputType === "insertText" && event.data === " ") {
43
109
  if (behavior.text !== "---" || sel.from !== 3) return CONTINUE;
44
110
 
45
- const node = block.node;
46
- const parentId = node.parent()?.id.toString() || null;
47
- const index = node.index() ?? 0;
48
-
49
- behavior.delete({ index: 0, length: 3 });
50
- block.node.data.set("type", "divider");
51
-
52
- const PClass = nabu.registry.get('paragraph');
53
- const newParagraph = PClass ? PClass.create(nabu, 'paragraph', {}, parentId, index + 1) : null;
54
-
55
- nabu.commit().then(() => {
56
- if (!newParagraph) return;
57
- const fresh = nabu.blocks.get(newParagraph.id);
111
+ /** @type {Block | null} */
112
+ let paragraph = null;
113
+ // Undo gives back "--- " (trigger space included): see Nabu.shortcut()
114
+ nabu.shortcut(block, " ", (b) => {
115
+ b.delete({ index: 0, length: 4 });
116
+ paragraph = insertDivider(nabu, block);
117
+ }).then(() => {
118
+ const fresh = paragraph && nabu.blocks.get(/** @type {Block} */ (paragraph).id);
58
119
  if (fresh) nabu.selection.setCursor(fresh, 0);
59
120
  });
60
121
  return BREAK;
@@ -63,22 +124,27 @@ const onBeforeInput = (nabu, event, block) => {
63
124
  return CONTINUE;
64
125
  };
65
126
 
127
+ /**
128
+ * The divider block (a horizontal rule): the `--- ` shortcut, markdown and HTML paste rules, and the "Divider" slash entry.
129
+ */
66
130
  export const DividerExtension = extension("divider", {
67
131
  // @ts-ignore — static-side variance on create() (same pattern as Paragraph/Heading)
68
132
  block: DividerBlock,
69
133
  component: DividerComponent,
134
+ slashCommands: [
135
+ { title: 'Divider', icon: '—', aliases: ['divider', 'hr', 'separator', 'rule'], group: 'blocks', order: 40, run: (e) => e.exec('divider:insert') },
136
+ ],
70
137
  actions: {
71
138
  /**
72
- * Insert a divider after the anchor block's position.
139
+ * Insert a divider like the `--- ` shortcut does (see insertDivider): an empty paragraph
140
+ * becomes the divider, any other block gets one right after it; the caret lands in a new
141
+ * paragraph below the divider.
73
142
  * @param {Nabu} nabu
74
143
  */
75
144
  'divider:insert': (nabu) => {
76
145
  const anchor = nabu.selection.anchorBlock;
77
146
  if (!anchor) return;
78
- const parentId = anchor.node.parent()?.id.toString() || null;
79
- const index = anchor.node.index() ?? 0;
80
- DividerBlock.create(nabu, 'divider', {}, parentId, index + 1);
81
- return nabu.commit();
147
+ return commitDivider(nabu, anchor);
82
148
  },
83
149
  },
84
150
  hooks: {
@@ -14,8 +14,13 @@ export class DividerBlock extends Block {
14
14
  static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock): string;
15
15
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
16
16
  static toHtml(pb: import("../../utils/extensions.js").PasteBlock): string;
17
+ /**
18
+ * Thematic break (CommonMark): 3+ `-`, `*` or `_` (the same one), spaces allowed between (`* * *`), up to 3 spaces of
19
+ * indent. A `---` right under a line of text is a setext heading underline, not a divider (see the heading block).
20
+ */
17
21
  static markdownRules: {
18
22
  priority: number;
23
+ interruptsParagraph: boolean;
19
24
  detect: RegExp;
20
25
  consume: () => number;
21
26
  }[];
@@ -31,8 +36,8 @@ export class DividerBlock extends Block {
31
36
  * @returns {import('../../utils/extensions.js').PasteBlock}
32
37
  */
33
38
  static fromHTML(): import("../../utils/extensions.js").PasteBlock;
34
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
35
- static create(nabu: Nabu, type: string, props?: Object, parentId?: string | null, index?: number | null): DividerBlock;
39
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
40
+ static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): DividerBlock;
36
41
  /** @param {Nabu} nabu @param {DividerNode} node */
37
42
  constructor(nabu: Nabu, node: DividerNode);
38
43
  component: import("svelte").Component<any, any, string> | import("svelte").Component<{
@@ -46,10 +46,15 @@ export class DividerBlock extends Block {
46
46
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
47
47
  static toHtml(pb) { return '<hr>'; }
48
48
 
49
+ /**
50
+ * Thematic break (CommonMark): 3+ `-`, `*` or `_` (the same one), spaces allowed between (`* * *`), up to 3 spaces of
51
+ * indent. A `---` right under a line of text is a setext heading underline, not a divider (see the heading block).
52
+ */
49
53
  static markdownRules = [
50
54
  {
51
55
  priority: 20,
52
- detect: /^\s*(---+|\*\*\*+|___+)\s*$/,
56
+ interruptsParagraph: true,
57
+ detect: /^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/,
53
58
  consume: () => 1,
54
59
  }
55
60
  ];
@@ -59,7 +64,7 @@ export class DividerBlock extends Block {
59
64
  * @returns {import('../../utils/extensions.js').PasteBlock | null}
60
65
  */
61
66
  static fromMarkdown(lines) {
62
- if (!/^\s*(---+|\*\*\*+|___+)\s*$/.test(lines[0])) return null;
67
+ if (!/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/.test(lines[0])) return null;
63
68
  return { type: 'divider', partial: false };
64
69
  }
65
70
 
@@ -74,9 +79,9 @@ export class DividerBlock extends Block {
74
79
  return { type: 'divider', partial: false };
75
80
  }
76
81
 
77
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
82
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
78
83
  static create(nabu, type, props = {}, parentId = null, index = null) {
79
- const node = nabu.tree.createNode(/** @type {any} */ (parentId || undefined), index || undefined);
84
+ const node = nabu.tree.createNode(/** @type {import('loro-crdt').TreeID | undefined} */ (parentId || undefined), index ?? undefined);
80
85
  /** @type {any} */ (node.data).set("type", "divider");
81
86
  const block = new DividerBlock(nabu, /** @type {DividerNode} */ (/** @type {unknown} */ (node)));
82
87
  return block;
@@ -1,6 +1,7 @@
1
1
  <script>
2
2
  /** @type {{ block: import('./file.svelte.js').FileBlock }} */
3
3
  let { block } = $props();
4
+ $effect(() => block.holdSource());
4
5
  </script>
5
6
 
6
7
  <div
@@ -13,20 +14,26 @@
13
14
  class:selected={block.selected}
14
15
  class:pending={block.status === 'pending'}
15
16
  class:error={block.status === 'error'}
17
+ class:missing={block.isMissing}
16
18
  >
17
19
  {#if block.status === 'error'}
18
20
  <div class="nabu-file-chip nabu-file-chip--error">⚠️ Upload failed</div>
21
+ {:else if block.isMissing}
22
+ <div class="nabu-file-chip nabu-file-chip--error nabu-file-chip--missing" data-nabu-missing>
23
+ <span>📎</span><span>{block.name || 'file'}</span><span class="nabu-file-chip-status">Missing file</span>
24
+ </div>
19
25
  {:else if block.status === 'pending'}
20
26
  <div class="nabu-file-chip nabu-file-chip--pending">
21
- <span>📎</span>
22
- <span>{block.name || 'file'}</span>
23
- <span class="nabu-file-chip-status">Uploading…</span>
27
+ <span>📎</span><span>{block.name || 'file'}</span><span class="nabu-file-chip-status">Uploading…</span>
24
28
  </div>
25
- {:else}
29
+ {:else if block.displaySrc}
26
30
  <a href={block.displaySrc} download={block.name} class="nabu-file-chip">
27
- <span>📎</span>
28
- <span>{block.name || 'file'}</span>
31
+ <span>📎</span><span>{block.name || 'file'}</span>
29
32
  </a>
33
+ {:else}
34
+ <div class="nabu-file-chip">
35
+ <span>📎</span><span>{block.name || 'file'}</span>
36
+ </div>
30
37
  {/if}
31
38
  </div>
32
39
 
@@ -1 +1,4 @@
1
- export const FileExtension: import("../..").Extension;
1
+ /**
2
+ * The file block: an attachment (name, size, download link) stored through the `files` option; the `file:*` actions, file paste for any file type and the "File" slash entry.
3
+ */
4
+ export const FileExtension: import("../../extend.js").Extension;
@@ -1,12 +1,20 @@
1
1
  import { extension } from "../../utils/extensions";
2
2
  import { FileBlock } from "./file.svelte.js";
3
3
  import FileComponent from "./File.svelte";
4
- import { pickMedia, insertMediaUrl } from "../media/media.helpers.js";
4
+ import { pickMedia, insertMediaUrl, mediaFileHandler } from "../media/media.helpers.js";
5
5
 
6
+ /**
7
+ * The file block: an attachment (name, size, download link) stored through the `files` option; the `file:*` actions, file paste for any file type and the "File" slash entry.
8
+ */
6
9
  export const FileExtension = extension("file", {
7
10
  // @ts-ignore — static-side variance on create()
8
11
  block: FileBlock,
9
12
  component: FileComponent,
13
+ // A file pasted from the clipboard becomes this block.
14
+ pasteFileHandlers: [mediaFileHandler('file', (file) => file.size > 0 || !!file.type)],
15
+ slashCommands: [
16
+ { title: 'File', icon: '⎘', aliases: ['file', 'attachment', 'upload', 'document'], group: 'media', order: 20, run: (e) => e.exec('file:pick') },
17
+ ],
10
18
  actions: {
11
19
  'file:pick': (nabu) => pickMedia(nabu, 'file', '*/*'),
12
20
  /**
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export class FileBlock extends MediaBlock {
9
9
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
10
- static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock): string;
10
+ static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock): any;
11
11
  /** @param {import('../../utils/extensions.js').PasteBlock} pb */
12
12
  static toHtml(pb: import("../../utils/extensions.js").PasteBlock): string;
13
13
  static htmlRules: {
@@ -19,8 +19,8 @@ export class FileBlock extends MediaBlock {
19
19
  * @returns {import('../../utils/extensions.js').PasteBlock}
20
20
  */
21
21
  static fromHTML(el: Element): import("../../utils/extensions.js").PasteBlock;
22
- /** @param {Nabu} nabu @param {string} type @param {Object} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
23
- static create(nabu: Nabu, type: string, props?: Object, parentId?: string | null, index?: number | null): FileBlock;
22
+ /** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
23
+ static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): FileBlock;
24
24
  component: import("svelte").Component<any, any, string> | import("svelte").Component<{
25
25
  block: import("./file.svelte.js").FileBlock;
26
26
  }, {}, "">;