import { wrapInList } from 'prosemirror-schema-list';
import { joinPreviousBlock } from "../../../commands/join.js";
import { findAnyParentList, isListNode, isListOrItemNode } from "./utils.js";
export function toList(listType) {
    return (state, dispatch) => {
        const parentList = findAnyParentList(state.schema)(state.selection);
        if (parentList) {
            if (listType === parentList.node.type)
                return true;
            dispatch?.(state.tr.setNodeMarkup(parentList.pos, listType));
            return true;
        }
        return wrapInList(listType)(state, dispatch);
    };
}
export const joinPrevList = joinPreviousBlock({
    checkPrevNode: isListNode,
    skipNode: isListOrItemNode,
});
//# sourceMappingURL=commands.js.map
