import Editor from "../editor" ; import StructureType from "../const/structure-type" ; import focusAt from "../selection/focus-at" ; import { Cursor } from "../selection/util" ; import deleteSelection from "./delete-selection" ; const backspace = ( editor , start , end = start , event ? ) => { if ( start . id === end . id && start . offset === end . offset ) { let block = editor . storeManage . getBlockById ( start . id ) ; if ( event && [ StructureType . content , StructureType . plainText ] . includes ( block . structureType ) ) { if ( start . offset <= 1 ) { event ?. preventDefault ( ) ; let operator = block . remove ( start . offset - 1 , start . offset ) ; return focusAt ( editor , operator ?. [ 0 ] || start , operator ?. [ 1 ] ) ; } editor . articleManage . stopUpdate ( ) ; block . remove ( start . offset - 1 , start . offset ) ; editor . articleManage . startUpdate ( ) ; return ; } event ?. preventDefault ( ) ; let operator = block . remove ( start . offset , start . offset + 1 ) ; return focusAt ( editor , operator ?. [ 0 ] || start , operator ?. [ 1 ] ) ; } event ?. preventDefault ( ) ; deleteSelection ( editor , start , end ) ; } ; export default backspace ;