"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Underline = exports.underlineType = exports.underlineMarkName = void 0;
const prosemirror_commands_1 = require("prosemirror-commands");
const actions_1 = require("../../../utils/actions.js");
const inputrules_1 = require("../../../utils/inputrules.js");
const keymap_1 = require("../../../utils/keymap.js");
const UnderlineSpecs_1 = require("./UnderlineSpecs/index.js");
var UnderlineSpecs_2 = require("./UnderlineSpecs/index.js");
Object.defineProperty(exports, "underlineMarkName", { enumerable: true, get: function () { return UnderlineSpecs_2.underlineMarkName; } });
Object.defineProperty(exports, "underlineType", { enumerable: true, get: function () { return UnderlineSpecs_2.underlineType; } });
const undAction = 'underline';
const Underline = (builder, opts) => {
    builder.use(UnderlineSpecs_1.UnderlineSpecs);
    builder
        .addAction(undAction, ({ schema }) => (0, actions_1.createToggleMarkAction)((0, UnderlineSpecs_1.underlineType)(schema)))
        .addInputRules(({ schema }) => ({
        rules: [
            (0, inputrules_1.markInputRule)({ open: '++', close: '++', ignoreBetween: '+' }, (0, UnderlineSpecs_1.underlineType)(schema)),
        ],
    }));
    if (opts?.underlineKey) {
        const { underlineKey } = opts;
        builder.addKeymap(({ schema }) => ({
            [underlineKey]: (0, keymap_1.withLogAction)('underline', (0, prosemirror_commands_1.toggleMark)((0, UnderlineSpecs_1.underlineType)(schema))),
        }));
    }
};
exports.Underline = Underline;
//# sourceMappingURL=index.js.map
