mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
Merge pull request #1452 from YousefED/patch-2
use forwardRef for react wrappers
This commit is contained in:
commit
55203d38eb
@ -5,17 +5,20 @@ export interface NodeViewContentProps {
|
||||
as?: React.ElementType,
|
||||
}
|
||||
|
||||
export const NodeViewContent: React.FC<NodeViewContentProps> = props => {
|
||||
const Tag = props.as || 'div'
|
||||
export const NodeViewContent: React.FC<NodeViewContentProps> =
|
||||
React.forwardRef((props, ref) => {
|
||||
const Tag = props.as || 'div'
|
||||
|
||||
return (
|
||||
<Tag
|
||||
{...props}
|
||||
data-node-view-content=""
|
||||
style={{
|
||||
...props.style,
|
||||
whiteSpace: 'pre-wrap',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Tag
|
||||
{...props}
|
||||
ref={ref}
|
||||
data-node-view-content=""
|
||||
style={{
|
||||
...props.style,
|
||||
whiteSpace: 'pre-wrap',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -6,19 +6,21 @@ export interface NodeViewWrapperProps {
|
||||
as?: React.ElementType,
|
||||
}
|
||||
|
||||
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {
|
||||
const { onDragStart } = useReactNodeView()
|
||||
const Tag = props.as || 'div'
|
||||
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> =
|
||||
React.forwardRef((props, ref) => {
|
||||
const { onDragStart } = useReactNodeView()
|
||||
const Tag = props.as || 'div'
|
||||
|
||||
return (
|
||||
<Tag
|
||||
{...props}
|
||||
data-node-view-wrapper=""
|
||||
onDragStart={onDragStart}
|
||||
style={{
|
||||
...props.style,
|
||||
whiteSpace: 'normal',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Tag
|
||||
{...props}
|
||||
ref={ref}
|
||||
data-node-view-wrapper=""
|
||||
onDragStart={onDragStart}
|
||||
style={{
|
||||
...props.style,
|
||||
whiteSpace: 'normal',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user