@aionbuilders/nabu 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (46) hide show
  1. package/dist/behaviors/text/rich-text.extension.js +96 -30
  2. package/dist/behaviors/text/text.behavior.svelte.d.ts +19 -0
  3. package/dist/behaviors/text/text.behavior.svelte.js +49 -0
  4. package/dist/blocks/Nabu.svelte +3 -0
  5. package/dist/blocks/block.extension.d.ts +2 -0
  6. package/dist/blocks/block.extension.js +32 -0
  7. package/dist/blocks/block.svelte.d.ts +17 -4
  8. package/dist/blocks/block.svelte.js +18 -4
  9. package/dist/blocks/container.utils.d.ts +54 -0
  10. package/dist/blocks/container.utils.js +165 -8
  11. package/dist/blocks/dialogue/dialogue.svelte.js +2 -0
  12. package/dist/blocks/dialogue/index.js +1 -5
  13. package/dist/blocks/heading/heading.svelte.d.ts +36 -0
  14. package/dist/blocks/heading/heading.svelte.js +58 -2
  15. package/dist/blocks/heading/index.js +9 -5
  16. package/dist/blocks/index.d.ts +1 -0
  17. package/dist/blocks/index.js +1 -0
  18. package/dist/blocks/list/index.js +13 -1
  19. package/dist/blocks/list/list-item.svelte.d.ts +41 -0
  20. package/dist/blocks/list/list-item.svelte.js +136 -85
  21. package/dist/blocks/list/list.svelte.d.ts +53 -0
  22. package/dist/blocks/list/list.svelte.js +112 -11
  23. package/dist/blocks/megablock.svelte.d.ts +27 -0
  24. package/dist/blocks/megablock.svelte.js +103 -1
  25. package/dist/blocks/nabu.svelte.d.ts +28 -2
  26. package/dist/blocks/nabu.svelte.js +383 -10
  27. package/dist/blocks/paragraph/index.js +21 -6
  28. package/dist/blocks/paragraph/paragraph.svelte.d.ts +28 -0
  29. package/dist/blocks/paragraph/paragraph.svelte.js +53 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +2 -1
  32. package/dist/paste/html.paste.d.ts +12 -0
  33. package/dist/paste/html.paste.js +192 -0
  34. package/dist/paste/index.d.ts +4 -0
  35. package/dist/paste/index.js +4 -0
  36. package/dist/paste/markdown.paste.d.ts +12 -0
  37. package/dist/paste/markdown.paste.js +140 -0
  38. package/dist/paste/nabu.paste.d.ts +2 -0
  39. package/dist/paste/nabu.paste.js +20 -0
  40. package/dist/paste/plain-text.paste.d.ts +8 -0
  41. package/dist/paste/plain-text.paste.js +42 -0
  42. package/dist/presets.js +6 -4
  43. package/dist/utils/extensions.d.ts +63 -0
  44. package/dist/utils/extensions.js +33 -0
  45. package/dist/utils/selection.svelte.js +0 -5
  46. package/package.json +14 -3
@@ -2,6 +2,27 @@
2
2
  * @import { Nabu, Block } from '../blocks'
3
3
  */
4
4
 
5
+ /**
6
+ * @typedef {Object} PasteBlock
7
+ * @property {string} type
8
+ * @property {'start' | 'end' | 'both' | false} partial
9
+ * @property {Record<string, any>} [props]
10
+ * @property {import('loro-crdt').Delta<string>[]} [delta]
11
+ * @property {PasteBlock[]} [children]
12
+ */
13
+
14
+ /**
15
+ * @typedef {Object} PasteFragment
16
+ * @property {PasteBlock[]} blocks
17
+ */
18
+
19
+ /**
20
+ * @typedef {Object} PasteInterpreter
21
+ * @property {string} format - MIME type géré ('application/x-nabu+json', 'text/html', 'text/plain')
22
+ * @property {number} [priority] - Plus haut = appelé en premier (default: 0)
23
+ * @property {(raw: string, nabu: Nabu) => PasteFragment | null} interpret
24
+ */
25
+
5
26
  /**
6
27
  * @typedef {{
7
28
  * onInit: function(Nabu): void,
@@ -23,6 +44,12 @@
23
44
  * @property {typeof Block} [block]
24
45
  * @property {Partial<ExtensionHooks>} [hooks]
25
46
  * @property {Record<string, (nabu: Nabu) => any>} [serializers]
47
+ * @property {Record<string, (nabu: Nabu, data: any, topic: string) => any>} [actions]
48
+ * @property {PasteInterpreter[]} [pasteInterpreters]
49
+ * @property {Record<string, { expand: 'after' | 'before' | 'both' | 'none' }>} [loroTextStyles]
50
+ * Loro text style configuration required by this extension.
51
+ * Passed to `LoroDoc.configTextStyle()` during Nabu initialization so that
52
+ * `applyDelta` with these attributes works correctly.
26
53
  */
