"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MathSpecs = exports.mathBType = exports.mathIType = exports.MathNode = void 0;
const latex_extension_1 = require("@diplodoc/latex-extension");
const schema_1 = require("../../../../utils/schema.js");
const const_1 = require("./const.js");
var const_2 = require("./const.js");
Object.defineProperty(exports, "MathNode", { enumerable: true, get: function () { return const_2.MathNode; } });
exports.mathIType = (0, schema_1.nodeTypeFactory)(const_1.MathNode.Inline);
exports.mathBType = (0, schema_1.nodeTypeFactory)(const_1.MathNode.Block);
const MathSpecs = (builder) => {
    builder.configureMd((md) => md.use((0, latex_extension_1.transform)({ bundle: false, validate: false }), { output: '' }));
    builder
        .addNode(const_1.MathNode.Inline, () => ({
        spec: {
            group: 'inline math',
            content: 'text*',
            inline: true,
            marks: '',
            code: true,
            toDOM: () => [
                'span',
                { class: const_1.CLASSNAMES.Inline.Container },
                ['span', { class: const_1.CLASSNAMES.Inline.Sharp, contenteditable: 'false' }, '$'],
                ['span', { class: const_1.CLASSNAMES.Inline.Content }, 0],
                ['span', { class: const_1.CLASSNAMES.Inline.Sharp, contenteditable: 'false' }, '$'],
            ],
            parseDOM: [{ tag: `span.${const_1.CLASSNAMES.Inline.Content}`, priority: 200 }],
        },
        fromMd: {
            tokenName: 'math_inline',
            tokenSpec: { name: const_1.MathNode.Inline, type: 'block', noCloseToken: true },
        },
        toMd: (state, node) => {
            state.text(`$${node.textContent}$`, false);
            state.closeBlock();
        },
    }))
        .addNode(const_1.MathNode.Block, () => ({
        spec: {
            group: 'block math',
            content: 'text*',
            marks: '',
            code: true,
            toDOM: () => ['div', { class: 'math-block' }, 0],
            parseDOM: [{ tag: 'div.math-block', priority: 200 }],
            selectable: true,
        },
        fromMd: {
            tokenName: 'math_block',
            tokenSpec: { name: const_1.MathNode.Block, type: 'block', noCloseToken: true },
        },
        toMd: (state, node) => {
            state.text(`$$${node.textContent}$$\n\n`, false);
            state.closeBlock();
        },
    }));
};
exports.MathSpecs = MathSpecs;
//# sourceMappingURL=index.js.map
