@prosekit/solid 0.1.2 → 0.1.4

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.
@@ -17,16 +17,13 @@ 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 { UserProjectConfigExport } from 'vitest/dist/config.js';
20
+ import { Priority } from '@prosekit/core';
21
21
 
22
22
  declare const AutocompleteEmpty: Component<AutocompleteEmptyProps>;
23
23
  export { AutocompleteEmpty }
24
24
  export { AutocompleteEmpty as AutocompleteEmpty_alias_1 }
25
25
 
26
- declare type AutocompleteEmptyProps = {
27
- class?: string;
28
- children?: JSXElement;
29
- } & AutocompleteEmptyProps_2;
26
+ declare type AutocompleteEmptyProps = PropsWithChildren<PropsWithClass<AutocompleteEmptyProps_2>>;
30
27
  export { AutocompleteEmptyProps }
31
28
  export { AutocompleteEmptyProps as AutocompleteEmptyProps_alias_1 }
32
29
 
@@ -34,10 +31,7 @@ declare const AutocompleteItem: Component<AutocompleteItemProps>;
34
31
  export { AutocompleteItem }
35
32
  export { AutocompleteItem as AutocompleteItem_alias_1 }
36
33
 
37
- declare type AutocompleteItemProps = {
38
- class?: string;
39
- children?: JSXElement;
40
- } & AutocompleteItemProps_2;
34
+ declare type AutocompleteItemProps = PropsWithChildren<PropsWithClass<AutocompleteItemProps_2>>;
41
35
  export { AutocompleteItemProps }
42
36
  export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
43
37
 
@@ -45,10 +39,7 @@ declare const AutocompleteList: Component<AutocompleteListProps>;
45
39
  export { AutocompleteList }
46
40
  export { AutocompleteList as AutocompleteList_alias_1 }
47
41
 
48
- declare type AutocompleteListProps = {
49
- class?: string;
50
- children?: JSXElement;
51
- } & AutocompleteListProps_2;
42
+ declare type AutocompleteListProps = PropsWithChildren<PropsWithClass<AutocompleteListProps_2>>;
52
43
  export { AutocompleteListProps }
53
44
  export { AutocompleteListProps as AutocompleteListProps_alias_1 }
54
45
 
@@ -56,10 +47,7 @@ declare const AutocompletePopover: Component<AutocompletePopoverProps>;
56
47
  export { AutocompletePopover }
57
48
  export { AutocompletePopover as AutocompletePopover_alias_1 }
58
49
 
59
- declare type AutocompletePopoverProps = {
60
- class?: string;
61
- children?: JSXElement;
62
- } & AutocompletePopoverProps_2;
50
+ declare type AutocompletePopoverProps = PropsWithChildren<PropsWithClass<AutocompletePopoverProps_2>>;
63
51
  export { AutocompletePopoverProps }
64
52
  export { AutocompletePopoverProps as AutocompletePopoverProps_alias_1 }
65
53
 
@@ -67,33 +55,25 @@ export declare const ComboBox: Component<ComboBoxProps>;
67
55
 
68
56
  export declare const ComboBoxInput: Component<ComboBoxInputProps>;
69
57
 
70
- export declare type ComboBoxInputProps = {
71
- class?: string;
72
- children?: JSXElement;
73
- } & ComboBoxInputProps_2;
58
+ export declare type ComboBoxInputProps = PropsWithChildren<PropsWithClass<ComboBoxInputProps_2>>;
74
59
 
75
60
  export declare const ComboBoxItem: Component<ComboBoxItemProps>;
76
61
 
77
- export declare type ComboBoxItemProps = {
78
- class?: string;
79
- children?: JSXElement;
80
- } & ComboBoxItemProps_2;
62
+ export declare type ComboBoxItemProps = PropsWithChildren<PropsWithClass<ComboBoxItemProps_2>>;
81
63
 
82
64
  export declare const ComboBoxList: Component<ComboBoxListProps>;
83
65
 
84
- export declare type ComboBoxListProps = {
85
- class?: string;
86
- children?: JSXElement;
87
- } & ComboBoxListProps_2;
66
+ export declare type ComboBoxListProps = PropsWithChildren<PropsWithClass<ComboBoxListProps_2>>;
88
67
 
89
- export declare type ComboBoxProps = {
90
- class?: string;
91
- children?: JSXElement;
92
- } & ComboBoxProps_2;
68
+ export declare type ComboBoxProps = PropsWithChildren<PropsWithClass<ComboBoxProps_2>>;
93
69
 
94
70
  export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
95
71
 
96
- export declare const default_alias_1: UserProjectConfigExport;
72
+ export declare const default_alias_1: {
73
+ test: {
74
+ environment: "jsdom";
75
+ };
76
+ };
97
77
 
