@prosekit/solid 0.6.6 → 0.6.8

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.
Files changed (89) hide show
  1. package/dist/{create-component-B7NzEJxP.js → create-component.js} +3 -4
  2. package/dist/create-component.js.map +1 -0
  3. package/dist/{create-props-CFK4CtjG.d.ts → create-props.d.ts} +1 -1
  4. package/dist/create-props.d.ts.map +1 -0
  5. package/dist/{editor-context-CAdqwRwB.js → editor-context.js} +2 -3
  6. package/dist/editor-context.js.map +1 -0
  7. package/dist/prosekit-solid-autocomplete.d.ts +2 -2
  8. package/dist/prosekit-solid-autocomplete.js +2 -6
  9. package/dist/prosekit-solid-autocomplete.js.map +1 -1
  10. package/dist/prosekit-solid-block-handle.d.ts +2 -2
  11. package/dist/prosekit-solid-block-handle.js +2 -5
  12. package/dist/prosekit-solid-block-handle.js.map +1 -1
  13. package/dist/prosekit-solid-drop-indicator.d.ts +2 -2
  14. package/dist/prosekit-solid-drop-indicator.js +2 -3
  15. package/dist/prosekit-solid-drop-indicator.js.map +1 -1
  16. package/dist/prosekit-solid-inline-popover.d.ts +2 -2
  17. package/dist/prosekit-solid-inline-popover.js +2 -3
  18. package/dist/prosekit-solid-inline-popover.js.map +1 -1
  19. package/dist/prosekit-solid-popover.d.ts +2 -2
  20. package/dist/prosekit-solid-popover.js +2 -5
  21. package/dist/prosekit-solid-popover.js.map +1 -1
  22. package/dist/prosekit-solid-resizable.d.ts +2 -2
  23. package/dist/prosekit-solid-resizable.js +2 -4
  24. package/dist/prosekit-solid-resizable.js.map +1 -1
  25. package/dist/prosekit-solid-table-handle.d.ts +2 -2
  26. package/dist/prosekit-solid-table-handle.js +2 -11
  27. package/dist/prosekit-solid-table-handle.js.map +1 -1
  28. package/dist/prosekit-solid-tooltip.d.ts +2 -2
  29. package/dist/prosekit-solid-tooltip.js +2 -5
  30. package/dist/prosekit-solid-tooltip.js.map +1 -1
  31. package/dist/prosekit-solid.d.ts +18 -18
  32. package/dist/prosekit-solid.d.ts.map +1 -1
  33. package/dist/prosekit-solid.js +115 -140
  34. package/dist/prosekit-solid.js.map +1 -1
  35. package/dist/{types-Bx9mKDTJ.d.ts → types.d.ts} +1 -1
  36. package/dist/types.d.ts.map +1 -0
  37. package/package.json +7 -6
  38. package/src/components/autocomplete/autocomplete-empty.gen.ts +3 -3
  39. package/src/components/autocomplete/autocomplete-item.gen.ts +3 -3
  40. package/src/components/autocomplete/autocomplete-list.gen.ts +3 -3
  41. package/src/components/autocomplete/autocomplete-popover.gen.ts +3 -3
  42. package/src/components/autocomplete/index.gen.ts +4 -4
  43. package/src/components/block-handle/block-handle-add.gen.ts +3 -3
  44. package/src/components/block-handle/block-handle-draggable.gen.ts +3 -3
  45. package/src/components/block-handle/block-handle-popover.gen.ts +3 -3
  46. package/src/components/block-handle/index.gen.ts +3 -3
  47. package/src/components/create-component.ts +2 -2
  48. package/src/components/drop-indicator/drop-indicator.gen.ts +3 -3
  49. package/src/components/drop-indicator/index.gen.ts +1 -1
  50. package/src/components/inline-popover/index.gen.ts +1 -1
  51. package/src/components/inline-popover/inline-popover.gen.ts +3 -3
  52. package/src/components/popover/index.gen.ts +3 -3
  53. package/src/components/popover/popover-content.gen.ts +3 -3
  54. package/src/components/popover/popover-root.gen.ts +3 -3
  55. package/src/components/popover/popover-trigger.gen.ts +3 -3
  56. package/src/components/prosekit.ts +7 -7
  57. package/src/components/resizable/index.gen.ts +2 -2
  58. package/src/components/resizable/resizable-handle.gen.ts +3 -3
  59. package/src/components/resizable/resizable-root.gen.ts +3 -3
  60. package/src/components/table-handle/index.gen.ts +9 -9
  61. package/src/components/table-handle/table-handle-column-root.gen.ts +3 -3
  62. package/src/components/table-handle/table-handle-column-trigger.gen.ts +3 -3
  63. package/src/components/table-handle/table-handle-drag-preview.gen.ts +3 -3
  64. package/src/components/table-handle/table-handle-drop-indicator.gen.ts +3 -3
  65. package/src/components/table-handle/table-handle-popover-content.gen.ts +3 -3
  66. package/src/components/table-handle/table-handle-popover-item.gen.ts +3 -3
  67. package/src/components/table-handle/table-handle-root.gen.ts +3 -3
  68. package/src/components/table-handle/table-handle-row-root.gen.ts +3 -3
  69. package/src/components/table-handle/table-handle-row-trigger.gen.ts +3 -3
  70. package/src/components/tooltip/index.gen.ts +3 -3
  71. package/src/components/tooltip/tooltip-content.gen.ts +3 -3
  72. package/src/components/tooltip/tooltip-root.gen.ts +3 -3
  73. package/src/components/tooltip/tooltip-trigger.gen.ts +3 -3
  74. package/src/components/view-renderer.ts +24 -0
  75. package/src/extensions/helpers.ts +4 -0
  76. package/src/extensions/solid-mark-view.ts +29 -49
  77. package/src/extensions/solid-node-view.ts +29 -64
  78. package/src/hooks/use-doc-change.ts +1 -1
  79. package/src/hooks/use-editor-derived-value.ts +3 -3
  80. package/src/hooks/use-editor-extension.ts +3 -3
  81. package/src/hooks/use-editor.ts +1 -1
  82. package/src/hooks/use-extension.ts +3 -3
  83. package/src/hooks/use-keymap.ts +1 -1
  84. package/src/hooks/use-state-update.ts +1 -1
  85. package/src/index.ts +10 -10
  86. package/dist/create-component-B7NzEJxP.js.map +0 -1
  87. package/dist/create-props-CFK4CtjG.d.ts.map +0 -1
  88. package/dist/editor-context-CAdqwRwB.js.map +0 -1
  89. package/dist/types-Bx9mKDTJ.d.ts.map +0 -1
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/popover'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link PopoverContent} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/popover'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link PopoverRoot} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/popover'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link PopoverTrigger} component.
@@ -1,10 +1,9 @@
1
1
  import type { Editor } from '@prosekit/core'
