diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index e51c423..59a11ee 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -682,7 +682,7 @@ export class Draw { if (!this.control.getActiveControl()) { let deleteIndex = endIndex - 1 while (deleteIndex >= start) { - if (elementList[deleteIndex].control?.deletable !== false) { + if (elementList[deleteIndex]?.control?.deletable !== false) { elementList.splice(deleteIndex, 1) } deleteIndex-- diff --git a/src/editor/core/event/handlers/keydown/delete.ts b/src/editor/core/event/handlers/keydown/delete.ts index 34b4cf1..96b2242 100644 --- a/src/editor/core/event/handlers/keydown/delete.ts +++ b/src/editor/core/event/handlers/keydown/delete.ts @@ -26,6 +26,7 @@ export function del(evt: KeyboardEvent, host: CanvasEvent) { if (!isCollapsed) { draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex) } else { + if (!elementList[index + 1]) return draw.spliceElementList(elementList, index + 1, 1) } curIndex = isCollapsed ? index : startIndex