UNPKG

@atlaskit/adf-schema

Version:

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

132 lines (126 loc) 3.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.layoutSectionWithSingleColumnLocalId = exports.layoutSectionWithSingleColumn = exports.layoutSectionWithLocalId = exports.layoutSectionFull = exports.layoutSection = void 0; var _nodeTypes = require("../../next-schema/generated/nodeTypes"); var _uuid = require("../../utils/uuid"); /** * @name layoutSection_node */ /** * Need duplicate `type` and `marks` to make both validator and json-schema satisfied */ /** * @name layoutSection_full_node */ /** * @stage 0 * @name layoutSection_with_single_column_node */ var layoutSection = exports.layoutSection = (0, _nodeTypes.layoutSection)({ parseDOM: [{ context: 'layoutSection//|layoutColumn//', tag: 'div[data-layout-section]', skip: true }, { tag: 'div[data-layout-section]' }], toDOM: function toDOM() { var attrs = { 'data-layout-section': 'true' }; return ['div', attrs, 0]; } }); var layoutSectionFull = exports.layoutSectionFull = (0, _nodeTypes.layoutSectionFull)({ parseDOM: [{ context: 'layoutSection//|layoutColumn//', tag: 'div[data-layout-section]', skip: true }, { tag: 'div[data-layout-section]' }], toDOM: function toDOM() { var attrs = { 'data-layout-section': 'true' }; return ['div', attrs, 0]; } }); // stage-0 support for columnRuleStyle attribute and 1-5 columns var layoutSectionWithSingleColumn = exports.layoutSectionWithSingleColumn = (0, _nodeTypes.layoutSectionWithSingleColumnStage0)({ parseDOM: [{ context: 'layoutSection//|layoutColumn//', tag: 'div[data-layout-section]', skip: true }, { tag: 'div[data-layout-section]', getAttrs: function getAttrs(dom) { var columnRuleStyle = dom.getAttribute('data-column-rule-style'); return columnRuleStyle ? { columnRuleStyle: columnRuleStyle } : {}; } }], toDOM: function toDOM(node) { var columnRuleStyle = node.attrs.columnRuleStyle; var attrs = { 'data-layout-section': 'true', 'data-column-rule-style': columnRuleStyle || undefined }; return ['div', attrs, 0]; } }); var layoutSectionWithLocalId = exports.layoutSectionWithLocalId = (0, _nodeTypes.layoutSection)({ parseDOM: [{ context: 'layoutSection//|layoutColumn//', tag: 'div[data-layout-section]', skip: true }, { tag: 'div[data-layout-section]', getAttrs: function getAttrs() { var localId = _uuid.uuid.generate(); return { localId: localId }; } }], toDOM: function toDOM(node) { var localId = node.attrs.localId; var attrs = { 'data-layout-section': 'true', 'data-local-id': localId }; return ['div', attrs, 0]; } }); var layoutSectionWithSingleColumnLocalId = exports.layoutSectionWithSingleColumnLocalId = (0, _nodeTypes.layoutSectionWithSingleColumnStage0)({ parseDOM: [{ context: 'layoutSection//|layoutColumn//', tag: 'div[data-layout-section]', skip: true }, { tag: 'div[data-layout-section]', getAttrs: function getAttrs(dom) { var columnRuleStyle = dom.getAttribute('data-column-rule-style'); var localId = _uuid.uuid.generate(); return columnRuleStyle ? { columnRuleStyle: columnRuleStyle, localId: localId } : { localId: localId }; } }], toDOM: function toDOM(node) { var _node$attrs; var columnRuleStyle = node.attrs.columnRuleStyle; var attrs = { 'data-layout-section': 'true', 'data-column-rule-style': columnRuleStyle || undefined, 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined }; return ['div', attrs, 0]; } });