2
- import { ProsemirrorAdapterProvider } from '@prosemirror-adapter/solid'
3
2
  import { createComponent, type Component, type ParentProps } from 'solid-js'
4
3
 
5
- import { EditorContextProvider } from '../contexts/editor-context'
6
- import { consumeSolidMarkViews } from '../extensions/solid-mark-view'
7
- import { consumeSolidNodeViews } from '../extensions/solid-node-view'
4
+ import { EditorContextProvider } from '../contexts/editor-context.ts'
5
+
6
+ import { ViewRenderer } from './view-renderer.ts'
8
7
 
9
8
  export type ProseKitProps = ParentProps<{
10
9
  editor: Editor
@@ -21,10 +20,11 @@ export const ProseKit: Component<ProseKitProps> = (props) => {
21
20
  return props.editor
22
21
  },
23
22
  get children() {
24
- return createComponent(ProsemirrorAdapterProvider, {
23
+ return createComponent(ViewRenderer, {
24
+ get editor() {
25
+ return props.editor
26
+ },
25
27
  get children() {
26
- consumeSolidNodeViews()
27
- consumeSolidMarkViews()
28
28
  return props.children
29
29
  },
30
30
  })
@@ -1,3 +1,3 @@
1
- export { ResizableHandle, type ResizableHandleProps } from './resizable-handle.gen'
1
+ export { ResizableHandle, type ResizableHandleProps } from './resizable-handle.gen.ts'
2
2
 
3
- export { ResizableRoot, type ResizableRootProps } from './resizable-root.gen'
3
+ export { ResizableRoot, type ResizableRootProps } from './resizable-root.gen.ts'
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/resizable'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link ResizableHandle} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/resizable'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link ResizableRoot} component.
@@ -1,17 +1,17 @@
1
- export { TableHandleColumnRoot, type TableHandleColumnRootProps } from './table-handle-column-root.gen'
1
+ export { TableHandleColumnRoot, type TableHandleColumnRootProps } from './table-handle-column-root.gen.ts'
2
2
 
3
- export { TableHandleColumnTrigger, type TableHandleColumnTriggerProps } from './table-handle-column-trigger.gen'
3
+ export { TableHandleColumnTrigger, type TableHandleColumnTriggerProps } from './table-handle-column-trigger.gen.ts'
4
4
 
5
- export { TableHandleDragPreview, type TableHandleDragPreviewProps } from './table-handle-drag-preview.gen'
5
+ export { TableHandleDragPreview, type TableHandleDragPreviewProps } from './table-handle-drag-preview.gen.ts'
6
6
 
7
- export { TableHandleDropIndicator, type TableHandleDropIndicatorProps } from './table-handle-drop-indicator.gen'
7
+ export { TableHandleDropIndicator, type TableHandleDropIndicatorProps } from './table-handle-drop-indicator.gen.ts'
8
8
 
9
- export { TableHandlePopoverContent, type TableHandlePopoverContentProps } from './table-handle-popover-content.gen'
9
+ export { TableHandlePopoverContent, type TableHandlePopoverContentProps } from './table-handle-popover-content.gen.ts'
10
10
 
11
- export { TableHandlePopoverItem, type TableHandlePopoverItemProps } from './table-handle-popover-item.gen'
11
+ export { TableHandlePopoverItem, type TableHandlePopoverItemProps } from './table-handle-popover-item.gen.ts'
12
12
 
13
- export { TableHandleRoot, type TableHandleRootProps } from './table-handle-root.gen'
13
+ export { TableHandleRoot, type TableHandleRootProps } from './table-handle-root.gen.ts'
14
14
 
15
- export { TableHandleRowRoot, type TableHandleRowRootProps } from './table-handle-row-root.gen'
15
+ export { TableHandleRowRoot, type TableHandleRowRootProps } from './table-handle-row-root.gen.ts'
16
16
 
17
- export { TableHandleRowTrigger, type TableHandleRowTriggerProps } from './table-handle-row-trigger.gen'
17
+ export { TableHandleRowTrigger, type TableHandleRowTriggerProps } from './table-handle-row-trigger.gen.ts'
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleColumnRoot} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleColumnTrigger} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleDragPreview} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleDropIndicator} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandlePopoverContent} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandlePopoverItem} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleRoot} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleRowRoot} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/table-handle'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TableHandleRowTrigger} component.
@@ -1,5 +1,5 @@
1
- export { TooltipContent, type TooltipContentProps } from './tooltip-content.gen'
1
+ export { TooltipContent, type TooltipContentProps } from './tooltip-content.gen.ts'
2
2
 
