@prosekit/react 0.0.0-next-20231120040948 → 0.0.0-next-20240427133255
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 +283 -132
- package/dist/chunk-BH56NR2Q.js +12 -0
- package/dist/chunk-UG3RPLME.js +51 -0
- package/dist/prosekit-react-autocomplete.d.ts +4 -0
- package/dist/prosekit-react-autocomplete.js +50 -0
- package/dist/prosekit-react-block-handle.d.ts +2 -0
- package/dist/prosekit-react-block-handle.js +28 -0
- package/dist/prosekit-react-inline-popover.d.ts +0 -1
- package/dist/prosekit-react-inline-popover.js +14 -14
- package/dist/prosekit-react-popover.d.ts +3 -2
- package/dist/prosekit-react-popover.js +37 -15
- package/dist/prosekit-react-resizable.d.ts +2 -0
- package/dist/prosekit-react-resizable.js +28 -0
- package/dist/prosekit-react-tooltip.d.ts +3 -0
- package/dist/prosekit-react-tooltip.js +39 -0
- package/dist/prosekit-react.d.ts +6 -3
- package/dist/prosekit-react.js +284 -82
- package/package.json +43 -74
- package/dist/prosekit-react-autocomplete-empty.d.ts +0 -2
- package/dist/prosekit-react-autocomplete-empty.js +0 -17
- package/dist/prosekit-react-autocomplete-item.d.ts +0 -2
- package/dist/prosekit-react-autocomplete-item.js +0 -17
- package/dist/prosekit-react-autocomplete-list.d.ts +0 -2
- package/dist/prosekit-react-autocomplete-list.js +0 -17
- package/dist/prosekit-react-autocomplete-popover.d.ts +0 -3
- package/dist/prosekit-react-autocomplete-popover.js +0 -17
- package/dist/prosekit-react-combo-box-input.d.ts +0 -2
- package/dist/prosekit-react-combo-box-input.js +0 -17
- package/dist/prosekit-react-combo-box-item.d.ts +0 -2
- package/dist/prosekit-react-combo-box-item.js +0 -17
- package/dist/prosekit-react-combo-box-list.d.ts +0 -2
- package/dist/prosekit-react-combo-box-list.js +0 -17
- package/dist/prosekit-react-combo-box.d.ts +0 -2
- package/dist/prosekit-react-combo-box.js +0 -17
- package/src/index.ts +0 -10
@@ -1,192 +1,343 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
import {
|
15
|
-
import {
|
16
|
-
import {
|
17
|
-
import { ComboBoxListProps as ComboBoxListProps_2 } from '@prosekit/lit/combo-box-list';
|
18
|
-
import { ComboBoxProps as ComboBoxProps_2 } from '@prosekit/lit/combo-box';
|
3
|
+
import type { Attrs } from '@prosekit/pm/model';
|
4
|
+
import { AutocompleteEmptyElement } from '@prosekit/web/autocomplete';
|
5
|
+
import { AutocompleteEmptyProps } from '@prosekit/web/autocomplete';
|
6
|
+
import { AutocompleteItemElement } from '@prosekit/web/autocomplete';
|
7
|
+
import { AutocompleteItemProps } from '@prosekit/web/autocomplete';
|
8
|
+
import { AutocompleteListElement } from '@prosekit/web/autocomplete';
|
9
|
+
import { AutocompleteListProps } from '@prosekit/web/autocomplete';
|
10
|
+
import { AutocompletePopoverElement } from '@prosekit/web/autocomplete';
|
11
|
+
import { AutocompletePopoverProps } from '@prosekit/web/autocomplete';
|
12
|
+
import { BaseNodeViewOptions } from '@prosekit/core';
|
13
|
+
import { BlockDragHandleElement } from '@prosekit/web/block-handle';
|
14
|
+
import { BlockDragHandleProps } from '@prosekit/web/block-handle';
|
15
|
+
import { BlockPopoverElement } from '@prosekit/web/block-handle';
|
16
|
+
import { BlockPopoverProps } from '@prosekit/web/block-handle';
|
19
17
|
import { CommandArgs } from '@prosekit/core';
|
20
18
|
import { ComponentType } from 'react';
|
21
19
|
import { Context } from 'react';
|
20
|
+
import { CoreNodeView } from '@prosemirror-adapter/core';
|
21
|
+
import type { CoreNodeViewSpec } from '@prosemirror-adapter/core';
|
22
|
+
import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core';
|
23
|
+
import type { Decoration } from '@prosekit/pm/view';
|
24
|
+
import type { DecorationSource } from '@prosekit/pm/view';
|
22
25
|
import { Editor } from '@prosekit/core';
|
26
|
+
import type { EditorState } from '@prosekit/pm/state';
|
27
|
+
import type { EditorView } from '@prosekit/pm/view';
|
23
28
|
import { Extension } from '@prosekit/core';
|
24
29
|
import { ExtensionTyping } from '@prosekit/core';
|
25
|
-
import
|
26
|
-
import {
|
27
|
-
import {
|
30
|
+
import { FC } from 'react';
|
31
|
+
import { ForwardRefExoticComponent } from 'react';
|
32
|
+
import { HTMLAttributes } from 'react';
|
33
|
+
import { InlinePopoverElement } from '@prosekit/web/inline-popover';
|
34
|
+
import { InlinePopoverProps } from '@prosekit/web/inline-popover';
|
28
35
|
import { Keymap } from '@prosekit/core';
|
29
|
-
import type {
|
36
|
+
import type { Node as Node_2 } from '@prosekit/pm/model';
|
37
|
+
import type { NodeViewConstructor } from '@prosekit/pm/view';
|
30
38
|
import { Options } from 'tsup';
|
31
|
-
import {
|
32
|
-
import {
|
33
|
-
import {
|
34
|
-
import
|
35
|
-
import {
|
36
|
-
import
|
37
|
-
import
|
38
|
-
import {
|
39
|
-
import {
|
40
|
-
import {
|
41
|
-
|
42
|
-
|
39
|
+
import { PopoverContentElement } from '@prosekit/web/popover';
|
40
|
+
import { PopoverContentProps } from '@prosekit/web/popover';
|
41
|
+
import { PopoverRootElement } from '@prosekit/web/popover';
|
42
|
+
import { PopoverRootProps } from '@prosekit/web/popover';
|
43
|
+
import { PopoverTriggerElement } from '@prosekit/web/popover';
|
44
|
+
import { PopoverTriggerProps } from '@prosekit/web/popover';
|
45
|
+
import { Priority } from '@prosekit/core';
|
46
|
+
import type { ProseMirrorNode } from '@prosekit/pm/model';
|
47
|
+
import { Provider } from 'react';
|
48
|
+
import { ReactNode } from 'react';
|
49
|
+
import { ReactPortal } from 'react';
|
50
|
+
import { RefAttributes } from 'react';
|
51
|
+
import { ResizableHandleElement } from '@prosekit/web/resizable';
|
52
|
+
import { ResizableHandleProps } from '@prosekit/web/resizable';
|
53
|
+
import { ResizableRootElement } from '@prosekit/web/resizable';
|
54
|
+
import { ResizableRootProps } from '@prosekit/web/resizable';
|
55
|
+
import { TooltipContentElement } from '@prosekit/web/tooltip';
|
56
|
+
import { TooltipContentProps } from '@prosekit/web/tooltip';
|
57
|
+
import { TooltipRootElement } from '@prosekit/web/tooltip';
|
58
|
+
import { TooltipRootProps } from '@prosekit/web/tooltip';
|
59
|
+
import { TooltipTriggerElement } from '@prosekit/web/tooltip';
|
60
|
+
import { TooltipTriggerProps } from '@prosekit/web/tooltip';
|
61
|
+
|
62
|
+
declare const AutocompleteEmpty: ForwardRefExoticComponent<Partial<AutocompleteEmptyProps> & RefAttributes<AutocompleteEmptyElement> & HTMLAttributes<AutocompleteEmptyElement>>;
|
43
63
|
export { AutocompleteEmpty }
|
44
64
|
export { AutocompleteEmpty as AutocompleteEmpty_alias_1 }
|
45
65
|
|
46
|
-
declare
|
47
|
-
className?: string;
|
48
|
-
children?: React_2.ReactNode;
|
49
|
-
} & AutocompleteEmptyProps_2>;
|
50
|
-
export { AutocompleteEmptyProps }
|
51
|
-
export { AutocompleteEmptyProps as AutocompleteEmptyProps_alias_1 }
|
52
|
-
|
53
|
-
declare const AutocompleteItem: ForwardRefExoticComponent<PropsWithoutRef<AutocompleteItemProps> & RefAttributes<AutocompleteItem_2>>;
|
66
|
+
declare const AutocompleteItem: ForwardRefExoticComponent<Partial<AutocompleteItemProps> & RefAttributes<AutocompleteItemElement> & HTMLAttributes<AutocompleteItemElement>>;
|
54
67
|
export { AutocompleteItem }
|
55
68
|
export { AutocompleteItem as AutocompleteItem_alias_1 }
|
56
69
|
|
57
|
-
declare
|
58
|
-
className?: string;
|
59
|
-
children?: React_2.ReactNode;
|
60
|
-
} & AutocompleteItemProps_2>;
|
61
|
-
export { AutocompleteItemProps }
|
62
|
-
export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
|
63
|
-
|
64
|
-
declare const AutocompleteList: ForwardRefExoticComponent<PropsWithoutRef<AutocompleteListProps> & RefAttributes<AutocompleteList_2>>;
|
70
|
+
declare const AutocompleteList: ForwardRefExoticComponent<Partial<AutocompleteListProps> & RefAttributes<AutocompleteListElement> & HTMLAttributes<AutocompleteListElement>>;
|
65
71
|
export { AutocompleteList }
|
66
72
|
export { AutocompleteList as AutocompleteList_alias_1 }
|
67
73
|
|
68
|
-
declare
|
69
|
-
className?: string;
|
70
|
-
children?: React_2.ReactNode;
|
71
|
-
} & AutocompleteListProps_2>;
|
72
|
-
export { AutocompleteListProps }
|
73
|
-
export { AutocompleteListProps as AutocompleteListProps_alias_1 }
|
74
|
-
|
75
|
-
declare const AutocompletePopover: ForwardRefExoticComponent<PropsWithoutRef<AutocompletePopoverProps> & RefAttributes<AutocompletePopover_2>>;
|
74
|
+
declare const AutocompletePopover: ForwardRefExoticComponent<Partial<AutocompletePopoverProps> & RefAttributes<AutocompletePopoverElement> & HTMLAttributes<AutocompletePopoverElement>>;
|
76
75
|
export { AutocompletePopover }
|
77
76
|
export { AutocompletePopover as AutocompletePopover_alias_1 }
|
78
77
|
|
79
|
-
declare
|
80
|
-
|
81
|
-
|
82
|
-
} & AutocompletePopoverProps_2>;
|
83
|
-
export { AutocompletePopoverProps }
|
84
|
-
export { AutocompletePopoverProps as AutocompletePopoverProps_alias_1 }
|
85
|
-
|
86
|
-
export declare const ComboBox: ForwardRefExoticComponent<PropsWithoutRef<ComboBoxProps> & RefAttributes<ComboBox_2>>;
|
87
|
-
|
88
|
-
export declare const ComboBoxInput: ForwardRefExoticComponent<PropsWithoutRef<ComboBoxInputProps> & RefAttributes<ComboBoxInput_2>>;
|
78
|
+
declare const BlockDragHandle: ForwardRefExoticComponent<Partial<BlockDragHandleProps> & RefAttributes<BlockDragHandleElement> & HTMLAttributes<BlockDragHandleElement>>;
|
79
|
+
export { BlockDragHandle }
|
80
|
+
export { BlockDragHandle as BlockDragHandle_alias_1 }
|
89
81
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
} & ComboBoxInputProps_2>;
|
82
|
+
declare const BlockPopover: ForwardRefExoticComponent<Partial<BlockPopoverProps> & RefAttributes<BlockPopoverElement> & HTMLAttributes<BlockPopoverElement>>;
|
83
|
+
export { BlockPopover }
|
84
|
+
export { BlockPopover as BlockPopover_alias_1 }
|
94
85
|
|
95
|
-
export declare
|
86
|
+
export declare function createComponent<Props extends object, CustomElement extends HTMLElement>(tagName: string, displayName: string, defaultProps: Props): ForwardRefExoticComponent<Partial<Props> & RefAttributes<CustomElement> & HTMLAttributes<CustomElement>>;
|
96
87
|
|
97
|
-
export declare
|
98
|
-
className?: string;
|
99
|
-
children?: React_2.ReactNode;
|
100
|
-
} & ComboBoxItemProps_2>;
|
88
|
+
export declare const createNodeViewContext: Context<NodeViewFactory | null>;
|
101
89
|
|
102
|
-
|
103
|
-
|
104
|
-
export
|
105
|
-
className?: string;
|
106
|
-
children?: React_2.ReactNode;
|
107
|
-
} & ComboBoxListProps_2>;
|
108
|
-
|
109
|
-
export declare type ComboBoxProps = SimplifyUnion<{
|
110
|
-
className?: string;
|
111
|
-
children?: React_2.ReactNode;
|
112
|
-
} & ComboBoxProps_2>;
|
90
|
+
declare type CreateReactNodeView = ReturnType<typeof useReactNodeViewCreator>;
|
91
|
+
export { CreateReactNodeView }
|
92
|
+
export { CreateReactNodeView as CreateReactNodeView_alias_1 }
|
113
93
|
|
114
94
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
115
95
|
|
116
|
-
export declare const default_alias_1:
|
117
|
-
|
96
|
+
export declare const default_alias_1: {
|
97
|
+
test: {
|
98
|
+
environment: "jsdom";
|
99
|
+
};
|
100
|
+
};
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Defines a node view using a React component.
|
104
|
+
*
|
105
|
+
* @public
|
106
|
+
*/
|
118
107
|
declare function defineReactNodeView(options: ReactNodeViewOptions): Extension;
|
119
108
|
export { defineReactNodeView }
|
120
109
|
export { defineReactNodeView as defineReactNodeView_alias_1 }
|
121
110
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
export declare const
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
export
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
export
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
export
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
111
|
+
/**
|
112
|
+
* @internal
|
113
|
+
*/
|
114
|
+
export declare function defineReactNodeViewFactory(nodeViewFactory: NodeViewFactory): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* @internal
|
118
|
+
*/
|
119
|
+
export declare const EditorContextProvider: Provider<Editor<any> | null>;
|
120
|
+
|
121
|
+
declare const InlinePopover: ForwardRefExoticComponent<Partial<InlinePopoverProps> & RefAttributes<InlinePopoverElement> & HTMLAttributes<InlinePopoverElement>>;
|
122
|
+
export { InlinePopover }
|
123
|
+
export { InlinePopover as InlinePopover_alias_1 }
|
124
|
+
|
125
|
+
export declare type NodeViewFactory = (options: ReactNodeViewUserOptions) => NodeViewConstructor;
|
126
|
+
|
127
|
+
declare const PopoverContent: ForwardRefExoticComponent<Partial<PopoverContentProps> & RefAttributes<PopoverContentElement> & HTMLAttributes<PopoverContentElement>>;
|
128
|
+
export { PopoverContent }
|
129
|
+
export { PopoverContent as PopoverContent_alias_1 }
|
130
|
+
|
131
|
+
declare const PopoverRoot: ForwardRefExoticComponent<Partial<PopoverRootProps> & RefAttributes<PopoverRootElement> & HTMLAttributes<PopoverRootElement>>;
|
132
|
+
export { PopoverRoot }
|
133
|
+
export { PopoverRoot as PopoverRoot_alias_1 }
|
134
|
+
|
135
|
+
declare const PopoverTrigger: ForwardRefExoticComponent<Partial<PopoverTriggerProps> & RefAttributes<PopoverTriggerElement> & HTMLAttributes<PopoverTriggerElement>>;
|
136
|
+
export { PopoverTrigger }
|
137
|
+
export { PopoverTrigger as PopoverTrigger_alias_1 }
|
138
|
+
|
139
|
+
/**
|
140
|
+
* @internal
|
141
|
+
*/
|
142
|
+
declare type PropsWithClassName<P = unknown> = P & {
|
143
|
+
className?: string | undefined;
|
144
|
+
};
|
145
|
+
export { PropsWithClassName }
|
146
|
+
export { PropsWithClassName as PropsWithClassName_alias_1 }
|
147
|
+
|
148
|
+
/**
|
149
|
+
* The root component for a ProseKit editor.
|
150
|
+
*
|
151
|
+
* @public
|
152
|
+
*/
|
148
153
|
declare const ProseKit: ComponentType<ProseKitProps>;
|
149
154
|
export { ProseKit }
|
150
155
|
export { ProseKit as ProseKit_alias_1 }
|
151
156
|
|
152
157
|
declare interface ProseKitProps {
|
153
158
|
editor: Editor;
|
154
|
-
children?:
|
159
|
+
children?: ReactNode;
|
155
160
|
}
|
156
161
|
export { ProseKitProps }
|
157
162
|
export { ProseKitProps as ProseKitProps_alias_1 }
|
158
163
|
|
159
|
-
declare
|
160
|
-
|
161
|
-
|
164
|
+
export declare class ReactNodeView extends CoreNodeView<ReactNodeViewComponent> implements ReactRenderer<ReactNodeViewProps> {
|
165
|
+
key: string;
|
166
|
+
context: ReactNodeViewProps;
|
167
|
+
updateContext: () => void;
|
168
|
+
render: () => ReactPortal;
|
169
|
+
}
|
162
170
|
|
163
|
-
|
171
|
+
/**
|
172
|
+
* @public
|
173
|
+
*/
|
174
|
+
declare type ReactNodeViewComponent = ComponentType<ReactNodeViewProps>;
|
175
|
+
export { ReactNodeViewComponent }
|
176
|
+
export { ReactNodeViewComponent as ReactNodeViewComponent_alias_1 }
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Options for {@link defineReactNodeView}.
|
180
|
+
*
|
181
|
+
* @public
|
182
|
+
*/
|
183
|
+
declare interface ReactNodeViewOptions extends BaseNodeViewOptions {
|
184
|
+
/**
|
185
|
+
* The name of the node type.
|
186
|
+
*/
|
164
187
|
name: string;
|
165
|
-
|
166
|
-
|
167
|
-
|
188
|
+
/**
|
189
|
+
* The React component to render the node.
|
190
|
+
*/
|
191
|
+
component: ReactNodeViewComponent;
|
168
192
|
}
|
169
193
|
export { ReactNodeViewOptions }
|
170
194
|
export { ReactNodeViewOptions as ReactNodeViewOptions_alias_1 }
|
171
195
|
|
172
|
-
|
173
|
-
|
174
|
-
|
196
|
+
/**
|
197
|
+
* @public
|
198
|
+
*/
|
199
|
+
declare interface ReactNodeViewProps {
|
200
|
+
contentRef: (node: HTMLElement | null) => void;
|
201
|
+
view: EditorView;
|
202
|
+
getPos: () => number | undefined;
|
203
|
+
setAttrs: (attrs: Attrs) => void;
|
204
|
+
node: Node_2;
|
205
|
+
selected: boolean;
|
206
|
+
decorations: readonly Decoration[];
|
207
|
+
innerDecorations: DecorationSource;
|
208
|
+
}
|
209
|
+
export { ReactNodeViewProps }
|
210
|
+
export { ReactNodeViewProps as ReactNodeViewProps_alias_1 }
|
175
211
|
|
176
|
-
declare
|
177
|
-
|
212
|
+
export declare type ReactNodeViewSpec = CoreNodeViewSpec<ReactNodeViewComponent>;
|
213
|
+
|
214
|
+
export declare type ReactNodeViewUserOptions = CoreNodeViewUserOptions<ReactNodeViewComponent>;
|
215
|
+
|
216
|
+
export declare interface ReactRenderer<Context> {
|
217
|
+
key: string;
|
218
|
+
context: Context;
|
219
|
+
render: () => ReactPortal;
|
220
|
+
updateContext: () => void;
|
221
|
+
}
|
222
|
+
|
223
|
+
export declare interface ReactRendererResult {
|
224
|
+
readonly portals: Record<string, ReactPortal>;
|
225
|
+
readonly renderReactRenderer: (nodeView: ReactRenderer<unknown>, update?: boolean) => void;
|
226
|
+
readonly removeReactRenderer: (nodeView: ReactRenderer<unknown>) => void;
|
178
227
|
}
|
179
|
-
export { UseEditorOptions }
|
180
|
-
export { UseEditorOptions as UseEditorOptions_alias_1 }
|
181
228
|
|
182
|
-
declare
|
229
|
+
export declare const ReactViewsConsumer: FC;
|
230
|
+
|
231
|
+
declare const ReactViewsProvider: FC<{
|
232
|
+
children: ReactNode;
|
233
|
+
}>;
|
234
|
+
export { ReactViewsProvider }
|
235
|
+
export { ReactViewsProvider as ReactViewsProvider_alias_1 }
|
236
|
+
|
237
|
+
declare const ResizableHandle: ForwardRefExoticComponent<Partial<ResizableHandleProps> & RefAttributes<ResizableHandleElement> & HTMLAttributes<ResizableHandleElement>>;
|
238
|
+
export { ResizableHandle }
|
239
|
+
export { ResizableHandle as ResizableHandle_alias_1 }
|
240
|
+
|
241
|
+
declare const ResizableRoot: ForwardRefExoticComponent<Partial<ResizableRootProps> & RefAttributes<ResizableRootElement> & HTMLAttributes<ResizableRootElement>>;
|
242
|
+
export { ResizableRoot }
|
243
|
+
export { ResizableRoot as ResizableRoot_alias_1 }
|
244
|
+
|
245
|
+
declare const TooltipContent: ForwardRefExoticComponent<Partial<TooltipContentProps> & RefAttributes<TooltipContentElement> & HTMLAttributes<TooltipContentElement>>;
|
246
|
+
export { TooltipContent }
|
247
|
+
export { TooltipContent as TooltipContent_alias_1 }
|
248
|
+
|
249
|
+
declare const TooltipRoot: ForwardRefExoticComponent<Partial<TooltipRootProps> & RefAttributes<TooltipRootElement> & HTMLAttributes<TooltipRootElement>>;
|
250
|
+
export { TooltipRoot }
|
251
|
+
export { TooltipRoot as TooltipRoot_alias_1 }
|
252
|
+
|
253
|
+
declare const TooltipTrigger: ForwardRefExoticComponent<Partial<TooltipTriggerProps> & RefAttributes<TooltipTriggerElement> & HTMLAttributes<TooltipTriggerElement>>;
|
254
|
+
export { TooltipTrigger }
|
255
|
+
export { TooltipTrigger as TooltipTrigger_alias_1 }
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Calls the given handler whenever the editor document changes.
|
259
|
+
*
|
260
|
+
* @public
|
261
|
+
*/
|
262
|
+
declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
|
263
|
+
export { useDocChange }
|
264
|
+
export { useDocChange as useDocChange_alias_1 }
|
265
|
+
|
266
|
+
/**
|
267
|
+
* Retrieves the editor instance from the nearest ProseKit component.
|
268
|
+
*
|
269
|
+
* @public
|
270
|
+
*/
|
271
|
+
declare function useEditor<E extends Extension = any>(options?: {
|
272
|
+
/**
|
273
|
+
* Whether to update the component when the editor is mounted or editor state
|
274
|
+
* is updated.
|
275
|
+
*
|
276
|
+
* @default false
|
277
|
+
*/
|
278
|
+
update?: boolean;
|
279
|
+
}): Editor<E>;
|
280
|
+
export { useEditor }
|
281
|
+
export { useEditor as useEditor_alias_1 }
|
282
|
+
|
283
|
+
/**
|
284
|
+
* @internal
|
285
|
+
*/
|
286
|
+
export declare function useEditorContext<E extends Extension>(): Editor<E> | null;
|
287
|
+
|
288
|
+
/**
|
289
|
+
* @internal
|
290
|
+
*/
|
291
|
+
export declare function useEditorExtension(editor: Editor | null | undefined, extension: Extension | null): void;
|
292
|
+
|
293
|
+
/**
|
294
|
+
* Add an extension to the editor.
|
295
|
+
*/
|
296
|
+
declare function useExtension(
|
297
|
+
/**
|
298
|
+
* The extension to add to the editor. If it changes, the previous
|
299
|
+
* extension will be removed and the new one (if not null) will be added.
|
300
|
+
*/
|
301
|
+
extension: Extension | null, options?: UseExtensionOptions): void;
|
183
302
|
export { useExtension }
|
184
303
|
export { useExtension as useExtension_alias_1 }
|
185
304
|
|
186
|
-
declare
|
305
|
+
declare interface UseExtensionOptions {
|
306
|
+
/**
|
307
|
+
* The editor to add the extension to. If not provided, it will use the
|
308
|
+
* editor from the nearest `ProseKit` component.
|
309
|
+
*/
|
310
|
+
editor?: Editor;
|
311
|
+
/**
|
312
|
+
* Optional priority to add the extension with.
|
313
|
+
*/
|
314
|
+
priority?: Priority;
|
315
|
+
}
|
316
|
+
export { UseExtensionOptions }
|
317
|
+
export { UseExtensionOptions as UseExtensionOptions_alias_1 }
|
318
|
+
|
319
|
+
declare function useKeymap(keymap: Keymap, options?: UseExtensionOptions): void;
|
187
320
|
export { useKeymap }
|
188
321
|
export { useKeymap as useKeymap_alias_1 }
|
189
322
|
|
190
|
-
export
|
323
|
+
export declare function useNodeViewFactory(): NodeViewFactory;
|
324
|
+
|
325
|
+
/**
|
326
|
+
* @internal
|
327
|
+
*/
|
328
|
+
export declare function usePriorityExtension<T extends Extension = Extension>(extension: T | null, priority?: Priority | null): T | null;
|
329
|
+
|
330
|
+
export declare function useReactNodeViewCreator(renderReactRenderer: ReactRendererResult['renderReactRenderer'], removeReactRenderer: ReactRendererResult['removeReactRenderer']): (options: ReactNodeViewUserOptions) => NodeViewConstructor;
|
331
|
+
|
332
|
+
export declare function useReactRenderer(): ReactRendererResult;
|
333
|
+
|
334
|
+
/**
|
335
|
+
* Calls the given handler whenever the editor state changes.
|
336
|
+
*
|
337
|
+
* @public
|
338
|
+
*/
|
339
|
+
declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
|
340
|
+
export { useStateUpdate }
|
341
|
+
export { useStateUpdate as useStateUpdate_alias_1 }
|
191
342
|
|
192
343
|
export { }
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// src/contexts/editor-context.ts
|
2
|
+
import { createContext, useContext } from "react";
|
3
|
+
var editorContext = createContext(null);
|
4
|
+
function useEditorContext() {
|
5
|
+
return useContext(editorContext);
|
6
|
+
}
|
7
|
+
var EditorContextProvider = editorContext.Provider;
|
8
|
+
|
9
|
+
export {
|
10
|
+
useEditorContext,
|
11
|
+
EditorContextProvider
|
12
|
+
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import {
|
2
|
+
useEditorContext
|
3
|
+
} from "./chunk-BH56NR2Q.js";
|
4
|
+
|
5
|
+
// src/components/create-component.ts
|
6
|
+
import {
|
7
|
+
createElement,
|
8
|
+
forwardRef,
|
9
|
+
useLayoutEffect,
|
10
|
+
useState
|
11
|
+
} from "react";
|
12
|
+
import { mergeRefs } from "react-merge-refs";
|
13
|
+
function createComponent(tagName, displayName, defaultProps) {
|
14
|
+
const propertyNames = Object.keys(defaultProps);
|
15
|
+
const hasEditor = Object.hasOwn(defaultProps, "editor");
|
16
|
+
const Component = forwardRef((props, ref) => {
|
17
|
+
const [el, setEl] = useState(null);
|
18
|
+
const properties = {};
|
19
|
+
const attributes = {};
|
20
|
+
for (const [name, value] of Object.entries(props)) {
|
21
|
+
if (propertyNames.includes(name)) {
|
22
|
+
properties[name] = value;
|
23
|
+
} else {
|
24
|
+
attributes[name === "className" ? "class" : name] = value;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
const editor = useEditorContext();
|
28
|
+
if (hasEditor && editor && !properties["editor"]) {
|
29
|
+
properties["editor"] = editor;
|
30
|
+
}
|
31
|
+
useLayoutEffect(() => {
|
32
|
+
if (el) {
|
33
|
+
for (const [name, value] of Object.entries(properties)) {
|
34
|
+
if (value !== void 0) {
|
35
|
+
el[name] = value;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}, [el, ...propertyNames.map((name) => properties[name])]);
|
40
|
+
return createElement(tagName, {
|
41
|
+
...attributes,
|
42
|
+
ref: mergeRefs([ref, setEl])
|
43
|
+
});
|
44
|
+
});
|
45
|
+
Component.displayName = displayName;
|
46
|
+
return Component;
|
47
|
+
}
|
48
|
+
|
49
|
+
export {
|
50
|
+
createComponent
|
51
|
+
};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { AutocompleteEmpty_alias_1 as AutocompleteEmpty } from './_tsup-dts-rollup';
|
2
|
+
export { AutocompleteItem_alias_1 as AutocompleteItem } from './_tsup-dts-rollup';
|
3
|
+
export { AutocompleteList_alias_1 as AutocompleteList } from './_tsup-dts-rollup';
|
4
|
+
export { AutocompletePopover_alias_1 as AutocompletePopover } from './_tsup-dts-rollup';
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import {
|
2
|
+
createComponent
|
3
|
+
} from "./chunk-UG3RPLME.js";
|
4
|
+
import "./chunk-BH56NR2Q.js";
|
5
|
+
|
6
|
+
// src/components/autocomplete/autocomplete-empty.gen.ts
|
7
|
+
import {
|
8
|
+
defaultAutocompleteEmptyProps
|
9
|
+
} from "@prosekit/web/autocomplete";
|
10
|
+
var AutocompleteEmpty = createComponent(
|
11
|
+
"prosekit-autocomplete-empty",
|
12
|
+
"AutocompleteEmpty",
|
13
|
+
defaultAutocompleteEmptyProps
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/autocomplete/autocomplete-item.gen.ts
|
17
|
+
import {
|
18
|
+
defaultAutocompleteItemProps
|
19
|
+
} from "@prosekit/web/autocomplete";
|
20
|
+
var AutocompleteItem = createComponent(
|
21
|
+
"prosekit-autocomplete-item",
|
22
|
+
"AutocompleteItem",
|
23
|
+
defaultAutocompleteItemProps
|
24
|
+
);
|
25
|
+
|
26
|
+
// src/components/autocomplete/autocomplete-list.gen.ts
|
27
|
+
import {
|
28
|
+
defaultAutocompleteListProps
|
29
|
+
} from "@prosekit/web/autocomplete";
|
30
|
+
var AutocompleteList = createComponent(
|
31
|
+
"prosekit-autocomplete-list",
|
32
|
+
"AutocompleteList",
|
33
|
+
defaultAutocompleteListProps
|
34
|
+
);
|
35
|
+
|
36
|
+
// src/components/autocomplete/autocomplete-popover.gen.ts
|
37
|
+
import {
|
38
|
+
defaultAutocompletePopoverProps
|
39
|
+
} from "@prosekit/web/autocomplete";
|
40
|
+
var AutocompletePopover = createComponent(
|
41
|
+
"prosekit-autocomplete-popover",
|
42
|
+
"AutocompletePopover",
|
43
|
+
defaultAutocompletePopoverProps
|
44
|
+
);
|
45
|
+
export {
|
46
|
+
AutocompleteEmpty,
|
47
|
+
AutocompleteItem,
|
48
|
+
AutocompleteList,
|
49
|
+
AutocompletePopover
|
50
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import {
|
2
|
+
createComponent
|
3
|
+
} from "./chunk-UG3RPLME.js";
|
4
|
+
import "./chunk-BH56NR2Q.js";
|
5
|
+
|
6
|
+
// src/components/block-handle/block-drag-handle.gen.ts
|
7
|
+
import {
|
8
|
+
defaultBlockDragHandleProps
|
9
|
+
} from "@prosekit/web/block-handle";
|
10
|
+
var BlockDragHandle = createComponent(
|
11
|
+
"prosekit-block-drag-handle",
|
12
|
+
"BlockDragHandle",
|
13
|
+
defaultBlockDragHandleProps
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/block-handle/block-popover.gen.ts
|
17
|
+
import {
|
18
|
+
defaultBlockPopoverProps
|
19
|
+
} from "@prosekit/web/block-handle";
|
20
|
+
var BlockPopover = createComponent(
|
21
|
+
"prosekit-block-popover",
|
22
|
+
"BlockPopover",
|
23
|
+
defaultBlockPopoverProps
|
24
|
+
);
|
25
|
+
export {
|
26
|
+
BlockDragHandle,
|
27
|
+
BlockPopover
|
28
|
+
};
|