@prosekit/react 0.1.5 → 0.2.0

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.
@@ -38,8 +38,8 @@ import type { Node as Node_2 } from '@prosekit/pm/model';
38
38
  import type { NodeViewConstructor } from '@prosekit/pm/view';
39
39
  import { Options } from 'tsup';
40
40
  import { Popover as Popover_2 } from '@prosekit/lit/popover';
41
- import { PopoverOptions } from '@prosekit/lit/autocomplete-popover';
42
41
  import { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
42
+ import { PositioningOptions } from '@prosekit/lit/autocomplete-popover';
43
43
  import { Priority } from '@prosekit/core';
44
44
  import { default as React_2 } from 'react';
45
45
  import { ReactNode } from 'react';
@@ -139,10 +139,10 @@ export declare type NodeViewFactory = (options: ReactNodeViewUserOptions) => Nod
139
139
 
140
140
  export declare const Popover: React_2.ComponentType<PopoverProps & React_2.RefAttributes<Popover_2>>;
141
141
 
142
- export { PopoverOptions }
143
-
144
142
  export declare type PopoverProps = React_2.PropsWithChildren<PropsWithClassName<PopoverProps_2>>;
145
143
 
144
+ export { PositioningOptions }
145
+
146
146
  /**
147
147
  * @internal
148
148
  */
@@ -244,7 +244,18 @@ export declare type ResizableHandleProps = React_2.PropsWithChildren<PropsWithCl
244
244
 
245
245
  export declare type ResizableProps = React_2.PropsWithChildren<PropsWithClassName<ResizableProps_2>>;
246
246
 
247
+ /**
248
+ * Retrieves the editor instance from the nearest ProseKit component.
249
+ *
250
+ * @public
251
+ */
247
252
  declare function useEditor<E extends Extension = any>(options?: {
253
+ /**
254
+ * Whether to update the component when the editor is mounted or editor state
255
+ * is updated.
256
+ *
257
+ * @default false
258
+ */
248
259
  update?: boolean;
249
260
  }): Editor<E>;
250
261
  export { useEditor }
@@ -1,3 +1,3 @@
1
- export { PopoverOptions } from './_tsup-dts-rollup';
1
+ export { PositioningOptions } from './_tsup-dts-rollup';
2
2
  export { AutocompletePopover_alias_1 as AutocompletePopover } from './_tsup-dts-rollup';
3
3
  export { AutocompletePopoverProps_alias_1 as AutocompletePopoverProps } from './_tsup-dts-rollup';
@@ -35,7 +35,9 @@ import { useEffect as useEffect2 } from "react";
35
35
  // src/hooks/use-editor.ts
36
36
  import {
37
37
  ProseKitError,
38
- defineUpdateHandler
38
+ defineUpdateHandler,
39
+ union,
40
+ defineMountHandler
39
41
  } from "@prosekit/core";
40
42
  import { useContext, useEffect, useReducer } from "react";
41
43
  function useEditor(options) {
@@ -51,7 +53,11 @@ function useEditor(options) {
51
53
  const forceUpdate = useForceUpdate();
52
54
  useEffect(() => {
53
55
  if (update) {
54
- return editor.use(defineUpdateHandler(forceUpdate));
56
+ const extension = union([
57
+ defineMountHandler(forceUpdate),
58
+ defineUpdateHandler(forceUpdate)
59
+ ]);
60
+ return editor.use(extension);
55
61
  }
56
62
  }, [editor, update, forceUpdate]);
57
63
  return editor;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/react",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.2.0",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -96,8 +96,8 @@
96
96
  ],
97
97
  "dependencies": {
98
98
  "@lit/react": "^1.0.2",
99
- "@prosekit/core": "^0.2.2",
100
- "@prosekit/lit": "^0.1.7",
99
+ "@prosekit/core": "^0.2.5",
100
+ "@prosekit/lit": "^0.2.0",
101
101
  "@prosekit/pm": "^0.1.1",
102
102
  "@prosemirror-adapter/core": "^0.2.6"
103
103
  },
@@ -121,7 +121,7 @@
121
121
  "react-dom": "^18.2.0",
122
122
  "tsup": "^8.0.1",
123
123
  "typescript": "^5.3.3",
124
- "vitest": "^1.1.3"
124
+ "vitest": "^1.2.0"
125
125
  },
126
126
  "scripts": {
127
127
  "build:tsup": "tsup",