@prosekit/svelte 0.3.7 → 0.3.9
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/contexts/editor-context.d.ts +1 -1
- package/dist/build/contexts/editor-context.d.ts.map +1 -1
- package/dist/build/contexts/editor-context.js +2 -3
- package/dist/build/hooks/use-editor-extension.d.ts.map +1 -1
- package/dist/build/hooks/use-editor-extension.js +21 -17
- package/dist/build/hooks/use-editor.d.ts.map +1 -1
- package/dist/build/hooks/use-editor.js +3 -4
- package/package.json +9 -9
|
@@ -6,5 +6,5 @@ export declare function setEditorContext(editor: Editor): void;
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export declare function useEditorContext<E extends Extension>(): Editor<E> |
|
|
9
|
+
export declare function useEditorContext<E extends Extension>(): Editor<E> | void;
|
|
10
10
|
//# sourceMappingURL=editor-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/editor-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK3E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"editor-context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/editor-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK3E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAIxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE5E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5C;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,cAAc,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"use-editor-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE5E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5C;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,cAAc,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,QA6B3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor, EditorNotFoundError } from '@prosekit/core';
|
|
2
|
-
import {
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
3
|
import {} from 'svelte/store';
|
|
4
4
|
import { useEditorContext } from '../contexts/editor-context';
|
|
5
5
|
/**
|
|
@@ -7,21 +7,25 @@ import { useEditorContext } from '../contexts/editor-context';
|
|
|
7
7
|
*/
|
|
8
8
|
export function useEditorExtension(maybeEditor, extensionStore) {
|
|
9
9
|
const editorContext = useEditorContext();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
onMount(() => {
|
|
11
|
+
let cleanup;
|
|
12
|
+
let unsubscribe;
|
|
13
|
+
unsubscribe = extensionStore.subscribe((extension) => {
|
|
14
|
+
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
|
15
|
+
cleanup = undefined;
|
|
16
|
+
const editor = maybeEditor || editorContext;
|
|
17
|
+
if (!editor) {
|
|
18
|
+
throw new EditorNotFoundError();
|
|
19
|
+
}
|
|
20
|
+
if (extension) {
|
|
21
|
+
cleanup = editor.use(extension);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return () => {
|
|
25
|
+
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
|
26
|
+
cleanup = undefined;
|
|
27
|
+
unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
|
|
28
|
+
unsubscribe = undefined;
|
|
29
|
+
};
|
|
26
30
|
});
|
|
27
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,MAAM,EACX,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIhE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CA0BtB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineMountHandler, defineUpdateHandler, union,
|
|
2
|
-
import {
|
|
1
|
+
import { ProseKitError, defineMountHandler, defineUpdateHandler, union, } from '@prosekit/core';
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
3
|
import { readonly, writable } from 'svelte/store';
|
|
4
4
|
import { useEditorContext } from '../contexts/editor-context';
|
|
5
5
|
/**
|
|
@@ -24,8 +24,7 @@ export function useEditor(options) {
|
|
|
24
24
|
defineMountHandler(forceUpdate),
|
|
25
25
|
defineUpdateHandler(forceUpdate),
|
|
26
26
|
]);
|
|
27
|
-
|
|
28
|
-
onDestroy(dispose);
|
|
27
|
+
return editor.use(extension);
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
return readonly(editorStore);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.9",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "ocavue",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"dist"
|
|
72
72
|
],
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@prosekit/core": "^0.
|
|
75
|
-
"@prosekit/
|
|
76
|
-
"@prosekit/
|
|
74
|
+
"@prosekit/core": "^0.7.0",
|
|
75
|
+
"@prosekit/pm": "^0.1.5",
|
|
76
|
+
"@prosekit/web": "^0.2.2"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"svelte": ">= 3.0.0"
|
|
@@ -85,13 +85,13 @@
|
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@sveltejs/package": "^2.3.2",
|
|
88
|
-
"@types/node": "^20.14.
|
|
88
|
+
"@types/node": "^20.14.9",
|
|
89
89
|
"read-pkg": "^9.0.1",
|
|
90
90
|
"svelte": "^4.2.18",
|
|
91
|
-
"svelte-check": "^3.8.
|
|
92
|
-
"tsx": "^4.
|
|
93
|
-
"typescript": "^5.5.
|
|
94
|
-
"vitest": "^
|
|
91
|
+
"svelte-check": "^3.8.4",
|
|
92
|
+
"tsx": "^4.16.2",
|
|
93
|
+
"typescript": "^5.5.3",
|
|
94
|
+
"vitest": "^2.0.0-beta.13",
|
|
95
95
|
"@prosekit/dev": "0.0.0"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|