"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schemaSpecs = void 0;
const tslib_1 = require("tslib");
const sanitize_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/sanitize"));
const const_1 = require("./const.js");
var DomAttr;
(function (DomAttr) {
    DomAttr["Html"] = "data-html";
    DomAttr["HtmlRaw"] = "data-html-raw";
})(DomAttr || (DomAttr = {}));
exports.schemaSpecs = {
    [const_1.HtmlNode.Block]: {
        atom: true,
        group: 'block',
        attrs: { [const_1.HtmlAttr.Content]: {} },
        parseDOM: [
            {
                tag: `div[${DomAttr.Html}]`,
                getAttrs(dom) {
                    const dom_ = dom;
                    return {
                        [const_1.HtmlAttr.Content]: dom_.getAttribute(DomAttr.HtmlRaw) || dom_.innerHTML,
                    };
                },
            },
        ],
        toDOM(node) {
            const htmlContent = node.attrs[const_1.HtmlAttr.Content];
            const elem = document.createElement('div');
            elem.setAttribute(DomAttr.Html, '');
            elem.setAttribute(DomAttr.HtmlRaw, htmlContent);
            elem.contentEditable = 'false';
            elem.innerHTML = (0, sanitize_1.default)(htmlContent);
            return elem;
        },
    },
    [const_1.HtmlNode.Inline]: {
        atom: true,
        inline: true,
        group: 'inline',
        attrs: { [const_1.HtmlAttr.Content]: {} },
        parseDOM: [
            {
                tag: `span[${DomAttr.Html}]`,
                getAttrs(dom) {
                    return { [const_1.HtmlAttr.Content]: dom.textContent };
                },
            },
        ],
        toDOM(node) {
            const elem = document.createElement('span');
            elem.setAttribute(DomAttr.Html, '');
            elem.contentEditable = 'false';
            elem.textContent = node.attrs[const_1.HtmlAttr.Content];
            return elem;
        },
    },
};
//# sourceMappingURL=schema.js.map
