"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.YfmNote = exports.noteTitleType = exports.noteType = exports.YfmNoteNode = void 0;
const prosemirror_commands_1 = require("prosemirror-commands");
const inputrules_1 = require("../../../utils/inputrules.js");
const keymap_1 = require("../../../utils/keymap.js");
const YfmNoteSpecs_1 = require("./YfmNoteSpecs/index.js");
const toYfmNote_1 = require("./actions/toYfmNote.js");
const commands_1 = require("./commands.js");
const YfmNoteTooltipPlugin_1 = require("./plugins/YfmNoteTooltipPlugin/index.js");
const utils_1 = require("./utils.js");
require("./index.css");
const noteAction = 'toYfmNote';
var YfmNoteSpecs_2 = require("./YfmNoteSpecs/index.js");
Object.defineProperty(exports, "YfmNoteNode", { enumerable: true, get: function () { return YfmNoteSpecs_2.YfmNoteNode; } });
Object.defineProperty(exports, "noteType", { enumerable: true, get: function () { return YfmNoteSpecs_2.noteType; } });
Object.defineProperty(exports, "noteTitleType", { enumerable: true, get: function () { return YfmNoteSpecs_2.noteTitleType; } });
const YfmNote = (builder, opts) => {
    builder.use(YfmNoteSpecs_1.YfmNoteSpecs, opts);
    builder
        .addKeymap(() => ({
        Enter: (0, prosemirror_commands_1.chainCommands)(commands_1.exitFromNoteTitle, commands_1.liftEmptyBlockFromNote),
        Backspace: (0, prosemirror_commands_1.chainCommands)(commands_1.backToNoteTitle, commands_1.removeNote),
    }))
        .addAction(noteAction, () => toYfmNote_1.toYfmNote)
        .addInputRules(({ schema }) => ({
        rules: [(0, inputrules_1.nodeInputRule)(/(?:^)({% note)\s$/, (0, utils_1.noteType)(schema).createAndFill(), 1)],
    }));
    if (opts?.yfmNoteKey) {
        const { yfmNoteKey } = opts;
        builder.addKeymap(() => ({ [yfmNoteKey]: (0, keymap_1.withLogAction)('yfm_note', toYfmNote_1.createYfmNote) }));
    }
    builder.addPlugin(YfmNoteTooltipPlugin_1.yfmNoteTooltipPlugin);
};
exports.YfmNote = YfmNote;
//# sourceMappingURL=index.js.map
