@prosekit/preact 0.1.3 → 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.
- package/dist/_tsup-dts-rollup.d.ts +24 -1
- package/dist/prosekit-preact-resizable-handle.d.ts +2 -0
- package/dist/prosekit-preact-resizable-handle.js +9 -0
- package/dist/prosekit-preact-resizable.d.ts +2 -0
- package/dist/prosekit-preact-resizable.js +9 -0
- package/dist/prosekit-preact.js +28 -6
- package/package.json +20 -4
@@ -17,6 +17,8 @@ import { Options } from 'tsup';
|
|
17
17
|
import { PopoverOptions } from '@prosekit/lit/autocomplete-popover';
|
18
18
|
import type { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
|
19
19
|
import { Priority } from '@prosekit/core';
|
20
|
+
import type { ResizableHandleProps as ResizableHandleProps_2 } from '@prosekit/lit/resizable-handle';
|
21
|
+
import type { ResizableProps as ResizableProps_2 } from '@prosekit/lit/resizable';
|
20
22
|
|
21
23
|
declare const AutocompleteEmpty: ComponentType<AutocompleteEmptyProps>;
|
22
24
|
export { AutocompleteEmpty }
|
@@ -120,7 +122,28 @@ declare interface ProseKitProps {
|
|
120
122
|
export { ProseKitProps }
|
121
123
|
export { ProseKitProps as ProseKitProps_alias_1 }
|
122
124
|
|
123
|
-
declare
|
125
|
+
export declare const Resizable: ComponentType<ResizableProps>;
|
126
|
+
|
127
|
+
export declare const ResizableHandle: ComponentType<ResizableHandleProps>;
|
128
|
+
|
129
|
+
export declare type ResizableHandleProps = PropsWithChildren<PropsWithClass<ResizableHandleProps_2>>;
|
130
|
+
|
131
|
+
export declare type ResizableProps = PropsWithChildren<PropsWithClass<ResizableProps_2>>;
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Retrieves the editor instance from the nearest ProseKit component.
|
135
|
+
*
|
136
|
+
* @public
|
137
|
+
*/
|
138
|
+
declare function useEditor<E extends Extension = any>(options?: {
|
139
|
+
/**
|
140
|
+
* Whether to update the component when the editor is mounted or editor state
|
141
|
+
* is updated.
|
142
|
+
*
|
143
|
+
* @default false
|
144
|
+
*/
|
145
|
+
update?: boolean;
|
146
|
+
}): Editor<E>;
|
124
147
|
export { useEditor }
|
125
148
|
export { useEditor as useEditor_alias_1 }
|
126
149
|
|
package/dist/prosekit-preact.js
CHANGED
@@ -13,24 +13,46 @@ var ProseKit = (props) => {
|
|
13
13
|
var EditorContextProvider = editorContext.Provider;
|
14
14
|
|
15
15
|
// src/hooks/use-editor.ts
|
16
|
-
import {
|
17
|
-
|
18
|
-
|
16
|
+
import {
|
17
|
+
ProseKitError,
|
18
|
+
defineMountHandler,
|
19
|
+
defineUpdateHandler,
|
20
|
+
union
|
21
|
+
} from "@prosekit/core";
|
22
|
+
import { useContext, useEffect, useReducer } from "preact/hooks";
|
23
|
+
function useEditor(options) {
|
24
|
+
var _a;
|
25
|
+
const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
|
19
26
|
const value = useContext(editorContext);
|
20
27
|
if (!value) {
|
21
28
|
throw new ProseKitError(
|
22
29
|
"useEditor must be used within the ProseKit component"
|
23
30
|
);
|
24
31
|
}
|
25
|
-
|
32
|
+
const editor = value.editor;
|
33
|
+
const forceUpdate = useForceUpdate();
|
34
|
+
useEffect(() => {
|
35
|
+
if (update) {
|
36
|
+
const extension = union([
|
37
|
+
defineMountHandler(forceUpdate),
|
38
|
+
defineUpdateHandler(forceUpdate)
|
39
|
+
]);
|
40
|
+
return editor.use(extension);
|
41
|
+
}
|
42
|
+
}, [editor, update, forceUpdate]);
|
43
|
+
return editor;
|
44
|
+
}
|
45
|
+
function useForceUpdate() {
|
46
|
+
const [, dispatch] = useReducer((x) => x + 1, 0);
|
47
|
+
return dispatch;
|
26
48
|
}
|
27
49
|
|
28
50
|
// src/hooks/use-extension.ts
|
29
51
|
import "@prosekit/core";
|
30
|
-
import { useEffect } from "preact/hooks";
|
52
|
+
import { useEffect as useEffect2 } from "preact/hooks";
|
31
53
|
function useExtension(extension) {
|
32
54
|
const editor = useEditor();
|
33
|
-
|
55
|
+
useEffect2(() => {
|
34
56
|
if (extension) {
|
35
57
|
return editor.use(extension);
|
36
58
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/preact",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.5",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -79,14 +79,24 @@
|
|
79
79
|
"types": "./dist/prosekit-preact-popover.d.ts",
|
80
80
|
"import": "./dist/prosekit-preact-popover.js",
|
81
81
|
"default": "./dist/prosekit-preact-popover.js"
|
82
|
+
},
|
83
|
+
"./resizable": {
|
84
|
+
"types": "./dist/prosekit-preact-resizable.d.ts",
|
85
|
+
"import": "./dist/prosekit-preact-resizable.js",
|
86
|
+
"default": "./dist/prosekit-preact-resizable.js"
|
87
|
+
},
|
88
|
+
"./resizable-handle": {
|
89
|
+
"types": "./dist/prosekit-preact-resizable-handle.d.ts",
|
90
|
+
"import": "./dist/prosekit-preact-resizable-handle.js",
|
91
|
+
"default": "./dist/prosekit-preact-resizable-handle.js"
|
82
92
|
}
|
83
93
|
},
|
84
94
|
"files": [
|
85
95
|
"dist"
|
86
96
|
],
|
87
97
|
"dependencies": {
|
88
|
-
"@prosekit/core": "^0.2.
|
89
|
-
"@prosekit/lit": "^0.1.
|
98
|
+
"@prosekit/core": "^0.2.5",
|
99
|
+
"@prosekit/lit": "^0.1.9"
|
90
100
|
},
|
91
101
|
"peerDependencies": {
|
92
102
|
"preact": ">= 9.0.0"
|
@@ -101,7 +111,7 @@
|
|
101
111
|
"preact": "^10.19.3",
|
102
112
|
"tsup": "^8.0.1",
|
103
113
|
"typescript": "^5.3.3",
|
104
|
-
"vitest": "^1.
|
114
|
+
"vitest": "^1.2.0"
|
105
115
|
},
|
106
116
|
"scripts": {
|
107
117
|
"build:tsup": "tsup",
|
@@ -142,6 +152,12 @@
|
|
142
152
|
],
|
143
153
|
"popover": [
|
144
154
|
"./dist/prosekit-preact-popover.d.ts"
|
155
|
+
],
|
156
|
+
"resizable": [
|
157
|
+
"./dist/prosekit-preact-resizable.d.ts"
|
158
|
+
],
|
159
|
+
"resizable-handle": [
|
160
|
+
"./dist/prosekit-preact-resizable-handle.d.ts"
|
145
161
|
]
|
146
162
|
}
|
147
163
|
}
|