"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _reactstrap = require("reactstrap");
var _reactI18next = require("react-i18next");
var _components = require("../../../components");
require("./style.css");
const isMac = window.navigator.platform.indexOf('Win') < 0 ? true : false;
const controlKey = isMac ? '⌘' : 'CTRL';
class KeyboardShortcuts extends _react.default.PureComponent {
  constructor() {
    super(...arguments);
    (0, _defineProperty2.default)(this, "renderShortcut", keys => {
      return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
        className: "keyboard-shortcut"
      }, keys.map((key, index) => {
        return /*#__PURE__*/_react.default.createElement("kbd", {
          key: index
        }, key);
      })), /*#__PURE__*/_react.default.createElement("br", null));
    });
    (0, _defineProperty2.default)(this, "renderContainer", (keys, description) => {
      return /*#__PURE__*/_react.default.createElement("div", {
        className: "keyboard-shortcut-container"
      }, /*#__PURE__*/_react.default.createElement("div", {
        className: "col-4"
      }, this.renderShortcut(keys)), /*#__PURE__*/_react.default.createElement("div", {
        className: "col-8"
      }, description));
    });
  }
  render() {
    let {
      t,
      toggleShortcutDialog,
      isRichEditor
    } = this.props;
    const userHelp = t('userHelp', {
      returnObjects: true
    });
    const userHelpData = userHelp.userHelpData;
    return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
      isOpen: true,
      toggle: toggleShortcutDialog,
      className: "keyboard-shortcut-dialog",
      zIndex: 1071
    }, /*#__PURE__*/_react.default.createElement(_components.ModalHeader, {
      toggle: toggleShortcutDialog
    }, /*#__PURE__*/_react.default.createElement("span", {
      className: "mr-2"
    }, t(userHelp.title))), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[1]['shortcutType'])), this.renderContainer(['#', 'space'], t(userHelpData[1].shortcutData['Heading_1'])), this.renderContainer(['##', 'space'], t(userHelpData[1].shortcutData['Heading_2'])), this.renderContainer(['###', 'space'], t(userHelpData[1].shortcutData['Heading_3'])), this.renderContainer(['####', 'space'], t(userHelpData[1].shortcutData['Heading_4'])), this.renderContainer(['#####', 'space'], t(userHelpData[1].shortcutData['Heading_5'])), this.renderContainer(['######', 'space'], t(userHelpData[1].shortcutData['Heading_6']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[0]['shortcutType'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-container"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "col-4"
    }, this.renderShortcut(['*', 'space']), this.renderShortcut(['-', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "col-8"
    }, t(userHelpData[0].shortcutData['Make_list']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-container"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "col-4"
    }, this.renderShortcut(['1.', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "col-8"
    }, t(userHelpData[0].shortcutData['Make_ordered_list']))), this.renderContainer(['Tab'], t(userHelpData[0].shortcutData['Increase_depth'])), this.renderContainer(['Shift', 'Enter'], t(userHelpData[0].shortcutData['Insert_child_in_item'])), this.renderContainer(['Enter'], t(userHelpData[0].shortcutData['Insert_new_item']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[6]['shortcutType'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-container"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "col-4"
    }, this.renderShortcut(['**bold**', 'space']), this.renderShortcut(['__bold__', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "col-8"
    }, t(userHelpData[6].shortcutData['Bold']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-container"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "col-4"
    }, this.renderShortcut(['*italic*', 'space']), this.renderShortcut(['_italic_', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "col-8"
    }, t(userHelpData[6].shortcutData['Italic']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-container"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "col-4"
    }, this.renderShortcut(['***italic***', 'space']), this.renderShortcut(['___italic___', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "col-8"
    }, t(userHelpData[6].shortcutData['Italic_bold']))), this.renderContainer(['`code`', 'space'], t(userHelpData[6].shortcutData['Inline_code']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[2]['shortcutType'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-container"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "col-4"
    }, this.renderShortcut(['```', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
      className: "col-8"
    }, t(userHelpData[2].shortcutData['Make_code_block']))), this.renderContainer(['Tab'], t(userHelpData[2].shortcutData['Insert_indent'])), this.renderContainer(['Enter'], t(userHelpData[2].shortcutData['Insert_new_line'])), this.renderContainer([controlKey, 'Enter'], t(userHelpData[2].shortcutData['Escape_code_block']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[3]['shortcutType'])), this.renderContainer(['>', 'space'], t(userHelpData[3].shortcutData['Make_block_quote'])), this.renderContainer(['Enter'], t(userHelpData[3].shortcutData['Escape_block_quote']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[4]['shortcutType'])), this.renderContainer(['Enter'], t(userHelpData[4].shortcutData['Insert_table_row'])), this.renderContainer([controlKey, 'Enter'], t(userHelpData[4].shortcutData['Escape_table']))), isRichEditor && /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[7]['shortcutType'])), this.renderContainer([controlKey, 's'], t(userHelpData[7].shortcutData['Save_file']))), /*#__PURE__*/_react.default.createElement("div", {
      className: "pb-2"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "keyboard-shortcut-title pb-1"
    }, t(userHelpData[8]['shortcutType'])), this.renderContainer([controlKey, 'v'], t(userHelpData[8].shortcutData['Paste_screen_shot']))))));
  }
}
var _default = exports.default = (0, _reactI18next.withTranslation)('seafile-editor')(KeyboardShortcuts);