Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs): backspace in header #2703

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions packages/docs/src/commands/commands/delete.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,24 @@ export const MergeTwoParagraphCommand: ICommand<IMergeTwoParagraphParams> = {
if (activeRange == null || ranges == null) {
return false;
}

const { segmentId, style } = activeRange;
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
const originBody = docDataModel?.getBody();
const originBody = docDataModel?.getSelfOrHeaderFooterModel(segmentId).getBody();
if (!docDataModel || !originBody) {
return false;
}

const actualRange = getDeleteSelection(activeRange, originBody);

const { segmentId, style } = activeRange;
const { startOffset, collapsed } = actualRange;

if (!collapsed) {
return false;
}

const startIndex = direction === DeleteDirection.LEFT ? startOffset : startOffset + 1;
const endIndex = docDataModel
.getBody()
?.paragraphs
const endIndex = originBody.paragraphs
?.find((p) => p.startIndex >= startIndex)?.startIndex!;
const body = getParagraphBody(docDataModel.getBody()!, startIndex, endIndex);
const body = getParagraphBody(originBody, startIndex, endIndex);

const cursor = direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset;

Expand Down Expand Up @@ -203,7 +199,7 @@ export const DeleteLeftCommand: ICommand = {
isFirstGlyph(curGlyph) && preGlyph !== curGlyph && (isBullet === true || isIndent === true);

if (isUpdateParagraph && collapsed) {
const paragraph = getParagraphByGlyph(curGlyph, docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody());
const paragraph = getParagraphByGlyph(curGlyph, body);

if (paragraph == null) {
return false;
Expand Down
Loading