import { liftListItem, sinkListItem, splitListItem } from 'prosemirror-schema-list';
import { withLogAction } from "../../../utils/keymap.js";
import { ListsSpecs, blType, liType, olType } from "./ListsSpecs/index.js";
import { actions } from "./actions.js";
import { joinPrevList, toList } from "./commands.js";
import { ListAction } from "./const.js";
import { ListsInputRulesExtension } from "./inputrules.js";
import { mergeListsPlugin } from "./plugins/MergeListsPlugin.js";
export { ListNode, ListsAttr, blType, liType, olType } from "./ListsSpecs/index.js";
export const Lists = (builder, opts) => {
    builder.use(ListsSpecs);
    builder.addKeymap(({ schema }) => {
        const { ulKey, olKey } = opts ?? {};
        const bindings = {};
        if (ulKey)
            bindings[ulKey] = withLogAction('bulletList', toList(blType(schema)));
        if (olKey)
            bindings[olKey] = withLogAction('orderedList', toList(olType(schema)));
        return {
            Tab: sinkListItem(liType(schema)),
            'Shift-Tab': liftListItem(liType(schema)),
            'Mod-[': liftListItem(liType(schema)),
            'Mod-]': sinkListItem(liType(schema)),
            ...bindings,
        };
    }, builder.Priority.High);
    builder.addKeymap(({ schema }) => ({
        Enter: splitListItem(liType(schema)),
        Backspace: joinPrevList,
    }), builder.Priority.Low);
    builder.use(ListsInputRulesExtension, { bulletListInputRule: opts?.ulInputRules });
    builder.addPlugin(mergeListsPlugin);
    builder
        .addAction(ListAction.ToBulletList, actions.toBulletList)
        .addAction(ListAction.ToOrderedList, actions.toOrderedList)
        .addAction(ListAction.SinkListItem, actions.sinkListItem)
        .addAction(ListAction.LiftListItem, actions.liftListItem);
};
//# sourceMappingURL=index.js.map
