Skip to content

Commit

Permalink
fix: backspace in header and footer (#2704)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs authored Jul 7, 2024
1 parent 8598e02 commit 749b407
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/docs/src/commands/commands/break-line.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 749b407

Please sign in to comment.