Skip to content
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
8 changes: 4 additions & 4 deletions packages/super-editor/src/core/commands/toggleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ export const toggleList =
if (!range) return false;

const parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);
const { numbering } = editor.converter;
const numbering = editor.converter?.numbering ?? null;

// This is the case when we toggle an existing list.
if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {
// If we toggle to the same list type,
// then execute `liftListItem` command.
if (parentList.node.type === listType) {
const { listId } = parentList.node.attrs;
editor.converter.numbering = removeListDefinitions(listId, numbering);
if (editor.converter) editor.converter.numbering = removeListDefinitions(listId, numbering);
return commands.liftListItem(itemType);
}

Expand Down Expand Up @@ -108,8 +108,8 @@ export const toggleList =
};

// Update the numbering definition for this document
const newListId = getNewListId(numbering.definitions);
editor.converter.numbering = generateNewListDefinition(newListId, numbering, listType);
const newListId = numbering?.definitions ? getNewListId(numbering.definitions) : null;
if (editor.converter) editor.converter.numbering = generateNewListDefinition(newListId, numbering, listType);
attributes.listId = newListId;

// This is the case when there is no need to ensureMarks.
Expand Down
Loading