"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _useSelectionUpdate = _interopRequireDefault(require("../../../hooks/use-selection-update"));
var _commons = require("../../commons");
var _menu = _interopRequireDefault(require("../../plugins/blockquote/menu"));
var _menu2 = _interopRequireDefault(require("../../plugins/header/menu"));
var _menu3 = _interopRequireDefault(require("../../plugins/text-style/menu"));
var _menu4 = _interopRequireDefault(require("../../plugins/link/menu"));
var _constants = require("../../constants");
var _menu5 = _interopRequireDefault(require("../../plugins/check-list/menu"));
var _menu6 = _interopRequireDefault(require("../../plugins/list/menu"));
var _elementTypes = require("../../constants/element-types");
var _menu7 = _interopRequireDefault(require("../../plugins/clear-format/menu"));
var _shortcutDialog = _interopRequireDefault(require("../user-help/shortcut-dialog"));
var _insertToolbar = _interopRequireDefault(require("../header-toolbar/insert-toolbar"));
var _imageMenuDialog = _interopRequireDefault(require("../../plugins/image/menu/image-menu-dialog"));
require("./index.css");
const InlineToolbar = _ref => {
  let {
    editor,
    readonly = false,
    isRichEditor = false,
    isSupportFormula = false,
    isSupportInsertSeafileImage = false,
    isSupportColumn = false,
    onExpandEditorToggle
  } = _ref;
  (0, _useSelectionUpdate.default)();
  const [isShowInternetImageModal, setIsShowInternetImageModal] = (0, _react.useState)(false);
  const [isShowHelpModal, setIsShowHelpModal] = (0, _react.useState)(false);
  const onHelpIconToggle = (0, _react.useCallback)(() => {
    setIsShowHelpModal(!isShowHelpModal);
  }, [isShowHelpModal]);
  const onToggleImageDialog = (0, _react.useCallback)(() => {
    setIsShowInternetImageModal(false);
  }, []);
  const commonProps = {
    editor,
    readonly,
    isRichEditor
  };
  return /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-slate-editor-toolbar"
  }, isRichEditor && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_insertToolbar.default, {
    editor: editor,
    readonly: readonly,
    isSupportFormula: isSupportFormula,
    isSupportColumn: isSupportColumn,
    setIsShowInternetImageModal: setIsShowInternetImageModal
  })), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_menu2.default, commonProps)), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_menu3.default, Object.assign({}, commonProps, {
    type: _constants.TEXT_STYLE_MAP.ITALIC
  })), /*#__PURE__*/_react.default.createElement(_menu3.default, Object.assign({}, commonProps, {
    type: _constants.TEXT_STYLE_MAP.BOLD
  })), /*#__PURE__*/_react.default.createElement(_menu3.default, Object.assign({}, commonProps, {
    type: _constants.TEXT_STYLE_MAP.UNDERLINE
  })), /*#__PURE__*/_react.default.createElement(_menu3.default, Object.assign({}, commonProps, {
    type: _constants.TEXT_STYLE_MAP.CODE
  })), /*#__PURE__*/_react.default.createElement(_menu4.default, commonProps)), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_menu.default, commonProps), /*#__PURE__*/_react.default.createElement(_menu5.default, commonProps)), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_commons.MoreMenu, commonProps, /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_menu6.default, Object.assign({}, commonProps, {
    type: _elementTypes.UNORDERED_LIST
  })), /*#__PURE__*/_react.default.createElement(_menu6.default, Object.assign({}, commonProps, {
    type: _elementTypes.ORDERED_LIST
  })), /*#__PURE__*/_react.default.createElement(_menu7.default, commonProps)), !isRichEditor && /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-menu-group-item sf-slate-help-info-control",
    onClick: onHelpIconToggle
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: "iconfont icon-use-help"
  })))), onExpandEditorToggle && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, onExpandEditorToggle && /*#__PURE__*/_react.default.createElement(_commons.ExpandEditorMenu, Object.assign({}, commonProps, {
    onExpandEditorToggle: onExpandEditorToggle
  }))), isShowHelpModal && /*#__PURE__*/_react.default.createElement(_shortcutDialog.default, {
    isRichEditor: isRichEditor,
    toggleShortcutDialog: onHelpIconToggle
  }), isShowInternetImageModal && /*#__PURE__*/_react.default.createElement(_imageMenuDialog.default, {
    editor: editor,
    closeDialog: onToggleImageDialog
  }));
};
var _default = exports.default = InlineToolbar;