UNPKG

@atlaskit/adf-schema

Version:

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

65 lines (60 loc) 1.33 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) { return { level: level, localId: // eslint-disable-next-line @atlaskit/editor/no-as-casting domNode.getAttribute('data-local-id') || null }; }; }; 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]); } });