@prosekit/svelte 0.0.22 → 0.1.1
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/build/hooks/use-extension.d.ts +9 -1
- package/dist/build/hooks/use-extension.d.ts.map +1 -1
- package/dist/build/hooks/use-extension.js +15 -7
- package/dist/build/hooks/use-keymap.d.ts +2 -1
- package/dist/build/hooks/use-keymap.d.ts.map +1 -1
- package/dist/build/hooks/use-keymap.js +4 -3
- package/package.json +9 -9
- package/src/index.ts +5 -0
@@ -1,3 +1,11 @@
|
|
1
1
|
import { type Extension } from '@prosekit/core';
|
2
|
-
|
2
|
+
import { type Readable } from 'svelte/store';
|
3
|
+
/**
|
4
|
+
* Add an extension to the editor.
|
5
|
+
*
|
6
|
+
* It accepts a store to an optional extension. If the extension is changed, the
|
7
|
+
* previous extension will be removed and the new one (if not null) will be
|
8
|
+
* added.
|
9
|
+
*/
|
10
|
+
export declare function useExtension<T extends Extension = Extension>(extensionStore: Readable<T | null>): void;
|
3
11
|
//# sourceMappingURL=use-extension.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"use-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIrD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAC1D,cAAc,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,GACjC,IAAI,CAWN"}
|
@@ -1,14 +1,22 @@
|
|
1
1
|
import {} from '@prosekit/core';
|
2
|
+
import { derived } from 'svelte/store';
|
2
3
|
import { useEditor } from './use-editor';
|
3
|
-
|
4
|
+
/**
|
5
|
+
* Add an extension to the editor.
|
6
|
+
*
|
7
|
+
* It accepts a store to an optional extension. If the extension is changed, the
|
8
|
+
* previous extension will be removed and the new one (if not null) will be
|
9
|
+
* added.
|
10
|
+
*/
|
11
|
+
export function useExtension(extensionStore) {
|
4
12
|
const editorStore = useEditor();
|
13
|
+
const store = derived([editorStore, extensionStore], (values) => values);
|
5
14
|
let cleanup = null;
|
6
|
-
|
7
|
-
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
8
|
-
cleanup = editor.use(extension);
|
9
|
-
});
|
10
|
-
return () => {
|
15
|
+
store.subscribe(([editor, extension]) => {
|
11
16
|
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
12
17
|
cleanup = null;
|
13
|
-
|
18
|
+
if (extension) {
|
19
|
+
cleanup = editor.use(extension);
|
20
|
+
}
|
21
|
+
});
|
14
22
|
}
|
@@ -1,3 +1,4 @@
|
|
1
1
|
import { type Keymap } from '@prosekit/core';
|
2
|
-
|
2
|
+
import { type Readable } from 'svelte/store';
|
3
|
+
export declare function useKeymap(keymapStore: Readable<Keymap>): void;
|
3
4
|
//# sourceMappingURL=use-keymap.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-keymap.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-keymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"use-keymap.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-keymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIrD,wBAAgB,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAG7D"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { defineKeymap } from '@prosekit/core';
|
2
|
+
import { derived } from 'svelte/store';
|
2
3
|
import { useExtension } from './use-extension';
|
3
|
-
export function useKeymap(
|
4
|
-
const extension = defineKeymap(keymap);
|
5
|
-
|
4
|
+
export function useKeymap(keymapStore) {
|
5
|
+
const extension = derived(keymapStore, (keymap) => defineKeymap(keymap));
|
6
|
+
useExtension(extension);
|
6
7
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/svelte",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.1.1",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -95,8 +95,8 @@
|
|
95
95
|
"dist"
|
96
96
|
],
|
97
97
|
"dependencies": {
|
98
|
-
"@prosekit/core": "^0.0
|
99
|
-
"@prosekit/lit": "^0.0
|
98
|
+
"@prosekit/core": "^0.1.0",
|
99
|
+
"@prosekit/lit": "^0.1.0"
|
100
100
|
},
|
101
101
|
"peerDependencies": {
|
102
102
|
"svelte": ">= 3.0.0"
|
@@ -109,12 +109,12 @@
|
|
109
109
|
"devDependencies": {
|
110
110
|
"@prosekit/dev": "*",
|
111
111
|
"@sveltejs/package": "^2.2.2",
|
112
|
-
"@types/node": "^20.9.
|
113
|
-
"read-pkg": "^9.0.
|
114
|
-
"svelte": "^4.2.
|
115
|
-
"svelte-check": "^3.
|
116
|
-
"tsx": "^
|
117
|
-
"typescript": "^5.
|
112
|
+
"@types/node": "^20.9.4",
|
113
|
+
"read-pkg": "^9.0.1",
|
114
|
+
"svelte": "^4.2.7",
|
115
|
+
"svelte-check": "^3.6.0",
|
116
|
+
"tsx": "^4.2.0",
|
117
|
+
"typescript": "^5.3.2",
|
118
118
|
"vitest": "^0.34.6"
|
119
119
|
},
|
120
120
|
"scripts": {
|