3
- export { TooltipRoot, type TooltipRootProps } from './tooltip-root.gen'
3
+ export { TooltipRoot, type TooltipRootProps } from './tooltip-root.gen.ts'
4
4
 
5
- export { TooltipTrigger, type TooltipTriggerProps } from './tooltip-trigger.gen'
5
+ export { TooltipTrigger, type TooltipTriggerProps } from './tooltip-trigger.gen.ts'
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/tooltip'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TooltipContent} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/tooltip'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TooltipRoot} component.
@@ -7,9 +7,9 @@ import {
7
7
  } from '@prosekit/web/tooltip'
8
8
  import type { Component } from 'solid-js'
9
9
 
10
- import type { PropsWithElement } from '../../types'
11
- import { createComponent } from '../create-component'
12
- import type { CreateProps } from '../create-props'
10
+ import type { PropsWithElement } from '../../types.ts'
11
+ import { createComponent } from '../create-component.ts'
12
+ import type { CreateProps } from '../create-props.ts'
13
13
 
14
14
  /**
15
15
  * Props for the {@link TooltipTrigger} component.
@@ -0,0 +1,24 @@
1
+ import { union, type Editor } from '@prosekit/core'
2
+ import { useSolidRenderer } from '@prosemirror-adapter/solid'
3
+ import type { Component, JSX, ParentProps } from 'solid-js'
4
+
5
+ import { defineSolidMarkViewFactory } from '../extensions/solid-mark-view.ts'
6
+ import { defineSolidNodeViewFactory } from '../extensions/solid-node-view.ts'
7
+ import { useEditorExtension } from '../hooks/use-editor-extension.ts'
8
+
9
+ type ViewRendererProps = ParentProps<{
10
+ editor: Editor
11
+ }>
12
+
13
+ export const ViewRenderer: Component<ViewRendererProps> = (props): JSX.Element => {
14
+ const { renderSolidRenderer, removeSolidRenderer, render } = useSolidRenderer()
15
+
16
+ const extension = union([
17
+ defineSolidMarkViewFactory(renderSolidRenderer, removeSolidRenderer),
18
+ defineSolidNodeViewFactory(renderSolidRenderer, removeSolidRenderer),
19
+ ])
20
+
21
+ useEditorExtension(() => props.editor, () => extension)
22
+
23
+ return [props.children, render] as unknown as JSX.Element
24
+ }
@@ -0,0 +1,4 @@
1
+ export function hidePortalDiv(el: HTMLElement): void {
2
+ el.style.display = 'contents'
3
+ el.dataset.solidPortal = 'true'
4
+ }
@@ -1,15 +1,15 @@
1
1
  import { defineMarkViewComponent, defineMarkViewFactory, type Extension } from '@prosekit/core'
2
- import type { MarkViewConstructor } from '@prosekit/pm/view'
3
2
  import type { CoreMarkViewUserOptions } from '@prosemirror-adapter/core'
4
3
  import {
5
- useMarkViewContext,
6
- useMarkViewFactory,
4
+ AbstractSolidMarkView,
5
+ buildSolidMarkViewCreator,
7
6
  type MarkViewContextProps,
8
- type SolidMarkViewUserOptions,
7
+ type SolidRendererResult,
9
8
  } from '@prosemirror-adapter/solid'
10
- import { createComponent, createMemo, type Accessor, type Component } from 'solid-js'
9
+ import { createComponent, type Component, type JSX } from 'solid-js'
10
+ import { Portal } from 'solid-js/web'
11
11
 
12
- import { useExtension } from '../hooks/use-extension'
12
+ import { hidePortalDiv } from './helpers.ts'
13
13
 
14
14
  /**
15
15
  * @public
@@ -33,37 +33,33 @@ export interface SolidMarkViewOptions extends CoreMarkViewUserOptions<SolidMarkV
33
33
  name: string
34
34
  }
35
35
 
36
- function withMarkViewProps(
37
- component: SolidMarkViewComponent,
38
- ): Component<SolidMarkViewProps> {
39
- return function MarkViewPropsWrapper() {
40
- const context: Accessor<SolidMarkViewProps> = useMarkViewContext()
41
- const props: SolidMarkViewProps = {
42
- get contentRef() {
43
- return context().contentRef
36
+ class ProseKitSolidMarkView extends AbstractSolidMarkView<SolidMarkViewComponent> {
37
+ render = (): JSX.Element => {
38
+ const UserComponent = this.component
39
+ const getProps = this.context
40
+ return createComponent(Portal, {
41
+ mount: this.dom,
42
+ get children() {
43
+ const props: MarkViewContextProps = getProps()
44
+ return createComponent(UserComponent, props)
44
45
  },
45
- get view() {
46
- return context().view
47
- },
48
- get mark() {
49
- return context().mark
50
- },
51
- }
52
- return createComponent(component, props)
46
+ ref: hidePortalDiv,
47
+ })
53
48
  }
54
49
  }
55
50
 
56
51
  /**
57
52
  * @internal
58
53
  */
