"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EditorModeKeymap = void 0;
const shortcuts_1 = require("../../../shortcuts/index.js");
const version_1 = require("../../../version.js");
/**
 * Use this extension if you need to handle form actions like cancel and/or submit.
 */
const EditorModeKeymap = (builder, opts) => {
    builder.addKeymap(() => {
        const bindings = {};
        const { onCancel, onSubmit } = opts;
        if (onCancel)
            bindings[shortcuts_1.formatter.toPM(shortcuts_1.Action.Cancel)] = () => onCancel();
        if (onSubmit)
            bindings[shortcuts_1.formatter.toPM(shortcuts_1.Action.Submit)] = () => onSubmit();
        bindings[shortcuts_1.formatter.toPM(shortcuts_1.Action.__debug)] = () => {
            debug();
            return true;
        };
        return bindings;
    });
    if (opts.ignoreKeysList?.length) {
        const ignore = () => true;
        const bindings = {};
        for (const key of opts.ignoreKeysList) {
            bindings[key] = ignore;
        }
        builder.addKeymap(() => bindings, builder.Priority.Lowest);
    }
};
exports.EditorModeKeymap = EditorModeKeymap;
function debug() {
    const message = ['YFM-Editor Debug info', `Version: ${version_1.VERSION}`].join('\n');
    console.info(message);
}
//# sourceMappingURL=index.js.map
