"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.renderHeader = void 0;
var _react = _interopRequireDefault(require("react"));
var _core = require("../../core");
var _constants = require("../../constants");
const renderHeader = (props, editor) => {
  const {
    element,
    attributes,
    children
  } = props;
  const HeaderTagName = "h".concat(getHeaderTagName(element));
  const style = {
    textAlign: element.align
  };
  function getHeaderTagName(element) {
    const currentNodeType = (0, _core.getNodeType)(element);
    if (currentNodeType.indexOf(_constants.ELementTypes.HEADER) > -1) {
      return currentNodeType.split(_constants.ELementTypes.HEADER)[1];
    }
    return 'p';
  }
  return /*#__PURE__*/_react.default.createElement(HeaderTagName, Object.assign({
    "data-id": element.id,
    id: element.id // used for click left outline item, page scroll this element
    ,
    "data-root": "true"
  }, attributes, {
    style: style
  }), children);
};
exports.renderHeader = renderHeader;