@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
171 lines (169 loc) • 5.61 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "table", {
enumerable: true,
get: function get() {
return _tableStub.table;
}
});
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");
var _tableStub = require("./tableStub");
var valign = {
type: 'enum',
values: ['top', 'middle', 'bottom'],
default: null,
optional: true
};
var cellAttributes = {
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
},
localId: {
type: 'string',
default: null,
optional: true
},
valign: valign
};
var tableCell = (0, _adfSchemaGenerator.adfNode)('tableCell').define({
isolating: true,
selectable: false,
tableRole: 'cell',
marks: [_unsupportedMark.unsupportedMark, _unsupportedNodeAttribute.unsupportedNodeAttribute],
attrs: cellAttributes,
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, _tableStub.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: cellAttributes,
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, _tableStub.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',
attrs: {
localId: {
type: 'string',
default: null,
optional: true
}
},
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']
});
_tableStub.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']
});
// Re-export the now-defined `table` stub as this module's public API. Importing `table` from here
// (rather than from `./tableStub`) forces this definition module to evaluate first, so consumers
// that eagerly call `table.use('with_nested_table')` see the defined variant.
// eslint-disable-next-line @atlaskit/editor/no-re-export