import Editor from "../editor" ; import Block from "../components/block" ; import getSelection from "./get-selection" ; import deleteSelection from "../operator/delete-selection" ; import focusAt from "./focus-at" ; const insertBlock = ( editor , ... blockList ) => { let selection = getSelection ( editor ) ; if ( ! selection . isCollapsed ) { deleteSelection ( editor , selection . range [ 0 ] , selection . range [ 1 ] ) ; selection = getSelection ( editor ) ; } try { let nowComponent = editor . storeManage . getBlockById ( selection . range [ 0 ] . id ) ; let start = selection . range [ 0 ] ; let operator = nowComponent . split ( start . offset , ... blockList ) ; focusAt ( editor , operator ?. [ 0 ] || start , operator ?. [ 1 ] ) ; } catch ( e ) { console . warn ( e ) ; } } ; export default insertBlock ;