import Editor from "../editor" ; import focusAt from "../selection/focus-at" ; import getSelectedIdList from "../selection/get-selected-id-list" ; import { Cursor } from "../selection/util" ; const enter = ( editor , start , end = start , event ? ) => { event ?. preventDefault ( ) ; let idList = getSelectedIdList ( editor . article , start . id , end . id ) ; if ( idList . length === 0 ) return ; if ( idList . length === 1 ) { let component = editor . storeManage . getBlockById ( idList [ 0 ] ) ; component . remove ( start . offset , end . offset ) ; let operator = component . split ( start . offset ) ; return focusAt ( editor , operator ?. [ 0 ] || start , operator ?. [ 1 ] ) ; } let firstComponent = editor . storeManage . getBlockById ( idList [ 0 ] ) ; let lastComponent = editor . storeManage . getBlockById ( idList [ idList . length - 1 ] ) ; firstComponent . remove ( start . offset ) ; lastComponent . remove ( 0 , end . offset ) ; for ( let i = 1 ; i < idList . length - 1 ; i ++ ) { editor . storeManage . getBlockById ( idList [ i ] ) . removeSelf ( ) ; } focusAt ( editor , { id : lastComponent . id , offset : 0 , } ) ; return ; } ; export default enter ;