"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lists = exports.olType = exports.liType = exports.blType = exports.ListsAttr = exports.ListNode = void 0;
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
const keymap_1 = require("../../../utils/keymap.js");
const ListsSpecs_1 = require("./ListsSpecs/index.js");
const actions_1 = require("./actions.js");
const commands_1 = require("./commands.js");
const const_1 = require("./const.js");
const inputrules_1 = require("./inputrules.js");
const CollapseListsPlugin_1 = require("./plugins/CollapseListsPlugin.js");
const MergeListsPlugin_1 = require("./plugins/MergeListsPlugin.js");
var ListsSpecs_2 = require("./ListsSpecs/index.js");
Object.defineProperty(exports, "ListNode", { enumerable: true, get: function () { return ListsSpecs_2.ListNode; } });
Object.defineProperty(exports, "ListsAttr", { enumerable: true, get: function () { return ListsSpecs_2.ListsAttr; } });
Object.defineProperty(exports, "blType", { enumerable: true, get: function () { return ListsSpecs_2.blType; } });
Object.defineProperty(exports, "liType", { enumerable: true, get: function () { return ListsSpecs_2.liType; } });
Object.defineProperty(exports, "olType", { enumerable: true, get: function () { return ListsSpecs_2.olType; } });
const Lists = (builder, opts) => {
    builder.use(ListsSpecs_1.ListsSpecs);
    builder.addKeymap(({ schema }) => {
        const { ulKey, olKey } = opts ?? {};
        const bindings = {};
        if (ulKey)
            bindings[ulKey] = (0, keymap_1.withLogAction)('bulletList', (0, commands_1.toList)((0, ListsSpecs_1.blType)(schema)));
        if (olKey)
            bindings[olKey] = (0, keymap_1.withLogAction)('orderedList', (0, commands_1.toList)((0, ListsSpecs_1.olType)(schema)));
        return {
            Tab: (0, commands_1.sinkOnlySelectedListItem)((0, ListsSpecs_1.liType)(schema)),
            'Shift-Tab': (0, prosemirror_schema_list_1.liftListItem)((0, ListsSpecs_1.liType)(schema)),
            'Mod-[': (0, prosemirror_schema_list_1.liftListItem)((0, ListsSpecs_1.liType)(schema)),
            'Mod-]': (0, commands_1.sinkOnlySelectedListItem)((0, ListsSpecs_1.liType)(schema)),
            ...bindings,
        };
    }, builder.Priority.High);
    builder.addKeymap(({ schema }) => ({
        Enter: (0, prosemirror_schema_list_1.splitListItem)((0, ListsSpecs_1.liType)(schema)),
        Backspace: commands_1.joinPrevList,
    }), builder.Priority.Low);
    builder.use(inputrules_1.ListsInputRulesExtension, { bulletListInputRule: opts?.ulInputRules });
    builder.addPlugin(MergeListsPlugin_1.mergeListsPlugin);
    builder.addPlugin(CollapseListsPlugin_1.collapseListsPlugin);
    builder
        .addAction(const_1.ListAction.ToBulletList, actions_1.actions.toBulletList)
        .addAction(const_1.ListAction.ToOrderedList, actions_1.actions.toOrderedList)
        .addAction(const_1.ListAction.SinkListItem, actions_1.actions.sinkListItem)
        .addAction(const_1.ListAction.LiftListItem, actions_1.actions.liftListItem);
};
exports.Lists = Lists;
//# sourceMappingURL=index.js.map
