@prosekit/react 0.6.7 → 0.6.9
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/{create-component-D8vvwyIA.js → create-component.js} +3 -5
- package/dist/create-component.js.map +1 -0
- package/dist/{create-props-PUVFMh9y.d.ts → create-props.d.ts} +1 -1
- package/dist/create-props.d.ts.map +1 -0
- package/dist/{editor-context-DHjS00Fa.js → editor-context.js} +2 -3
- package/dist/editor-context.js.map +1 -0
- package/dist/prosekit-react-autocomplete.d.ts +1 -1
- package/dist/prosekit-react-autocomplete.js +2 -6
- package/dist/prosekit-react-autocomplete.js.map +1 -1
- package/dist/prosekit-react-block-handle.d.ts +1 -1
- package/dist/prosekit-react-block-handle.js +2 -5
- package/dist/prosekit-react-block-handle.js.map +1 -1
- package/dist/prosekit-react-drop-indicator.d.ts +1 -1
- package/dist/prosekit-react-drop-indicator.js +2 -3
- package/dist/prosekit-react-drop-indicator.js.map +1 -1
- package/dist/prosekit-react-inline-popover.d.ts +1 -1
- package/dist/prosekit-react-inline-popover.js +2 -3
- package/dist/prosekit-react-inline-popover.js.map +1 -1
- package/dist/prosekit-react-popover.d.ts +1 -1
- package/dist/prosekit-react-popover.js +2 -5
- package/dist/prosekit-react-popover.js.map +1 -1
- package/dist/prosekit-react-resizable.d.ts +1 -1
- package/dist/prosekit-react-resizable.js +2 -4
- package/dist/prosekit-react-resizable.js.map +1 -1
- package/dist/prosekit-react-table-handle.d.ts +1 -1
- package/dist/prosekit-react-table-handle.js +2 -11
- package/dist/prosekit-react-table-handle.js.map +1 -1
- package/dist/prosekit-react-tooltip.d.ts +1 -1
- package/dist/prosekit-react-tooltip.js +2 -5
- package/dist/prosekit-react-tooltip.js.map +1 -1
- package/dist/prosekit-react.d.ts +22 -22
- package/dist/prosekit-react.d.ts.map +1 -1
- package/dist/prosekit-react.js +109 -118
- package/dist/prosekit-react.js.map +1 -1
- package/package.json +8 -7
- package/src/components/autocomplete/autocomplete-empty.gen.ts +4 -4
- package/src/components/autocomplete/autocomplete-item.gen.ts +4 -4
- package/src/components/autocomplete/autocomplete-list.gen.ts +4 -4
- package/src/components/autocomplete/autocomplete-popover.gen.ts +4 -4
- package/src/components/autocomplete/index.gen.ts +4 -4
- package/src/components/block-handle/block-handle-add.gen.ts +4 -4
- package/src/components/block-handle/block-handle-draggable.gen.ts +4 -4
- package/src/components/block-handle/block-handle-popover.gen.ts +4 -4
- package/src/components/block-handle/index.gen.ts +3 -3
- package/src/components/create-component.ts +2 -3
- package/src/components/drop-indicator/drop-indicator.gen.ts +4 -4
- package/src/components/drop-indicator/index.gen.ts +1 -1
- package/src/components/inline-popover/index.gen.ts +1 -1
- package/src/components/inline-popover/inline-popover.gen.ts +4 -4
- package/src/components/popover/index.gen.ts +3 -3
- package/src/components/popover/popover-content.gen.ts +4 -4
- package/src/components/popover/popover-root.gen.ts +4 -4
- package/src/components/popover/popover-trigger.gen.ts +4 -4
- package/src/components/prosekit.ts +5 -9
- package/src/components/resizable/index.gen.ts +2 -2
- package/src/components/resizable/resizable-handle.gen.ts +4 -4
- package/src/components/resizable/resizable-root.gen.ts +4 -4
- package/src/components/table-handle/index.gen.ts +9 -9
- package/src/components/table-handle/table-handle-column-root.gen.ts +4 -4
- package/src/components/table-handle/table-handle-column-trigger.gen.ts +4 -4
- package/src/components/table-handle/table-handle-drag-preview.gen.ts +4 -4
- package/src/components/table-handle/table-handle-drop-indicator.gen.ts +4 -4
- package/src/components/table-handle/table-handle-popover-content.gen.ts +4 -4
- package/src/components/table-handle/table-handle-popover-item.gen.ts +4 -4
- package/src/components/table-handle/table-handle-root.gen.ts +4 -4
- package/src/components/table-handle/table-handle-row-root.gen.ts +4 -4
- package/src/components/table-handle/table-handle-row-trigger.gen.ts +4 -4
- package/src/components/tooltip/index.gen.ts +3 -3
- package/src/components/tooltip/tooltip-content.gen.ts +4 -4
- package/src/components/tooltip/tooltip-root.gen.ts +4 -4
- package/src/components/tooltip/tooltip-trigger.gen.ts +4 -4
- package/src/components/view-renderer.ts +27 -0
- package/src/extensions/react-mark-view.ts +29 -37
- package/src/extensions/react-node-view.ts +29 -37
- package/src/hooks/use-doc-change.ts +2 -2
- package/src/hooks/use-editor-derived-value.ts +1 -1
- package/src/hooks/use-editor.ts +1 -1
- package/src/hooks/use-extension.ts +3 -3
- package/src/hooks/use-keymap.ts +1 -1
- package/src/hooks/use-state-update.ts +2 -2
- package/src/index.ts +10 -10
- package/dist/create-component-D8vvwyIA.js.map +0 -1
- package/dist/create-props-PUVFMh9y.d.ts.map +0 -1
- package/dist/editor-context-DHjS00Fa.js.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
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
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
AbstractReactMarkView,
|
|
5
|
+
buildReactMarkViewCreator,
|
|
6
|
+
type MarkViewContext,
|
|
7
|
+
type ReactRendererResult,
|
|
8
|
+
} from '@prosemirror-adapter/react'
|
|
9
|
+
import { createElement, type ComponentType, type ReactPortal } from 'react'
|
|
10
|
+
import { createPortal } from 'react-dom'
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @public
|
|
@@ -28,25 +31,30 @@ export interface ReactMarkViewOptions extends CoreMarkViewUserOptions<ReactMarkV
|
|
|
28
31
|
name: string
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
34
|
+
class ProseKitReactMarkView extends AbstractReactMarkView<ReactMarkViewComponent> {
|
|
35
|
+
render = (): ReactPortal => {
|
|
36
|
+
const UserComponent = this.component
|
|
37
|
+
const props = { ...this.context }
|
|
38
|
+
return createPortal(
|
|
39
|
+
createElement(UserComponent, props),
|
|
40
|
+
this.dom,
|
|
41
|
+
this.key,
|
|
42
|
+
)
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
/**
|
|
39
47
|
* @internal
|
|
40
48
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
export function defineReactMarkViewFactory(
|
|
50
|
+
renderReactRenderer: ReactRendererResult['renderReactRenderer'],
|
|
51
|
+
removeReactRenderer: ReactRendererResult['removeReactRenderer'],
|
|
52
|
+
): Extension {
|
|
53
|
+
const factory = buildReactMarkViewCreator(renderReactRenderer, removeReactRenderer, ProseKitReactMarkView)
|
|
54
|
+
return defineMarkViewFactory<ReactMarkViewOptions>({
|
|
55
|
+
group: 'react',
|
|
56
|
+
factory,
|
|
57
|
+
})
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
/**
|
|
@@ -55,25 +63,9 @@ export const ReactMarkViewConsumer: FC = () => {
|
|
|
55
63
|
* @public
|
|
56
64
|
*/
|
|
57
65
|
export function defineReactMarkView(options: ReactMarkViewOptions): Extension {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const args: ReactMarkViewUserOptions = {
|
|
61
|
-
...userOptions,
|
|
62
|
-
component: withMarkViewProps(component),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return defineMarkViewComponent<ReactMarkViewUserOptions>({
|
|
66
|
-
group: 'react',
|
|
67
|
-
name,
|
|
68
|
-
args,
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function defineReactMarkViewFactory(
|
|
73
|
-
factory: (options: ReactMarkViewUserOptions) => MarkViewConstructor,
|
|
74
|
-
) {
|
|
75
|
-
return defineMarkViewFactory<ReactMarkViewUserOptions>({
|
|
66
|
+
return defineMarkViewComponent<ReactMarkViewOptions>({
|
|
76
67
|
group: 'react',
|
|
77
|
-
|
|
68
|
+
name: options.name,
|
|
69
|
+
args: options,
|
|
78
70
|
})
|
|
79
71
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
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
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
AbstractReactNodeView,
|
|
5
|
+
buildReactNodeViewCreator,
|
|
6
|
+
type NodeViewContext,
|
|
7
|
+
type ReactRendererResult,
|
|
8
|
+
} from '@prosemirror-adapter/react'
|
|
9
|
+
import { createElement, type ComponentType, type ReactPortal } from 'react'
|
|
10
|
+
import { createPortal } from 'react-dom'
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @public
|
|
@@ -28,25 +31,30 @@ export interface ReactNodeViewOptions extends CoreNodeViewUserOptions<ReactNodeV
|
|
|
28
31
|
name: string
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
34
|
+
class ProseKitReactNodeView extends AbstractReactNodeView<ReactNodeViewComponent> {
|
|
35
|
+
render = (): ReactPortal => {
|
|
36
|
+
const UserComponent = this.component
|
|
37
|
+
const props = { ...this.context }
|
|
38
|
+
return createPortal(
|
|
39
|
+
createElement(UserComponent, props),
|
|
40
|
+
this.dom,
|
|
41
|
+
this.key,
|
|
42
|
+
)
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
/**
|
|
39
47
|
* @internal
|
|
40
48
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
export function defineReactNodeViewFactory(
|
|
50
|
+
renderReactRenderer: ReactRendererResult['renderReactRenderer'],
|
|
51
|
+
removeReactRenderer: ReactRendererResult['removeReactRenderer'],
|
|
52
|
+
): Extension {
|
|
53
|
+
const factory = buildReactNodeViewCreator(renderReactRenderer, removeReactRenderer, ProseKitReactNodeView)
|
|
54
|
+
return defineNodeViewFactory<ReactNodeViewOptions>({
|
|
55
|
+
group: 'react',
|
|
56
|
+
factory,
|
|
57
|
+
})
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
/**
|
|
@@ -55,25 +63,9 @@ export const ReactNodeViewConsumer: FC = () => {
|
|
|
55
63
|
* @public
|
|
56
64
|
*/
|
|
57
65
|
export function defineReactNodeView(options: ReactNodeViewOptions): Extension {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const args: ReactNodeViewUserOptions = {
|
|
61
|
-
...userOptions,
|
|
62
|
-
component: withNodeViewProps(component),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return defineNodeViewComponent<ReactNodeViewUserOptions>({
|
|
66
|
-
group: 'react',
|
|
67
|
-
name,
|
|
68
|
-
args,
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function defineReactNodeViewFactory(
|
|
73
|
-
factory: (options: ReactNodeViewUserOptions) => NodeViewConstructor,
|
|
74
|
-
) {
|
|
75
|
-
return defineNodeViewFactory<ReactNodeViewUserOptions>({
|
|
66
|
+
return defineNodeViewComponent<ReactNodeViewOptions>({
|
|
76
67
|
group: 'react',
|
|
77
|
-
|
|
68
|
+
name: options.name,
|
|
69
|
+
args: options,
|
|
78
70
|
})
|
|
79
71
|
}
|
|
@@ -2,8 +2,8 @@ import { defineDocChangeHandler } from '@prosekit/core'
|
|
|
2
2
|
import type { ProseMirrorNode } from '@prosekit/pm/model'
|
|
3
3
|
import { useMemo } from 'react'
|
|
4
4
|
|
|
5
|
-
import { useEventCallback } from './use-event-callback'
|
|
6
|
-
import { useExtension, type UseExtensionOptions } from './use-extension'
|
|
5
|
+
import { useEventCallback } from './use-event-callback.ts'
|
|
6
|
+
import { useExtension, type UseExtensionOptions } from './use-extension.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Calls the given handler whenever the editor document changes.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineMountHandler, defineUpdateHandler, EditorNotFoundError, union, type Editor, type Extension } from '@prosekit/core'
|
|
2
2
|
import { useMemo, useSyncExternalStore } from 'react'
|
|
3
3
|
|
|
4
|
-
import { useEditorContext } from '../contexts/editor-context'
|
|
4
|
+
import { useEditorContext } from '../contexts/editor-context.ts'
|
|
5
5
|
|
|
6
6
|
export interface UseEditorDerivedOptions<E extends Extension = any> {
|
|
7
7
|
/**
|
package/src/hooks/use-editor.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineMountHandler, defineUpdateHandler, ProseKitError, union, type Editor, type Extension } from '@prosekit/core'
|
|
2
2
|
import { useEffect, useReducer } from 'react'
|
|
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,9 +1,9 @@
|
|
|
1
1
|
import type { Editor, Extension, Priority } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { useEditorContext } from '../contexts/editor-context'
|
|
3
|
+
import { useEditorContext } from '../contexts/editor-context.ts'
|
|
4
4
|
|
|
5
|
-
import { useEditorExtension } from './use-editor-extension'
|
|
6
|
-
import { usePriorityExtension } from './use-priority-extension'
|
|
5
|
+
import { useEditorExtension } from './use-editor-extension.ts'
|
|
6
|
+
import { usePriorityExtension } from './use-priority-extension.ts'
|
|
7
7
|
|
|
8
8
|
export interface UseExtensionOptions {
|
|
9
9
|
/**
|
package/src/hooks/use-keymap.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineKeymap, type Keymap } from '@prosekit/core'
|
|
2
2
|
import { useMemo } from 'react'
|
|
3
3
|
|
|
4
|
-
import { useExtension, type UseExtensionOptions } from './use-extension'
|
|
4
|
+
import { useExtension, type UseExtensionOptions } from './use-extension.ts'
|
|
5
5
|
|
|
6
6
|
export function useKeymap(keymap: Keymap, options?: UseExtensionOptions): void {
|
|
7
7
|
const extension = useMemo(() => defineKeymap(keymap), [keymap])
|
|
@@ -2,8 +2,8 @@ import { defineUpdateHandler } from '@prosekit/core'
|
|
|
2
2
|
import type { EditorState } from '@prosekit/pm/state'
|
|
3
3
|
import { useMemo } from 'react'
|
|
4
4
|
|
|
5
|
-
import { useEventCallback } from './use-event-callback'
|
|
6
|
-
import { useExtension, type UseExtensionOptions } from './use-extension'
|
|
5
|
+
import { useEventCallback } from './use-event-callback.ts'
|
|
6
|
+
import { useExtension, type UseExtensionOptions } from './use-extension.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Calls the given handler whenever the editor state changes.
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { ProseKit, type ProseKitProps } from './components/prosekit'
|
|
1
|
+
export { ProseKit, type ProseKitProps } from './components/prosekit.ts'
|
|
2
2
|
export {
|
|
3
3
|
defineReactMarkView,
|
|
4
4
|
type ReactMarkViewComponent,
|
|
5
5
|
type ReactMarkViewOptions,
|
|
6
6
|
type ReactMarkViewProps,
|
|
7
|
-
} from './extensions/react-mark-view'
|
|
7
|
+
} from './extensions/react-mark-view.ts'
|
|
8
8
|
export {
|
|
9
9
|
defineReactNodeView,
|
|
10
10
|
type ReactNodeViewComponent,
|
|
11
11
|
type ReactNodeViewOptions,
|
|
12
12
|
type ReactNodeViewProps,
|
|
13
|
-
} from './extensions/react-node-view'
|
|
14
|
-
export { useDocChange } from './hooks/use-doc-change'
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export { useExtension, type UseExtensionOptions } from './hooks/use-extension'
|
|
18
|
-
export { useKeymap } from './hooks/use-keymap'
|
|
19
|
-
export { useStateUpdate } from './hooks/use-state-update'
|
|
20
|
-
export { type PropsWithClassName } from './types'
|
|
13
|
+
} from './extensions/react-node-view.ts'
|
|
14
|
+
export { useDocChange } from './hooks/use-doc-change.ts'
|
|
15
|
+
export { useEditorDerivedValue, type UseEditorDerivedOptions } from './hooks/use-editor-derived-value.ts'
|
|
16
|
+
export { useEditor } from './hooks/use-editor.ts'
|
|
17
|
+
export { useExtension, type UseExtensionOptions } from './hooks/use-extension.ts'
|
|
18
|
+
export { useKeymap } from './hooks/use-keymap.ts'
|
|
19
|
+
export { useStateUpdate } from './hooks/use-state-update.ts'
|
|
20
|
+
export { type PropsWithClassName } from './types.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-component-D8vvwyIA.js","names":[],"sources":["../src/components/merge-refs.ts","../src/components/create-component.ts"],"sourcesContent":["import type { Ref } from 'react'\n\n/**\n * Assigns a value to a ref.\n * @returns The ref cleanup callback, if any.\n */\nfunction assignRef<T>(\n ref: Ref<T> | undefined,\n value: T | null,\n): VoidFunction | void {\n if (typeof ref === 'function') {\n return ref(value)\n } else if (ref) {\n ref.current = value\n }\n}\n\n/**\n * Merges multiple refs into a single one.\n */\nexport function mergeRefs<T>(refs: (Ref<T> | undefined)[]): Ref<T> {\n return (value: T | null) => {\n const cleanups: VoidFunction[] = []\n\n for (const ref of refs) {\n const cleanup = assignRef(ref, value)\n const isCleanup = typeof cleanup === 'function'\n cleanups.push(isCleanup ? cleanup : () => assignRef(ref, null))\n }\n\n return () => {\n for (const cleanup of cleanups) cleanup()\n }\n }\n}\n","import type { AnyFunction } from '@prosekit/core'\nimport {\n createElement,\n forwardRef,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ForwardRefExoticComponent,\n type HTMLAttributes,\n type RefAttributes,\n} from 'react'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\nimport { mergeRefs } from './merge-refs'\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport function createComponent<\n Props extends object,\n CustomElement extends HTMLElement,\n>(\n tagName: string,\n displayName: string,\n propNames: string[],\n eventNames: string[],\n): ForwardRefExoticComponent<\n Partial<Props> & RefAttributes<CustomElement> & HTMLAttributes<CustomElement>\n> {\n const hasEditor = propNames.includes('editor')\n const lowerCaseEventNameMap = new Map(\n eventNames.map((name) => [name.toLowerCase(), name]),\n )\n\n const Component = forwardRef<any, any>((props: Props, ref) => {\n const [el, setEl] = useState<HTMLElement | null>(null)\n\n const properties: Record<string, unknown> = {}\n const attributes: Record<string, unknown> = {}\n const eventHandlersRef = useRef<Record<string, AnyFunction>>({})\n const eventHandlers: Record<string, AnyFunction> = {}\n\n for (const [name, value] of Object.entries(props)) {\n if (value === undefined) {\n continue\n }\n\n if (propNames.includes(name)) {\n properties[name] = value\n continue\n }\n\n if (name.startsWith('on')) {\n const lowerCaseEventName = name.slice(2).toLowerCase()\n const eventName = lowerCaseEventNameMap.get(lowerCaseEventName)\n if (eventName) {\n const extractDetail = eventName.endsWith('Change')\n eventHandlers[eventName] = (event: Event) => {\n const handler = value as AnyFunction | null\n if (typeof handler === 'function') {\n handler(extractDetail ? (event as CustomEvent).detail : event)\n }\n }\n continue\n }\n }\n\n if (name === 'className') {\n attributes['class'] = value\n } else {\n attributes[name] = value\n }\n }\n\n const editor = useEditorContext()\n\n if (hasEditor && editor && !properties['editor']) {\n properties['editor'] = editor\n }\n\n // Set all properties.\n useIsomorphicLayoutEffect(() => {\n if (!el) return\n for (const [name, value] of Object.entries(properties)) {\n if (value !== undefined) {\n // @ts-expect-error: we know that name is a valid property name\n // eslint-disable-next-line react-hooks/immutability\n el[name] = value\n }\n }\n }, [el, ...propNames.map((name) => properties[name])])\n\n // Put all event listeners extracted from `props` into `eventHandlersRef`.\n useIsomorphicLayoutEffect(() => {\n eventHandlersRef.current = eventHandlers\n })\n\n // Register the event listeners to the element.\n useIsomorphicLayoutEffect(() => {\n if (!el) {\n return\n }\n\n const fixedEventHandlers: Record<string, AnyFunction> = {}\n\n for (const eventName of eventNames) {\n fixedEventHandlers[eventName] = (event: Event) => {\n eventHandlersRef.current[eventName]?.(event)\n }\n }\n\n for (const [name, handler] of Object.entries(fixedEventHandlers)) {\n el.addEventListener(name, handler)\n }\n\n return () => {\n for (const [name, handler] of Object.entries(fixedEventHandlers)) {\n el.removeEventListener(name, handler)\n }\n }\n }, [el])\n\n const mergedRef = useMemo(() => mergeRefs([ref, setEl]), [ref])\n\n return createElement(tagName, {\n ...attributes,\n // Suppress hydration warnings for web components as the attributes are set after the component is mounted.\n suppressHydrationWarning: true,\n ref: mergedRef,\n })\n })\n\n Component.displayName = displayName\n\n return Component\n}\n"],"mappings":";;;;;;;;AAMA,SAAS,UACP,KACA,OACqB;AACrB,KAAI,OAAO,QAAQ,WACjB,QAAO,IAAI,MAAM;UACR,IACT,KAAI,UAAU;;;;;AAOlB,SAAgB,UAAa,MAAsC;AACjE,SAAQ,UAAoB;EAC1B,MAAM,WAA2B,EAAE;AAEnC,OAAK,MAAM,OAAO,MAAM;GACtB,MAAM,UAAU,UAAU,KAAK,MAAM;GACrC,MAAM,YAAY,OAAO,YAAY;AACrC,YAAS,KAAK,YAAY,gBAAgB,UAAU,KAAK,KAAK,CAAC;;AAGjE,eAAa;AACX,QAAK,MAAM,WAAW,SAAU,UAAS;;;;;;;ACb/C,MAAM,4BAA4B,OAAO,WAAW,cAAc,kBAAkB;AAEpF,SAAgB,gBAId,SACA,aACA,WACA,YAGA;CACA,MAAM,YAAY,UAAU,SAAS,SAAS;CAC9C,MAAM,wBAAwB,IAAI,IAChC,WAAW,KAAK,SAAS,CAAC,KAAK,aAAa,EAAE,KAAK,CAAC,CACrD;CAED,MAAM,YAAY,YAAsB,OAAc,QAAQ;EAC5D,MAAM,CAAC,IAAI,SAAS,SAA6B,KAAK;EAEtD,MAAM,aAAsC,EAAE;EAC9C,MAAM,aAAsC,EAAE;EAC9C,MAAM,mBAAmB,OAAoC,EAAE,CAAC;EAChE,MAAM,gBAA6C,EAAE;AAErD,OAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,EAAE;AACjD,OAAI,UAAU,OACZ;AAGF,OAAI,UAAU,SAAS,KAAK,EAAE;AAC5B,eAAW,QAAQ;AACnB;;AAGF,OAAI,KAAK,WAAW,KAAK,EAAE;IACzB,MAAM,qBAAqB,KAAK,MAAM,EAAE,CAAC,aAAa;IACtD,MAAM,YAAY,sBAAsB,IAAI,mBAAmB;AAC/D,QAAI,WAAW;KACb,MAAM,gBAAgB,UAAU,SAAS,SAAS;AAClD,mBAAc,cAAc,UAAiB;MAC3C,MAAM,UAAU;AAChB,UAAI,OAAO,YAAY,WACrB,SAAQ,gBAAiB,MAAsB,SAAS,MAAM;;AAGlE;;;AAIJ,OAAI,SAAS,YACX,YAAW,WAAW;OAEtB,YAAW,QAAQ;;EAIvB,MAAM,SAAS,kBAAkB;AAEjC,MAAI,aAAa,UAAU,CAAC,WAAW,UACrC,YAAW,YAAY;AAIzB,kCAAgC;AAC9B,OAAI,CAAC,GAAI;AACT,QAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,WAAW,CACpD,KAAI,UAAU,OAGZ,IAAG,QAAQ;KAGd,CAAC,IAAI,GAAG,UAAU,KAAK,SAAS,WAAW,MAAM,CAAC,CAAC;AAGtD,kCAAgC;AAC9B,oBAAiB,UAAU;IAC3B;AAGF,kCAAgC;AAC9B,OAAI,CAAC,GACH;GAGF,MAAM,qBAAkD,EAAE;AAE1D,QAAK,MAAM,aAAa,WACtB,oBAAmB,cAAc,UAAiB;AAChD,qBAAiB,QAAQ,aAAa,MAAM;;AAIhD,QAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,mBAAmB,CAC9D,IAAG,iBAAiB,MAAM,QAAQ;AAGpC,gBAAa;AACX,SAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,mBAAmB,CAC9D,IAAG,oBAAoB,MAAM,QAAQ;;KAGxC,CAAC,GAAG,CAAC;EAER,MAAM,YAAY,cAAc,UAAU,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;AAE/D,SAAO,cAAc,SAAS;GAC5B,GAAG;GAEH,0BAA0B;GAC1B,KAAK;GACN,CAAC;GACF;AAEF,WAAU,cAAc;AAExB,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-props-PUVFMh9y.d.ts","names":[],"sources":["../src/components/create-props.ts"],"mappings":";KAAY,WAAA,oCACyB,KAAA,mDACE,MAAA,GAAS,WAAA,MAC5C,KAAA,GAAQ,gBAAA,CAAiB,MAAA;AAAA,KAExB,gBAAA,sCACkC,MAAA,GAAS,WAAA,4BAE1B,MAAA,SAAe,UAAA,UAAoB,SAAA,OACrD,KAAA,EAAO,SAAA,6BAAsC,MAAA,CAAO,SAAA,cAChD,MAAA,CAAO,SAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor-context-DHjS00Fa.js","names":[],"sources":["../src/contexts/editor-context.ts"],"sourcesContent":["import type { Editor, Extension } from '@prosekit/core'\nimport { createContext, useContext, type Provider } from 'react'\n\nconst EditorContext = createContext<Editor | null>(null)\n\n/**\n * @internal\n */\nexport function useEditorContext<E extends Extension>(): Editor<E> | null {\n return useContext(EditorContext)\n}\n\n/**\n * @internal\n */\nexport const EditorContextProvider: Provider<Editor | null> = EditorContext.Provider\n"],"mappings":";;;AAGA,MAAM,gBAAgB,cAA6B,KAAK;;;;AAKxD,SAAgB,mBAA0D;AACxE,QAAO,WAAW,cAAc;;;;;AAMlC,MAAa,wBAAiD,cAAc"}
|