@prosekit/solid 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 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,269 @@
1
+ import { Accessor } from 'solid-js';
2
+ import { AutocompleteEmptyElement } from '@prosekit/web/autocomplete';
3
+ import { AutocompleteEmptyProps } from '@prosekit/web/autocomplete';
4
+ import { AutocompleteItemElement } from '@prosekit/web/autocomplete';
5
+ import { AutocompleteItemProps } from '@prosekit/web/autocomplete';
6
+ import { AutocompleteListElement } from '@prosekit/web/autocomplete';
7
+ import { AutocompleteListProps } from '@prosekit/web/autocomplete';
8
+ import { AutocompletePopoverElement } from '@prosekit/web/autocomplete';
9
+ import { AutocompletePopoverProps } from '@prosekit/web/autocomplete';
10
+ import { BlockDragHandleElement } from '@prosekit/web/block-handle';
11
+ import { BlockDragHandleProps } from '@prosekit/web/block-handle';
12
+ import { BlockPopoverElement } from '@prosekit/web/block-handle';
13
+ import { BlockPopoverProps } from '@prosekit/web/block-handle';
14
+ import { Component } from 'solid-js';
15
+ import { ContextProviderComponent } from 'solid-js';
16
+ import { Editor } from '@prosekit/core';
17
+ import type { EditorState } from '@prosekit/pm/state';
18
+ import { Extension } from '@prosekit/core';
19
+ import { InlinePopoverElement } from '@prosekit/web/inline-popover';
20
+ import { InlinePopoverProps } from '@prosekit/web/inline-popover';
21
+ import { JSX } from 'solid-js';
22
+ import type { JSXElement } from 'solid-js';
23
+ import { Keymap } from '@prosekit/core';
24
+ import { Options } from 'tsup';
25
+ import { ParentProps } from 'solid-js';
26
+ import { PopoverContentElement } from '@prosekit/web/popover';
27
+ import { PopoverContentProps } from '@prosekit/web/popover';
28
+ import { PopoverRootElement } from '@prosekit/web/popover';
29
+ import { PopoverRootProps } from '@prosekit/web/popover';
30
+ import { PopoverTriggerElement } from '@prosekit/web/popover';
31
+ import { PopoverTriggerProps } from '@prosekit/web/popover';
32
+ import { Priority } from '@prosekit/core';
33
+ import type { ProseMirrorNode } from '@prosekit/pm/model';
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: Component<Partial<AutocompleteEmptyProps> & JSX<AutocompleteEmptyElement>>;
46
+ export { AutocompleteEmpty }
47
+ export { AutocompleteEmpty as AutocompleteEmpty_alias_1 }
48
+
49
+ declare const AutocompleteItem: Component<Partial<AutocompleteItemProps> & JSX<AutocompleteItemElement>>;
50
+ export { AutocompleteItem }
51
+ export { AutocompleteItem as AutocompleteItem_alias_1 }
52
+
53
+ declare const AutocompleteList: Component<Partial<AutocompleteListProps> & JSX<AutocompleteListElement>>;
54
+ export { AutocompleteList }
55
+ export { AutocompleteList as AutocompleteList_alias_1 }
56
+
57
+ declare const AutocompletePopover: Component<Partial<AutocompletePopoverProps> & JSX<AutocompletePopoverElement>>;
58
+ export { AutocompletePopover }
59
+ export { AutocompletePopover as AutocompletePopover_alias_1 }
60
+
61
+ declare const BlockDragHandle: Component<Partial<BlockDragHandleProps> & JSX<BlockDragHandleElement>>;
62
+ export { BlockDragHandle }
63
+ export { BlockDragHandle as BlockDragHandle_alias_1 }
64
+
65
+ declare const BlockPopover: Component<Partial<BlockPopoverProps> & JSX<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, defaultProps: Props): Component<Partial<Props> & JSX.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: ContextProviderComponent<Editor<any> | null>;
83
+
84
+ export declare function forceProps<T extends Record<string, any>>(props: T): T;
85
+
86
+ declare const InlinePopover: Component<Partial<InlinePopoverProps> & JSX<InlinePopoverElement>>;
87
+ export { InlinePopover }
88
+ export { InlinePopover as InlinePopover_alias_1 }
89
+
90
+ /**
91
+ * T or a reactive/non-reactive function returning T
92
+ */
93
+ declare type MaybeAccessor<T> = T | Accessor<T>;
94
+ export { MaybeAccessor }
95
+ export { MaybeAccessor as MaybeAccessor_alias_1 }
96
+
97
+ /**
98
+ * Accessed value of a MaybeAccessor
99
+ *
100
+ * @example
101
+ *
102
+ * ```ts
103
+ * MaybeAccessorValue<MaybeAccessor<string>>
104
+ * // => string
105
+ * MaybeAccessorValue<MaybeAccessor<() => string>>
106
+ * // => string | (() => string)
107
+ * MaybeAccessorValue<MaybeAccessor<string> | Function>
108
+ * // => string | void
109
+ * ```
110
+ */
111
+ export declare type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends () => any ? ReturnType<T> : T;
112
+
113
+ declare const PopoverContent: Component<Partial<PopoverContentProps> & JSX<PopoverContentElement>>;
114
+ export { PopoverContent }
115
+ export { PopoverContent as PopoverContent_alias_1 }
116
+
117
+ declare const PopoverRoot: Component<Partial<PopoverRootProps> & JSX<PopoverRootElement>>;
118
+ export { PopoverRoot }
119
+ export { PopoverRoot as PopoverRoot_alias_1 }
120
+
121
+ declare const PopoverTrigger: Component<Partial<PopoverTriggerProps> & JSX<PopoverTriggerElement>>;
122
+ export { PopoverTrigger }
123
+ export { PopoverTrigger as PopoverTrigger_alias_1 }
124
+
125
+ /**
126
+ * @internal
127
+ */
128
+ declare type PropsWithChildren<P = unknown> = P & {
129
+ children?: JSXElement | undefined;
130
+ };
131
+ export { PropsWithChildren }
132
+ export { PropsWithChildren as PropsWithChildren_alias_1 }
133
+
134
+ /**
135
+ * @internal
136
+ */
137
+ declare type PropsWithClass<P = unknown> = P & {
138
+ class?: string | undefined;
139
+ };
140
+ export { PropsWithClass }
141
+ export { PropsWithClass as PropsWithClass_alias_1 }
142
+
143
+ /**
144
+ * The root component for a ProseKit editor.
145
+ *
146
+ * @public
147
+ */
148
+ declare const ProseKit: Component<ProseKitProps>;
149
+ export { ProseKit }
150
+ export { ProseKit as ProseKit_alias_1 }
151
+
152
+ declare type ProseKitProps = ParentProps<{
153
+ editor: Editor;
154
+ }>;
155
+ export { ProseKitProps }
156
+ export { ProseKitProps as ProseKitProps_alias_1 }
157
+
158
+ declare const ResizableHandle: Component<Partial<ResizableHandleProps> & JSX<ResizableHandleElement>>;
159
+ export { ResizableHandle }
160
+ export { ResizableHandle as ResizableHandle_alias_1 }
161
+
162
+ declare const ResizableRoot: Component<Partial<ResizableRootProps> & JSX<ResizableRootElement>>;
163
+ export { ResizableRoot }
164
+ export { ResizableRoot as ResizableRoot_alias_1 }
165
+
166
+ declare const TooltipContent: Component<Partial<TooltipContentProps> & JSX<TooltipContentElement>>;
167
+ export { TooltipContent }
168
+ export { TooltipContent as TooltipContent_alias_1 }
169
+
170
+ declare const TooltipRoot: Component<Partial<TooltipRootProps> & JSX<TooltipRootElement>>;
171
+ export { TooltipRoot }
172
+ export { TooltipRoot as TooltipRoot_alias_1 }
173
+
174
+ declare const TooltipTrigger: Component<Partial<TooltipTriggerProps> & JSX<TooltipTriggerElement>>;
175
+ export { TooltipTrigger }
176
+ export { TooltipTrigger as TooltipTrigger_alias_1 }
177
+
178
+ /**
179
+ * Accesses the value of a MaybeAccessor
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * access("foo") // => "foo"
184
+ * access(() => "foo") // => "foo"
185
+ * ```
186
+ */
187
+ export declare function toValue<T extends MaybeAccessor<any>>(v: T): MaybeAccessorValue<T>;
188
+
189
+ /**
190
+ * Calls the given handler whenever the editor document changes.
191
+ *
192
+ * @public
193
+ */
194
+ declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
195
+ export { useDocChange }
196
+ export { useDocChange as useDocChange_alias_1 }
197
+
198
+ /**
199
+ * Retrieves the editor instance from the nearest ProseKit component.
200
+ *
201
+ * @public
202
+ */
203
+ declare function useEditor<E extends Extension = any>(options?: {
204
+ /**
205
+ * Whether to update the component when the editor is mounted or editor state
206
+ * is updated.
207
+ *
208
+ * @default false
209
+ */
210
+ update?: boolean;
211
+ }): () => Editor<E>;
212
+ export { useEditor }
213
+ export { useEditor as useEditor_alias_1 }
214
+
215
+ /**
216
+ * @internal
217
+ */
218
+ export declare function useEditorContext<E extends Extension>(): Editor<E> | null;
219
+
220
+ /**
221
+ * @internal
222
+ */
223
+ export declare function useEditorExtension(editorAccessor: MaybeAccessor<Editor> | undefined | null, extensionAccessor: Accessor<Extension | null>): void;
224
+
225
+ /**
226
+ * Add an extension to the editor.
227
+ */
228
+ declare function useExtension(
229
+ /**
230
+ * The accessor to an extension to add to the editor. If it changes, the previous
231
+ * extension will be removed and the new one (if not null) will be added.
232
+ */
233
+ extension: Accessor<Extension | null>, options?: UseExtensionOptions): void;
234
+ export { useExtension }
235
+ export { useExtension as useExtension_alias_1 }
236
+
237
+ declare interface UseExtensionOptions {
238
+ /**
239
+ * The editor to add the extension to. If not provided, it will use the
240
+ * editor from the nearest `ProseKit` component.
241
+ */
242
+ editor?: MaybeAccessor<Editor>;
243
+ /**
244
+ * Optional priority to add the extension with.
245
+ */
246
+ priority?: Priority;
247
+ }
248
+ export { UseExtensionOptions }
249
+ export { UseExtensionOptions as UseExtensionOptions_alias_1 }
250
+
251
+ declare function useKeymap(keymap: () => Keymap, options?: UseExtensionOptions): void;
252
+ export { useKeymap }
253
+ export { useKeymap as useKeymap_alias_1 }
254
+
255
+ /**
256
+ * @internal
257
+ */
258
+ export declare function usePriorityExtension<T extends Extension = Extension>(extension: () => T | null, priority?: Priority | null): () => T | null;
259
+
260
+ /**
261
+ * Calls the given handler whenever the editor state changes.
262
+ *
263
+ * @public
264
+ */
265
+ declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
266
+ export { useStateUpdate }
267
+ export { useStateUpdate as useStateUpdate_alias_1 }
268
+
269
+ export { }
@@ -0,0 +1,12 @@
1
+ // src/contexts/editor-context.ts
2
+ import { createContext, useContext } from "solid-js";
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,26 @@
1
+ import {
2
+ useEditorContext
3
+ } from "./chunk-XXXIBXNC.js";
4
+
5
+ // src/components/create-component.ts
6
+ import h from "solid-js/h";
7
+ function createComponent(tagName, defaultProps) {
8
+ const propertyNames = Object.keys(defaultProps);
9
+ const hasEditor = Object.hasOwn(defaultProps, "editor");
10
+ const Component = (props) => {
11
+ const p = {};
12
+ for (const key of Object.keys(props)) {
13
+ p[propertyNames.includes(key) ? "prop:" + key : key] = () => props[key];
14
+ }
15
+ const editor = useEditorContext();
16
+ if (hasEditor && editor) {
17
+ p["prop:editor"] = () => props["editor"] || editor;
18
+ }
19
+ return h(tagName, p);
20
+ };
21
+ return Component;
22
+ }
23
+
24
+ export {
25
+ createComponent
26
+ };
@@ -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,46 @@
1
+ import {
2
+ createComponent
3
+ } from "./chunk-Z3TWLQOI.js";
4
+ import "./chunk-XXXIBXNC.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
+ defaultAutocompleteEmptyProps
13
+ );
14
+
15
+ // src/components/autocomplete/autocomplete-item.gen.ts
16
+ import {
17
+ defaultAutocompleteItemProps
18
+ } from "@prosekit/web/autocomplete";
19
+ var AutocompleteItem = createComponent(
20
+ "prosekit-autocomplete-item",
21
+ defaultAutocompleteItemProps
22
+ );
23
+
24
+ // src/components/autocomplete/autocomplete-list.gen.ts
25
+ import {
26
+ defaultAutocompleteListProps
27
+ } from "@prosekit/web/autocomplete";
28
+ var AutocompleteList = createComponent(
29
+ "prosekit-autocomplete-list",
30
+ defaultAutocompleteListProps
31
+ );
32
+
33
+ // src/components/autocomplete/autocomplete-popover.gen.ts
34
+ import {
35
+ defaultAutocompletePopoverProps
36
+ } from "@prosekit/web/autocomplete";
37
+ var AutocompletePopover = createComponent(
38
+ "prosekit-autocomplete-popover",
39
+ defaultAutocompletePopoverProps
40
+ );
41
+ export {
42
+ AutocompleteEmpty,
43
+ AutocompleteItem,
44
+ AutocompleteList,
45
+ AutocompletePopover
46
+ };
@@ -0,0 +1,2 @@
1
+ export { BlockDragHandle_alias_1 as BlockDragHandle } from './_tsup-dts-rollup';
2
+ export { BlockPopover_alias_1 as BlockPopover } from './_tsup-dts-rollup';
@@ -0,0 +1,26 @@
1
+ import {
2
+ createComponent
3
+ } from "./chunk-Z3TWLQOI.js";
4
+ import "./chunk-XXXIBXNC.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
+ defaultBlockDragHandleProps
13
+ );
14
+
15
+ // src/components/block-handle/block-popover.gen.ts
16
+ import {
17
+ defaultBlockPopoverProps
18
+ } from "@prosekit/web/block-handle";
19
+ var BlockPopover = createComponent(
20
+ "prosekit-block-popover",
21
+ defaultBlockPopoverProps
22
+ );
23
+ export {
24
+ BlockDragHandle,
25
+ BlockPopover
26
+ };
@@ -0,0 +1 @@
1
+ export { InlinePopover } from './_tsup-dts-rollup';
@@ -0,0 +1,16 @@
1
+ import {
2
+ createComponent
3
+ } from "./chunk-Z3TWLQOI.js";
4
+ import "./chunk-XXXIBXNC.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
+ defaultInlinePopoverProps
13
+ );
14
+ export {
15
+ InlinePopover
16
+ };
@@ -0,0 +1,3 @@
1
+ export { PopoverContent } from './_tsup-dts-rollup';
2
+ export { PopoverRoot } from './_tsup-dts-rollup';
3
+ export { PopoverTrigger } from './_tsup-dts-rollup';
@@ -0,0 +1,36 @@
1
+ import {
2
+ createComponent
3
+ } from "./chunk-Z3TWLQOI.js";
4
+ import "./chunk-XXXIBXNC.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
+ defaultPopoverContentProps
13
+ );
14
+
15
+ // src/components/popover/popover-root.gen.ts
16
+ import {
17
+ defaultPopoverRootProps
18
+ } from "@prosekit/web/popover";
19
+ var PopoverRoot = createComponent(
20
+ "prosekit-popover-root",
21
+ defaultPopoverRootProps
22
+ );
23
+
24
+ // src/components/popover/popover-trigger.gen.ts
25
+ import {
26
+ defaultPopoverTriggerProps
27
+ } from "@prosekit/web/popover";
28
+ var PopoverTrigger = createComponent(
29
+ "prosekit-popover-trigger",
30
+ defaultPopoverTriggerProps
31
+ );
32
+ export {
33
+ PopoverContent,
34
+ PopoverRoot,
35
+ PopoverTrigger
36
+ };
@@ -0,0 +1,2 @@
1
+ export { ResizableHandle } from './_tsup-dts-rollup';
2
+ export { ResizableRoot } from './_tsup-dts-rollup';
@@ -0,0 +1,26 @@
1
+ import {
2
+ createComponent
3
+ } from "./chunk-Z3TWLQOI.js";
4
+ import "./chunk-XXXIBXNC.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
+ defaultResizableHandleProps
13
+ );
14
+
15
+ // src/components/resizable/resizable-root.gen.ts
16
+ import {
17
+ defaultResizableRootProps
18
+ } from "@prosekit/web/resizable";
19
+ var ResizableRoot = createComponent(
20
+ "prosekit-resizable-root",
21
+ defaultResizableRootProps
22
+ );
23
+ export {
24
+ ResizableHandle,
25
+ ResizableRoot
26
+ };
@@ -0,0 +1,3 @@
1
+ export { TooltipContent } from './_tsup-dts-rollup';
2
+ export { TooltipRoot } from './_tsup-dts-rollup';
3
+ export { TooltipTrigger } from './_tsup-dts-rollup';
@@ -0,0 +1,36 @@
1
+ import {
2
+ createComponent
3
+ } from "./chunk-Z3TWLQOI.js";
4
+ import "./chunk-XXXIBXNC.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
+ defaultTooltipContentProps
13
+ );
14
+
15
+ // src/components/tooltip/tooltip-root.gen.ts
16
+ import {
17
+ defaultTooltipRootProps
18
+ } from "@prosekit/web/tooltip";
19
+ var TooltipRoot = createComponent(
20
+ "prosekit-tooltip-root",
21
+ defaultTooltipRootProps
22
+ );
23
+
24
+ // src/components/tooltip/tooltip-trigger.gen.ts
25
+ import {
26
+ defaultTooltipTriggerProps
27
+ } from "@prosekit/web/tooltip";
28
+ var TooltipTrigger = createComponent(
29
+ "prosekit-tooltip-trigger",
30
+ defaultTooltipTriggerProps
31
+ );
32
+ export {
33
+ TooltipContent,
34
+ TooltipRoot,
35
+ TooltipTrigger
36
+ };
@@ -0,0 +1,11 @@
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 { MaybeAccessor } from './_tsup-dts-rollup';
10
+ export { PropsWithChildren } from './_tsup-dts-rollup';
11
+ export { PropsWithClass } from './_tsup-dts-rollup';
@@ -0,0 +1,127 @@
1
+ import {
2
+ EditorContextProvider,
3
+ useEditorContext
4
+ } from "./chunk-XXXIBXNC.js";
5
+
6
+ // src/components/prosekit.ts
7
+ import { createComponent } from "solid-js";
8
+ var ProseKit = (props) => {
9
+ return createComponent(EditorContextProvider, {
10
+ get value() {
11
+ return props.editor;
12
+ },
13
+ get children() {
14
+ return props.children;
15
+ }
16
+ });
17
+ };
18
+
19
+ // src/hooks/use-editor.ts
20
+ import {
21
+ ProseKitError,
22
+ defineMountHandler,
23
+ defineUpdateHandler,
24
+ union
25
+ } from "@prosekit/core";
26
+ import { createEffect, createSignal } from "solid-js";
27
+ function useEditor(options) {
28
+ var _a;
29
+ const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
30
+ const editor = useEditorContext();
31
+ if (!editor) {
32
+ throw new ProseKitError(
33
+ "useEditor must be used within the ProseKit component"
34
+ );
35
+ }
36
+ const [depend, forceUpdate] = useForceUpdate();
37
+ createEffect(() => {
38
+ if (update) {
39
+ const extension = union([
40
+ defineMountHandler(forceUpdate),
41
+ defineUpdateHandler(forceUpdate)
42
+ ]);
43
+ return editor.use(extension);
44
+ }
45
+ }, [editor, update, forceUpdate]);
46
+ return () => {
47
+ depend();
48
+ return editor;
49
+ };
50
+ }
51
+ function useForceUpdate() {
52
+ return createSignal(void 0, { equals: false });
53
+ }
54
+
55
+ // src/hooks/use-extension.ts
56
+ import "@prosekit/core";
57
+ import "solid-js";
58
+
59
+ // src/hooks/use-editor-extension.ts
60
+ import { EditorNotFoundError } from "@prosekit/core";
61
+ import { createEffect as createEffect2, onCleanup } from "solid-js";
62
+
63
+ // src/utils/to-value.ts
64
+ function toValue(v) {
65
+ return typeof v === "function" && v.length === 0 ? v() : v;
66
+ }
67
+
68
+ // src/hooks/use-editor-extension.ts
69
+ function useEditorExtension(editorAccessor, extensionAccessor) {
70
+ const editorContext = useEditorContext();
71
+ createEffect2(() => {
72
+ const editor = toValue(editorAccessor) || toValue(editorContext);
73
+ const extension = extensionAccessor();
74
+ if (!editor) {
75
+ throw new EditorNotFoundError();
76
+ }
77
+ if (extension) {
78
+ onCleanup(editor.use(extension));
79
+ }
80
+ });
81
+ }
82
+
83
+ // src/hooks/use-priority-extension.ts
84
+ import { withPriority } from "@prosekit/core";
85
+ function usePriorityExtension(extension, priority) {
86
+ return () => {
87
+ const ext = extension();
88
+ return ext && priority ? withPriority(ext, priority) : ext;
89
+ };
90
+ }
91
+
92
+ // src/hooks/use-extension.ts
93
+ function useExtension(extension, options) {
94
+ useEditorExtension(
95
+ options == null ? void 0 : options.editor,
96
+ usePriorityExtension(extension, options == null ? void 0 : options.priority)
97
+ );
98
+ }
99
+
100
+ // src/hooks/use-keymap.ts
101
+ import { defineKeymap } from "@prosekit/core";
102
+ function useKeymap(keymap, options) {
103
+ const extension = () => defineKeymap(keymap());
104
+ return useExtension(extension, options);
105
+ }
106
+
107
+ // src/hooks/use-state-update.ts
108
+ import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
109
+ function useStateUpdate(handler, options) {
110
+ const extension = defineUpdateHandler2((view) => handler(view.state));
111
+ return useExtension(() => extension, options);
112
+ }
113
+
114
+ // src/hooks/use-doc-change.ts
115
+ import { defineDocChangeHandler } from "@prosekit/core";
116
+ function useDocChange(handler, options) {
117
+ const extension = defineDocChangeHandler((view) => handler(view.state.doc));
118
+ return useExtension(() => extension, options);
119
+ }
120
+ export {
121
+ ProseKit,
122
+ useDocChange,
123
+ useEditor,
124
+ useExtension,
125
+ useKeymap,
126
+ useStateUpdate
127
+ };
package/package.json ADDED
@@ -0,0 +1,117 @@
1
+ {
2
+ "name": "@prosekit/solid",
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/solid"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/ocavue/prosekit/issues"
20
+ },
21
+ "keywords": [
22
+ "ProseMirror"
23
+ ],
24
+ "sideEffects": false,
25
+ "main": "./dist/prosekit-solid.js",
26
+ "module": "./dist/prosekit-solid.js",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/prosekit-solid.d.ts",
30
+ "import": "./dist/prosekit-solid.js",
31
+ "default": "./dist/prosekit-solid.js"
32
+ },
33
+ "./autocomplete": {
34
+ "types": "./dist/prosekit-solid-autocomplete.d.ts",
35
+ "import": "./dist/prosekit-solid-autocomplete.js",
36
+ "default": "./dist/prosekit-solid-autocomplete.js"
37
+ },
38
+ "./block-handle": {
39
+ "types": "./dist/prosekit-solid-block-handle.d.ts",
40
+ "import": "./dist/prosekit-solid-block-handle.js",
41
+ "default": "./dist/prosekit-solid-block-handle.js"
42
+ },
43
+ "./inline-popover": {
44
+ "types": "./dist/prosekit-solid-inline-popover.d.ts",
45
+ "import": "./dist/prosekit-solid-inline-popover.js",
46
+ "default": "./dist/prosekit-solid-inline-popover.js"
47
+ },
48
+ "./popover": {
49
+ "types": "./dist/prosekit-solid-popover.d.ts",
50
+ "import": "./dist/prosekit-solid-popover.js",
51
+ "default": "./dist/prosekit-solid-popover.js"
52
+ },
53
+ "./resizable": {
54
+ "types": "./dist/prosekit-solid-resizable.d.ts",
55
+ "import": "./dist/prosekit-solid-resizable.js",
56
+ "default": "./dist/prosekit-solid-resizable.js"
57
+ },
58
+ "./tooltip": {
59
+ "types": "./dist/prosekit-solid-tooltip.d.ts",
60
+ "import": "./dist/prosekit-solid-tooltip.js",
61
+ "default": "./dist/prosekit-solid-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
+ },
72
+ "peerDependencies": {
73
+ "solid-js": ">= 1.7.0"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "solid-js": {
77
+ "optional": true
78
+ }
79
+ },
80
+ "devDependencies": {
81
+ "@prosekit/dev": "*",
82
+ "solid-js": "^1.8.16",
83
+ "tsup": "^8.0.2",
84
+ "typescript": "^5.4.5",
85
+ "vitest": "^1.5.0"
86
+ },
87
+ "scripts": {
88
+ "build:tsup": "tsup",
89
+ "build:tsc": "tsc -b tsconfig.json"
90
+ },
91
+ "types": "./dist/prosekit-solid.d.ts",
92
+ "typesVersions": {
93
+ "*": {
94
+ ".": [
95
+ "./dist/prosekit-solid.d.ts"
96
+ ],
97
+ "autocomplete": [
98
+ "./dist/prosekit-solid-autocomplete.d.ts"
99
+ ],
100
+ "block-handle": [
101
+ "./dist/prosekit-solid-block-handle.d.ts"
102
+ ],
103
+ "inline-popover": [
104
+ "./dist/prosekit-solid-inline-popover.d.ts"
105
+ ],
106
+ "popover": [
107
+ "./dist/prosekit-solid-popover.d.ts"
108
+ ],
109
+ "resizable": [
110
+ "./dist/prosekit-solid-resizable.d.ts"
111
+ ],
112
+ "tooltip": [
113
+ "./dist/prosekit-solid-tooltip.d.ts"
114
+ ]
115
+ }
116
+ }
117
+ }