From 453044042aebc0cc03d1460bc93bed5290334a75 Mon Sep 17 00:00:00 2001 From: lovefield Date: Tue, 20 Aug 2024 15:34:19 +0900 Subject: [PATCH] fix: list backspace bug --- src/runtime/utils/keyboardEvent.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/runtime/utils/keyboardEvent.ts b/src/runtime/utils/keyboardEvent.ts index 611b6dd..52f1af2 100644 --- a/src/runtime/utils/keyboardEvent.ts +++ b/src/runtime/utils/keyboardEvent.ts @@ -786,6 +786,7 @@ function defaultBlockBackspaceEvent(e: KeyboardEvent, store: any, $element: Elem // 내용이 없는 경우 e.preventDefault(); + // arrangeCursorAndContentInBackspaceEvent($textBlock, $textBlock); const $preBlock = $textBlock.previousElementSibling as HTMLElement; const { type: preBlockType } = _getBlockType($preBlock); @@ -867,19 +868,10 @@ function defaultBlockBackspaceEvent(e: KeyboardEvent, store: any, $element: Elem function listBlockBackspaceEvent(e: KeyboardEvent, store: any, $element: Element) { const $listBlock = $element as HTMLElement; const $targetItem = _findContentEditableElement(store.cursorData.startNode as HTMLElement) as HTMLLIElement; - const childList = store.$content.querySelectorAll(".de-block"); const liList = $listBlock.querySelectorAll(".de-item"); const $target: HTMLElement = _getParentElementIfNodeIsText(store.cursorData.startNode, $targetItem) as HTMLElement; - let elementIdx: number = -1; let liIdx: number = -1; - for (let i = 0; childList.length > i; i += 1) { - if (childList[i] === $element) { - elementIdx = i; - break; - } - } - for (let i = 0; liList.length > i; i += 1) { if (liList[i] === $targetItem) { liIdx = i; @@ -937,6 +929,7 @@ function listBlockBackspaceEvent(e: KeyboardEvent, store: any, $element: Element } $targetItem.remove(); + $listBlock.remove(); } } }