refactoring
This commit is contained in:
@@ -6,19 +6,14 @@ export interface NodeViewContentProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const NodeViewContent: React.FC<NodeViewContentProps> = props => {
|
export const NodeViewContent: React.FC<NodeViewContentProps> = props => {
|
||||||
// TODO
|
|
||||||
// @ts-ignore
|
|
||||||
const { isEditable } = useReactNodeView()
|
const { isEditable } = useReactNodeView()
|
||||||
|
|
||||||
const Tag = props.as || 'div'
|
const Tag = props.as || 'div'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tag
|
<Tag
|
||||||
data-node-view-content=""
|
data-node-view-content=""
|
||||||
contentEditable={isEditable}
|
contentEditable={isEditable}
|
||||||
style={{
|
style={{ whiteSpace: 'pre-wrap' }}
|
||||||
whiteSpace: 'pre-wrap'
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,14 @@ export interface NodeViewWrapperProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {
|
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {
|
||||||
// TODO
|
|
||||||
// @ts-ignore
|
|
||||||
const { onDragStart } = useReactNodeView()
|
const { onDragStart } = useReactNodeView()
|
||||||
|
|
||||||
const Tag = props.as || 'div'
|
const Tag = props.as || 'div'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tag
|
<Tag
|
||||||
data-node-view-wrapper=""
|
data-node-view-wrapper=""
|
||||||
style={{
|
|
||||||
whiteSpace: 'normal'
|
|
||||||
}}
|
|
||||||
onDragStart={onDragStart}
|
onDragStart={onDragStart}
|
||||||
|
style={{ whiteSpace: 'normal' }}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import React, { useContext } from 'react'
|
import React, { useContext } from 'react'
|
||||||
|
|
||||||
export const ReactNodeViewContext = React.createContext<any>({
|
export interface ReactNodeViewContextProps {
|
||||||
|
isEditable: boolean,
|
||||||
|
onDragStart: (event: DragEvent) => void,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ReactNodeViewContext = React.createContext<Partial<ReactNodeViewContextProps>>({
|
||||||
isEditable: undefined,
|
isEditable: undefined,
|
||||||
onDragStart: undefined,
|
onDragStart: undefined,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user