"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _CommandMenuButton = _interopRequireDefault(require("./CommandMenuButton"));

var _licitUiCommands = require("@modusoperandi/licit-ui-commands");

var React = _interopRequireWildcard(require("react"));

var _findActiveFontType = _interopRequireWildcard(require("./findActiveFontType"));

var _prosemirrorState = require("prosemirror-state");

var _prosemirrorView = require("prosemirror-view");

var _FontTypeMarkSpec = require("../FontTypeMarkSpec");

var _prosemirrorTransform = require("prosemirror-transform");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

const FONT_TYPE_COMMANDS = {
  [_findActiveFontType.FONT_TYPE_NAME_DEFAULT]: new _licitUiCommands.FontTypeCommand('')
};

_FontTypeMarkSpec.FONT_TYPE_NAMES.forEach(name => {
  FONT_TYPE_COMMANDS[name] = new _licitUiCommands.FontTypeCommand(name);
});

const COMMAND_GROUPS = [FONT_TYPE_COMMANDS];

class FontTypeCommandMenuButton extends React.PureComponent {
  constructor() {
    super(...arguments);

    _defineProperty(this, "props", void 0);
  }

  render() {
    const {
      dispatch,
      editorState,
      editorView
    } = this.props;
    const fontType = (0, _findActiveFontType.default)(editorState);
    return /*#__PURE__*/React.createElement(_CommandMenuButton.default, {
      className: "width-100" // [FS] IRAD-1008 2020-07-16
      // Disable font type menu on editor disable state
      ,
      commandGroups: COMMAND_GROUPS,
      disabled: editorView && editorView.disabled ? true : false,
      dispatch: dispatch,
      editorState: editorState,
      editorView: editorView,
      label: fontType
    });
  }

}

var _default = FontTypeCommandMenuButton;
exports.default = _default;