@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
138 lines (137 loc) • 4.59 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.mediaSingle = void 0;
var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
var _link = require("../marks/link");
var _unsupportedMark = require("../marks/unsupportedMark");
var _unsupportedNodeAttribute = require("../marks/unsupportedNodeAttribute");
var _caption = require("./caption");
var _media = require("./media");
var _unsupportedBlock = require("./unsupportedBlock");
var mediaSingle = exports.mediaSingle = (0, _adfSchemaGenerator.adfNode)('mediaSingle').define({
atom: true,
selectable: true,
marks: [_link.link, _unsupportedMark.unsupportedMark, _unsupportedNodeAttribute.unsupportedNodeAttribute],
attrs: {
anyOf: [{
width: {
type: 'number',
minimum: 0,
maximum: 100,
default: null,
optional: true
},
layout: {
type: 'enum',
values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start'],
default: 'center'
},
widthType: {
type: 'enum',
values: ['percentage'],
default: 'percentage',
optional: true
}
}, {
width: {
type: 'number',
minimum: 0,
default: null
},
widthType: {
type: 'enum',
values: ['pixel'],
default: null
},
layout: {
type: 'enum',
values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start'],
default: 'center'
}
}]
},
DANGEROUS_MANUAL_OVERRIDE: {
'pm-spec': {
content: {
value: 'media|unsupportedBlock+|media unsupportedBlock+',
reason: 'The content expression is not correct or redundant around `media|media|unsupportedBlock+`. This case is not supported by the DSL.'
},
attrs: {
value: {
layout: {
default: 'center'
},
width: {
default: null
}
},
reason: 'the widthType was not in attrs of original spec'
},
marks: {
value: 'annotation border link unsupportedMark unsupportedNodeAttribute',
reason: "Types and PM Spec don't match, in types base mediaSingle doesn't have children, and in ADF DSL marks are derived from children"
}
},
'validator-spec': {
required: {
remove: true,
reason: '@DSLCompatibilityException - should be present in spec but removed for compatibility'
}
}
}
}).variant('caption', {
atom: false,
ignore: [],
marks: [],
contentMinItems: 1,
contentMaxItems: 2,
content: [(0, _adfSchemaGenerator.$or)(_media.media, _unsupportedBlock.unsupportedBlock), (0, _adfSchemaGenerator.$or)(_caption.caption, _unsupportedBlock.unsupportedBlock)],
DANGEROUS_MANUAL_OVERRIDE: {
'pm-spec': {
content: {
value: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*',
reason: 'The content expression is not correct or redundant around `media|media|unsupportedBlock+`. This case is not supported by the DSL.'
},
attrs: {
value: {
layout: {
default: 'center'
},
width: {
default: null
}
},
reason: 'the widthType was not in attrs of original spec of mediaSingleWithCaption'
}
}
}
}).variant('full', {
atom: false,
content: [(0, _adfSchemaGenerator.$range)(1, 1, (0, _adfSchemaGenerator.$or)(_media.media, _unsupportedBlock.unsupportedBlock))],
ignore: [],
marks: [],
DANGEROUS_MANUAL_OVERRIDE: {
'pm-spec': {
content: {
value: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*',
reason: 'The content expression is not correct or redundant around `media|media|unsupportedBlock+`. This case is not supported by the DSL.'
}
}
}
}).variant('width_type', {
content: [(0, _adfSchemaGenerator.$range)(1, 1, (0, _adfSchemaGenerator.$or)(_media.media, _unsupportedBlock.unsupportedBlock))],
// @DSLCompatibilityException - Generated JSON Schema does not have this.
// We should introduce this to the JSON Schema since it is in PM Spec
ignore: ['json-schema'],
marks: [],
DANGEROUS_MANUAL_OVERRIDE: {
'pm-spec': {
content: {
value: 'media|unsupportedBlock+|media unsupportedBlock+',
reason: 'The content expression is not correct or redundant around `media|media|unsupportedBlock+`. This case is not supported by the DSL.'
}
}
}
});