"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 = ColumnMenu;
var _react = _interopRequireWildcard(require("react"));
var _menusConfig = require("../../../constants/menus-config");
var _elementTypes = require("../../../constants/element-types");
var _helpers = require("../helpers");
var _dropdownMenuItem = _interopRequireDefault(require("../../../commons/dropdown-menu-item"));
const menuConfig = _menusConfig.MENUS_CONFIG_MAP[_elementTypes.COLUMN];
const isActive = editor => {
  return (0, _helpers.getColumnType)(editor) === _elementTypes.COLUMN;
};
function ColumnMenu(_ref) {
  let {
    readonly,
    editor,
    toggle
  } = _ref;
  const insertColumn = (0, _react.useCallback)(event => {
    event.stopPropagation();
    toggle && toggle();
    const active = isActive(editor);
    (0, _helpers.insertSeaTableColumn)(editor, active);
  }, [editor, toggle]);
  return /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
    disabled: readonly,
    menuConfig: menuConfig,
    className: "pr-2",
    onClick: insertColumn
  });
}