Skip to content

Commit c904e66

Browse files
committed
add checks in toggleList command
1 parent 3851d3a commit c904e66

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/super-editor/src/core/commands/toggleList.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ export const toggleList =
6868
if (!range) return false;
6969

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

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

@@ -108,8 +108,8 @@ export const toggleList =
108108
};
109109

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

115115
// This is the case when there is no need to ensureMarks.

0 commit comments

Comments
 (0)