UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

166 lines (165 loc) 5.32 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.table = void 0; var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator"); var _fragment = require("../marks/fragment"); var _unsupportedMark = require("../marks/unsupportedMark"); var _unsupportedNodeAttribute = require("../marks/unsupportedNodeAttribute"); var _tableCellContentPseudoGroup = require("../groups/tableCellContentPseudoGroup"); var _tableCellContent = require("./tableCellContent"); var _nestedExpand = require("./nestedExpand"); var _unsupportedBlock = require("./unsupportedBlock"); // Declare early to allow for circular references within the file var table = exports.table = (0, _adfSchemaGenerator.adfNode)('table'); var tableCell = (0, _adfSchemaGenerator.adfNode)('tableCell').define({ isolating: true, selectable: false, tableRole: 'cell', marks: [_unsupportedMark.unsupportedMark, _unsupportedNodeAttribute.unsupportedNodeAttribute], attrs: { colspan: { type: 'number', default: 1, optional: true }, rowspan: { type: 'number', default: 1, optional: true }, colwidth: { type: 'array', items: { type: 'number' }, default: null, optional: true }, background: { type: 'string', default: null, optional: true } }, content: [_tableCellContentPseudoGroup.tableCellContentPseudoGroup], DANGEROUS_MANUAL_OVERRIDE: { 'validator-spec': { required: { reason: '@DSLCompatibilityException - required for tableCell validator spec', value: ['content'] } } } }).variant('with_nested_table', { content: [(0, _adfSchemaGenerator.$onePlus)(_adfSchemaGenerator.$or.apply(void 0, (0, _toConsumableArray2.default)(_tableCellContentPseudoGroup.tableCellContentNodes).concat([_unsupportedBlock.unsupportedBlock, table])))], ignore: ['json-schema', 'validator-spec'] }); var tableHeader = (0, _adfSchemaGenerator.adfNode)('tableHeader').define({ isolating: true, selectable: false, tableRole: 'header_cell', marks: [_unsupportedMark.unsupportedMark, _unsupportedNodeAttribute.unsupportedNodeAttribute], attrs: { colspan: { type: 'number', default: 1, optional: true }, rowspan: { type: 'number', default: 1, optional: true }, colwidth: { type: 'array', items: { type: 'number' }, default: null, optional: true }, background: { type: 'string', default: null, optional: true } }, content: [_tableCellContentPseudoGroup.tableHeaderContentPseudoGroup], DANGEROUS_MANUAL_OVERRIDE: { 'validator-spec': { required: { reason: '@DSLCompatibilityException - required for tableHeader validator spec', value: ['content'] } } } }).variant('with_nested_table', { content: [(0, _adfSchemaGenerator.$onePlus)(_adfSchemaGenerator.$or.apply(void 0, (0, _toConsumableArray2.default)(_tableCellContentPseudoGroup.tableCellContentNodes).concat([_nestedExpand.nestedExpand, table])))], ignore: ['json-schema', 'validator-spec'] }); var tableRow = (0, _adfSchemaGenerator.adfNode)('tableRow').define({ selectable: false, marks: [_unsupportedMark.unsupportedMark, _unsupportedNodeAttribute.unsupportedNodeAttribute], content: [(0, _adfSchemaGenerator.$onePlus)((0, _adfSchemaGenerator.$or)(tableCell, tableHeader, _tableCellContent.tableCellContent))], tableRole: 'row', DANGEROUS_MANUAL_OVERRIDE: { 'validator-spec': { 'props.content.minItems': { reason: '@DSLCompatibilityException - required for tableRow validator spec', remove: true } } } }).variant('with_nested_table', { content: [(0, _adfSchemaGenerator.$onePlus)((0, _adfSchemaGenerator.$or)(tableCell.use('with_nested_table'), tableHeader.use('with_nested_table')))], ignore: ['json-schema', 'validator-spec'] }); table.define({ isolating: true, selectable: true, tableRole: 'table', marks: [_fragment.fragment, _unsupportedMark.unsupportedMark, _unsupportedNodeAttribute.unsupportedNodeAttribute], attrs: { displayMode: { type: 'enum', values: ['default', 'fixed'], default: null, optional: true }, isNumberColumnEnabled: { type: 'boolean', default: false, optional: true }, layout: { type: 'enum', values: ['wide', 'full-width', 'center', 'align-end', 'align-start', 'default'], default: 'default', optional: true }, localId: { type: 'string', minLength: 1, default: '', optional: true }, width: { type: 'number', default: null, optional: true }, __autoSize: { type: 'boolean', default: false, optional: true } }, content: [(0, _adfSchemaGenerator.$onePlus)((0, _adfSchemaGenerator.$or)(tableRow))] }).variant('with_nested_table', { content: [(0, _adfSchemaGenerator.$onePlus)((0, _adfSchemaGenerator.$or)(tableRow.use('with_nested_table')))], ignore: ['json-schema', 'validator-spec'] });