59
- export function consumeSolidMarkViews(): void {
60
- const markViewFactory = useMarkViewFactory()
61
- const extension = createMemo(
62
- () => defineSolidMarkViewFactory(markViewFactory),
63
- [markViewFactory],
64
- )
65
-
66
- useExtension(extension)
54
+ export function defineSolidMarkViewFactory(
55
+ renderSolidRenderer: SolidRendererResult['renderSolidRenderer'],
56
+ removeSolidRenderer: SolidRendererResult['removeSolidRenderer'],
57
+ ): Extension {
58
+ const factory = buildSolidMarkViewCreator(renderSolidRenderer, removeSolidRenderer, ProseKitSolidMarkView)
59
+ return defineMarkViewFactory<SolidMarkViewOptions>({
60
+ group: 'solid',
61
+ factory,
62
+ })
67
63
  }
68
64
 
69
65
  /**
@@ -72,25 +68,9 @@ export function consumeSolidMarkViews(): void {
72
68
  * @public
73
69
  */
74
70
  export function defineSolidMarkView(options: SolidMarkViewOptions): Extension {
75
- const { name, component, ...userOptions } = options
76
-
77
- const args: SolidMarkViewUserOptions = {
78
- ...userOptions,
79
- component: withMarkViewProps(component),
80
- }
81
-
82
- return defineMarkViewComponent<SolidMarkViewUserOptions>({
83
- group: 'solid',
84
- name,
85
- args,
86
- })
87
- }
88
-
89
- function defineSolidMarkViewFactory(
90
- factory: (options: SolidMarkViewOptions) => MarkViewConstructor,
91
- ) {
92
- return defineMarkViewFactory<SolidMarkViewOptions>({
71
+ return defineMarkViewComponent<SolidMarkViewOptions>({
93
72
  group: 'solid',
94
- factory,
73
+ name: options.name,
74
+ args: options,
95
75
  })
96
76
  }
@@ -1,15 +1,15 @@
1
1
  import { defineNodeViewComponent, defineNodeViewFactory, type Extension } from '@prosekit/core'
2
- import type { NodeViewConstructor } from '@prosekit/pm/view'
3
2
  import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core'
4
3
  import {
5
- useNodeViewContext,
6
- useNodeViewFactory,
4
+ AbstractSolidNodeView,
5
+ buildSolidNodeViewCreator,
7
6
  type NodeViewContextProps,
8
- type SolidNodeViewUserOptions,
7
+ type SolidRendererResult,
9
8
  } from '@prosemirror-adapter/solid'
10
- import { createComponent, createMemo, type Accessor, type Component } from 'solid-js'
9
+ import { createComponent, type Component, type JSX } from 'solid-js'
10
+ import { Portal } from 'solid-js/web'
11
11
 
12
- import { useExtension } from '../hooks/use-extension'
12
+ import { hidePortalDiv } from './helpers.ts'
13
13
 
14
14
  /**
15
15
  * @public
@@ -33,52 +33,33 @@ export interface SolidNodeViewOptions extends CoreNodeViewUserOptions<SolidNodeV
33
33
  name: string
34
34
  }
35
35
 
36
- function withNodeViewProps(
37
- component: SolidNodeViewComponent,
38
- ): Component<SolidNodeViewProps> {
39
- return function NodeViewPropsWrapper() {
40
- const context: Accessor<SolidNodeViewProps> = useNodeViewContext()
41
- const props: SolidNodeViewProps = {
42
- get contentRef() {
43
- return context().contentRef
36
+ class ProseKitSolidNodeView extends AbstractSolidNodeView<SolidNodeViewComponent> {
37
+ render = (): JSX.Element => {
38
+ const UserComponent = this.component
39
+ const getProps = this.context
40
+ return createComponent(Portal, {
41
+ mount: this.dom,
42
+ get children() {
43
+ const props: SolidNodeViewProps = getProps()
44
+ return createComponent(UserComponent, props)
44
45
  },
45
- get view() {
46
- return context().view
47
- },
48
- get getPos() {
49
- return context().getPos
50
- },
51
- get setAttrs() {
52
- return context().setAttrs
53
- },
54
- get node() {
55
- return context().node
56
- },
57
- get selected() {
58
- return context().selected
59
- },
60
- get decorations() {
61
- return context().decorations
62
- },
63
- get innerDecorations() {
64
- return context().innerDecorations
65
- },
66
- }
67
- return createComponent(component, props)
46
+ ref: hidePortalDiv,
47
+ })
68
48
  }
69
49
  }
70
50
 
71
51
  /**
72
52
  * @internal
73
53
  */
74
- export function consumeSolidNodeViews(): void {
75
- const nodeViewFactory = useNodeViewFactory()
76
- const extension = createMemo(
77
- () => defineSolidNodeViewFactory(nodeViewFactory),
78
- [nodeViewFactory],
79
- )
80
-
81
- useExtension(extension)
54
+ export function defineSolidNodeViewFactory(
55
+ renderSolidRenderer: SolidRendererResult['renderSolidRenderer'],
56
+ removeSolidRenderer: SolidRendererResult['removeSolidRenderer'],
57
+ ): Extension {
58
+ const factory = buildSolidNodeViewCreator(renderSolidRenderer, removeSolidRenderer, ProseKitSolidNodeView)
59
+ return defineNodeViewFactory<SolidNodeViewOptions>({
60
+ group: 'solid',
61
+ factory,
62
+ })
82
63
  }
83
64
 
84
65
  /**
@@ -87,25 +68,9 @@ export function consumeSolidNodeViews(): void {
87
68
  * @public
88
69
  */
89
70
  export function defineSolidNodeView(options: SolidNodeViewOptions): Extension {
90
- const { name, component, ...userOptions } = options
91
-
92
- const args: SolidNodeViewUserOptions = {
93
- ...userOptions,
94
- component: withNodeViewProps(component),
95
- }
96
-
97
- return defineNodeViewComponent<SolidNodeViewUserOptions>({
98
- group: 'solid',
99
- name,
100
- args,
101
- })
102
- }
103
-
104
- function defineSolidNodeViewFactory(
105
- factory: (options: SolidNodeViewOptions) => NodeViewConstructor,
106
- ) {
107
- return defineNodeViewFactory<SolidNodeViewOptions>({
71
+ return defineNodeViewComponent<SolidNodeViewOptions>({
108
72
  group: 'solid',
109
- factory,
73
+ name: options.name,
74
+ args: options,
110
75
  })
111
76
  }
@@ -1,7 +1,7 @@
1
1
  import { defineDocChangeHandler } from '@prosekit/core'
2
2
  import type { ProseMirrorNode } from '@prosekit/pm/model'
3
3
 
4
- import { useExtension, type UseExtensionOptions } from './use-extension'
4
+ import { useExtension, type UseExtensionOptions } from './use-extension.ts'
5
5
 
6
6
  /**
7
7
  * Calls the given handler whenever the editor document changes.
@@ -1,10 +1,10 @@
1
1
  import type { Editor, Extension } from '@prosekit/core'
2
2
  import { createMemo, type Accessor } from 'solid-js'
3
3
 
4
- import type { MaybeAccessor } from '../types'
5
- import { toValue } from '../utils/to-value'
4
+ import type { MaybeAccessor } from '../types.ts'
5
+ import { toValue } from '../utils/to-value.ts'
6
6
 
7
- import { useEditor } from './use-editor'
7
+ import { useEditor } from './use-editor.ts'
8
8
 
9
9
  export interface UseEditorDerivedOptions<E extends Extension = any> {
10
10
  /**
@@ -1,9 +1,9 @@
1
1
  import { EditorNotFoundError, type Editor, type Extension } from '@prosekit/core'
2
2
  import { createEffect, onCleanup, type Accessor } from 'solid-js'
3
3
 
4
- import { useEditorContext } from '../contexts/editor-context'
5
- import type { MaybeAccessor } from '../types'
6
- import { toValue } from '../utils/to-value'
4
+ import { useEditorContext } from '../contexts/editor-context.ts'
5
+ import type { MaybeAccessor } from '../types.ts'
6
+ import { toValue } from '../utils/to-value.ts'
7
7
 
8
8
  /**
9
9
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { defineMountHandler, defineUpdateHandler, ProseKitError, union, type Editor, type Extension } from '@prosekit/core'
2
2
  import { createEffect, createSignal } from 'solid-js'
3
3
 
4
- import { useEditorContext } from '../contexts/editor-context'
4
+ import { useEditorContext } from '../contexts/editor-context.ts'
5
5
 
6
6
  /**
7
7
  * Retrieves the editor instance from the nearest ProseKit component.
@@ -1,10 +1,10 @@
1
1
  import type { Editor, Extension, Priority } from '@prosekit/core'
2
2
  import type { Accessor } from 'solid-js'
3
3
 
4
- import type { MaybeAccessor } from '../types'
4
+ import type { MaybeAccessor } from '../types.ts'
5
5
 
6
- import { useEditorExtension } from './use-editor-extension'
7
- import { usePriorityExtension } from './use-priority-extension'
6
+ import { useEditorExtension } from './use-editor-extension.ts'
7
+ import { usePriorityExtension } from './use-priority-extension.ts'
8
8
 
9
9
  export interface UseExtensionOptions {
10
10
  /**