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

View File

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