"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinPrevList = void 0;
exports.toList = toList;
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
const join_1 = require("../../../commands/join.js");
const utils_1 = require("./utils.js");
function toList(listType) {
    return (state, dispatch) => {
        const parentList = (0, utils_1.findAnyParentList)(state.schema)(state.selection);
        if (parentList) {
            if (listType === parentList.node.type)
                return true;
            dispatch?.(state.tr.setNodeMarkup(parentList.pos, listType));
            return true;
        }
        return (0, prosemirror_schema_list_1.wrapInList)(listType)(state, dispatch);
    };
}
exports.joinPrevList = (0, join_1.joinPreviousBlock)({
    checkPrevNode: utils_1.isListNode,
    skipNode: utils_1.isListOrItemNode,
});
//# sourceMappingURL=commands.js.map
