@prosekit/svelte 0.0.18 → 0.0.20
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.
@@ -1,8 +1,11 @@
|
|
1
1
|
import { type Editor, type Extension } from '@prosekit/core';
|
2
|
+
import { type Readable } from 'svelte/store';
|
2
3
|
export interface EditorContext {
|
3
4
|
editor: Editor;
|
4
5
|
}
|
5
6
|
export declare function setEditorContext(editor: Editor): void;
|
6
7
|
export declare function getEditorContext(): EditorContext;
|
7
|
-
export declare function getEditor<E extends Extension = any>(
|
8
|
+
export declare function getEditor<E extends Extension = any>(options?: {
|
9
|
+
update?: boolean;
|
10
|
+
}): Readable<Editor<E>>;
|
8
11
|
//# 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,
|
1
|
+
{"version":3,"file":"editor-context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/editor-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEhE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAOhD;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAiBtB"}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { ProseKitError } from '@prosekit/core';
|
2
|
-
import { getContext, hasContext, setContext } from 'svelte';
|
1
|
+
import { ProseKitError, defineEventHandler, } from '@prosekit/core';
|
2
|
+
import { getContext, hasContext, onDestroy, onMount, setContext } from 'svelte';
|
3
|
+
import { readonly, writable } from 'svelte/store';
|
3
4
|
const key = 'prosekit-svelte-editor-context';
|
4
5
|
export function setEditorContext(editor) {
|
5
6
|
if (!editor) {
|
@@ -14,6 +15,19 @@ export function getEditorContext() {
|
|
14
15
|
}
|
15
16
|
return getContext(key);
|
16
17
|
}
|
17
|
-
export function getEditor() {
|
18
|
-
|
18
|
+
export function getEditor(options) {
|
19
|
+
var _a;
|
20
|
+
const update = (_a = options === null || options === void 0 ? void 0 : options.update) !== null && _a !== void 0 ? _a : false;
|
21
|
+
const editor = getEditorContext().editor;
|
22
|
+
const editorStore = writable(editor);
|
23
|
+
if (update) {
|
24
|
+
onMount(() => {
|
25
|
+
const forceUpdate = () => {
|
26
|
+
editorStore.set(editor);
|
27
|
+
};
|
28
|
+
const dispose = editor.use(defineEventHandler({ update: forceUpdate }));
|
29
|
+
onDestroy(dispose);
|
30
|
+
});
|
31
|
+
}
|
32
|
+
return readonly(editorStore);
|
19
33
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/svelte",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.20",
|
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.0.18",
|
99
|
+
"@prosekit/lit": "^0.0.22"
|
100
100
|
},
|
101
101
|
"peerDependencies": {
|
102
102
|
"svelte": ">= 3.0.0"
|
@@ -109,8 +109,8 @@
|
|
109
109
|
"devDependencies": {
|
110
110
|
"@prosekit/dev": "*",
|
111
111
|
"@sveltejs/package": "^2.2.2",
|
112
|
-
"@types/node": "^20.8.
|
113
|
-
"read-pkg": "^
|
112
|
+
"@types/node": "^20.8.10",
|
113
|
+
"read-pkg": "^9.0.0",
|
114
114
|
"svelte": "^4.2.2",
|
115
115
|
"svelte-check": "^3.5.2",
|
116
116
|
"tsx": "^3.14.0",
|
package/src/index.ts
DELETED