const createContentBlock = (blockData = {}) => { const { key, type, text, data, inlineStyles, entityData } = blockData; let blockSpec = { type: type !== null && type !== undefined ? type : 'unstyled', text: text !== null && text !== undefined ? text : '', key: key !== null && key !== undefined ? key : genKey(), }; if (data) { blockSpec.data = fromJS(data); } if (inlineStyles || entityData) { let entityKey; if (entityData) { const { type, mutability, data } = entityData; entityKey = Entity.create(type, mutability, data); } else { entityKey = null; } const style = OrderedSet(inlineStyles || []); const charData = CharacterMetadata.applyEntity( CharacterMetadata.create({ style, entityKey }), entityKey, ); blockSpec.characterList = List(Repeat(charData, text.length)); } return new ContentBlock(blockSpec); }
const createContentBlock = (blockData = {}) => { const { key, type, text, data, inlineStyles, entityData } = blockData; let blockSpec = { type: type !== null && type !== undefined ? type : 'unstyled', text: text !== null && text !== undefined ? text : '', key: key !== null && key !== undefined ? key : genKey(), }; if (data) { blockSpec.data = fromJS(data); } if (inlineStyles || entityData) { let entityKey; if (entityData) { const { type, mutability, data } = entityData; entityKey = Entity.create(type, mutability, data); } else { entityKey = null; } const style = OrderedSet(inlineStyles || []); const charData = CharacterMetadata.applyEntity( CharacterMetadata.create({ style, entityKey }), entityKey, ); blockSpec.characterList = List(Repeat(charData, text.length)); } return new ContentBlock(blockSpec); }