@prosekit/solid 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.
@@ -10,6 +10,7 @@ import type { ComboBoxProps as ComboBoxProps_2 } from '@prosekit/lit/combo-box';
10
10
  import { Component } from 'solid-js';
11
11
  import { ContextProviderComponent } from 'solid-js';
12
12
  import { Editor } from '@prosekit/core';
13
+ import type { EditorState } from '@prosekit/pm/state';
13
14
  import { Extension } from '@prosekit/core';
14
15
  import type { InlinePopoverProps as InlinePopoverProps_2 } from '@prosekit/lit/inline-popover';
15
16
  import type { JSXElement } from 'solid-js';
@@ -232,4 +233,13 @@ export { useKeymap as useKeymap_alias_1 }
232
233
  */
233
234
  export declare function usePriorityExtension<T extends Extension = Extension>(extension: () => T | null, priority?: Priority | null): () => T | null;
234
235
 
236
+ /**
237
+ * Calls the given handler whenever the editor state changes.
238
+ *
239
+ * @public
240
+ */
241
+ declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
242
+ export { useStateUpdate }
243
+ export { useStateUpdate as useStateUpdate_alias_1 }
244
+
235
245
  export { }
@@ -4,6 +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';
7
8
  export { MaybeAccessor } from './_tsup-dts-rollup';
8
9
  export { PropsWithChildren } from './_tsup-dts-rollup';
9
10
  export { PropsWithClass } from './_tsup-dts-rollup';
@@ -108,9 +108,17 @@ function useKeymap(keymap, options) {
108
108
  const extension = () => defineKeymap(keymap());
109
109
  return useExtension(extension, options);
110
110
  }
111
+
112
+ // src/hooks/use-state-update.ts
113
+ import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
114
+ function useStateUpdate(handler, options) {
115
+ const extension = defineUpdateHandler2((view) => handler(view.state));
116
+ return useExtension(() => extension, options);
117
+ }
111
118
  export {
112
119
  ProseKit,
113
120
  useEditor,
114
121
  useExtension,
115
- useKeymap
122
+ useKeymap,
123
+ useStateUpdate
116
124
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/solid",
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
  "solid-js": ">= 1.7.0"