"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BoldSpecs = exports.BoldAttrs = exports.boldType = exports.boldMarkName = void 0;
const schema_1 = require("../../../../utils/schema.js");
exports.boldMarkName = 'strong';
exports.boldType = (0, schema_1.markTypeFactory)(exports.boldMarkName);
exports.BoldAttrs = {
    Markup: 'data-markup',
};
const defaultMarkup = '**';
const BoldSpecs = (builder) => {
    builder.addMark(exports.boldMarkName, () => ({
        spec: {
            attrs: { [exports.BoldAttrs.Markup]: { default: defaultMarkup } },
            parseDOM: [
                { tag: 'b' },
                {
                    tag: 'strong',
                    getAttrs: (node) => ({
                        [exports.BoldAttrs.Markup]: node.getAttribute(exports.BoldAttrs.Markup),
                    }),
                },
                {
                    style: 'font-weight',
                    getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
                },
            ],
            toDOM(mark) {
                return ['strong', mark.attrs];
            },
        },
        fromMd: {
            tokenSpec: {
                name: exports.boldMarkName,
                type: 'mark',
                getAttrs: (token) => ({
                    [exports.BoldAttrs.Markup]: token.markup,
                }),
            },
        },
        toMd: { open: getMarkup, close: getMarkup, mixable: true, expelEnclosingWhitespace: true },
    }));
};
exports.BoldSpecs = BoldSpecs;
function getMarkup(_, mark) {
    const attr = mark.attrs[exports.BoldAttrs.Markup];
    return attr || defaultMarkup;
}
//# sourceMappingURL=index.js.map
