@prosekit/react 0.1.0 → 0.1.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.
- package/dist/_tsup-dts-rollup.d.ts +42 -56
- package/dist/prosekit-react.d.ts +1 -0
- package/dist/prosekit-react.js +18 -4
- package/package.json +6 -6
- package/src/index.ts +11 -0
@@ -22,7 +22,6 @@ import { Context } from 'react';
|
|
22
22
|
import { Editor } from '@prosekit/core';
|
23
23
|
import { Extension } from '@prosekit/core';
|
24
24
|
import { ExtensionTyping } from '@prosekit/core';
|
25
|
-
import type { ForwardRefExoticComponent } from 'react';
|
26
25
|
import { InlinePopover as InlinePopover_2 } from '@prosekit/lit/inline-popover';
|
27
26
|
import { InlinePopoverProps as InlinePopoverProps_2 } from '@prosekit/lit/inline-popover';
|
28
27
|
import { Keymap } from '@prosekit/core';
|
@@ -31,85 +30,59 @@ import { Options } from 'tsup';
|
|
31
30
|
import { Popover as Popover_2 } from '@prosekit/lit/popover';
|
32
31
|
import { PopoverOptions } from '@prosekit/lit/autocomplete-popover';
|
33
32
|
import { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
|
34
|
-
import
|
33
|
+
import { Priority } from '@prosekit/core';
|
35
34
|
import { default as React_2 } from 'react';
|
36
|
-
import type { RefAttributes } from 'react';
|
37
|
-
import type { SimplifyUnion } from '@prosekit/core';
|
38
35
|
import { useNodeViewContext } from '@prosemirror-adapter/react';
|
39
36
|
import { useNodeViewFactory } from '@prosemirror-adapter/react';
|
40
37
|
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
41
38
|
|
42
|
-
declare const AutocompleteEmpty:
|
39
|
+
declare const AutocompleteEmpty: React_2.ComponentType<AutocompleteEmptyProps & React_2.RefAttributes<AutocompleteEmpty_2>>;
|
43
40
|
export { AutocompleteEmpty }
|
44
41
|
export { AutocompleteEmpty as AutocompleteEmpty_alias_1 }
|
45
42
|
|
46
|
-
declare type AutocompleteEmptyProps =
|
47
|
-
className?: string;
|
48
|
-
children?: React_2.ReactNode;
|
49
|
-
} & AutocompleteEmptyProps_2>;
|
43
|
+
declare type AutocompleteEmptyProps = React_2.PropsWithChildren<PropsWithClassName<AutocompleteEmptyProps_2>>;
|
50
44
|
export { AutocompleteEmptyProps }
|
51
45
|
export { AutocompleteEmptyProps as AutocompleteEmptyProps_alias_1 }
|
52
46
|
|
53
|
-
declare const AutocompleteItem:
|
47
|
+
declare const AutocompleteItem: React_2.ComponentType<AutocompleteItemProps & React_2.RefAttributes<AutocompleteItem_2>>;
|
54
48
|
export { AutocompleteItem }
|
55
49
|
export { AutocompleteItem as AutocompleteItem_alias_1 }
|
56
50
|
|
57
|
-
declare type AutocompleteItemProps =
|
58
|
-
className?: string;
|
59
|
-
children?: React_2.ReactNode;
|
60
|
-
} & AutocompleteItemProps_2>;
|
51
|
+
declare type AutocompleteItemProps = React_2.PropsWithChildren<PropsWithClassName<AutocompleteItemProps_2>>;
|
61
52
|
export { AutocompleteItemProps }
|
62
53
|
export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
|
63
54
|
|
64
|
-
declare const AutocompleteList:
|
55
|
+
declare const AutocompleteList: React_2.ComponentType<AutocompleteListProps & React_2.RefAttributes<AutocompleteList_2>>;
|
65
56
|
export { AutocompleteList }
|
66
57
|
export { AutocompleteList as AutocompleteList_alias_1 }
|
67
58
|
|
68
|
-
declare type AutocompleteListProps =
|
69
|
-
className?: string;
|
70
|
-
children?: React_2.ReactNode;
|
71
|
-
} & AutocompleteListProps_2>;
|
59
|
+
declare type AutocompleteListProps = React_2.PropsWithChildren<PropsWithClassName<AutocompleteListProps_2>>;
|
72
60
|
export { AutocompleteListProps }
|
73
61
|
export { AutocompleteListProps as AutocompleteListProps_alias_1 }
|
74
62
|
|
75
|
-
declare const AutocompletePopover:
|
63
|
+
declare const AutocompletePopover: React_2.ComponentType<AutocompletePopoverProps & React_2.RefAttributes<AutocompletePopover_2>>;
|
76
64
|
export { AutocompletePopover }
|
77
65
|
export { AutocompletePopover as AutocompletePopover_alias_1 }
|
78
66
|
|
79
|
-
declare type AutocompletePopoverProps =
|
80
|
-
className?: string;
|
81
|
-
children?: React_2.ReactNode;
|
82
|
-
} & AutocompletePopoverProps_2>;
|
67
|
+
declare type AutocompletePopoverProps = React_2.PropsWithChildren<PropsWithClassName<AutocompletePopoverProps_2>>;
|
83
68
|
export { AutocompletePopoverProps }
|
84
69
|
export { AutocompletePopoverProps as AutocompletePopoverProps_alias_1 }
|
85
70
|
|
86
|
-
export declare const ComboBox:
|
71
|
+
export declare const ComboBox: React_2.ComponentType<ComboBoxProps & React_2.RefAttributes<ComboBox_2>>;
|
87
72
|
|
88
|
-
export declare const ComboBoxInput:
|
73
|
+
export declare const ComboBoxInput: React_2.ComponentType<ComboBoxInputProps & React_2.RefAttributes<ComboBoxInput_2>>;
|
89
74
|
|
90
|
-
export declare type ComboBoxInputProps =
|
91
|
-
className?: string;
|
92
|
-
children?: React_2.ReactNode;
|
93
|
-
} & ComboBoxInputProps_2>;
|
75
|
+
export declare type ComboBoxInputProps = React_2.PropsWithChildren<PropsWithClassName<ComboBoxInputProps_2>>;
|
94
76
|
|
95
|
-
export declare const ComboBoxItem:
|
77
|
+
export declare const ComboBoxItem: React_2.ComponentType<ComboBoxItemProps & React_2.RefAttributes<ComboBoxItem_2>>;
|
96
78
|
|
97
|
-
export declare type ComboBoxItemProps =
|
98
|
-
className?: string;
|
99
|
-
children?: React_2.ReactNode;
|
100
|
-
} & ComboBoxItemProps_2>;
|
79
|
+
export declare type ComboBoxItemProps = React_2.PropsWithChildren<PropsWithClassName<ComboBoxItemProps_2>>;
|
101
80
|
|
102
|
-
export declare const ComboBoxList:
|
81
|
+
export declare const ComboBoxList: React_2.ComponentType<ComboBoxListProps & React_2.RefAttributes<ComboBoxList_2>>;
|
103
82
|
|
104
|
-
export declare type ComboBoxListProps =
|
105
|
-
className?: string;
|
106
|
-
children?: React_2.ReactNode;
|
107
|
-
} & ComboBoxListProps_2>;
|
83
|
+
export declare type ComboBoxListProps = React_2.PropsWithChildren<PropsWithClassName<ComboBoxListProps_2>>;
|
108
84
|
|
109
|
-
export declare type ComboBoxProps =
|
110
|
-
className?: string;
|
111
|
-
children?: React_2.ReactNode;
|
112
|
-
} & ComboBoxProps_2>;
|
85
|
+
export declare type ComboBoxProps = React_2.PropsWithChildren<PropsWithClassName<ComboBoxProps_2>>;
|
113
86
|
|
114
87
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
115
88
|
|
@@ -129,21 +102,24 @@ export declare interface EditorContext {
|
|
129
102
|
|
130
103
|
export declare const editorContext: Context<EditorContext | null>;
|
131
104
|
|
132
|
-
export declare const InlinePopover:
|
105
|
+
export declare const InlinePopover: React_2.ComponentType<InlinePopoverProps & React_2.RefAttributes<InlinePopover_2>>;
|
133
106
|
|
134
|
-
export declare type InlinePopoverProps =
|
135
|
-
className?: string;
|
136
|
-
children?: React_2.ReactNode;
|
137
|
-
} & InlinePopoverProps_2>;
|
107
|
+
export declare type InlinePopoverProps = React_2.PropsWithChildren<PropsWithClassName<InlinePopoverProps_2>>;
|
138
108
|
|
139
|
-
export declare const Popover:
|
109
|
+
export declare const Popover: React_2.ComponentType<PopoverProps & React_2.RefAttributes<Popover_2>>;
|
140
110
|
|
141
111
|
export { PopoverOptions }
|
142
112
|
|
143
|
-
export declare type PopoverProps =
|
144
|
-
|
145
|
-
|
146
|
-
|
113
|
+
export declare type PopoverProps = React_2.PropsWithChildren<PropsWithClassName<PopoverProps_2>>;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @internal
|
117
|
+
*/
|
118
|
+
declare type PropsWithClassName<P = unknown> = P & {
|
119
|
+
className?: string | undefined;
|
120
|
+
};
|
121
|
+
export { PropsWithClassName }
|
122
|
+
export { PropsWithClassName as PropsWithClassName_alias_1 }
|
147
123
|
|
148
124
|
declare const ProseKit: ComponentType<ProseKitProps>;
|
149
125
|
export { ProseKit }
|
@@ -179,14 +155,24 @@ declare interface UseEditorOptions {
|
|
179
155
|
export { UseEditorOptions }
|
180
156
|
export { UseEditorOptions as UseEditorOptions_alias_1 }
|
181
157
|
|
182
|
-
|
158
|
+
/**
|
159
|
+
* Add an extension to the editor.
|
160
|
+
*
|
161
|
+
* It accepts an optional extension. If the extension is changed, the previous
|
162
|
+
* extension will be removed and the new one (if not null) will be added.
|
163
|
+
*/
|
164
|
+
declare function useExtension<T extends Extension = Extension>(extension: T | null): void;
|
183
165
|
export { useExtension }
|
184
166
|
export { useExtension as useExtension_alias_1 }
|
185
167
|
|
186
|
-
declare function useKeymap(keymap: Keymap
|
168
|
+
declare function useKeymap(keymap: Keymap, options?: {
|
169
|
+
priority?: Priority;
|
170
|
+
}): void;
|
187
171
|
export { useKeymap }
|
188
172
|
export { useKeymap as useKeymap_alias_1 }
|
189
173
|
|
190
174
|
export { useNodeViewContext }
|
191
175
|
|
176
|
+
export declare function usePriorityExtension<T extends Extension = Extension>(extension: T | null, priority?: Priority | null): void;
|
177
|
+
|
192
178
|
export { }
|
package/dist/prosekit-react.d.ts
CHANGED
package/dist/prosekit-react.js
CHANGED
@@ -87,7 +87,9 @@ function useForceUpdate() {
|
|
87
87
|
function useExtension(extension) {
|
88
88
|
const editor = useEditor();
|
89
89
|
useEffect2(() => {
|
90
|
-
|
90
|
+
if (extension) {
|
91
|
+
return editor.use(extension);
|
92
|
+
}
|
91
93
|
}, [editor, extension]);
|
92
94
|
}
|
93
95
|
|
@@ -118,10 +120,22 @@ var EditorContextProvider = editorContext.Provider;
|
|
118
120
|
|
119
121
|
// src/hooks/use-keymap.ts
|
120
122
|
import { defineKeymap } from "@prosekit/core";
|
123
|
+
import { useMemo as useMemo3 } from "react";
|
124
|
+
|
125
|
+
// src/hooks/use-priority-extension.ts
|
126
|
+
import { withPriority } from "@prosekit/core";
|
121
127
|
import { useMemo as useMemo2 } from "react";
|
122
|
-
function
|
123
|
-
const
|
124
|
-
|
128
|
+
function usePriorityExtension(extension, priority) {
|
129
|
+
const extensionWithPriority = useMemo2(() => {
|
130
|
+
return extension && priority ? withPriority(extension, priority) : extension;
|
131
|
+
}, [extension, priority]);
|
132
|
+
return useExtension(extensionWithPriority);
|
133
|
+
}
|
134
|
+
|
135
|
+
// src/hooks/use-keymap.ts
|
136
|
+
function useKeymap(keymap, options) {
|
137
|
+
const extension = useMemo3(() => defineKeymap(keymap), [keymap]);
|
138
|
+
usePriorityExtension(extension, options == null ? void 0 : options.priority);
|
125
139
|
}
|
126
140
|
export {
|
127
141
|
ProseKit,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.2",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -85,7 +85,7 @@
|
|
85
85
|
"dist"
|
86
86
|
],
|
87
87
|
"dependencies": {
|
88
|
-
"@lit/react": "^1.0.
|
88
|
+
"@lit/react": "^1.0.2",
|
89
89
|
"@prosekit/core": "^0.1.0",
|
90
90
|
"@prosekit/lit": "^0.1.0",
|
91
91
|
"@prosemirror-adapter/react": "^0.2.6"
|
@@ -104,12 +104,12 @@
|
|
104
104
|
},
|
105
105
|
"devDependencies": {
|
106
106
|
"@prosekit/dev": "*",
|
107
|
-
"@types/react": "^18.2.
|
108
|
-
"@types/react-dom": "^18.2.
|
107
|
+
"@types/react": "^18.2.39",
|
108
|
+
"@types/react-dom": "^18.2.17",
|
109
109
|
"react": "^18.2.0",
|
110
110
|
"react-dom": "^18.2.0",
|
111
|
-
"tsup": "^
|
112
|
-
"typescript": "^5.
|
111
|
+
"tsup": "^8.0.1",
|
112
|
+
"typescript": "^5.3.2",
|
113
113
|
"vitest": "^0.34.6"
|
114
114
|
},
|
115
115
|
"scripts": {
|
package/src/index.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
export { useNodeViewContext } from '@prosemirror-adapter/react'
|
2
|
+
export { ProseKit, type ProseKitProps } from './components/prosekit'
|
3
|
+
export {
|
4
|
+
defineReactNodeView,
|
5
|
+
type ReactNodeViewComponentProps,
|
6
|
+
type ReactNodeViewOptions,
|
7
|
+
} from './extensions/react-node-view'
|
8
|
+
export { useEditor, type UseEditorOptions } from './hooks/use-editor'
|
9
|
+
export { useExtension } from './hooks/use-extension'
|
10
|
+
export { useKeymap } from './hooks/use-keymap'
|
11
|
+
export { type PropsWithClassName } from './types'
|