@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.
- package/dist/behaviors/text/rich-text.extension.js +96 -30
- package/dist/behaviors/text/text.behavior.svelte.d.ts +19 -0
- package/dist/behaviors/text/text.behavior.svelte.js +49 -0
- package/dist/blocks/Nabu.svelte +3 -0
- package/dist/blocks/block.extension.d.ts +2 -0
- package/dist/blocks/block.extension.js +32 -0
- package/dist/blocks/block.svelte.d.ts +17 -4
- package/dist/blocks/block.svelte.js +18 -4
- package/dist/blocks/container.utils.d.ts +54 -0
- package/dist/blocks/container.utils.js +165 -8
- package/dist/blocks/dialogue/dialogue.svelte.js +2 -0
- package/dist/blocks/dialogue/index.js +1 -5
- package/dist/blocks/heading/heading.svelte.d.ts +36 -0
- package/dist/blocks/heading/heading.svelte.js +58 -2
- package/dist/blocks/heading/index.js +9 -5
- package/dist/blocks/index.d.ts +1 -0
- package/dist/blocks/index.js +1 -0
- package/dist/blocks/list/index.js +13 -1
- package/dist/blocks/list/list-item.svelte.d.ts +41 -0
- package/dist/blocks/list/list-item.svelte.js +136 -85
- package/dist/blocks/list/list.svelte.d.ts +53 -0
- package/dist/blocks/list/list.svelte.js +112 -11
- package/dist/blocks/megablock.svelte.d.ts +27 -0
- package/dist/blocks/megablock.svelte.js +103 -1
- package/dist/blocks/nabu.svelte.d.ts +28 -2
- package/dist/blocks/nabu.svelte.js +383 -10
- package/dist/blocks/paragraph/index.js +21 -6
- package/dist/blocks/paragraph/paragraph.svelte.d.ts +28 -0
- package/dist/blocks/paragraph/paragraph.svelte.js +53 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/paste/html.paste.d.ts +12 -0
- package/dist/paste/html.paste.js +192 -0
- package/dist/paste/index.d.ts +4 -0
- package/dist/paste/index.js +4 -0
- package/dist/paste/markdown.paste.d.ts +12 -0
- package/dist/paste/markdown.paste.js +140 -0
- package/dist/paste/nabu.paste.d.ts +2 -0
- package/dist/paste/nabu.paste.js +20 -0
- package/dist/paste/plain-text.paste.d.ts +8 -0
- package/dist/paste/plain-text.paste.js +42 -0
- package/dist/presets.js +6 -4
- package/dist/utils/extensions.d.ts +63 -0
- package/dist/utils/extensions.js +33 -0
- package/dist/utils/selection.svelte.js +0 -5
- package/package.json +14 -3
package/dist/utils/extensions.js
CHANGED
|
@@ -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.
|
|
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
|
}
|