diff --git a/shared/editor/commands/toggleList.ts b/shared/editor/commands/toggleList.ts index 82b8295689..3f290ff71f 100644 --- a/shared/editor/commands/toggleList.ts +++ b/shared/editor/commands/toggleList.ts @@ -39,7 +39,7 @@ export default function toggleList( const currentItemType = parentList.node.content.firstChild?.type; const differentType = currentItemType && currentItemType !== itemType; - if (differentType || differentListStyle) { + if (differentType) { return chainTransactions( clearNodes(), wrapInList(listType, { listStyle }) @@ -50,10 +50,14 @@ export default function toggleList( isList(parentList.node, schema) && listType.validContent(parentList.node.content) ) { - tr.setNodeMarkup( + tr.doc.nodesBetween( parentList.pos, - listType, - listStyle ? { listStyle } : {} + parentList.pos + parentList.node.nodeSize, + (node, pos) => { + if (isList(node, schema)) { + tr.setNodeMarkup(pos, listType, listStyle ? { listStyle } : {}); + } + } ); dispatch?.(tr);