Skip to content

Commit

Permalink
fix: list backspace bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lovefields committed Aug 20, 2024
1 parent a6f7340 commit 4530440
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/runtime/utils/keyboardEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -937,6 +929,7 @@ function listBlockBackspaceEvent(e: KeyboardEvent, store: any, $element: Element
}

$targetItem.remove();
$listBlock.remove();
}
}
}
Expand Down

0 comments on commit 4530440

Please sign in to comment.