From c6c1936468a7e8a479854c1524d29d8e555907dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Wed, 6 Apr 2022 18:06:01 +0800 Subject: [PATCH] fix:event error at control boundary --- src/editor/core/event/CanvasEvent.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/editor/core/event/CanvasEvent.ts b/src/editor/core/event/CanvasEvent.ts index dfd25df..96a7f37 100644 --- a/src/editor/core/event/CanvasEvent.ts +++ b/src/editor/core/event/CanvasEvent.ts @@ -273,6 +273,7 @@ export class CanvasEvent { const { index } = cursorPosition const { startIndex, endIndex } = this.range.getRange() const isCollapsed = startIndex === endIndex + const element = elementList[index] // 当前激活控件 const isPartRangeInControlOutside = this.control.isPartRangeInControlOutside() const activeControl = this.control.getActiveControl() @@ -299,10 +300,8 @@ export class CanvasEvent { } else if (evt.key === KeyMap.Delete) { if (isReadonly || isPartRangeInControlOutside) return let curIndex: number - if (activeControl) { + if (activeControl && elementList[endIndex + 1]?.controlId === element.controlId) { curIndex = this.control.keydown(evt) - } else if (elementList[endIndex + 1]?.type === ElementType.CONTROL) { - curIndex = this.control.removeControl(endIndex + 1) } else { if (!isCollapsed) { elementList.splice(startIndex + 1, endIndex - startIndex) @@ -522,7 +521,7 @@ export class CanvasEvent { }) // 控件-移除placeholder let curIndex: number - if (activeControl) { + if (activeControl && elementList[endIndex + 1]?.controlId === element.controlId) { curIndex = this.control.setValue(inputData) } else { let start = 0