98
78
  declare interface EditorContext {
99
79
  editor: Editor;
@@ -105,19 +85,31 @@ export declare function forceProps<T extends Record<string, any>>(props: T): T;
105
85
 
106
86
  export declare const InlinePopover: Component<InlinePopoverProps>;
107
87
 
108
- export declare type InlinePopoverProps = {
109
- class?: string;
110
- children?: JSXElement;
111
- } & InlinePopoverProps_2;
88
+ export declare type InlinePopoverProps = PropsWithChildren<PropsWithClass<InlinePopoverProps_2>>;
112
89
 
113
90
  export declare const Popover: Component<PopoverProps>;
114
91
 
115
92
  export { PopoverOptions }
116
93
 
117
- export declare type PopoverProps = {
118
- class?: string;
119
- children?: JSXElement;
120
- } & PopoverProps_2;
94
+ export declare type PopoverProps = PropsWithChildren<PropsWithClass<PopoverProps_2>>;
95
+
96
+ /**
97
+ * @internal
98
+ */
99
+ declare type PropsWithChildren<P = unknown> = P & {
100
+ children?: JSXElement | undefined;
101
+ };
102
+ export { PropsWithChildren }
103
+ export { PropsWithChildren as PropsWithChildren_alias_1 }
104
+
105
+ /**
106
+ * @internal
107
+ */
108
+ declare type PropsWithClass<P = unknown> = P & {
109
+ class?: string | undefined;
110
+ };
111
+ export { PropsWithClass }
112
+ export { PropsWithClass as PropsWithClass_alias_1 }
121
113
 
122
114
  declare const ProseKit: Component<ProseKitProps>;
123
115
  export { ProseKit }
@@ -129,26 +121,29 @@ declare type ProseKitProps = ParentProps<{
129
121
  export { ProseKitProps }
130
122
  export { ProseKitProps as ProseKitProps_alias_1 }
131
123
 
132
- declare function useEditor<E extends Extension = any>(options?: UseEditorOptions): () => Editor<E>;
124
+ declare function useEditor<E extends Extension = any>(options?: {
125
+ update?: boolean;
126
+ }): () => Editor<E>;
133
127
  export { useEditor }
134
128
  export { useEditor as useEditor_alias_1 }
135
129
 
136
- export declare interface UseEditorOptions {
137
- update?: boolean;
138
- }
139
-
140
130
  /**
141
131
  * Add an extension to the editor.
142
132
  *
143
- * It accepts an optional extension. If the extension is changed, the previous
144
- * extension will be removed and the new one (if not null) will be added.
133
+ * It accepts an accessor to an optional extension. If the extension is changed,
134
+ * the previous extension will be removed and the new one (if not null) will be
135
+ * added.
145
136
  */
146
- declare function useExtension<T extends Extension = Extension>(extension: T | null): void;
137
+ declare function useExtension<T extends Extension = Extension>(extension: (T | null) | (() => T | null)): void;
147
138
  export { useExtension }
148
139
  export { useExtension as useExtension_alias_1 }
149
140
 
150
- declare function useKeymap(keymap: Keymap): void;
141
+ declare function useKeymap(keymap: Keymap | (() => Keymap), options?: {
142
+ priority?: Priority;
143
+ }): void;
151
144
  export { useKeymap }
152
145
  export { useKeymap as useKeymap_alias_1 }
153
146
 
147
+ export declare function usePriorityExtension<T extends Extension = Extension>(extension: () => T | null, priority?: Priority | null): void;
148
+
154
149
  export { }
@@ -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';
@@ -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
- if (extension) {
60
- onCleanup(editor().use(extension));
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
- function useKeymap(keymap) {
68
- const extension = defineKeymap(keymap);
69
- useExtension(extension);
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.2",
4
+ "version": "0.1.4",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -85,8 +85,8 @@
85
85
  "dist"
86
86
  ],
87
87
  "dependencies": {
88
- "@prosekit/core": "^0.1.0",
89
- "@prosekit/lit": "^0.1.0"
88
+ "@prosekit/core": "^0.2.0",
89
+ "@prosekit/lit": "^0.1.5"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "solid-js": ">= 1.7.0"
@@ -98,10 +98,10 @@
98
98
  },
99
99
  "devDependencies": {
100
100
  "@prosekit/dev": "*",
101
- "solid-js": "^1.8.5",
101
+ "solid-js": "^1.8.7",
102
102
  "tsup": "^8.0.1",
103
- "typescript": "^5.3.2",
104
- "vitest": "^0.34.6"
103
+ "typescript": "^5.3.3",
104
+ "vitest": "^1.1.0"
105
105
  },
106
106
  "scripts": {
107
107
  "build:tsup": "tsup",
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'