@prosekit/react 0.1.5 → 0.1.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/_tsup-dts-rollup.d.ts +11 -0
- package/dist/prosekit-react.js +8 -2
- package/package.json +4 -4
@@ -244,7 +244,18 @@ export declare type ResizableHandleProps = React_2.PropsWithChildren<PropsWithCl
|
|
244
244
|
|
245
245
|
export declare type ResizableProps = React_2.PropsWithChildren<PropsWithClassName<ResizableProps_2>>;
|
246
246
|
|
247
|
+
/**
|
248
|
+
* Retrieves the editor instance from the nearest ProseKit component.
|
249
|
+
*
|
250
|
+
* @public
|
251
|
+
*/
|
247
252
|
declare function useEditor<E extends Extension = any>(options?: {
|
253
|
+
/**
|
254
|
+
* Whether to update the component when the editor is mounted or editor state
|
255
|
+
* is updated.
|
256
|
+
*
|
257
|
+
* @default false
|
258
|
+
*/
|
248
259
|
update?: boolean;
|
249
260
|
}): Editor<E>;
|
250
261
|
export { useEditor }
|
package/dist/prosekit-react.js
CHANGED
@@ -35,7 +35,9 @@ import { useEffect as useEffect2 } from "react";
|
|
35
35
|
// src/hooks/use-editor.ts
|
36
36
|
import {
|
37
37
|
ProseKitError,
|
38
|
-
defineUpdateHandler
|
38
|
+
defineUpdateHandler,
|
39
|
+
union,
|
40
|
+
defineMountHandler
|
39
41
|
} from "@prosekit/core";
|
40
42
|
import { useContext, useEffect, useReducer } from "react";
|
41
43
|
function useEditor(options) {
|
@@ -51,7 +53,11 @@ function useEditor(options) {
|
|
51
53
|
const forceUpdate = useForceUpdate();
|
52
54
|
useEffect(() => {
|
53
55
|
if (update) {
|
54
|
-
|
56
|
+
const extension = union([
|
57
|
+
defineMountHandler(forceUpdate),
|
58
|
+
defineUpdateHandler(forceUpdate)
|
59
|
+
]);
|
60
|
+
return editor.use(extension);
|
55
61
|
}
|
56
62
|
}, [editor, update, forceUpdate]);
|
57
63
|
return editor;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.6",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -96,8 +96,8 @@
|
|
96
96
|
],
|
97
97
|
"dependencies": {
|
98
98
|
"@lit/react": "^1.0.2",
|
99
|
-
"@prosekit/core": "^0.2.
|
100
|
-
"@prosekit/lit": "^0.1.
|
99
|
+
"@prosekit/core": "^0.2.5",
|
100
|
+
"@prosekit/lit": "^0.1.9",
|
101
101
|
"@prosekit/pm": "^0.1.1",
|
102
102
|
"@prosemirror-adapter/core": "^0.2.6"
|
103
103
|
},
|
@@ -121,7 +121,7 @@
|
|
121
121
|
"react-dom": "^18.2.0",
|
122
122
|
"tsup": "^8.0.1",
|
123
123
|
"typescript": "^5.3.3",
|
124
|
-
"vitest": "^1.
|
124
|
+
"vitest": "^1.2.0"
|
125
125
|
},
|
126
126
|
"scripts": {
|
127
127
|
"build:tsup": "tsup",
|