import { EditorState } from '@craftjs/core' ; import mergeElements from './mergeElements' ; import { removeInvalidNodes } from './removeInvalidNodes' ; import { splitSlate } from './splitSlate' ; import { wrapRogueElement } from './wrapRogueElement' ; export const normalizeSlate = ( slateType , elementResolver , leafElementType ) => ( state ) => { const elementTypes = Object . values ( elementResolver ) ; const acceptableChildrenTypes = [ ... elementTypes , leafElementType ] ; splitSlate ( state , slateType , acceptableChildrenTypes ) ; wrapRogueElement ( state , slateType , acceptableChildrenTypes ) ; mergeElements ( slateType , state ) ; removeInvalidNodes ( state , slateType , elementTypes , leafElementType ) ; return state ; } ;