@prosekit/solid 0.3.26 → 0.3.28
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 +60 -0
- package/dist/prosekit-solid.d.ts +4 -0
- package/dist/prosekit-solid.js +103 -46
- package/package.json +6 -5
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Accessor } from 'solid-js';
|
2
|
+
import type { Attrs } from '@prosekit/pm/model';
|
2
3
|
import { AutocompleteEmptyElement } from '@prosekit/web/autocomplete';
|
3
4
|
import { AutocompleteEmptyProps } from '@prosekit/web/autocomplete';
|
4
5
|
import { AutocompleteItemElement } from '@prosekit/web/autocomplete';
|
@@ -7,6 +8,7 @@ import { AutocompleteListElement } from '@prosekit/web/autocomplete';
|
|
7
8
|
import { AutocompleteListProps } from '@prosekit/web/autocomplete';
|
8
9
|
import { AutocompletePopoverElement } from '@prosekit/web/autocomplete';
|
9
10
|
import { AutocompletePopoverProps } from '@prosekit/web/autocomplete';
|
11
|
+
import { BaseNodeViewOptions } from '@prosekit/core';
|
10
12
|
import { BlockDragHandleElement } from '@prosekit/web/block-handle';
|
11
13
|
import { BlockDragHandleProps } from '@prosekit/web/block-handle';
|
12
14
|
import { BlockHandleAddElement } from '@prosekit/web/block-handle';
|
@@ -19,9 +21,12 @@ import { BlockPopoverElement } from '@prosekit/web/block-handle';
|
|
19
21
|
import { BlockPopoverProps } from '@prosekit/web/block-handle';
|
20
22
|
import { Component } from 'solid-js';
|
21
23
|
import { ContextProviderComponent } from 'solid-js';
|
24
|
+
import type { Decoration } from '@prosekit/pm/view';
|
25
|
+
import type { DecorationSource } from '@prosekit/pm/view';
|
22
26
|
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
23
27
|
import { Editor } from '@prosekit/core';
|
24
28
|
import type { EditorState } from '@prosekit/pm/state';
|
29
|
+
import type { EditorView } from '@prosekit/pm/view';
|
25
30
|
import { Extension } from '@prosekit/core';
|
26
31
|
import { InlinePopoverElement } from '@prosekit/web/inline-popover';
|
27
32
|
import { InlinePopoverProps } from '@prosekit/web/inline-popover';
|
@@ -99,12 +104,26 @@ declare const BlockPopover: Component<Partial<BlockPopoverProps> & JSX<BlockPopo
|
|
99
104
|
export { BlockPopover }
|
100
105
|
export { BlockPopover as BlockPopover_alias_1 }
|
101
106
|
|
107
|
+
/**
|
108
|
+
* @internal
|
109
|
+
*/
|
110
|
+
export declare function consumeSolidViews(): void;
|
111
|
+
|
102
112
|
export declare function createComponent<Props extends object, CustomElement extends HTMLElement>(tagName: string, defaultProps: Props): Component<Partial<Props> & JSX.HTMLAttributes<CustomElement>>;
|
103
113
|
|
104
114
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
105
115
|
|
106
116
|
export { default_alias_1 }
|
107
117
|
|
118
|
+
/**
|
119
|
+
* Defines a node view using a Solid component.
|
120
|
+
*
|
121
|
+
* @public
|
122
|
+
*/
|
123
|
+
declare function defineSolidNodeView(options: SolidNodeViewOptions): Extension;
|
124
|
+
export { defineSolidNodeView }
|
125
|
+
export { defineSolidNodeView as defineSolidNodeView_alias_1 }
|
126
|
+
|
108
127
|
/**
|
109
128
|
* @internal
|
110
129
|
*/
|
@@ -190,6 +209,47 @@ declare const ResizableRoot: Component<Partial<ResizableRootProps> & JSX<Resizab
|
|
190
209
|
export { ResizableRoot }
|
191
210
|
export { ResizableRoot as ResizableRoot_alias_1 }
|
192
211
|
|
212
|
+
/**
|
213
|
+
* @public
|
214
|
+
*/
|
215
|
+
declare type SolidNodeViewComponent = Component<SolidNodeViewProps>;
|
216
|
+
export { SolidNodeViewComponent }
|
217
|
+
export { SolidNodeViewComponent as SolidNodeViewComponent_alias_1 }
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Options for {@link defineSolidNodeView}.
|
221
|
+
*
|
222
|
+
* @public
|
223
|
+
*/
|
224
|
+
declare interface SolidNodeViewOptions extends BaseNodeViewOptions {
|
225
|
+
/**
|
226
|
+
* The name of the node type.
|
227
|
+
*/
|
228
|
+
name: string;
|
229
|
+
/**
|
230
|
+
* The Solid component to render the node.
|
231
|
+
*/
|
232
|
+
component: SolidNodeViewComponent;
|
233
|
+
}
|
234
|
+
export { SolidNodeViewOptions }
|
235
|
+
export { SolidNodeViewOptions as SolidNodeViewOptions_alias_1 }
|
236
|
+
|
237
|
+
/**
|
238
|
+
* @public
|
239
|
+
*/
|
240
|
+
declare interface SolidNodeViewProps {
|
241
|
+
contentRef: (node: HTMLElement | null) => void;
|
242
|
+
view: EditorView;
|
243
|
+
getPos: () => number | undefined;
|
244
|
+
setAttrs: (attrs: Attrs) => void;
|
245
|
+
node: ProseMirrorNode;
|
246
|
+
selected: boolean;
|
247
|
+
decorations: readonly Decoration[];
|
248
|
+
innerDecorations: DecorationSource;
|
249
|
+
}
|
250
|
+
export { SolidNodeViewProps }
|
251
|
+
export { SolidNodeViewProps as SolidNodeViewProps_alias_1 }
|
252
|
+
|
193
253
|
declare const TableHandleColumnRoot: Component<Partial<TableHandleColumnRootProps> & JSX<TableHandleColumnRootElement>>;
|
194
254
|
export { TableHandleColumnRoot }
|
195
255
|
export { TableHandleColumnRoot as TableHandleColumnRoot_alias_1 }
|
package/dist/prosekit-solid.d.ts
CHANGED
@@ -9,3 +9,7 @@ export { useDocChange } from './_tsup-dts-rollup';
|
|
9
9
|
export { MaybeAccessor } from './_tsup-dts-rollup';
|
10
10
|
export { PropsWithChildren } from './_tsup-dts-rollup';
|
11
11
|
export { PropsWithClass } from './_tsup-dts-rollup';
|
12
|
+
export { defineSolidNodeView } from './_tsup-dts-rollup';
|
13
|
+
export { SolidNodeViewComponent } from './_tsup-dts-rollup';
|
14
|
+
export { SolidNodeViewOptions } from './_tsup-dts-rollup';
|
15
|
+
export { SolidNodeViewProps } from './_tsup-dts-rollup';
|
package/dist/prosekit-solid.js
CHANGED
@@ -4,59 +4,28 @@ import {
|
|
4
4
|
} from "./chunk-XXXIBXNC.js";
|
5
5
|
|
6
6
|
// src/components/prosekit.ts
|
7
|
-
import {
|
8
|
-
|
9
|
-
return createComponent(EditorContextProvider, {
|
10
|
-
get value() {
|
11
|
-
return props.editor;
|
12
|
-
},
|
13
|
-
get children() {
|
14
|
-
return props.children;
|
15
|
-
}
|
16
|
-
});
|
17
|
-
};
|
7
|
+
import { ProsemirrorAdapterProvider } from "@prosemirror-adapter/solid";
|
8
|
+
import { createComponent as createComponent2 } from "solid-js";
|
18
9
|
|
19
|
-
// src/
|
10
|
+
// src/extensions/solid-node-view.ts
|
20
11
|
import {
|
21
|
-
|
22
|
-
|
23
|
-
defineUpdateHandler,
|
24
|
-
union
|
12
|
+
defineNodeViewComponent,
|
13
|
+
defineNodeViewFactory
|
25
14
|
} from "@prosekit/core";
|
26
|
-
import {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
}
|
15
|
+
import {
|
16
|
+
useNodeViewContext,
|
17
|
+
useNodeViewFactory
|
18
|
+
} from "@prosemirror-adapter/solid";
|
19
|
+
import {
|
20
|
+
createComponent,
|
21
|
+
createMemo
|
22
|
+
} from "solid-js";
|
54
23
|
|
55
24
|
// src/hooks/use-editor-extension.ts
|
56
25
|
import {
|
57
26
|
EditorNotFoundError
|
58
27
|
} from "@prosekit/core";
|
59
|
-
import { createEffect
|
28
|
+
import { createEffect, onCleanup } from "solid-js";
|
60
29
|
|
61
30
|
// src/utils/to-value.ts
|
62
31
|
function toValue(v) {
|
@@ -66,7 +35,7 @@ function toValue(v) {
|
|
66
35
|
// src/hooks/use-editor-extension.ts
|
67
36
|
function useEditorExtension(editorAccessor, extensionAccessor) {
|
68
37
|
const editorContext = useEditorContext();
|
69
|
-
|
38
|
+
createEffect(() => {
|
70
39
|
const editor = toValue(editorAccessor) || toValue(editorContext);
|
71
40
|
const extension = extensionAccessor();
|
72
41
|
if (!editor) {
|
@@ -95,6 +64,93 @@ function useExtension(extension, options) {
|
|
95
64
|
);
|
96
65
|
}
|
97
66
|
|
67
|
+
// src/extensions/solid-node-view.ts
|
68
|
+
function withNodeViewProps(component) {
|
69
|
+
return function NodeViewPropsWrapper() {
|
70
|
+
const props = useNodeViewContext();
|
71
|
+
return createComponent(component, props());
|
72
|
+
};
|
73
|
+
}
|
74
|
+
function consumeSolidViews() {
|
75
|
+
const nodeViewFactory = useNodeViewFactory();
|
76
|
+
const extension = createMemo(
|
77
|
+
() => defineSolidNodeViewFactory(nodeViewFactory),
|
78
|
+
[nodeViewFactory]
|
79
|
+
);
|
80
|
+
useExtension(extension);
|
81
|
+
}
|
82
|
+
function defineSolidNodeView(options) {
|
83
|
+
const { name, component, ...userOptions } = options;
|
84
|
+
const args = {
|
85
|
+
...userOptions,
|
86
|
+
component: withNodeViewProps(component)
|
87
|
+
};
|
88
|
+
return defineNodeViewComponent({
|
89
|
+
group: "solid",
|
90
|
+
name,
|
91
|
+
args
|
92
|
+
});
|
93
|
+
}
|
94
|
+
function defineSolidNodeViewFactory(factory) {
|
95
|
+
return defineNodeViewFactory({
|
96
|
+
group: "solid",
|
97
|
+
factory
|
98
|
+
});
|
99
|
+
}
|
100
|
+
|
101
|
+
// src/components/prosekit.ts
|
102
|
+
var ProseKit = (props) => {
|
103
|
+
return createComponent2(ProsemirrorAdapterProvider, {
|
104
|
+
get children() {
|
105
|
+
return createComponent2(EditorContextProvider, {
|
106
|
+
get value() {
|
107
|
+
return props.editor;
|
108
|
+
},
|
109
|
+
get children() {
|
110
|
+
consumeSolidViews();
|
111
|
+
return props.children;
|
112
|
+
}
|
113
|
+
});
|
114
|
+
}
|
115
|
+
});
|
116
|
+
};
|
117
|
+
|
118
|
+
// src/hooks/use-editor.ts
|
119
|
+
import {
|
120
|
+
ProseKitError,
|
121
|
+
defineMountHandler,
|
122
|
+
defineUpdateHandler,
|
123
|
+
union
|
124
|
+
} from "@prosekit/core";
|
125
|
+
import { createEffect as createEffect2, createSignal } from "solid-js";
|
126
|
+
function useEditor(options) {
|
127
|
+
var _a;
|
128
|
+
const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
|
129
|
+
const editor = useEditorContext();
|
130
|
+
if (!editor) {
|
131
|
+
throw new ProseKitError(
|
132
|
+
"useEditor must be used within the ProseKit component"
|
133
|
+
);
|
134
|
+
}
|
135
|
+
const [depend, forceUpdate] = useForceUpdate();
|
136
|
+
createEffect2(() => {
|
137
|
+
if (update) {
|
138
|
+
const extension = union(
|
139
|
+
defineMountHandler(forceUpdate),
|
140
|
+
defineUpdateHandler(forceUpdate)
|
141
|
+
);
|
142
|
+
return editor.use(extension);
|
143
|
+
}
|
144
|
+
}, [editor, update, forceUpdate]);
|
145
|
+
return () => {
|
146
|
+
depend();
|
147
|
+
return editor;
|
148
|
+
};
|
149
|
+
}
|
150
|
+
function useForceUpdate() {
|
151
|
+
return createSignal(void 0, { equals: false });
|
152
|
+
}
|
153
|
+
|
98
154
|
// src/hooks/use-keymap.ts
|
99
155
|
import { defineKeymap } from "@prosekit/core";
|
100
156
|
function useKeymap(keymap, options) {
|
@@ -117,6 +173,7 @@ function useDocChange(handler, options) {
|
|
117
173
|
}
|
118
174
|
export {
|
119
175
|
ProseKit,
|
176
|
+
defineSolidNodeView,
|
120
177
|
useDocChange,
|
121
178
|
useEditor,
|
122
179
|
useExtension,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/solid",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.3.
|
4
|
+
"version": "0.3.28",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -70,9 +70,10 @@
|
|
70
70
|
"dist"
|
71
71
|
],
|
72
72
|
"dependencies": {
|
73
|
+
"@prosemirror-adapter/solid": "^0.2.6",
|
73
74
|
"@prosekit/core": "^0.7.11",
|
74
75
|
"@prosekit/pm": "^0.1.8",
|
75
|
-
"@prosekit/web": "^0.3.
|
76
|
+
"@prosekit/web": "^0.3.18"
|
76
77
|
},
|
77
78
|
"peerDependencies": {
|
78
79
|
"solid-js": ">= 1.7.0"
|
@@ -84,9 +85,9 @@
|
|
84
85
|
},
|
85
86
|
"devDependencies": {
|
86
87
|
"solid-js": "^1.8.22",
|
87
|
-
"tsup": "^8.
|
88
|
-
"typescript": "^5.
|
89
|
-
"vitest": "^2.
|
88
|
+
"tsup": "^8.3.0",
|
89
|
+
"typescript": "^5.6.2",
|
90
|
+
"vitest": "^2.1.1",
|
90
91
|
"@prosekit/dev": "0.0.0"
|
91
92
|
},
|
92
93
|
"scripts": {
|