2021-10-01 03:13:37 +08:00
|
|
|
import React from 'react'
|
2022-06-08 20:10:25 +08:00
|
|
|
|
2021-08-25 04:13:18 +08:00
|
|
|
import { useReactNodeView } from './useReactNodeView'
|
2021-03-14 23:30:06 +08:00
|
|
|
|
2021-03-15 04:45:14 +08:00
|
|
|
export interface NodeViewContentProps {
|
2021-04-24 05:38:38 +08:00
|
|
|
[key: string]: any,
|
2021-04-08 15:11:45 +08:00
|
|
|
as?: React.ElementType,
|
2021-03-15 04:45:14 +08:00
|
|
|
}
|
|
|
|
|
2021-10-01 03:13:37 +08:00
|
|
|
export const NodeViewContent: React.FC<NodeViewContentProps> = props => {
|
2021-06-14 22:03:29 +08:00
|
|
|
const Tag = props.as || 'div'
|
2021-10-01 03:13:37 +08:00
|
|
|
const { nodeViewContentRef } = useReactNodeView()
|
2021-03-15 04:45:14 +08:00
|
|
|
|
2021-06-14 22:03:29 +08:00
|
|
|
return (
|
2021-06-14 22:06:49 +08:00
|
|
|
<Tag
|
|
|
|
{...props}
|
2021-10-01 03:13:37 +08:00
|
|
|
ref={nodeViewContentRef}
|
2021-06-14 22:06:49 +08:00
|
|
|
data-node-view-content=""
|
|
|
|
style={{
|
|
|
|
whiteSpace: 'pre-wrap',
|
2022-06-21 01:41:33 +08:00
|
|
|
...props.style,
|
2021-06-14 22:06:49 +08:00
|
|
|
}}
|
|
|
|
/>
|
2021-06-14 22:03:29 +08:00
|
|
|
)
|
2021-10-01 03:13:37 +08:00
|
|
|
}
|