"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
var _constants = require("../../constants");
var _helpers = require("./helpers");
const withTextStyle = editor => {
  const {
    onHotKeyDown
  } = editor;
  const newEditor = editor;
  newEditor.onHotKeyDown = event => {
    // Does not meet text hotkey processing conditions
    if (!(0, _isHotkey.default)('mod+b', event) && !(0, _isHotkey.default)('mod+i', event)) {
      return onHotKeyDown && onHotKeyDown(event);
    }

    // handled by text hotkey
    if ((0, _helpers.isMenuDisabled)(newEditor)) {
      return true;
    }
    if ((0, _isHotkey.default)('mod+b', event)) {
      (0, _helpers.toggleTextStyle)(newEditor, _constants.TEXT_STYLE_MAP.BOLD);
      return true;
    }
    if ((0, _isHotkey.default)('mod+i', event)) {
      (0, _helpers.toggleTextStyle)(newEditor, _constants.TEXT_STYLE_MAP.ITALIC);
      return true;
    }
    return false;
  };
  return newEditor;
};
var _default = exports.default = withTextStyle;