From bc809e7098097973e34daf32096f51a9973e266c Mon Sep 17 00:00:00 2001 From: Jiuqing Song Date: Tue, 24 Oct 2023 11:06:14 -0700 Subject: [PATCH] Use Content Model to handle Delete/Backspace key in more cases (#2162) --- .../lib/publicApi/editing/keyboardDelete.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/editing/keyboardDelete.ts b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/editing/keyboardDelete.ts index 2634fe6c161..d22a9b8ee50 100644 --- a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/editing/keyboardDelete.ts +++ b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/editing/keyboardDelete.ts @@ -89,16 +89,12 @@ function shouldDeleteWithContentModel(range: Range | null, rawEvent: KeyboardEve } function canDeleteBefore(rawEvent: KeyboardEvent, range: Range) { - return ( - rawEvent.key == 'Backspace' && - (range.startOffset > 1 || range.startContainer.previousSibling) - ); + return rawEvent.key == 'Backspace' && range.startOffset > 1; } function canDeleteAfter(rawEvent: KeyboardEvent, range: Range) { return ( rawEvent.key == 'Delete' && - (range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1 || - range.startContainer.nextSibling) + range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1 ); }