import { ContentBlock, ContentState, EditorState } from 'draft-js'; const changeBlock = ( editorState: EditorState, block: ContentBlock, type: string, data: Record = {} // eslint-disable-line @typescript-eslint/no-explicit-any ): EditorState => { const contentState = editorState.getCurrentContent(); const nextCurrentBlock = block.merge({ type, data }) as ContentBlock; const nextContentState = contentState.merge({ blockMap: contentState.getBlockMap().set(block.getKey(), nextCurrentBlock), selectionAfter: editorState.getSelection(), }) as ContentState; return EditorState.push(editorState, nextContentState, 'change-block-type'); }; export default changeBlock;