Hi,
I am implementing a menu that should allow me to swap easily between bullet or ordered list. I’ve managed to get something that works unless we start mixing types of list:
- here is the starting point, an ordered list followed by a bullet list
- when I apply a bullet list, it will incorrectly nest the list. Instead it should have removed the existing level (using
liftListItem
) then rewrapped them with the correct type (usingwrapInList
). The lift part is probably incorrect.
The issue is that I didn’t yet find a way to iterate on the selection to detect all types of list it may contain.
I am doing const innerNode = state.selection.$from.node(1);
, which will correctly get the parent “bullet” or “ordered” list if there is only one type of list. If there is a mix in the selection, it will get only the 1st list.
selection.ranges
gives only one range, while I would have expected a list I could iterate on.
What features should I explore to bypass this issue? I probably miss something about selections and nodes.
I am also using liftListItem
which is probably too granular, instead I want to lift all items of all the selected lists before applying the new type. I think I can even reproduce the issue when creating two lists of the same type one after the other.