From 749b407fddbb2b8386924fffe2070f4c68919857 Mon Sep 17 00:00:00 2001 From: Ran Luo Date: Sun, 7 Jul 2024 14:08:37 +0800 Subject: [PATCH] fix: backspace in header and footer (#2704) --- packages/docs/src/commands/commands/break-line.command.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/docs/src/commands/commands/break-line.command.ts b/packages/docs/src/commands/commands/break-line.command.ts index d0cedf01c2a..26108ce59d0 100644 --- a/packages/docs/src/commands/commands/break-line.command.ts +++ b/packages/docs/src/commands/commands/break-line.command.ts @@ -63,18 +63,17 @@ export const BreakLineCommand: ICommand = { if (activeRange == null) { return false; } - + const { segmentId } = activeRange; const docDataModel = univerInstanceService.getCurrentUniverDocInstance(); - const body = docDataModel?.getBody(); + const body = docDataModel?.getSelfOrHeaderFooterModel(segmentId).getBody(); if (!docDataModel || !body) { return false; } const unitId = docDataModel.getUnitId(); const { startOffset, endOffset } = getInsertSelection(activeRange, body); - const { segmentId } = activeRange; - const paragraphs = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()?.paragraphs ?? []; + const paragraphs = body.paragraphs ?? []; const prevParagraph = paragraphs.find((p) => p.startIndex >= startOffset); // line breaks to 2 if (prevParagraph && prevParagraph.startIndex > endOffset) {