@prosekit/svelte 0.1.4 → 0.1.5
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,7 +1,18 @@
|
|
1
1
|
/// <reference types="svelte" />
|
2
2
|
import { type Editor, type Extension } from '@prosekit/core';
|
3
3
|
import { type Readable } from 'svelte/store';
|
4
|
+
/**
|
5
|
+
* Retrieves the editor instance from the nearest ProseKit component.
|
6
|
+
*
|
7
|
+
* @public
|
8
|
+
*/
|
4
9
|
export declare function useEditor<E extends Extension = any>(options?: {
|
10
|
+
/**
|
11
|
+
* Whether to update the component when the editor is mounted or editor state
|
12
|
+
* is updated.
|
13
|
+
*
|
14
|
+
* @default false
|
15
|
+
*/
|
5
16
|
update?: boolean;
|
6
17
|
}): Readable<Editor<E>>;
|
7
18
|
//# sourceMappingURL=use-editor.d.ts.map
|
@@ -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,EAIL,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,CAqBtB"}
|
@@ -1,7 +1,12 @@
|
|
1
|
-
import { defineUpdateHandler, } from '@prosekit/core';
|
1
|
+
import { defineMountHandler, defineUpdateHandler, union, } from '@prosekit/core';
|
2
2
|
import { onDestroy, onMount } from 'svelte';
|
3
3
|
import { readonly, writable } from 'svelte/store';
|
4
4
|
import { getEditorContext } from '../contexts/editor-context';
|
5
|
+
/**
|
6
|
+
* Retrieves the editor instance from the nearest ProseKit component.
|
7
|
+
*
|
8
|
+
* @public
|
9
|
+
*/
|
5
10
|
export function useEditor(options) {
|
6
11
|
var _a;
|
7
12
|
const update = (_a = options === null || options === void 0 ? void 0 : options.update) !== null && _a !== void 0 ? _a : false;
|
@@ -12,7 +17,11 @@ export function useEditor(options) {
|
|
12
17
|
const forceUpdate = () => {
|
13
18
|
editorStore.set(editor);
|
14
19
|
};
|
15
|
-
const
|
20
|
+
const extension = union([
|
21
|
+
defineMountHandler(forceUpdate),
|
22
|
+
defineUpdateHandler(forceUpdate),
|
23
|
+
]);
|
24
|
+
const dispose = editor.use(extension);
|
16
25
|
onDestroy(dispose);
|
17
26
|
});
|
18
27
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/svelte",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.5",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -107,8 +107,8 @@
|
|
107
107
|
"dist"
|
108
108
|
],
|
109
109
|
"dependencies": {
|
110
|
-
"@prosekit/core": "^0.2.
|
111
|
-
"@prosekit/lit": "^0.1.
|
110
|
+
"@prosekit/core": "^0.2.5",
|
111
|
+
"@prosekit/lit": "^0.1.9"
|
112
112
|
},
|
113
113
|
"peerDependencies": {
|
114
114
|
"svelte": ">= 3.0.0"
|
@@ -121,13 +121,13 @@
|
|
121
121
|
"devDependencies": {
|
122
122
|
"@prosekit/dev": "*",
|
123
123
|
"@sveltejs/package": "^2.2.5",
|
124
|
-
"@types/node": "^20.
|
124
|
+
"@types/node": "^20.11.0",
|
125
125
|
"read-pkg": "^9.0.1",
|
126
126
|
"svelte": "^4.2.8",
|
127
|
-
"svelte-check": "^3.6.
|
127
|
+
"svelte-check": "^3.6.3",
|
128
128
|
"tsx": "^4.7.0",
|
129
129
|
"typescript": "^5.3.3",
|
130
|
-
"vitest": "^1.
|
130
|
+
"vitest": "^1.2.0"
|
131
131
|
},
|
132
132
|
"scripts": {
|
133
133
|
"build": "svelte-package -i src -o dist/build && tsx scripts/re-export.ts"
|