27
54
 
28
55
  export class Extension {
@@ -35,6 +62,12 @@ export class Extension {
35
62
  this.hooks = init.hooks || {};
36
63
  /** @type {Record<string, (nabu: Nabu) => any>} */
37
64
  this.serializers = init.serializers || {};
65
+ /** @type {Record<string, (nabu: Nabu, data: any, topic: string) => any>} */
66
+ this.actions = init.actions || {};
67
+ /** @type {PasteInterpreter[]} */
68
+ this.pasteInterpreters = init.pasteInterpreters || [];
69
+ /** @type {Record<string, { expand: 'after' | 'before' | 'both' | 'none' }>} */
70
+ this.loroTextStyles = init.loroTextStyles || {};
38
71
  }
39
72
  }
40
73
 
@@ -519,12 +519,7 @@ export class SvelteSelection {
519
519
 
520
520
  if (relevantMutations.length === 0) return;
521
521
 
522
- // Debounce pour éviter trop d'appels
523
522
  this.#updateSelection();
524
- // clearTimeout(this.#debounceTimer);
525
- // this.#debounceTimer = setTimeout(() => {
526
- // this.#updateSelection();
527
- // }, debounceMs);
528
523
  });
529
524
  }
530
525
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aionbuilders/nabu",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.6",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",
@@ -8,7 +8,11 @@
8
8
  "prepare": "svelte-kit sync || echo ''",
9
9
  "prepack": "bunx svelte-kit sync && bunx svelte-package && bunx publint",
10
10
  "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
11
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
12
+ "test:unit": "vitest run",
13
+ "test:unit:watch": "vitest",
14
+ "test:e2e": "playwright test",
15
+ "test": "bun run test:unit && bun run test:e2e"
12
16
  },
13
17
  "files": [
14
18
  "dist",
@@ -31,17 +35,23 @@
31
35
  "svelte": "^5.0.0"
32
36
  },
33
37
  "devDependencies": {
38
+ "@playwright/test": "^1.58.2",
34
39
  "@sveltejs/adapter-auto": "^7.0.0",
35
40
  "@sveltejs/kit": "^2.50.2",
36
41
  "@sveltejs/package": "^2.5.7",
37
42
  "@sveltejs/vite-plugin-svelte": "^6.2.4",
43
+ "playwright": "^1.58.2",
38
44
  "publint": "^0.3.17",
39
45
  "svelte": "^5.49.2",
46
+ "svelte-adapter-bun": "^1.0.1",
40
47
  "svelte-check": "^4.3.6",
41
48
  "typescript": "^5.9.3",
42
49
  "vite": "^7.3.1",
43
50
  "vite-plugin-top-level-await": "^1.6.0",
44
- "vite-plugin-wasm": "^3.5.0"
51
+ "vite-plugin-wasm": "^3.5.0",
52
+ "vitest": "^3.0.0",
53
+ "@vitest/coverage-v8": "^3.0.0",
54
+ "happy-dom": "^16.0.0"
45
55
  },
46
56
  "description": "Modular, local-first block editor engine for Svelte 5, built on a single contenteditable architecture and Loro-CRDT.",
47
57
  "author": {
@@ -69,6 +79,7 @@
69
79
  "collaborative"
70
80
  ],
71
81
  "dependencies": {
82
+ "@aionbuilders/pulse": "^1.0.1",
72
83
  "loro-crdt": "^1.10.6"
73
84
  }
74
85
  }