@prosekit/solid 0.1.2 → 0.1.3
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 +38 -44
- package/dist/prosekit-solid.d.ts +2 -0
- package/dist/prosekit-solid.js +30 -5
- package/package.json +2 -2
- package/src/index.ts +1 -0
@@ -17,16 +17,14 @@ import { Options } from 'tsup';
|
|
17
17
|
import { ParentProps } from 'solid-js';
|
18
18
|
import { PopoverOptions } from '@prosekit/lit/autocomplete-popover';
|
19
19
|
import type { PopoverProps as PopoverProps_2 } from '@prosekit/lit/popover';
|
20
|
+
import { Priority } from '@prosekit/core';
|
20
21
|
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
21
22
|
|
22
23
|
declare const AutocompleteEmpty: Component<AutocompleteEmptyProps>;
|
23
24
|
export { AutocompleteEmpty }
|
24
25
|
export { AutocompleteEmpty as AutocompleteEmpty_alias_1 }
|
25
26
|
|
26
|
-
declare type AutocompleteEmptyProps =
|
27
|
-
class?: string;
|
28
|
-
children?: JSXElement;
|
29
|
-
} & AutocompleteEmptyProps_2;
|
27
|
+
declare type AutocompleteEmptyProps = PropsWithChildren<PropsWithClass<AutocompleteEmptyProps_2>>;
|
30
28
|
export { AutocompleteEmptyProps }
|
31
29
|
export { AutocompleteEmptyProps as AutocompleteEmptyProps_alias_1 }
|
32
30
|
|
@@ -34,10 +32,7 @@ declare const AutocompleteItem: Component<AutocompleteItemProps>;
|
|
34
32
|
export { AutocompleteItem }
|
35
33
|
export { AutocompleteItem as AutocompleteItem_alias_1 }
|
36
34
|
|
37
|
-
declare type AutocompleteItemProps =
|
38
|
-
class?: string;
|
39
|
-
children?: JSXElement;
|
40
|
-
} & AutocompleteItemProps_2;
|
35
|
+
declare type AutocompleteItemProps = PropsWithChildren<PropsWithClass<AutocompleteItemProps_2>>;
|
41
36
|
export { AutocompleteItemProps }
|
42
37
|
export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
|
43
38
|
|
@@ -45,10 +40,7 @@ declare const AutocompleteList: Component<AutocompleteListProps>;
|
|
45
40
|
export { AutocompleteList }
|
46
41
|
export { AutocompleteList as AutocompleteList_alias_1 }
|
47
42
|
|
48
|
-
declare type AutocompleteListProps =
|
49
|
-
class?: string;
|
50
|
-
children?: JSXElement;
|
51
|
-
} & AutocompleteListProps_2;
|
43
|
+
declare type AutocompleteListProps = PropsWithChildren<PropsWithClass<AutocompleteListProps_2>>;
|
52
44
|
export { AutocompleteListProps }
|
53
45
|
export { AutocompleteListProps as AutocompleteListProps_alias_1 }
|
54
46
|
|
@@ -56,10 +48,7 @@ declare const AutocompletePopover: Component<AutocompletePopoverProps>;
|
|
56
48
|
export { AutocompletePopover }
|
57
49
|
export { AutocompletePopover as AutocompletePopover_alias_1 }
|
58
50
|
|
59
|
-
declare type AutocompletePopoverProps =
|
60
|
-
class?: string;
|
61
|
-
children?: JSXElement;
|
62
|
-
} & AutocompletePopoverProps_2;
|
51
|
+
declare type AutocompletePopoverProps = PropsWithChildren<PropsWithClass<AutocompletePopoverProps_2>>;
|
63
52
|
export { AutocompletePopoverProps }
|
64
53
|
export { AutocompletePopoverProps as AutocompletePopoverProps_alias_1 }
|
65
54
|
|
@@ -67,29 +56,17 @@ export declare const ComboBox: Component<ComboBoxProps>;
|
|
67
56
|
|
68
57
|
export declare const ComboBoxInput: Component<ComboBoxInputProps>;
|
69
58
|
|
70
|
-
export declare type ComboBoxInputProps =
|
71
|
-
class?: string;
|
72
|
-
children?: JSXElement;
|
73
|
-
} & ComboBoxInputProps_2;
|
59
|
+
export declare type ComboBoxInputProps = PropsWithChildren<PropsWithClass<ComboBoxInputProps_2>>;
|
74
60
|
|
75
61
|
export declare const ComboBoxItem: Component<ComboBoxItemProps>;
|
76
62
|
|
77
|
-
export declare type ComboBoxItemProps =
|
78
|
-
class?: string;
|
79
|
-
children?: JSXElement;
|
80
|
-
} & ComboBoxItemProps_2;
|
63
|
+
export declare type ComboBoxItemProps = PropsWithChildren<PropsWithClass<ComboBoxItemProps_2>>;
|
81
64
|
|
82
65
|
export declare const ComboBoxList: Component<ComboBoxListProps>;
|
83
66
|
|
84
|
-
export declare type ComboBoxListProps =
|
85
|
-
class?: string;
|
86
|
-
children?: JSXElement;
|
87
|
-
} & ComboBoxListProps_2;
|
67
|
+
export declare type ComboBoxListProps = PropsWithChildren<PropsWithClass<ComboBoxListProps_2>>;
|
88
68
|
|
89
|
-
export declare type ComboBoxProps =
|
90
|
-
class?: string;
|
91
|
-
children?: JSXElement;
|
92
|
-
} & ComboBoxProps_2;
|
69
|
+
export declare type ComboBoxProps = PropsWithChildren<PropsWithClass<ComboBoxProps_2>>;
|
93
70
|
|
94
71
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
95
72
|
|
@@ -105,19 +82,31 @@ export declare function forceProps<T extends Record<string, any>>(props: T): T;
|
|
105
82
|
|
106
83
|
export declare const InlinePopover: Component<InlinePopoverProps>;
|
107
84
|
|
108
|
-
export declare type InlinePopoverProps =
|
109
|
-
class?: string;
|
110
|
-
children?: JSXElement;
|
111
|
-
} & InlinePopoverProps_2;
|
85
|
+
export declare type InlinePopoverProps = PropsWithChildren<PropsWithClass<InlinePopoverProps_2>>;
|
112
86
|
|
113
87
|
export declare const Popover: Component<PopoverProps>;
|
114
88
|
|
115
89
|
export { PopoverOptions }
|
116
90
|
|
117
|
-
export declare type PopoverProps =
|
118
|
-
|
119
|
-
|
120
|
-
|
91
|
+
export declare type PopoverProps = PropsWithChildren<PropsWithClass<PopoverProps_2>>;
|
92
|
+
|
93
|
+
/**
|
94
|
+
* @internal
|
95
|
+
*/
|
96
|
+
declare type PropsWithChildren<P = unknown> = P & {
|
97
|
+
children?: JSXElement | undefined;
|
98
|
+
};
|
99
|
+
export { PropsWithChildren }
|
100
|
+
export { PropsWithChildren as PropsWithChildren_alias_1 }
|
101
|
+
|
102
|
+
/**
|
103
|
+
* @internal
|
104
|
+
*/
|
105
|
+
declare type PropsWithClass<P = unknown> = P & {
|
106
|
+
class?: string | undefined;
|
107
|
+
};
|
108
|
+
export { PropsWithClass }
|
109
|
+
export { PropsWithClass as PropsWithClass_alias_1 }
|
121
110
|
|
122
111
|
declare const ProseKit: Component<ProseKitProps>;
|
123
112
|
export { ProseKit }
|
@@ -140,15 +129,20 @@ export declare interface UseEditorOptions {
|
|
140
129
|
/**
|
141
130
|
* Add an extension to the editor.
|
142
131
|
*
|
143
|
-
* It accepts an optional extension. If the extension is changed,
|
144
|
-
* extension will be removed and the new one (if not null) will be
|
132
|
+
* It accepts an accessor to an optional extension. If the extension is changed,
|
133
|
+
* the previous extension will be removed and the new one (if not null) will be
|
134
|
+
* added.
|
145
135
|
*/
|
146
|
-
declare function useExtension<T extends Extension = Extension>(extension: T | null): void;
|
136
|
+
declare function useExtension<T extends Extension = Extension>(extension: (T | null) | (() => T | null)): void;
|
147
137
|
export { useExtension }
|
148
138
|
export { useExtension as useExtension_alias_1 }
|
149
139
|
|
150
|
-
declare function useKeymap(keymap: Keymap)
|
140
|
+
declare function useKeymap(keymap: Keymap | (() => Keymap), options?: {
|
141
|
+
priority?: Priority;
|
142
|
+
}): void;
|
151
143
|
export { useKeymap }
|
152
144
|
export { useKeymap as useKeymap_alias_1 }
|
153
145
|
|
146
|
+
export declare function usePriorityExtension<T extends Extension = Extension>(extension: () => T | null, priority?: Priority | null): void;
|
147
|
+
|
154
148
|
export { }
|
package/dist/prosekit-solid.d.ts
CHANGED
@@ -3,3 +3,5 @@ export { ProseKitProps } from './_tsup-dts-rollup';
|
|
3
3
|
export { useEditor } from './_tsup-dts-rollup';
|
4
4
|
export { useExtension } from './_tsup-dts-rollup';
|
5
5
|
export { useKeymap } from './_tsup-dts-rollup';
|
6
|
+
export { PropsWithChildren } from './_tsup-dts-rollup';
|
7
|
+
export { PropsWithClass } from './_tsup-dts-rollup';
|
package/dist/prosekit-solid.js
CHANGED
@@ -54,19 +54,44 @@ function useForceUpdate() {
|
|
54
54
|
import "@prosekit/core";
|
55
55
|
import { createEffect as createEffect2, onCleanup } from "solid-js";
|
56
56
|
function useExtension(extension) {
|
57
|
+
if (typeof extension !== "function") {
|
58
|
+
console.warn(
|
59
|
+
"useExtension should accept a function that returns an extension or null"
|
60
|
+
);
|
61
|
+
return useExtension(() => extension);
|
62
|
+
}
|
63
|
+
const extensionAccessor = extension;
|
57
64
|
const editor = useEditor();
|
58
65
|
createEffect2(() => {
|
59
|
-
|
60
|
-
|
66
|
+
const extension2 = extensionAccessor();
|
67
|
+
if (extension2) {
|
68
|
+
onCleanup(editor().use(extension2));
|
61
69
|
}
|
62
70
|
});
|
63
71
|
}
|
64
72
|
|
65
73
|
// src/hooks/use-keymap.ts
|
66
74
|
import { defineKeymap } from "@prosekit/core";
|
67
|
-
|
68
|
-
|
69
|
-
|
75
|
+
|
76
|
+
// src/hooks/use-priority-extension.ts
|
77
|
+
import { withPriority } from "@prosekit/core";
|
78
|
+
function usePriorityExtension(extension, priority) {
|
79
|
+
const extensionWithPriority = () => {
|
80
|
+
const ext = extension();
|
81
|
+
return ext && priority ? withPriority(ext, priority) : ext;
|
82
|
+
};
|
83
|
+
return useExtension(extensionWithPriority);
|
84
|
+
}
|
85
|
+
|
86
|
+
// src/hooks/use-keymap.ts
|
87
|
+
function useKeymap(keymap, options) {
|
88
|
+
if (typeof keymap !== "function") {
|
89
|
+
console.warn(
|
90
|
+
"useKeymap should accept a function that returns a keymap object"
|
91
|
+
);
|
92
|
+
return useKeymap(() => keymap);
|
93
|
+
}
|
94
|
+
return usePriorityExtension(() => defineKeymap(keymap()), options == null ? void 0 : options.priority);
|
70
95
|
}
|
71
96
|
export {
|
72
97
|
ProseKit,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/solid",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.3",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -98,7 +98,7 @@
|
|
98
98
|
},
|
99
99
|
"devDependencies": {
|
100
100
|
"@prosekit/dev": "*",
|
101
|
-
"solid-js": "^1.8.
|
101
|
+
"solid-js": "^1.8.6",
|
102
102
|
"tsup": "^8.0.1",
|
103
103
|
"typescript": "^5.3.2",
|
104
104
|
"vitest": "^0.34.6"
|
package/src/index.ts
CHANGED
@@ -2,3 +2,4 @@ export { ProseKit, type ProseKitProps } from './components/prosekit'
|
|
2
2
|
export { useEditor } from './hooks/use-editor'
|
3
3
|
export { useExtension } from './hooks/use-extension'
|
4
4
|
export { useKeymap } from './hooks/use-keymap'
|
5
|
+
export type { PropsWithChildren, PropsWithClass } from './types'
|