jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.38k stars 1.15k forks source link

Bold and Italic are not working together #1295

Open Durgesh2607 opened 1 year ago

Durgesh2607 commented 1 year ago

`const customContentStateConverter = (contentState) => { const newBlockMap = contentState.getBlockMap().map((block) => { const entityKey = block.getEntityAt(0); if (entityKey !== null) { const entityBlock = contentState.getEntity(entityKey); const entityType = entityBlock.getType(); switch (entityType) { case "IMAGE": { const newBlock = block.merge({ type: "atomic", text: "img", }); return newBlock; } default: return block; } } return block; }); const newContentState = contentState.set("blockMap", newBlockMap); return newContentState; };

class EmailBodyEditor extends Component { constructor(props) { super(props); let editorState; if (props.value !== "") { const processedHTML = convertFromHTML(props.value); const contentState = ContentState.createFromBlockArray(processedHTML); //move focus to the end. editorState = EditorState.createWithContent( customContentStateConverter(contentState) ); editorState = EditorState.moveFocusToEnd(editorState); } else { editorState = EditorState.createEmpty(); } this.state = { editorState: editorState, }; } keyBindingFn = (e) => { if (e.keyCode === 13) { const newEditorState = RichUtils.insertSoftNewline( this.state.editorState ); if (newEditorState !== this.state.editorState) { this.onEditorStateChange(newEditorState); } } else { return getDefaultKeyBinding(e); } }; onEditorStateChange = (editorState) => { this.setState({ editorState, }); };

render() { const { editorState } = this.state; return (

this.props.setContent(draftToHtml(e))} />
);

} }` This is what I'm doing? Any issue here?