@prosekit/react 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.
@@ -27,6 +27,7 @@ import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core';
27
27
  import type { Decoration } from '@prosekit/pm/view';
28
28
  import type { DecorationSource } from '@prosekit/pm/view';
29
29
  import { Editor } from '@prosekit/core';
30
+ import type { EditorState } from '@prosekit/pm/state';
30
31
  import type { EditorView } from '@prosekit/pm/view';
31
32
  import { Extension } from '@prosekit/core';
32
33
  import { ExtensionTyping } from '@prosekit/core';
@@ -41,6 +42,7 @@ import { Popover as Popover_2 } from '@prosekit/lit/popover';
41
42
  import { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
42
43
  import { PositioningOptions } from '@prosekit/lit/autocomplete-popover';
43
44
  import { Priority } from '@prosekit/core';
45
+ import type { ProseMirrorNode } from '@prosekit/pm/model';
44
46
  import { Provider } from 'react';
45
47
  import { default as React_2 } from 'react';
46
48
  import { ReactNode } from 'react';
@@ -249,6 +251,15 @@ export declare type ResizableHandleProps = React_2.PropsWithChildren<PropsWithCl
249
251
 
250
252
  export declare type ResizableProps = React_2.PropsWithChildren<PropsWithClassName<ResizableProps_2>>;
251
253
 
254
+ /**
255
+ * Calls the given handler whenever the editor document changes.
256
+ *
257
+ * @public
258
+ */
259
+ declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
260
+ export { useDocChange }
261
+ export { useDocChange as useDocChange_alias_1 }
262
+
252
263
  /**
253
264
  * Retrieves the editor instance from the nearest ProseKit component.
254
265
  *
@@ -317,4 +328,13 @@ export declare function useReactNodeViewCreator(renderReactRenderer: ReactRender
317
328
 
318
329
  export declare function useReactRenderer(): ReactRendererResult;
319
330
 
331
+ /**
332
+ * Calls the given handler whenever the editor state changes.
333
+ *
334
+ * @public
335
+ */
336
+ declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
337
+ export { useStateUpdate }
338
+ export { useStateUpdate as useStateUpdate_alias_1 }
339
+
320
340
  export { }
@@ -1,4 +1,3 @@
1
- export { ReactNodeViewComponent } from './_tsup-dts-rollup';
2
1
  export { ProseKit } from './_tsup-dts-rollup';
3
2
  export { ProseKitProps } from './_tsup-dts-rollup';
4
3
  export { defineReactNodeView } from './_tsup-dts-rollup';
@@ -7,5 +6,8 @@ export { useEditor } from './_tsup-dts-rollup';
7
6
  export { useExtension } from './_tsup-dts-rollup';
8
7
  export { UseExtensionOptions } from './_tsup-dts-rollup';
9
8
  export { useKeymap } from './_tsup-dts-rollup';
9
+ export { useStateUpdate } from './_tsup-dts-rollup';
10
+ export { useDocChange } from './_tsup-dts-rollup';
10
11
  export { PropsWithClassName } from './_tsup-dts-rollup';
12
+ export { ReactNodeViewComponent } from './_tsup-dts-rollup';
11
13
  export { ReactNodeViewProps } from './_tsup-dts-rollup';
@@ -305,10 +305,34 @@ function useKeymap(keymap, options) {
305
305
  const extension = useMemo4(() => defineKeymap(keymap), [keymap]);
306
306
  return useExtension(extension, options);
307
307
  }
308
+
309
+ // src/hooks/use-state-update.ts
310
+ import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
311
+ import { useMemo as useMemo5 } from "react";
312
+ function useStateUpdate(handler, options) {
313
+ const extension = useMemo5(
314
+ () => defineUpdateHandler2((view) => handler(view.state)),
315
+ [handler]
316
+ );
317
+ return useExtension(extension, options);
318
+ }
319
+
320
+ // src/hooks/use-doc-change.ts
321
+ import { defineDocChangeHandler } from "@prosekit/core";
322
+ import { useMemo as useMemo6 } from "react";
323
+ function useDocChange(handler, options) {
324
+ const extension = useMemo6(
325
+ () => defineDocChangeHandler((view) => handler(view.state.doc)),
326
+ [handler]
327
+ );
328
+ return useExtension(extension, options);
329
+ }
308
330
  export {
309
331
  ProseKit,
310
332
  defineReactNodeView,
333
+ useDocChange,
311
334
  useEditor,
312
335
  useExtension,
313
- useKeymap
336
+ useKeymap,
337
+ useStateUpdate
314
338
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/react",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",