tiptap/packages/react/src/NodeViewWrapper.tsx

22 lines
468 B
TypeScript
Raw Normal View History

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 {
as: React.ElementType
}
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {
2021-03-15 03:40:40 +08:00
const { onDragStart } = useReactNodeView()
2021-03-15 04:45:14 +08:00
const Tag = props.as || 'div'
2021-03-14 23:30:06 +08:00
return (
2021-03-15 04:45:14 +08:00
<Tag
2021-03-14 23:30:06 +08:00
data-node-view-wrapper=""
onDragStart={onDragStart}
2021-03-15 05:41:25 +08:00
style={{ whiteSpace: 'normal' }}
2021-03-14 23:30:06 +08:00
>
{props.children}
2021-03-15 04:45:14 +08:00
</Tag>
2021-03-14 23:30:06 +08:00
)
}