Hi , I'm trying to render more than one atomic blocks , with the blockRenderer
blockRenderer: (block)=>
if (block.getType() is 'atomic')
return (
component: ImageBlock
)
if (block.getType() is 'atomic:embed')
return (
component: embedBlock
)
return null;
Is there a way to label an Entity with custom name? I've tried with Entity.create('atomic:embed', 'IMMUTABLE', {foo}) but I always get "atomic" type in block.getType() on the blockRenderer
thanks
@michelson here you are checking block type studentViewState: state.studentView,
Entity.create('atomic:embed', 'IMMUTABLE', {foo}) is creating type for entity.. they are different types.
example for your use cased would be
blockRenderer: (block)=>
if (block.getType() is 'atomic')
if(Entity
.get(block.getEntityAt(0)).getType() is 'atomic:embed') {
//do something
}
return (
component: ImageBlock
)
return null;
// Entity
.get(block.getEntityAt(0)).getType() to get entity's type. and beware of this will be changed in next release I guess since draft-js team decide to move entities to content block
thanks @mzbac ! it works
yes, I've seen that creation of entities in master brach was moved to editorState, so Entity.create will be unsupported ?
best
Most helpful comment
@michelson here you are checking block type
studentViewState: state.studentView,Entity.create('atomic:embed', 'IMMUTABLE', {foo}) is creating type for entity.. they are different types.
example for your use cased would be