add dynamic tags

This commit is contained in:
Philipp Kühn
2021-03-14 21:45:14 +01:00
parent 380d27fe86
commit 8ccb1d08cf
2 changed files with 17 additions and 7 deletions

View File

@@ -1,13 +1,19 @@
import React from 'react' import React from 'react'
import { useReactNodeView } from './useReactNodeView' import { useReactNodeView } from './useReactNodeView'
export const NodeViewContent: React.FC = props => { export interface NodeViewContentProps {
as: React.ElementType
}
export const NodeViewContent: React.FC<NodeViewContentProps> = props => {
// TODO // TODO
// @ts-ignore // @ts-ignore
const { isEditable } = useReactNodeView() const { isEditable } = useReactNodeView()
const Tag = props.as || 'div'
return ( return (
<div <Tag
data-node-view-content="" data-node-view-content=""
contentEditable={isEditable} contentEditable={isEditable}
style={{ style={{
@@ -15,5 +21,4 @@ export const NodeViewContent: React.FC = props => {
}} }}
/> />
) )
} }

View File

@@ -1,13 +1,19 @@
import React from 'react' import React from 'react'
import { useReactNodeView } from './useReactNodeView' import { useReactNodeView } from './useReactNodeView'
export const NodeViewWrapper: React.FC = props => { export interface NodeViewWrapperProps {
as: React.ElementType
}
export const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {
// TODO // TODO
// @ts-ignore // @ts-ignore
const { onDragStart } = useReactNodeView() const { onDragStart } = useReactNodeView()
const Tag = props.as || 'div'
return ( return (
<div <Tag
data-node-view-wrapper="" data-node-view-wrapper=""
style={{ style={{
whiteSpace: 'normal' whiteSpace: 'normal'
@@ -15,7 +21,6 @@ export const NodeViewWrapper: React.FC = props => {
onDragStart={onDragStart} onDragStart={onDragStart}
> >
{props.children} {props.children}
</div> </Tag>
) )
} }