"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schemaSpecs = void 0;
const table_utils_1 = require("../../../../table-utils/index.js");
const const_1 = require("../const.js");
exports.schemaSpecs = {
    [const_1.TableNode.Table]: {
        group: 'block',
        content: `${const_1.TableNode.Head} ${const_1.TableNode.Body}`,
        isolating: true,
        parseDOM: [{ tag: 'table' }],
        toDOM() {
            return ['table', 0];
        },
        selectable: true,
        allowSelection: true,
        tableRole: table_utils_1.TableRole.Table,
        complex: 'root',
    },
    [const_1.TableNode.Head]: {
        group: 'block',
        content: const_1.TableNode.Row,
        isolating: true,
        parseDOM: [{ tag: 'thead' }],
        toDOM() {
            return ['thead', 0];
        },
        tableRole: table_utils_1.TableRole.Body,
        selectable: false,
        allowSelection: false,
        complex: 'inner',
    },
    [const_1.TableNode.Body]: {
        group: 'block',
        content: `${const_1.TableNode.Row}+`,
        isolating: true,
        parseDOM: [{ tag: 'tbody' }],
        toDOM() {
            return ['tbody', 0];
        },
        tableRole: table_utils_1.TableRole.Body,
        selectable: false,
        allowSelection: false,
        complex: 'inner',
    },
    [const_1.TableNode.Row]: {
        group: 'block',
        content: `(${const_1.TableNode.HeaderCell}|${const_1.TableNode.DataCell})+`,
        isolating: true,
        parseDOM: [{ tag: 'tr' }],
        toDOM() {
            return ['tr', 0];
        },
        tableRole: table_utils_1.TableRole.Row,
        selectable: false,
        allowSelection: false,
        complex: 'inner',
    },
    [const_1.TableNode.HeaderCell]: cellTemplate('th'),
    [const_1.TableNode.DataCell]: cellTemplate('td'),
};
function cellTemplate(tag) {
    return {
        attrs: { [const_1.TableAttrs.CellAlign]: { default: const_1.CellAlign.Left } },
        group: 'block',
        content: '(text | inline)*',
        isolating: true,
        parseDOM: [
            {
                tag,
                getAttrs(dom) {
                    if (!dom.hasAttribute(const_1.TableAttrs.CellAlign))
                        return null;
                    return {
                        [const_1.TableAttrs.CellAlign]: dom.getAttribute(const_1.TableAttrs.CellAlign),
                    };
                },
            },
        ],
        toDOM({ attrs }) {
            return [
                tag,
                {
                    ...attrs,
                    style: `text-align:${attrs[const_1.TableAttrs.CellAlign]}`,
                },
                0,
            ];
        },
        tableRole: table_utils_1.TableRole.Cell,
        selectable: false,
        allowSelection: false,
        complex: 'leaf',
    };
}
//# sourceMappingURL=schema.js.map
