From 8eeed0acb1ae88bac8fc5887a79eec88deb99738 Mon Sep 17 00:00:00 2001 From: "zhili.wzl" Date: Wed, 6 Oct 2021 11:14:54 +0800 Subject: [PATCH] chore(core): improve remove --- packages/core/src/models/Operation.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/core/src/models/Operation.ts b/packages/core/src/models/Operation.ts index 2eefca5bf..7ebff9f61 100644 --- a/packages/core/src/models/Operation.ts +++ b/packages/core/src/models/Operation.ts @@ -190,14 +190,10 @@ export class Operation { for (let i = nodes.length - 1; i >= 0; i--) { const node = nodes[i] if (node.allowDelete()) { - const previousIndex = node.index - 1 - const afterIndex = node.index + 1 - const parent = node.parent + const previous = node.previous + const next = node.next node.remove() - const previous = previousIndex > -1 && parent.children[previousIndex] - const after = - afterIndex < parent.children.length && parent.children[afterIndex] - this.selection.select(previous ? previous : after ? after : node.parent) + this.selection.select(previous ? previous : next ? next : node.parent) this.hover.clear() } }