"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaSpecs = void 0;
const table_utils_1 = require("../../../../table-utils/index.js");
const const_1 = require("./const.js");
const DEFAULT_CELL_PLACEHOLDER = 'Table cell';
const getSchemaSpecs = (opts, placeholder) => ({
    [const_1.YfmTableNode.Table]: {
        group: 'block yfm-table',
        content: `${const_1.YfmTableNode.Body}`,
        isolating: true,
        definingAsContext: true,
        parseDOM: [{ tag: 'table', priority: 200 }],
        toDOM() {
            return ['table', 0];
        },
        selectable: true,
        allowSelection: true,
        tableRole: table_utils_1.TableRole.Table,
        complex: 'root',
    },
    [const_1.YfmTableNode.Body]: {
        group: 'block yfm-table',
        content: `${const_1.YfmTableNode.Row}+`,
        isolating: true,
        definingAsContext: true,
        parseDOM: [
            { tag: 'tbody', priority: 200 },
            { tag: 'thead', priority: 200 },
        ],
        toDOM() {
            return ['tbody', 0];
        },
        tableRole: table_utils_1.TableRole.Body,
        selectable: false,
        allowSelection: false,
        complex: 'inner',
    },
    [const_1.YfmTableNode.Row]: {
        group: 'block yfm-table',
        content: `${const_1.YfmTableNode.Cell}+`,
        isolating: true,
        definingAsContext: true,
        parseDOM: [{ tag: 'tr', priority: 200 }],
        toDOM() {
            return ['tr', 0];
        },
        tableRole: table_utils_1.TableRole.Row,
        selectable: false,
        allowSelection: false,
        complex: 'inner',
    },
    [const_1.YfmTableNode.Cell]: {
        group: 'block yfm-table',
        content: 'block+',
        isolating: true,
        definingAsContext: true,
        attrs: {
            [const_1.YfmTableAttr.Colspan]: { default: null },
            [const_1.YfmTableAttr.Rowspan]: { default: null },
            [const_1.YfmTableAttr.CellAlign]: { default: null },
        },
        parseDOM: [
            { tag: 'td', priority: 200 },
            { tag: 'th', priority: 200 },
        ],
        toDOM(node) {
            return ['td', node.attrs, 0];
        },
        placeholder: {
            content: placeholder?.[const_1.YfmTableNode.Cell] ??
                opts?.yfmTableCellPlaceholder ??
                DEFAULT_CELL_PLACEHOLDER,
            alwaysVisible: true,
        },
        tableRole: table_utils_1.TableRole.Cell,
        selectable: false,
        allowSelection: false,
        complex: 'leaf',
    },
});
exports.getSchemaSpecs = getSchemaSpecs;
//# sourceMappingURL=schema.js.map
