2021-03-14 23:30:06 +08:00
|
|
|
import React from 'react'
|
2021-03-15 03:40:40 +08:00
|
|
|
import { useReactNodeView } from './useReactNodeView'
|
2021-03-14 23:30:06 +08:00
|
|
|
|
2021-03-15 04:45:14 +08:00
|
|
|
export interface NodeViewWrapperProps {
|
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-06-14 22:03:29 +08:00
|
|
|
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = React.forwardRef((props, ref) => {
|
|
|
|
const { onDragStart } = useReactNodeView()
|
|
|
|
const Tag = props.as || 'div'
|
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}
|
|
|
|
ref={ref}
|
|
|
|
data-node-view-wrapper=""
|
|
|
|
onDragStart={onDragStart}
|
|
|
|
style={{
|
|
|
|
...props.style,
|
|
|
|
whiteSpace: 'normal',
|
|
|
|
}}
|
|
|
|
/>
|
2021-06-14 22:03:29 +08:00
|
|
|
)
|
|
|
|
})
|