@prosekit/react 0.2.2 → 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.
@@ -42,6 +42,7 @@ import { Popover as Popover_2 } from '@prosekit/lit/popover';
42
42
  import { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
43
43
  import { PositioningOptions } from '@prosekit/lit/autocomplete-popover';
44
44
  import { Priority } from '@prosekit/core';
45
+ import type { ProseMirrorNode } from '@prosekit/pm/model';
45
46
  import { Provider } from 'react';
46
47
  import { default as React_2 } from 'react';
47
48
  import { ReactNode } from 'react';
@@ -250,6 +251,15 @@ export declare type ResizableHandleProps = React_2.PropsWithChildren<PropsWithCl
250
251
 
251
252
  export declare type ResizableProps = React_2.PropsWithChildren<PropsWithClassName<ResizableProps_2>>;
252
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
+
253
263
  /**
254
264
  * Retrieves the editor instance from the nearest ProseKit component.
255
265
  *
@@ -7,6 +7,7 @@ export { useExtension } from './_tsup-dts-rollup';
7
7
  export { UseExtensionOptions } from './_tsup-dts-rollup';
8
8
  export { useKeymap } from './_tsup-dts-rollup';
9
9
  export { useStateUpdate } from './_tsup-dts-rollup';
10
+ export { useDocChange } from './_tsup-dts-rollup';
10
11
  export { PropsWithClassName } from './_tsup-dts-rollup';
11
12
  export { ReactNodeViewComponent } from './_tsup-dts-rollup';
12
13
  export { ReactNodeViewProps } from './_tsup-dts-rollup';
@@ -308,13 +308,29 @@ function useKeymap(keymap, options) {
308
308
 
309
309
  // src/hooks/use-state-update.ts
310
310
  import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
311
+ import { useMemo as useMemo5 } from "react";
311
312
  function useStateUpdate(handler, options) {
312
- const extension = defineUpdateHandler2((view) => handler(view.state));
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
+ );
313
328
  return useExtension(extension, options);
314
329
  }
315
330
  export {
316
331
  ProseKit,
317
332
  defineReactNodeView,
333
+ useDocChange,
318
334
  useEditor,
319
335
  useExtension,
320
336
  useKeymap,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/react",
3
3
  "type": "module",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",