File size: 743 Bytes
2daf8de | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import type { ComponentProps } from 'react'
import React from 'react'
import { useReactNodeView } from './useReactNodeView.js'
export type NodeViewContentProps<T extends keyof React.JSX.IntrinsicElements = 'div'> = {
as?: NoInfer<T>
} & ComponentProps<T>
export function NodeViewContent<T extends keyof React.JSX.IntrinsicElements = 'div'>({
as: Tag = 'div' as T,
...props
}: NodeViewContentProps<T>) {
const { nodeViewContentRef, nodeViewContentChildren } = useReactNodeView()
return (
// @ts-ignore
<Tag
{...props}
ref={nodeViewContentRef}
data-node-view-content=""
style={{
whiteSpace: 'pre-wrap',
...props.style,
}}
>
{nodeViewContentChildren}
</Tag>
)
}
|