@prosekit/preact 0.2.1 → 0.2.2

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';
@@ -196,4 +197,13 @@ export { useKeymap as useKeymap_alias_1 }
196
197
  */
197
198
  export declare function usePriorityExtension<T extends Extension = Extension>(extension: T | null, priority?: Priority | null): T | null;
198
199
 
200
+ /**
201
+ * Calls the given handler whenever the editor state changes.
202
+ *
203
+ * @public
204
+ */
205
+ declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
206
+ export { useStateUpdate }
207
+ export { useStateUpdate as useStateUpdate_alias_1 }
208
+
199
209
  export { }
@@ -4,5 +4,6 @@ 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';
7
8
  export { PropsWithChildren } from './_tsup-dts-rollup';
8
9
  export { PropsWithClass } from './_tsup-dts-rollup';
@@ -92,9 +92,17 @@ 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
+ function useStateUpdate(handler, options) {
99
+ const extension = defineUpdateHandler2((view) => handler(view.state));
100
+ return useExtension(extension, options);
101
+ }
95
102
  export {
96
103
  ProseKit,
97
104
  useEditor,
98
105
  useExtension,
99
- useKeymap
106
+ useKeymap,
107
+ useStateUpdate
100
108
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/preact",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
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"