UNPKG

@atlaskit/adf-schema

Version:

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

64 lines (59 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.heading = void 0; var _nodeTypes = require("../../next-schema/generated/nodeTypes"); /** * @name heading_node */ /** * @name heading_with_no_marks_node */ // Check `paragraph` node for why we are doing things like this /** * @name heading_with_alignment_node */ /** * @name heading_with_indentation_node */ var getAttrs = function getAttrs(level) { return function (domNode) { var _heading$attrs, _heading$attrs$localI; return { level: level, localId: domNode.getAttribute('data-local-id') || ((_heading$attrs = heading.attrs) === null || _heading$attrs === void 0 ? void 0 : (_heading$attrs$localI = _heading$attrs.localId) === null || _heading$attrs$localI === void 0 ? void 0 : _heading$attrs$localI.default) }; }; }; var heading = exports.heading = (0, _nodeTypes.heading)({ parseDOM: [{ tag: 'h1', getAttrs: getAttrs(1) }, { tag: 'h2', getAttrs: getAttrs(2) }, { tag: 'h3', getAttrs: getAttrs(3) }, { tag: 'h4', getAttrs: getAttrs(4) }, { tag: 'h5', getAttrs: getAttrs(5) }, { tag: 'h6', getAttrs: getAttrs(6) }], toDOM: function toDOM(node) { var _node$attrs = node.attrs, level = _node$attrs.level, localId = _node$attrs.localId; var name = 'h' + level; var attrs = localId !== undefined && localId !== null ? [{ 'data-local-id': localId }] : []; return [name].concat(attrs, [0]); } });