@prosekit/preact 0.2.1 → 0.2.3
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.
@@ -9,6 +9,7 @@ import type { ComboBoxProps as ComboBoxProps_2 } from '@prosekit/lit/combo-box';
|
|
9
9
|
import { ComponentChildren } from 'preact';
|
10
10
|
import { ComponentType } from 'preact';
|
11
11
|
import { Editor } from '@prosekit/core';
|
12
|
+
import type { EditorState } from '@prosekit/pm/state';
|
12
13
|
import { Extension } from '@prosekit/core';
|
13
14
|
import type { InlinePopoverProps as InlinePopoverProps_2 } from '@prosekit/lit/inline-popover';
|
14
15
|
import { Keymap } from '@prosekit/core';
|
@@ -16,6 +17,7 @@ import { Options } from 'tsup';
|
|
16
17
|
import type { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
|
17
18
|
import { PositioningOptions } from '@prosekit/lit/autocomplete-popover';
|
18
19
|
import { Priority } from '@prosekit/core';
|
20
|
+
import type { ProseMirrorNode } from '@prosekit/pm/model';
|
19
21
|
import { Provider } from 'preact';
|
20
22
|
import type { ResizableHandleProps as ResizableHandleProps_2 } from '@prosekit/lit/resizable-handle';
|
21
23
|
import type { ResizableProps as ResizableProps_2 } from '@prosekit/lit/resizable';
|
@@ -134,6 +136,15 @@ export declare type ResizableHandleProps = PropsWithChildren<PropsWithClass<Resi
|
|
134
136
|
|
135
137
|
export declare type ResizableProps = PropsWithChildren<PropsWithClass<ResizableProps_2>>;
|
136
138
|
|
139
|
+
/**
|
140
|
+
* Calls the given handler whenever the editor document changes.
|
141
|
+
*
|
142
|
+
* @public
|
143
|
+
*/
|
144
|
+
declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
|
145
|
+
export { useDocChange }
|
146
|
+
export { useDocChange as useDocChange_alias_1 }
|
147
|
+
|
137
148
|
/**
|
138
149
|
* Retrieves the editor instance from the nearest ProseKit component.
|
139
150
|
*
|
@@ -196,4 +207,13 @@ export { useKeymap as useKeymap_alias_1 }
|
|
196
207
|
*/
|
197
208
|
export declare function usePriorityExtension<T extends Extension = Extension>(extension: T | null, priority?: Priority | null): T | null;
|
198
209
|
|
210
|
+
/**
|
211
|
+
* Calls the given handler whenever the editor state changes.
|
212
|
+
*
|
213
|
+
* @public
|
214
|
+
*/
|
215
|
+
declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
|
216
|
+
export { useStateUpdate }
|
217
|
+
export { useStateUpdate as useStateUpdate_alias_1 }
|
218
|
+
|
199
219
|
export { }
|
@@ -4,5 +4,7 @@ export { useEditor } from './_tsup-dts-rollup';
|
|
4
4
|
export { useExtension } from './_tsup-dts-rollup';
|
5
5
|
export { UseExtensionOptions } from './_tsup-dts-rollup';
|
6
6
|
export { useKeymap } from './_tsup-dts-rollup';
|
7
|
+
export { useStateUpdate } from './_tsup-dts-rollup';
|
8
|
+
export { useDocChange } from './_tsup-dts-rollup';
|
7
9
|
export { PropsWithChildren } from './_tsup-dts-rollup';
|
8
10
|
export { PropsWithClass } from './_tsup-dts-rollup';
|
package/dist/prosekit-preact.js
CHANGED
@@ -92,9 +92,33 @@ function useKeymap(keymap, options) {
|
|
92
92
|
const extension = useMemo2(() => defineKeymap(keymap), [keymap]);
|
93
93
|
return useExtension(extension, options);
|
94
94
|
}
|
95
|
+
|
96
|
+
// src/hooks/use-state-update.ts
|
97
|
+
import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
|
98
|
+
import { useMemo as useMemo3 } from "preact/hooks";
|
99
|
+
function useStateUpdate(handler, options) {
|
100
|
+
const extension = useMemo3(
|
101
|
+
() => defineUpdateHandler2((view) => handler(view.state)),
|
102
|
+
[handler]
|
103
|
+
);
|
104
|
+
return useExtension(extension, options);
|
105
|
+
}
|
106
|
+
|
107
|
+
// src/hooks/use-doc-change.ts
|
108
|
+
import { defineDocChangeHandler } from "@prosekit/core";
|
109
|
+
import { useMemo as useMemo4 } from "preact/hooks";
|
110
|
+
function useDocChange(handler, options) {
|
111
|
+
const extension = useMemo4(
|
112
|
+
() => defineDocChangeHandler((view) => handler(view.state.doc)),
|
113
|
+
[handler]
|
114
|
+
);
|
115
|
+
return useExtension(extension, options);
|
116
|
+
}
|
95
117
|
export {
|
96
118
|
ProseKit,
|
119
|
+
useDocChange,
|
97
120
|
useEditor,
|
98
121
|
useExtension,
|
99
|
-
useKeymap
|
122
|
+
useKeymap,
|
123
|
+
useStateUpdate
|
100
124
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/preact",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.2.
|
4
|
+
"version": "0.2.3",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -96,7 +96,8 @@
|
|
96
96
|
],
|
97
97
|
"dependencies": {
|
98
98
|
"@prosekit/core": "^0.2.7",
|
99
|
-
"@prosekit/lit": "^0.2.1"
|
99
|
+
"@prosekit/lit": "^0.2.1",
|
100
|
+
"@prosekit/pm": "^0.1.1"
|
100
101
|
},
|
101
102
|
"peerDependencies": {
|
102
103
|
"preact": ">= 9.0.0"
|