"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");
Object.defineProperty(exports, "MathNode", { enumerable: true, get: function () { return const_1.MathNode; } });
/** @deprecated Use LatexNodeType.Inline from `@gravity-ui/markdown-editor-latex-extension` */
exports.mathIType = (0, schema_1.nodeTypeFactory)(const_1.MathNode.Inline);
/** @deprecated Use LatexNodeType.Block from `@gravity-ui/markdown-editor-latex-extension` */
exports.mathBType = (0, schema_1.nodeTypeFactory)(const_1.MathNode.Block);
/** @deprecated Use LatexSpecsExtension from `@gravity-ui/markdown-editor-latex-extension` */
const MathSpecs = (builder) => {
    builder.configureMd((md) => md.use((0, latex_extension_1.transform)({ bundle: false, validate: false }), { output: '' }));
    builder
        .addNodeSpec(const_1.MathNode.Inline, () => ({
        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 }],
    }))
        .addMarkdownTokenParserSpec(const_1.MathToken.Inline, () => ({
        type: 'block',
        name: const_1.MathNode.Inline,
        noCloseToken: true,
    }))
        .addNodeSerializerSpec(const_1.MathNode.Inline, () => (state, node) => {
        state.text(`$${node.textContent}$`, false);
        state.closeBlock();
    });
    builder
        .addNodeSpec(const_1.MathNode.Block, () => ({
        group: 'block math',
        content: 'text*',
        marks: '',
        code: true,
        toDOM: () => ['div', { class: 'math-block' }, 0],
        parseDOM: [{ tag: 'div.math-block', priority: 200 }],
        selectable: true,
    }))
        .addMarkdownTokenParserSpec(const_1.MathToken.Block, () => ({
        type: 'block',
        name: const_1.MathNode.Block,
        noCloseToken: true,
    }))
        .addNodeSerializerSpec(const_1.MathNode.Block, () => (state, node) => {
        state.text(`$$${node.textContent}$$\n\n`, false);
        state.closeBlock();
    });
};
exports.MathSpecs = MathSpecs;
//# sourceMappingURL=index.js.map
