@prosekit/solid 0.4.5 → 0.4.7

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.
@@ -1,5 +1,4 @@
1
1
  import { Accessor } from 'solid-js';
2
- import type { Attrs } from '@prosekit/pm/model';
3
2
  import { AutocompleteEmptyElement } from '@prosekit/web/autocomplete';
4
3
  import { AutocompleteEmptyEvents } from '@prosekit/web/autocomplete';
5
4
  import { AutocompleteEmptyProps as AutocompleteEmptyProps_2 } from '@prosekit/web/autocomplete';
@@ -12,7 +11,6 @@ import { AutocompleteListProps as AutocompleteListProps_2 } from '@prosekit/web/
12
11
  import { AutocompletePopoverElement } from '@prosekit/web/autocomplete';
13
12
  import { AutocompletePopoverEvents } from '@prosekit/web/autocomplete';
14
13
  import { AutocompletePopoverProps as AutocompletePopoverProps_2 } from '@prosekit/web/autocomplete';
15
- import { BaseNodeViewOptions } from '@prosekit/core';
16
14
  import { BlockHandleAddElement } from '@prosekit/web/block-handle';
17
15
  import { BlockHandleAddEvents } from '@prosekit/web/block-handle';
18
16
  import { BlockHandleAddProps as BlockHandleAddProps_2 } from '@prosekit/web/block-handle';
@@ -24,12 +22,11 @@ import { BlockHandlePopoverEvents } from '@prosekit/web/block-handle';
24
22
  import { BlockHandlePopoverProps as BlockHandlePopoverProps_2 } from '@prosekit/web/block-handle';
25
23
  import { Component } from 'solid-js';
26
24
  import { ContextProviderComponent } from 'solid-js';
27
- import type { Decoration } from '@prosekit/pm/view';
28
- import type { DecorationSource } from '@prosekit/pm/view';
25
+ import type { CoreMarkViewUserOptions } from '@prosemirror-adapter/core';
26
+ import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core';
29
27
  import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
30
28
  import { Editor } from '@prosekit/core';
31
29
  import type { EditorState } from '@prosekit/pm/state';
32
- import type { EditorView } from '@prosekit/pm/view';
33
30
  import { Extension } from '@prosekit/core';
34
31
  import { InlinePopoverElement } from '@prosekit/web/inline-popover';
35
32
  import { InlinePopoverEvents } from '@prosekit/web/inline-popover';
@@ -37,6 +34,8 @@ import { InlinePopoverProps as InlinePopoverProps_2 } from '@prosekit/web/inline
37
34
  import { JSX } from 'solid-js';
38
35
  import type { JSXElement } from 'solid-js';
39
36
  import { Keymap } from '@prosekit/core';
37
+ import { MarkViewContextProps } from '@prosemirror-adapter/solid';
38
+ import { NodeViewContextProps } from '@prosemirror-adapter/solid';
40
39
  import { Options } from 'tsup';
41
40
  import { ParentProps } from 'solid-js';
42
41
  import { PopoverContentElement } from '@prosekit/web/popover';
@@ -174,7 +173,12 @@ export { BlockHandlePopoverProps as BlockHandlePopoverProps_alias_1 }
174
173
  /**
175
174
  * @internal
176
175
  */
177
- export declare function consumeSolidViews(): void;
176
+ export declare function consumeSolidMarkViews(): void;
177
+
178
+ /**
179
+ * @internal
180
+ */
181
+ export declare function consumeSolidNodeViews(): void;
178
182
 
179
183
  export declare function createComponent<Props extends object, CustomElement extends HTMLElement>(tagName: string, propNames: string[], eventNames: string[]): Component<Partial<Props> & JSX.HTMLAttributes<CustomElement>>;
180
184
 
