in src/ts/richtext/utils/listsHelpers.ts [25:43]
export function createListToggleCommand(
listItemNodeType: NodeType,
listNodeType: NodeType
): Command {
const wrapCommand = wrapInList(listNodeType);
const unwrapCommand = liftListItem(listItemNodeType);
return (state: EditorState, dispatch?: (tr: Transaction) => void, view?: EditorView) => {
const shouldUnwrap = isInNode(state, listNodeType);
if(shouldUnwrap){
return unwrapCommand(state, dispatch);
}
else{
const unwrap = unwrapCommand(state, dispatch);
const wrap = wrapCommand(view && view.state || state, dispatch);
return unwrap || wrap;
}
};
}