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): change list type error when cross table #2963

Merged
merged 1 commit into from
Aug 7, 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
13 changes: 6 additions & 7 deletions packages/docs/src/commands/commands/list.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,12 @@ export const ChangeListTypeCommand: ICommand<IChangeListTypeCommandParams> = {
const commandService = accessor.get(ICommandService);
const { listType } = params;
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
const activeRange = textSelectionManagerService.getActiveTextRangeWithStyle();
if (docDataModel == null || activeRange == null) {
const activeRanges = textSelectionManagerService.getDocRanges();
if (docDataModel == null || activeRanges == null || !activeRanges.length) {
return false;
}

const { segmentId } = activeRange;

const { segmentId } = activeRanges[0];
const selections = textSelectionManagerService.getDocRanges() ?? [];
const paragraphs = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()?.paragraphs;
const serializedSelections = selections.map(serializeDocRange);
Expand All @@ -237,7 +236,7 @@ export const ChangeListTypeCommand: ICommand<IChangeListTypeCommandParams> = {
}

const sectionBreaks = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()?.sectionBreaks ?? [];
const currentParagraphs = getParagraphsRelative(activeRange, paragraphs);
const currentParagraphs = getParagraphsRelative(activeRanges, paragraphs);
const unitId = docDataModel.getUnitId();
const ID_LENGTH = 6;
const listId = Tools.generateRandomId(ID_LENGTH);
Expand Down Expand Up @@ -766,8 +765,8 @@ export function getParagraphsInRange(activeRange: IActiveTextRange, paragraphs:
return results;
}

export function getParagraphsRelative(activeRange: IActiveTextRange, paragraphs: IParagraph[]) {
const selectionParagraphs = getParagraphsInRange(activeRange, paragraphs);
export function getParagraphsRelative(ranges: IDocRange[], paragraphs: IParagraph[]) {
const selectionParagraphs = getParagraphsInRanges(ranges, paragraphs);
const startIndex = paragraphs.indexOf(selectionParagraphs[0]);
const endIndex = paragraphs.indexOf(selectionParagraphs[selectionParagraphs.length - 1]);
if (selectionParagraphs[0].bullet) {
Expand Down
Loading