@@ -194,6 +198,15 @@ export declare const default_alias: Options | Options[] | ((overrideOptions: Opt
194
198
 
195
199
  export { default_alias_1 }
196
200
 
201
+ /**
202
+ * Defines a mark view using a Solid component.
203
+ *
204
+ * @public
205
+ */
206
+ declare function defineSolidMarkView(options: SolidMarkViewOptions): Extension;
207
+ export { defineSolidMarkView }
208
+ export { defineSolidMarkView as defineSolidMarkView_alias_1 }
209
+
197
210
  /**
198
211
  * Defines a node view using a Solid component.
199
212
  *
@@ -336,6 +349,35 @@ declare interface ResizableRootProps extends Partial<CreateProps<ResizableRootPr
336
349
  export { ResizableRootProps }
337
350
  export { ResizableRootProps as ResizableRootProps_alias_1 }
338
351
 
352
+ /**
353
+ * @public
354
+ */
355
+ declare type SolidMarkViewComponent = Component<SolidMarkViewProps>;
356
+ export { SolidMarkViewComponent }
357
+ export { SolidMarkViewComponent as SolidMarkViewComponent_alias_1 }
358
+
359
+ /**
360
+ * Options for {@link defineSolidMarkView}.
361
+ *
362
+ * @public
363
+ */
364
+ declare interface SolidMarkViewOptions extends CoreMarkViewUserOptions<SolidMarkViewComponent> {
365
+ /**
366
+ * The name of the mark type.
367
+ */
368
+ name: string;
369
+ }
370
+ export { SolidMarkViewOptions }
371
+ export { SolidMarkViewOptions as SolidMarkViewOptions_alias_1 }
372
+
373
+ /**
374
+ * @public
375
+ */
376
+ declare interface SolidMarkViewProps extends MarkViewContextProps {
377
+ }
378
+ export { SolidMarkViewProps }
379
+ export { SolidMarkViewProps as SolidMarkViewProps_alias_1 }
380
+
339
381
  /**
340
382
  * @public
341
383
  */
@@ -348,15 +390,11 @@ export { SolidNodeViewComponent as SolidNodeViewComponent_alias_1 }
348
390
  *
349
391
  * @public
350
392
  */
351
- declare interface SolidNodeViewOptions extends BaseNodeViewOptions {
393
+ declare interface SolidNodeViewOptions extends CoreNodeViewUserOptions<SolidNodeViewComponent> {
352
394
  /**
353
395
  * The name of the node type.
354
396
  */
355
397
  name: string;
356
- /**
357
- * The Solid component to render the node.
358
- */
359
- component: SolidNodeViewComponent;
360
398
  }
361
399
  export { SolidNodeViewOptions }
362
400
  export { SolidNodeViewOptions as SolidNodeViewOptions_alias_1 }
@@ -364,15 +402,7 @@ export { SolidNodeViewOptions as SolidNodeViewOptions_alias_1 }
364
402
  /**
365
403
  * @public
366
404
  */
367
- declare interface SolidNodeViewProps {
368
- contentRef: (node: HTMLElement | null) => void;
369
- view: EditorView;
370
- getPos: () => number | undefined;
371
- setAttrs: (attrs: Attrs) => void;
372
- node: ProseMirrorNode;
373
- selected: boolean;
374
- decorations: readonly Decoration[];
375
- innerDecorations: DecorationSource;
405
+ declare interface SolidNodeViewProps extends NodeViewContextProps {
376
406
  }
377
407
  export { SolidNodeViewProps }
378
408
  export { SolidNodeViewProps as SolidNodeViewProps_alias_1 }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useEditorContext
3
- } from "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-XDDJIQ4M.js";
4
4
 
5
5
  // src/components/create-component.ts
6
6
  import h from "solid-js/h";
@@ -1,5 +1,8 @@
1
1
  // src/contexts/editor-context.ts
2
- import { createContext, useContext } from "solid-js";
2
+ import {
3
+ createContext,
4
+ useContext
5
+ } from "solid-js";
3
6
  var editorContext = createContext(null);
4
7
  function useEditorContext() {
5
8
  return useContext(editorContext);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/autocomplete/autocomplete-empty.gen.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/block-handle/block-handle-add.gen.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/inline-popover/inline-popover.gen.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/popover/popover-content.gen.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/resizable/resizable-handle.gen.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/table-handle/table-handle-column-root.gen.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-SGL36LNK.js";
4
- import "./chunk-XXXIBXNC.js";
3
+ } from "./chunk-BZVX5KNK.js";
4
+ import "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/tooltip/tooltip-content.gen.ts
7
7
  import {
@@ -1,15 +1,19 @@
1
1
  export { ProseKit } from './_tsup-dts-rollup.js';
2
2
  export { ProseKitProps } from './_tsup-dts-rollup.js';
3
+ export { defineSolidMarkView } from './_tsup-dts-rollup.js';
4
+ export { SolidMarkViewComponent } from './_tsup-dts-rollup.js';
5
+ export { SolidMarkViewOptions } from './_tsup-dts-rollup.js';
6
+ export { SolidMarkViewProps } from './_tsup-dts-rollup.js';
7
+ export { defineSolidNodeView } from './_tsup-dts-rollup.js';
8
+ export { SolidNodeViewComponent } from './_tsup-dts-rollup.js';
9
+ export { SolidNodeViewOptions } from './_tsup-dts-rollup.js';
10
+ export { SolidNodeViewProps } from './_tsup-dts-rollup.js';
11
+ export { useDocChange } from './_tsup-dts-rollup.js';
3
12
  export { useEditor } from './_tsup-dts-rollup.js';
4
13
  export { useExtension } from './_tsup-dts-rollup.js';
5
14
  export { UseExtensionOptions } from './_tsup-dts-rollup.js';
6
15
  export { useKeymap } from './_tsup-dts-rollup.js';
7
16
  export { useStateUpdate } from './_tsup-dts-rollup.js';
8
- export { useDocChange } from './_tsup-dts-rollup.js';
9
17
  export { MaybeAccessor } from './_tsup-dts-rollup.js';
10
18
  export { PropsWithChildren } from './_tsup-dts-rollup.js';
11
19
  export { PropsWithClass } from './_tsup-dts-rollup.js';
12
- export { defineSolidNodeView } from './_tsup-dts-rollup.js';
13
- export { SolidNodeViewComponent } from './_tsup-dts-rollup.js';
14
- export { SolidNodeViewOptions } from './_tsup-dts-rollup.js';
15
- export { SolidNodeViewProps } from './_tsup-dts-rollup.js';
@@ -1,20 +1,22 @@
1
1
  import {
2
2
  EditorContextProvider,
3
3
  useEditorContext
4
- } from "./chunk-XXXIBXNC.js";
4
+ } from "./chunk-XDDJIQ4M.js";
5
5
 
6
6
  // src/components/prosekit.ts
7
7
  import { ProsemirrorAdapterProvider } from "@prosemirror-adapter/solid";
8
- import { createComponent as createComponent2 } from "solid-js";
8
+ import {
9
+ createComponent as createComponent3
10
+ } from "solid-js";
9
11
 
10
- // src/extensions/solid-node-view.ts
12
+ // src/extensions/solid-mark-view.ts
11
13
  import {
12
- defineNodeViewComponent,
13
- defineNodeViewFactory
14
+ defineMarkViewComponent,
15
+ defineMarkViewFactory
14
16
  } from "@prosekit/core";
15
17
  import {
16
- useNodeViewContext,
17
- useNodeViewFactory
18
+ useMarkViewContext,
19
+ useMarkViewFactory
18
20
  } from "@prosemirror-adapter/solid";
19
21
  import {
20
22
  createComponent,
@@ -25,7 +27,10 @@ import {
25
27
  import {
26
28
  EditorNotFoundError
27
29
  } from "@prosekit/core";
28
- import { createEffect, onCleanup } from "solid-js";
30
+ import {
31
+ createEffect,
32
+ onCleanup
33
+ } from "solid-js";
29
34
 
30
35
  // src/utils/to-value.ts
31
36
  function toValue(v) {
@@ -48,7 +53,9 @@ function useEditorExtension(editorAccessor, extensionAccessor) {
48
53
  }
49
54
 
50
55
  // src/hooks/use-priority-extension.ts
51
- import { withPriority } from "@prosekit/core";
56
+ import {
57
+ withPriority
58
+ } from "@prosekit/core";
52
59
  function usePriorityExtension(extension, priority) {
53
60
  return () => {
54
61
  const ext = extension();
@@ -64,16 +71,62 @@ function useExtension(extension, options) {
64
71
  );
65
72
  }
66
73
 
74
+ // src/extensions/solid-mark-view.ts
75
+ function withMarkViewProps(component) {
76
+ return function MarkViewPropsWrapper() {
77
+ const props = useMarkViewContext();
78
+ return createComponent(component, props());
79
+ };
80
+ }
81
+ function consumeSolidMarkViews() {
82
+ const markViewFactory = useMarkViewFactory();
83
+ const extension = createMemo(
84
+ () => defineSolidMarkViewFactory(markViewFactory),
85
+ [markViewFactory]
86
+ );
87
+ useExtension(extension);
88
+ }
89
+ function defineSolidMarkView(options) {
90
+ const { name, component, ...userOptions } = options;
91
+ const args = {
92
+ ...userOptions,
93
+ component: withMarkViewProps(component)
94
+ };
95
+ return defineMarkViewComponent({
96
+ group: "solid",
97
+ name,
98
+ args
99
+ });
100
+ }
101
+ function defineSolidMarkViewFactory(factory) {
102
+ return defineMarkViewFactory({
103
+ group: "solid",
104
+ factory
105
+ });
106
+ }
107
+
67
108
  // src/extensions/solid-node-view.ts
109
+ import {
110
+ defineNodeViewComponent,
111
+ defineNodeViewFactory
112
+ } from "@prosekit/core";
113
+ import {
114
+ useNodeViewContext,
115
+ useNodeViewFactory
116
+ } from "@prosemirror-adapter/solid";
117
+ import {
118
+ createComponent as createComponent2,
119
+ createMemo as createMemo2
120
+ } from "solid-js";
68
121
  function withNodeViewProps(component) {
69
122
  return function NodeViewPropsWrapper() {
70
123
  const props = useNodeViewContext();
71
- return createComponent(component, props());
124
+ return createComponent2(component, props());
72
125
  };
73
126
  }
74
- function consumeSolidViews() {
127
+ function consumeSolidNodeViews() {
75
128
  const nodeViewFactory = useNodeViewFactory();
76
- const extension = createMemo(
129
+ const extension = createMemo2(
77
130
  () => defineSolidNodeViewFactory(nodeViewFactory),
78
131
  [nodeViewFactory]
79
132
  );
@@ -100,14 +153,15 @@ function defineSolidNodeViewFactory(factory) {
100
153
 
101
154
  // src/components/prosekit.ts
102
155
  var ProseKit = (props) => {
103
- return createComponent2(ProsemirrorAdapterProvider, {
156
+ return createComponent3(ProsemirrorAdapterProvider, {
104
157
  get children() {
105
- return createComponent2(EditorContextProvider, {
158
+ return createComponent3(EditorContextProvider, {
106
159
  get value() {
107
160
  return props.editor;
108
161
  },
109
162
  get children() {
110
- consumeSolidViews();
163
+ consumeSolidNodeViews();
164
+ consumeSolidMarkViews();
111
165
  return props.children;
112
166
  }
113
167
  });
@@ -115,14 +169,24 @@ var ProseKit = (props) => {
115
169
  });
116
170
  };
117
171
 
172
+ // src/hooks/use-doc-change.ts
173
+ import { defineDocChangeHandler } from "@prosekit/core";
174
+ function useDocChange(handler, options) {
175
+ const extension = defineDocChangeHandler((view) => handler(view.state.doc));
176
+ return useExtension(() => extension, options);
177
+ }
178
+
118
179
  // src/hooks/use-editor.ts
119
180
  import {
120
- ProseKitError,
121
181
  defineMountHandler,
122
182
  defineUpdateHandler,
183
+ ProseKitError,
123
184
  union
124
185
  } from "@prosekit/core";
125
- import { createEffect as createEffect2, createSignal } from "solid-js";
186
+ import {
187
+ createEffect as createEffect2,
188
+ createSignal
189
+ } from "solid-js";
126
190
  function useEditor(options) {
127
191
  var _a;
128
192
  const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
@@ -152,7 +216,9 @@ function useForceUpdate() {
152
216
  }
153
217
 
154
218
  // src/hooks/use-keymap.ts
155
- import { defineKeymap } from "@prosekit/core";
219
+ import {
220
+ defineKeymap
221
+ } from "@prosekit/core";
156
222
  function useKeymap(keymap, options) {
157
223
  const extension = () => defineKeymap(keymap());
158
224
  return useExtension(extension, options);
@@ -164,15 +230,9 @@ function useStateUpdate(handler, options) {
164
230
  const extension = defineUpdateHandler2((view) => handler(view.state));
165
231
  return useExtension(() => extension, options);
166
232
  }
167
-
168
- // src/hooks/use-doc-change.ts
169
- import { defineDocChangeHandler } from "@prosekit/core";
170
- function useDocChange(handler, options) {
171
- const extension = defineDocChangeHandler((view) => handler(view.state.doc));
172
- return useExtension(() => extension, options);
173
- }
174
233
  export {
175
234
  ProseKit,
235
+ defineSolidMarkView,
176
236
  defineSolidNodeView,
177
237
  useDocChange,
178
238
  useEditor,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/solid",
3
3
  "type": "module",
4
- "version": "0.4.5",
4
+ "version": "0.4.7",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -70,10 +70,11 @@
70
70
  "dist"
71
71
  ],
72
72
  "dependencies": {
73
- "@prosemirror-adapter/solid": "^0.2.6",
74
- "@prosekit/core": "^0.7.13",
75
- "@prosekit/web": "^0.5.1",
76
- "@prosekit/pm": "^0.1.9"
73
+ "@prosemirror-adapter/core": "^0.4.0",
74
+ "@prosemirror-adapter/solid": "^0.4.0",
75
+ "@prosekit/core": "^0.7.14",
76
+ "@prosekit/pm": "^0.1.9",
77
+ "@prosekit/web": "^0.5.2"
77
78
  },
78
79
  "peerDependencies": {
79
80
  "solid-js": ">= 1.7.0"
@@ -86,8 +87,8 @@
86
87
  "devDependencies": {
87
88
  "solid-js": "^1.9.3",
88
89
  "tsup": "^8.3.5",
89
- "typescript": "^5.6.3",
90
- "vitest": "^2.1.6",
90
+ "typescript": "~5.6.3",
91
+ "vitest": "^2.1.8",
91
92
  "@prosekit/dev": "0.0.0"
92
93
  },
93
94
  "scripts": {