@prosekit/preact 0.4.5 → 0.4.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/prosekit-preact.d.ts +1 -1
- package/dist/prosekit-preact.js +64 -53
- package/package.json +6 -6
@@ -1,10 +1,10 @@
|
|
1
1
|
export { ProseKit } from './_tsup-dts-rollup.js';
|
2
2
|
export { ProseKitProps } from './_tsup-dts-rollup.js';
|
3
|
+
export { useDocChange } from './_tsup-dts-rollup.js';
|
3
4
|
export { useEditor } from './_tsup-dts-rollup.js';
|
4
5
|
export { useExtension } from './_tsup-dts-rollup.js';
|
5
6
|
export { UseExtensionOptions } from './_tsup-dts-rollup.js';
|
6
7
|
export { useKeymap } from './_tsup-dts-rollup.js';
|
7
8
|
export { useStateUpdate } from './_tsup-dts-rollup.js';
|
8
|
-
export { useDocChange } from './_tsup-dts-rollup.js';
|
9
9
|
export { PropsWithChildren } from './_tsup-dts-rollup.js';
|
10
10
|
export { PropsWithClass } from './_tsup-dts-rollup.js';
|
package/dist/prosekit-preact.js
CHANGED
@@ -4,56 +4,28 @@ import {
|
|
4
4
|
} from "./chunk-V253IGNY.js";
|
5
5
|
|
6
6
|
// src/components/prosekit.ts
|
7
|
-
import {
|
7
|
+
import {
|
8
|
+
h
|
9
|
+
} from "preact";
|
8
10
|
var ProseKit = (props) => {
|
9
11
|
const { editor, children } = props;
|
10
12
|
return h(EditorContextProvider, { value: editor, children });
|
11
13
|
};
|
12
14
|
|
13
|
-
// src/hooks/use-
|
14
|
-
import {
|
15
|
-
|
16
|
-
defineMountHandler,
|
17
|
-
defineUpdateHandler,
|
18
|
-
union
|
19
|
-
} from "@prosekit/core";
|
20
|
-
import { useEffect, useReducer } from "preact/hooks";
|
21
|
-
function useEditor(options) {
|
22
|
-
var _a;
|
23
|
-
const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
|
24
|
-
const editor = useEditorContext();
|
25
|
-
if (!editor) {
|
26
|
-
throw new ProseKitError(
|
27
|
-
"useEditor must be used within the ProseKit component"
|
28
|
-
);
|
29
|
-
}
|
30
|
-
const forceUpdate = useForceUpdate();
|
31
|
-
useEffect(() => {
|
32
|
-
if (update) {
|
33
|
-
const extension = union(
|
34
|
-
defineMountHandler(forceUpdate),
|
35
|
-
defineUpdateHandler(forceUpdate)
|
36
|
-
);
|
37
|
-
return editor.use(extension);
|
38
|
-
}
|
39
|
-
}, [editor, update, forceUpdate]);
|
40
|
-
return editor;
|
41
|
-
}
|
42
|
-
function useForceUpdate() {
|
43
|
-
const [, dispatch] = useReducer((x) => x + 1, 0);
|
44
|
-
return dispatch;
|
45
|
-
}
|
15
|
+
// src/hooks/use-doc-change.ts
|
16
|
+
import { defineDocChangeHandler } from "@prosekit/core";
|
17
|
+
import { useMemo as useMemo2 } from "preact/hooks";
|
46
18
|
|
47
19
|
// src/hooks/use-editor-extension.ts
|
48
20
|
import {
|
49
21
|
EditorNotFoundError
|
50
22
|
} from "@prosekit/core";
|
51
|
-
import { useEffect
|
23
|
+
import { useEffect } from "preact/hooks";
|
52
24
|
function useEditorExtension(editor, extension) {
|
53
25
|
if (!editor) {
|
54
26
|
throw new EditorNotFoundError();
|
55
27
|
}
|
56
|
-
|
28
|
+
useEffect(() => {
|
57
29
|
if (extension) {
|
58
30
|
return editor.use(extension);
|
59
31
|
}
|
@@ -61,7 +33,9 @@ function useEditorExtension(editor, extension) {
|
|
61
33
|
}
|
62
34
|
|
63
35
|
// src/hooks/use-priority-extension.ts
|
64
|
-
import {
|
36
|
+
import {
|
37
|
+
withPriority
|
38
|
+
} from "@prosekit/core";
|
65
39
|
import { useMemo } from "preact/hooks";
|
66
40
|
function usePriorityExtension(extension, priority) {
|
67
41
|
return useMemo(() => {
|
@@ -78,31 +52,68 @@ function useExtension(extension, options) {
|
|
78
52
|
);
|
79
53
|
}
|
80
54
|
|
81
|
-
// src/hooks/use-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
55
|
+
// src/hooks/use-doc-change.ts
|
56
|
+
function useDocChange(handler, options) {
|
57
|
+
const extension = useMemo2(
|
58
|
+
() => defineDocChangeHandler((view) => handler(view.state.doc)),
|
59
|
+
[handler]
|
60
|
+
);
|
86
61
|
return useExtension(extension, options);
|
87
62
|
}
|
88
63
|
|
89
|
-
// src/hooks/use-
|
90
|
-
import {
|
64
|
+
// src/hooks/use-editor.ts
|
65
|
+
import {
|
66
|
+
defineMountHandler,
|
67
|
+
defineUpdateHandler,
|
68
|
+
ProseKitError,
|
69
|
+
union
|
70
|
+
} from "@prosekit/core";
|
71
|
+
import {
|
72
|
+
useEffect as useEffect2,
|
73
|
+
useReducer
|
74
|
+
} from "preact/hooks";
|
75
|
+
function useEditor(options) {
|
76
|
+
var _a;
|
77
|
+
const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
|
78
|
+
const editor = useEditorContext();
|
79
|
+
if (!editor) {
|
80
|
+
throw new ProseKitError(
|
81
|
+
"useEditor must be used within the ProseKit component"
|
82
|
+
);
|
83
|
+
}
|
84
|
+
const forceUpdate = useForceUpdate();
|
85
|
+
useEffect2(() => {
|
86
|
+
if (update) {
|
87
|
+
const extension = union(
|
88
|
+
defineMountHandler(forceUpdate),
|
89
|
+
defineUpdateHandler(forceUpdate)
|
90
|
+
);
|
91
|
+
return editor.use(extension);
|
92
|
+
}
|
93
|
+
}, [editor, update, forceUpdate]);
|
94
|
+
return editor;
|
95
|
+
}
|
96
|
+
function useForceUpdate() {
|
97
|
+
const [, dispatch] = useReducer((x) => x + 1, 0);
|
98
|
+
return dispatch;
|
99
|
+
}
|
100
|
+
|
101
|
+
// src/hooks/use-keymap.ts
|
102
|
+
import {
|
103
|
+
defineKeymap
|
104
|
+
} from "@prosekit/core";
|
91
105
|
import { useMemo as useMemo3 } from "preact/hooks";
|
92
|
-
function
|
93
|
-
const extension = useMemo3(
|
94
|
-
() => defineUpdateHandler2((view) => handler(view.state)),
|
95
|
-
[handler]
|
96
|
-
);
|
106
|
+
function useKeymap(keymap, options) {
|
107
|
+
const extension = useMemo3(() => defineKeymap(keymap), [keymap]);
|
97
108
|
return useExtension(extension, options);
|
98
109
|
}
|
99
110
|
|
100
|
-
// src/hooks/use-
|
101
|
-
import {
|
111
|
+
// src/hooks/use-state-update.ts
|
112
|
+
import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
|
102
113
|
import { useMemo as useMemo4 } from "preact/hooks";
|
103
|
-
function
|
114
|
+
function useStateUpdate(handler, options) {
|
104
115
|
const extension = useMemo4(
|
105
|
-
() =>
|
116
|
+
() => defineUpdateHandler2((view) => handler(view.state)),
|
106
117
|
[handler]
|
107
118
|
);
|
108
119
|
return useExtension(extension, options);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/preact",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.4.
|
4
|
+
"version": "0.4.6",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -71,9 +71,9 @@
|
|
71
71
|
],
|
72
72
|
"dependencies": {
|
73
73
|
"react-merge-refs": "^2.1.1",
|
74
|
-
"@prosekit/core": "^0.7.13",
|
75
74
|
"@prosekit/pm": "^0.1.9",
|
76
|
-
"@prosekit/web": "^0.5.
|
75
|
+
"@prosekit/web": "^0.5.2",
|
76
|
+
"@prosekit/core": "^0.7.14"
|
77
77
|
},
|
78
78
|
"peerDependencies": {
|
79
79
|
"preact": ">= 10.11.0"
|
@@ -84,10 +84,10 @@
|
|
84
84
|
}
|
85
85
|
},
|
86
86
|
"devDependencies": {
|
87
|
-
"preact": "^10.
|
87
|
+
"preact": "^10.25.3",
|
88
88
|
"tsup": "^8.3.5",
|
89
|
-
"typescript": "
|
90
|
-
"vitest": "^2.1.
|
89
|
+
"typescript": "~5.6.3",
|
90
|
+
"vitest": "^2.1.8",
|
91
91
|
"@prosekit/dev": "0.0.0"
|
92
92
|
},
|
93
93
|
"scripts": {
|