@prosekit/preact 0.0.0-next-20240421132240
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/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/_tsup-dts-rollup.d.ts +235 -0
- package/dist/chunk-5LWA54E4.js +50 -0
- package/dist/chunk-V253IGNY.js +13 -0
- package/dist/prosekit-preact-autocomplete.d.ts +4 -0
- package/dist/prosekit-preact-autocomplete.js +50 -0
- package/dist/prosekit-preact-block-handle.d.ts +2 -0
- package/dist/prosekit-preact-block-handle.js +28 -0
- package/dist/prosekit-preact-inline-popover.d.ts +1 -0
- package/dist/prosekit-preact-inline-popover.js +17 -0
- package/dist/prosekit-preact-popover.d.ts +3 -0
- package/dist/prosekit-preact-popover.js +39 -0
- package/dist/prosekit-preact-resizable.d.ts +2 -0
- package/dist/prosekit-preact-resizable.js +28 -0
- package/dist/prosekit-preact-tooltip.d.ts +3 -0
- package/dist/prosekit-preact-tooltip.js +39 -0
- package/dist/prosekit-preact.d.ts +10 -0
- package/dist/prosekit-preact.js +118 -0
- package/package.json +118 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 ocavue
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
File without changes
|
@@ -0,0 +1,235 @@
|
|
1
|
+
import { AutocompleteEmptyElement } from '@prosekit/web/autocomplete';
|
2
|
+
import { AutocompleteEmptyProps } from '@prosekit/web/autocomplete';
|
3
|
+
import { AutocompleteItemElement } from '@prosekit/web/autocomplete';
|
4
|
+
import { AutocompleteItemProps } from '@prosekit/web/autocomplete';
|
5
|
+
import { AutocompleteListElement } from '@prosekit/web/autocomplete';
|
6
|
+
import { AutocompleteListProps } from '@prosekit/web/autocomplete';
|
7
|
+
import { AutocompletePopoverElement } from '@prosekit/web/autocomplete';
|
8
|
+
import { AutocompletePopoverProps } from '@prosekit/web/autocomplete';
|
9
|
+
import { BlockDragHandleElement } from '@prosekit/web/block-handle';
|
10
|
+
import { BlockDragHandleProps } from '@prosekit/web/block-handle';
|
11
|
+
import { BlockPopoverElement } from '@prosekit/web/block-handle';
|
12
|
+
import { BlockPopoverProps } from '@prosekit/web/block-handle';
|
13
|
+
import { ComponentChildren } from 'preact';
|
14
|
+
import { ComponentType } from 'preact';
|
15
|
+
import { Editor } from '@prosekit/core';
|
16
|
+
import type { EditorState } from '@prosekit/pm/state';
|
17
|
+
import { Extension } from '@prosekit/core';
|
18
|
+
import { ForwardRefExoticComponent } from 'preact/compat';
|
19
|
+
import { HTMLAttributes } from 'preact/compat';
|
20
|
+
import { InlinePopoverElement } from '@prosekit/web/inline-popover';
|
21
|
+
import { InlinePopoverProps } from '@prosekit/web/inline-popover';
|
22
|
+
import { Keymap } from '@prosekit/core';
|
23
|
+
import { Options } from 'tsup';
|
24
|
+
import { PopoverContentElement } from '@prosekit/web/popover';
|
25
|
+
import { PopoverContentProps } from '@prosekit/web/popover';
|
26
|
+
import { PopoverRootElement } from '@prosekit/web/popover';
|
27
|
+
import { PopoverRootProps } from '@prosekit/web/popover';
|
28
|
+
import { PopoverTriggerElement } from '@prosekit/web/popover';
|
29
|
+
import { PopoverTriggerProps } from '@prosekit/web/popover';
|
30
|
+
import { Priority } from '@prosekit/core';
|
31
|
+
import type { ProseMirrorNode } from '@prosekit/pm/model';
|
32
|
+
import { Provider } from 'preact';
|
33
|
+
import { RefAttributes } from 'preact/compat';
|
34
|
+
import { ResizableHandleElement } from '@prosekit/web/resizable';
|
35
|
+
import { ResizableHandleProps } from '@prosekit/web/resizable';
|
36
|
+
import { ResizableRootElement } from '@prosekit/web/resizable';
|
37
|
+
import { ResizableRootProps } from '@prosekit/web/resizable';
|
38
|
+
import { TooltipContentElement } from '@prosekit/web/tooltip';
|
39
|
+
import { TooltipContentProps } from '@prosekit/web/tooltip';
|
40
|
+
import { TooltipRootElement } from '@prosekit/web/tooltip';
|
41
|
+
import { TooltipRootProps } from '@prosekit/web/tooltip';
|
42
|
+
import { TooltipTriggerElement } from '@prosekit/web/tooltip';
|
43
|
+
import { TooltipTriggerProps } from '@prosekit/web/tooltip';
|
44
|
+
|
45
|
+
declare const AutocompleteEmpty: ForwardRefExoticComponent<Partial<AutocompleteEmptyProps> & RefAttributes<AutocompleteEmptyElement> & HTMLAttributes<AutocompleteEmptyElement>>;
|
46
|
+
export { AutocompleteEmpty }
|
47
|
+
export { AutocompleteEmpty as AutocompleteEmpty_alias_1 }
|
48
|
+
|
49
|
+
declare const AutocompleteItem: ForwardRefExoticComponent<Partial<AutocompleteItemProps> & RefAttributes<AutocompleteItemElement> & HTMLAttributes<AutocompleteItemElement>>;
|
50
|
+
export { AutocompleteItem }
|
51
|
+
export { AutocompleteItem as AutocompleteItem_alias_1 }
|
52
|
+
|
53
|
+
declare const AutocompleteList: ForwardRefExoticComponent<Partial<AutocompleteListProps> & RefAttributes<AutocompleteListElement> & HTMLAttributes<AutocompleteListElement>>;
|
54
|
+
export { AutocompleteList }
|
55
|
+
export { AutocompleteList as AutocompleteList_alias_1 }
|
56
|
+
|
57
|
+
declare const AutocompletePopover: ForwardRefExoticComponent<Partial<AutocompletePopoverProps> & RefAttributes<AutocompletePopoverElement> & HTMLAttributes<AutocompletePopoverElement>>;
|
58
|
+
export { AutocompletePopover }
|
59
|
+
export { AutocompletePopover as AutocompletePopover_alias_1 }
|
60
|
+
|
61
|
+
declare const BlockDragHandle: ForwardRefExoticComponent<Partial<BlockDragHandleProps> & RefAttributes<BlockDragHandleElement> & HTMLAttributes<BlockDragHandleElement>>;
|
62
|
+
export { BlockDragHandle }
|
63
|
+
export { BlockDragHandle as BlockDragHandle_alias_1 }
|
64
|
+
|
65
|
+
declare const BlockPopover: ForwardRefExoticComponent<Partial<BlockPopoverProps> & RefAttributes<BlockPopoverElement> & HTMLAttributes<BlockPopoverElement>>;
|
66
|
+
export { BlockPopover }
|
67
|
+
export { BlockPopover as BlockPopover_alias_1 }
|
68
|
+
|
69
|
+
export declare function createComponent<Props extends object, CustomElement extends HTMLElement>(tagName: string, displayName: string, defaultProps: Props): ForwardRefExoticComponent<Partial<Props> & RefAttributes<CustomElement> & HTMLAttributes<CustomElement>>;
|
70
|
+
|
71
|
+
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
72
|
+
|
73
|
+
export declare const default_alias_1: {
|
74
|
+
test: {
|
75
|
+
environment: "jsdom";
|
76
|
+
};
|
77
|
+
};
|
78
|
+
|
79
|
+
/**
|
80
|
+
* @internal
|
81
|
+
*/
|
82
|
+
export declare const EditorContextProvider: Provider<Editor<any> | null>;
|
83
|
+
|
84
|
+
declare const InlinePopover: ForwardRefExoticComponent<Partial<InlinePopoverProps> & RefAttributes<InlinePopoverElement> & HTMLAttributes<InlinePopoverElement>>;
|
85
|
+
export { InlinePopover }
|
86
|
+
export { InlinePopover as InlinePopover_alias_1 }
|
87
|
+
|
88
|
+
declare const PopoverContent: ForwardRefExoticComponent<Partial<PopoverContentProps> & RefAttributes<PopoverContentElement> & HTMLAttributes<PopoverContentElement>>;
|
89
|
+
export { PopoverContent }
|
90
|
+
export { PopoverContent as PopoverContent_alias_1 }
|
91
|
+
|
92
|
+
declare const PopoverRoot: ForwardRefExoticComponent<Partial<PopoverRootProps> & RefAttributes<PopoverRootElement> & HTMLAttributes<PopoverRootElement>>;
|
93
|
+
export { PopoverRoot }
|
94
|
+
export { PopoverRoot as PopoverRoot_alias_1 }
|
95
|
+
|
96
|
+
declare const PopoverTrigger: ForwardRefExoticComponent<Partial<PopoverTriggerProps> & RefAttributes<PopoverTriggerElement> & HTMLAttributes<PopoverTriggerElement>>;
|
97
|
+
export { PopoverTrigger }
|
98
|
+
export { PopoverTrigger as PopoverTrigger_alias_1 }
|
99
|
+
|
100
|
+
/**
|
101
|
+
* @internal
|
102
|
+
*/
|
103
|
+
declare type PropsWithChildren<P = unknown> = P & {
|
104
|
+
children?: ComponentChildren | undefined;
|
105
|
+
};
|
106
|
+
export { PropsWithChildren }
|
107
|
+
export { PropsWithChildren as PropsWithChildren_alias_1 }
|
108
|
+
|
109
|
+
/**
|
110
|
+
* @internal
|
111
|
+
*/
|
112
|
+
declare type PropsWithClass<P = unknown> = P & {
|
113
|
+
class?: string | undefined;
|
114
|
+
className?: string | undefined;
|
115
|
+
};
|
116
|
+
export { PropsWithClass }
|
117
|
+
export { PropsWithClass as PropsWithClass_alias_1 }
|
118
|
+
|
119
|
+
/**
|
120
|
+
* The root component for a ProseKit editor.
|
121
|
+
*
|
122
|
+
* @public
|
123
|
+
*/
|
124
|
+
declare const ProseKit: ComponentType<ProseKitProps>;
|
125
|
+
export { ProseKit }
|
126
|
+
export { ProseKit as ProseKit_alias_1 }
|
127
|
+
|
128
|
+
declare interface ProseKitProps {
|
129
|
+
editor: Editor;
|
130
|
+
children?: ComponentChildren;
|
131
|
+
}
|
132
|
+
export { ProseKitProps }
|
133
|
+
export { ProseKitProps as ProseKitProps_alias_1 }
|
134
|
+
|
135
|
+
declare const ResizableHandle: ForwardRefExoticComponent<Partial<ResizableHandleProps> & RefAttributes<ResizableHandleElement> & HTMLAttributes<ResizableHandleElement>>;
|
136
|
+
export { ResizableHandle }
|
137
|
+
export { ResizableHandle as ResizableHandle_alias_1 }
|
138
|
+
|
139
|
+
declare const ResizableRoot: ForwardRefExoticComponent<Partial<ResizableRootProps> & RefAttributes<ResizableRootElement> & HTMLAttributes<ResizableRootElement>>;
|
140
|
+
export { ResizableRoot }
|
141
|
+
export { ResizableRoot as ResizableRoot_alias_1 }
|
142
|
+
|
143
|
+
declare const TooltipContent: ForwardRefExoticComponent<Partial<TooltipContentProps> & RefAttributes<TooltipContentElement> & HTMLAttributes<TooltipContentElement>>;
|
144
|
+
export { TooltipContent }
|
145
|
+
export { TooltipContent as TooltipContent_alias_1 }
|
146
|
+
|
147
|
+
declare const TooltipRoot: ForwardRefExoticComponent<Partial<TooltipRootProps> & RefAttributes<TooltipRootElement> & HTMLAttributes<TooltipRootElement>>;
|
148
|
+
export { TooltipRoot }
|
149
|
+
export { TooltipRoot as TooltipRoot_alias_1 }
|
150
|
+
|
151
|
+
declare const TooltipTrigger: ForwardRefExoticComponent<Partial<TooltipTriggerProps> & RefAttributes<TooltipTriggerElement> & HTMLAttributes<TooltipTriggerElement>>;
|
152
|
+
export { TooltipTrigger }
|
153
|
+
export { TooltipTrigger as TooltipTrigger_alias_1 }
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Calls the given handler whenever the editor document changes.
|
157
|
+
*
|
158
|
+
* @public
|
159
|
+
*/
|
160
|
+
declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
|
161
|
+
export { useDocChange }
|
162
|
+
export { useDocChange as useDocChange_alias_1 }
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Retrieves the editor instance from the nearest ProseKit component.
|
166
|
+
*
|
167
|
+
* @public
|
168
|
+
*/
|
169
|
+
declare function useEditor<E extends Extension = any>(options?: {
|
170
|
+
/**
|
171
|
+
* Whether to update the component when the editor is mounted or editor state
|
172
|
+
* is updated.
|
173
|
+
*
|
174
|
+
* @default false
|
175
|
+
*/
|
176
|
+
update?: boolean;
|
177
|
+
}): Editor<E>;
|
178
|
+
export { useEditor }
|
179
|
+
export { useEditor as useEditor_alias_1 }
|
180
|
+
|
181
|
+
/**
|
182
|
+
* @internal
|
183
|
+
*/
|
184
|
+
export declare function useEditorContext<E extends Extension>(): Editor<E> | null;
|
185
|
+
|
186
|
+
/**
|
187
|
+
* @internal
|
188
|
+
*/
|
189
|
+
export declare function useEditorExtension(editor: Editor | null | undefined, extension: Extension | null): void;
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Add an extension to the editor.
|
193
|
+
*/
|
194
|
+
declare function useExtension(
|
195
|
+
/**
|
196
|
+
* The extension to add to the editor. If it changes, the previous
|
197
|
+
* extension will be removed and the new one (if not null) will be added.
|
198
|
+
*/
|
199
|
+
extension: Extension | null, options?: UseExtensionOptions): void;
|
200
|
+
export { useExtension }
|
201
|
+
export { useExtension as useExtension_alias_1 }
|
202
|
+
|
203
|
+
declare interface UseExtensionOptions {
|
204
|
+
/**
|
205
|
+
* The editor to add the extension to. If not provided, it will use the
|
206
|
+
* editor from the nearest `ProseKit` component.
|
207
|
+
*/
|
208
|
+
editor?: Editor;
|
209
|
+
/**
|
210
|
+
* Optional priority to add the extension with.
|
211
|
+
*/
|
212
|
+
priority?: Priority;
|
213
|
+
}
|
214
|
+
export { UseExtensionOptions }
|
215
|
+
export { UseExtensionOptions as UseExtensionOptions_alias_1 }
|
216
|
+
|
217
|
+
declare function useKeymap(keymap: Keymap, options?: UseExtensionOptions): void;
|
218
|
+
export { useKeymap }
|
219
|
+
export { useKeymap as useKeymap_alias_1 }
|
220
|
+
|
221
|
+
/**
|
222
|
+
* @internal
|
223
|
+
*/
|
224
|
+
export declare function usePriorityExtension<T extends Extension = Extension>(extension: T | null, priority?: Priority | null): T | null;
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Calls the given handler whenever the editor state changes.
|
228
|
+
*
|
229
|
+
* @public
|
230
|
+
*/
|
231
|
+
declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
|
232
|
+
export { useStateUpdate }
|
233
|
+
export { useStateUpdate as useStateUpdate_alias_1 }
|
234
|
+
|
235
|
+
export { }
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import {
|
2
|
+
useEditorContext
|
3
|
+
} from "./chunk-V253IGNY.js";
|
4
|
+
|
5
|
+
// src/components/create-component.ts
|
6
|
+
import { createElement } from "preact";
|
7
|
+
import {
|
8
|
+
forwardRef
|
9
|
+
} from "preact/compat";
|
10
|
+
import { useLayoutEffect, useState } from "preact/hooks";
|
11
|
+
import { mergeRefs } from "react-merge-refs";
|
12
|
+
function createComponent(tagName, displayName, defaultProps) {
|
13
|
+
const propertyNames = Object.keys(defaultProps);
|
14
|
+
const hasEditor = Object.hasOwn(defaultProps, "editor");
|
15
|
+
const Component = forwardRef((props, ref) => {
|
16
|
+
const [el, setEl] = useState(null);
|
17
|
+
const properties = {};
|
18
|
+
const attributes = {};
|
19
|
+
for (const [name, value] of Object.entries(props)) {
|
20
|
+
if (propertyNames.includes(name)) {
|
21
|
+
properties[name] = value;
|
22
|
+
} else {
|
23
|
+
attributes[name === "className" ? "class" : name] = value;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
const editor = useEditorContext();
|
27
|
+
if (hasEditor && editor && !properties["editor"]) {
|
28
|
+
properties["editor"] = editor;
|
29
|
+
}
|
30
|
+
useLayoutEffect(() => {
|
31
|
+
if (el) {
|
32
|
+
for (const [name, value] of Object.entries(properties)) {
|
33
|
+
if (value !== void 0) {
|
34
|
+
el[name] = value;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}, [el, ...propertyNames.map((name) => properties[name])]);
|
39
|
+
return createElement(tagName, {
|
40
|
+
...attributes,
|
41
|
+
ref: mergeRefs([ref, setEl])
|
42
|
+
});
|
43
|
+
});
|
44
|
+
Component.displayName = displayName;
|
45
|
+
return Component;
|
46
|
+
}
|
47
|
+
|
48
|
+
export {
|
49
|
+
createComponent
|
50
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// src/contexts/editor-context.ts
|
2
|
+
import { createContext } from "preact";
|
3
|
+
import { useContext } from "preact/hooks";
|
4
|
+
var editorContext = createContext(null);
|
5
|
+
function useEditorContext() {
|
6
|
+
return useContext(editorContext);
|
7
|
+
}
|
8
|
+
var EditorContextProvider = editorContext.Provider;
|
9
|
+
|
10
|
+
export {
|
11
|
+
useEditorContext,
|
12
|
+
EditorContextProvider
|
13
|
+
};
|
@@ -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-5LWA54E4.js";
|
4
|
+
import "./chunk-V253IGNY.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-5LWA54E4.js";
|
4
|
+
import "./chunk-V253IGNY.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
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { InlinePopover } from './_tsup-dts-rollup';
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {
|
2
|
+
createComponent
|
3
|
+
} from "./chunk-5LWA54E4.js";
|
4
|
+
import "./chunk-V253IGNY.js";
|
5
|
+
|
6
|
+
// src/components/inline-popover/inline-popover.gen.ts
|
7
|
+
import {
|
8
|
+
defaultInlinePopoverProps
|
9
|
+
} from "@prosekit/web/inline-popover";
|
10
|
+
var InlinePopover = createComponent(
|
11
|
+
"prosekit-inline-popover",
|
12
|
+
"InlinePopover",
|
13
|
+
defaultInlinePopoverProps
|
14
|
+
);
|
15
|
+
export {
|
16
|
+
InlinePopover
|
17
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import {
|
2
|
+
createComponent
|
3
|
+
} from "./chunk-5LWA54E4.js";
|
4
|
+
import "./chunk-V253IGNY.js";
|
5
|
+
|
6
|
+
// src/components/popover/popover-content.gen.ts
|
7
|
+
import {
|
8
|
+
defaultPopoverContentProps
|
9
|
+
} from "@prosekit/web/popover";
|
10
|
+
var PopoverContent = createComponent(
|
11
|
+
"prosekit-popover-content",
|
12
|
+
"PopoverContent",
|
13
|
+
defaultPopoverContentProps
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/popover/popover-root.gen.ts
|
17
|
+
import {
|
18
|
+
defaultPopoverRootProps
|
19
|
+
} from "@prosekit/web/popover";
|
20
|
+
var PopoverRoot = createComponent(
|
21
|
+
"prosekit-popover-root",
|
22
|
+
"PopoverRoot",
|
23
|
+
defaultPopoverRootProps
|
24
|
+
);
|
25
|
+
|
26
|
+
// src/components/popover/popover-trigger.gen.ts
|
27
|
+
import {
|
28
|
+
defaultPopoverTriggerProps
|
29
|
+
} from "@prosekit/web/popover";
|
30
|
+
var PopoverTrigger = createComponent(
|
31
|
+
"prosekit-popover-trigger",
|
32
|
+
"PopoverTrigger",
|
33
|
+
defaultPopoverTriggerProps
|
34
|
+
);
|
35
|
+
export {
|
36
|
+
PopoverContent,
|
37
|
+
PopoverRoot,
|
38
|
+
PopoverTrigger
|
39
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import {
|
2
|
+
createComponent
|
3
|
+
} from "./chunk-5LWA54E4.js";
|
4
|
+
import "./chunk-V253IGNY.js";
|
5
|
+
|
6
|
+
// src/components/resizable/resizable-handle.gen.ts
|
7
|
+
import {
|
8
|
+
defaultResizableHandleProps
|
9
|
+
} from "@prosekit/web/resizable";
|
10
|
+
var ResizableHandle = createComponent(
|
11
|
+
"prosekit-resizable-handle",
|
12
|
+
"ResizableHandle",
|
13
|
+
defaultResizableHandleProps
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/resizable/resizable-root.gen.ts
|
17
|
+
import {
|
18
|
+
defaultResizableRootProps
|
19
|
+
} from "@prosekit/web/resizable";
|
20
|
+
var ResizableRoot = createComponent(
|
21
|
+
"prosekit-resizable-root",
|
22
|
+
"ResizableRoot",
|
23
|
+
defaultResizableRootProps
|
24
|
+
);
|
25
|
+
export {
|
26
|
+
ResizableHandle,
|
27
|
+
ResizableRoot
|
28
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import {
|
2
|
+
createComponent
|
3
|
+
} from "./chunk-5LWA54E4.js";
|
4
|
+
import "./chunk-V253IGNY.js";
|
5
|
+
|
6
|
+
// src/components/tooltip/tooltip-content.gen.ts
|
7
|
+
import {
|
8
|
+
defaultTooltipContentProps
|
9
|
+
} from "@prosekit/web/tooltip";
|
10
|
+
var TooltipContent = createComponent(
|
11
|
+
"prosekit-tooltip-content",
|
12
|
+
"TooltipContent",
|
13
|
+
defaultTooltipContentProps
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/tooltip/tooltip-root.gen.ts
|
17
|
+
import {
|
18
|
+
defaultTooltipRootProps
|
19
|
+
} from "@prosekit/web/tooltip";
|
20
|
+
var TooltipRoot = createComponent(
|
21
|
+
"prosekit-tooltip-root",
|
22
|
+
"TooltipRoot",
|
23
|
+
defaultTooltipRootProps
|
24
|
+
);
|
25
|
+
|
26
|
+
// src/components/tooltip/tooltip-trigger.gen.ts
|
27
|
+
import {
|
28
|
+
defaultTooltipTriggerProps
|
29
|
+
} from "@prosekit/web/tooltip";
|
30
|
+
var TooltipTrigger = createComponent(
|
31
|
+
"prosekit-tooltip-trigger",
|
32
|
+
"TooltipTrigger",
|
33
|
+
defaultTooltipTriggerProps
|
34
|
+
);
|
35
|
+
export {
|
36
|
+
TooltipContent,
|
37
|
+
TooltipRoot,
|
38
|
+
TooltipTrigger
|
39
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export { ProseKit } from './_tsup-dts-rollup';
|
2
|
+
export { ProseKitProps } from './_tsup-dts-rollup';
|
3
|
+
export { useEditor } from './_tsup-dts-rollup';
|
4
|
+
export { useExtension } from './_tsup-dts-rollup';
|
5
|
+
export { UseExtensionOptions } from './_tsup-dts-rollup';
|
6
|
+
export { useKeymap } from './_tsup-dts-rollup';
|
7
|
+
export { useStateUpdate } from './_tsup-dts-rollup';
|
8
|
+
export { useDocChange } from './_tsup-dts-rollup';
|
9
|
+
export { PropsWithChildren } from './_tsup-dts-rollup';
|
10
|
+
export { PropsWithClass } from './_tsup-dts-rollup';
|
@@ -0,0 +1,118 @@
|
|
1
|
+
import {
|
2
|
+
EditorContextProvider,
|
3
|
+
useEditorContext
|
4
|
+
} from "./chunk-V253IGNY.js";
|
5
|
+
|
6
|
+
// src/components/prosekit.ts
|
7
|
+
import { h } from "preact";
|
8
|
+
var ProseKit = (props) => {
|
9
|
+
const { editor, children } = props;
|
10
|
+
return h(EditorContextProvider, { value: editor, children });
|
11
|
+
};
|
12
|
+
|
13
|
+
// src/hooks/use-editor.ts
|
14
|
+
import {
|
15
|
+
ProseKitError,
|
16
|
+
defineMountHandler,
|
17
|
+
defineUpdateHandler,
|
18
|
+
union
|
19
|
+
} from "@prosekit/core";
|
20
|
+
import { useEffect, useReducer } from "preact/hooks";
|
21
|
+
function useEditor(options) {
|
22
|
+
var _a;
|
23
|
+
const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
|
24
|
+
const editor = useEditorContext();
|
25
|
+
if (!editor) {
|
26
|
+
throw new ProseKitError(
|
27
|
+
"useEditor must be used within the ProseKit component"
|
28
|
+
);
|
29
|
+
}
|
30
|
+
const forceUpdate = useForceUpdate();
|
31
|
+
useEffect(() => {
|
32
|
+
if (update) {
|
33
|
+
const extension = union([
|
34
|
+
defineMountHandler(forceUpdate),
|
35
|
+
defineUpdateHandler(forceUpdate)
|
36
|
+
]);
|
37
|
+
return editor.use(extension);
|
38
|
+
}
|
39
|
+
}, [editor, update, forceUpdate]);
|
40
|
+
return editor;
|
41
|
+
}
|
42
|
+
function useForceUpdate() {
|
43
|
+
const [, dispatch] = useReducer((x) => x + 1, 0);
|
44
|
+
return dispatch;
|
45
|
+
}
|
46
|
+
|
47
|
+
// src/hooks/use-extension.ts
|
48
|
+
import "@prosekit/core";
|
49
|
+
|
50
|
+
// src/hooks/use-editor-extension.ts
|
51
|
+
import { EditorNotFoundError } from "@prosekit/core";
|
52
|
+
import { useEffect as useEffect2 } from "preact/hooks";
|
53
|
+
function useEditorExtension(editor, extension) {
|
54
|
+
if (!editor) {
|
55
|
+
throw new EditorNotFoundError();
|
56
|
+
}
|
57
|
+
useEffect2(() => {
|
58
|
+
if (extension) {
|
59
|
+
return editor.use(extension);
|
60
|
+
}
|
61
|
+
}, [editor, extension]);
|
62
|
+
}
|
63
|
+
|
64
|
+
// src/hooks/use-priority-extension.ts
|
65
|
+
import { withPriority } from "@prosekit/core";
|
66
|
+
import { useMemo } from "preact/hooks";
|
67
|
+
function usePriorityExtension(extension, priority) {
|
68
|
+
return useMemo(() => {
|
69
|
+
return extension && priority ? withPriority(extension, priority) : extension;
|
70
|
+
}, [extension, priority]);
|
71
|
+
}
|
72
|
+
|
73
|
+
// src/hooks/use-extension.ts
|
74
|
+
function useExtension(extension, options) {
|
75
|
+
const editorContext = useEditorContext();
|
76
|
+
useEditorExtension(
|
77
|
+
(options == null ? void 0 : options.editor) || editorContext,
|
78
|
+
usePriorityExtension(extension, options == null ? void 0 : options.priority)
|
79
|
+
);
|
80
|
+
}
|
81
|
+
|
82
|
+
// src/hooks/use-keymap.ts
|
83
|
+
import { defineKeymap } from "@prosekit/core";
|
84
|
+
import { useMemo as useMemo2 } from "preact/hooks";
|
85
|
+
function useKeymap(keymap, options) {
|
86
|
+
const extension = useMemo2(() => defineKeymap(keymap), [keymap]);
|
87
|
+
return useExtension(extension, options);
|
88
|
+
}
|
89
|
+
|
90
|
+
// src/hooks/use-state-update.ts
|
91
|
+
import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
|
92
|
+
import { useMemo as useMemo3 } from "preact/hooks";
|
93
|
+
function useStateUpdate(handler, options) {
|
94
|
+
const extension = useMemo3(
|
95
|
+
() => defineUpdateHandler2((view) => handler(view.state)),
|
96
|
+
[handler]
|
97
|
+
);
|
98
|
+
return useExtension(extension, options);
|
99
|
+
}
|
100
|
+
|
101
|
+
// src/hooks/use-doc-change.ts
|
102
|
+
import { defineDocChangeHandler } from "@prosekit/core";
|
103
|
+
import { useMemo as useMemo4 } from "preact/hooks";
|
104
|
+
function useDocChange(handler, options) {
|
105
|
+
const extension = useMemo4(
|
106
|
+
() => defineDocChangeHandler((view) => handler(view.state.doc)),
|
107
|
+
[handler]
|
108
|
+
);
|
109
|
+
return useExtension(extension, options);
|
110
|
+
}
|
111
|
+
export {
|
112
|
+
ProseKit,
|
113
|
+
useDocChange,
|
114
|
+
useEditor,
|
115
|
+
useExtension,
|
116
|
+
useKeymap,
|
117
|
+
useStateUpdate
|
118
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
{
|
2
|
+
"name": "@prosekit/preact",
|
3
|
+
"type": "module",
|
4
|
+
"version": "0.0.0-next-20240421132240",
|
5
|
+
"private": false,
|
6
|
+
"author": {
|
7
|
+
"name": "ocavue",
|
8
|
+
"email": "ocavue@gmail.com"
|
9
|
+
},
|
10
|
+
"license": "MIT",
|
11
|
+
"funding": "https://github.com/sponsors/ocavue",
|
12
|
+
"homepage": "https://github.com/ocavue/prosekit#readme",
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git+https://github.com/ocavue/prosekit.git",
|
16
|
+
"directory": "packages/preact"
|
17
|
+
},
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/ocavue/prosekit/issues"
|
20
|
+
},
|
21
|
+
"keywords": [
|
22
|
+
"ProseMirror"
|
23
|
+
],
|
24
|
+
"sideEffects": false,
|
25
|
+
"main": "./dist/prosekit-preact.js",
|
26
|
+
"module": "./dist/prosekit-preact.js",
|
27
|
+
"exports": {
|
28
|
+
".": {
|
29
|
+
"types": "./dist/prosekit-preact.d.ts",
|
30
|
+
"import": "./dist/prosekit-preact.js",
|
31
|
+
"default": "./dist/prosekit-preact.js"
|
32
|
+
},
|
33
|
+
"./autocomplete": {
|
34
|
+
"types": "./dist/prosekit-preact-autocomplete.d.ts",
|
35
|
+
"import": "./dist/prosekit-preact-autocomplete.js",
|
36
|
+
"default": "./dist/prosekit-preact-autocomplete.js"
|
37
|
+
},
|
38
|
+
"./block-handle": {
|
39
|
+
"types": "./dist/prosekit-preact-block-handle.d.ts",
|
40
|
+
"import": "./dist/prosekit-preact-block-handle.js",
|
41
|
+
"default": "./dist/prosekit-preact-block-handle.js"
|
42
|
+
},
|
43
|
+
"./inline-popover": {
|
44
|
+
"types": "./dist/prosekit-preact-inline-popover.d.ts",
|
45
|
+
"import": "./dist/prosekit-preact-inline-popover.js",
|
46
|
+
"default": "./dist/prosekit-preact-inline-popover.js"
|
47
|
+
},
|
48
|
+
"./popover": {
|
49
|
+
"types": "./dist/prosekit-preact-popover.d.ts",
|
50
|
+
"import": "./dist/prosekit-preact-popover.js",
|
51
|
+
"default": "./dist/prosekit-preact-popover.js"
|
52
|
+
},
|
53
|
+
"./resizable": {
|
54
|
+
"types": "./dist/prosekit-preact-resizable.d.ts",
|
55
|
+
"import": "./dist/prosekit-preact-resizable.js",
|
56
|
+
"default": "./dist/prosekit-preact-resizable.js"
|
57
|
+
},
|
58
|
+
"./tooltip": {
|
59
|
+
"types": "./dist/prosekit-preact-tooltip.d.ts",
|
60
|
+
"import": "./dist/prosekit-preact-tooltip.js",
|
61
|
+
"default": "./dist/prosekit-preact-tooltip.js"
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"files": [
|
65
|
+
"dist"
|
66
|
+
],
|
67
|
+
"dependencies": {
|
68
|
+
"@prosekit/core": "0.0.0-next-20240421132240",
|
69
|
+
"@prosekit/pm": "0.0.0-next-20240421132240",
|
70
|
+
"@prosekit/web": "0.0.0-next-20240421132240",
|
71
|
+
"react-merge-refs": "^2.1.1"
|
72
|
+
},
|
73
|
+
"peerDependencies": {
|
74
|
+
"preact": ">= 9.0.0"
|
75
|
+
},
|
76
|
+
"peerDependenciesMeta": {
|
77
|
+
"preact": {
|
78
|
+
"optional": true
|
79
|
+
}
|
80
|
+
},
|
81
|
+
"devDependencies": {
|
82
|
+
"@prosekit/dev": "*",
|
83
|
+
"preact": "^10.20.2",
|
84
|
+
"tsup": "^8.0.2",
|
85
|
+
"typescript": "^5.4.5",
|
86
|
+
"vitest": "^1.5.0"
|
87
|
+
},
|
88
|
+
"scripts": {
|
89
|
+
"build:tsup": "tsup",
|
90
|
+
"build:tsc": "tsc -b tsconfig.json"
|
91
|
+
},
|
92
|
+
"types": "./dist/prosekit-preact.d.ts",
|
93
|
+
"typesVersions": {
|
94
|
+
"*": {
|
95
|
+
".": [
|
96
|
+
"./dist/prosekit-preact.d.ts"
|
97
|
+
],
|
98
|
+
"autocomplete": [
|
99
|
+
"./dist/prosekit-preact-autocomplete.d.ts"
|
100
|
+
],
|
101
|
+
"block-handle": [
|
102
|
+
"./dist/prosekit-preact-block-handle.d.ts"
|
103
|
+
],
|
104
|
+
"inline-popover": [
|
105
|
+
"./dist/prosekit-preact-inline-popover.d.ts"
|
106
|
+
],
|
107
|
+
"popover": [
|
108
|
+
"./dist/prosekit-preact-popover.d.ts"
|
109
|
+
],
|
110
|
+
"resizable": [
|
111
|
+
"./dist/prosekit-preact-resizable.d.ts"
|
112
|
+
],
|
113
|
+
"tooltip": [
|
114
|
+
"./dist/prosekit-preact-tooltip.d.ts"
|
115
|
+
]
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|