columnLeft.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. exports.__esModule = true;
  3. exports.KEY = undefined;
  4. exports.default = columnLeftItem;
  5. var _utils = require('./../utils');
  6. var KEY = exports.KEY = 'col_left';
  7. function columnLeftItem() {
  8. return {
  9. key: KEY,
  10. name: 'Insert column on the left',
  11. callback: function callback(key, selection) {
  12. this.alter('insert_col', selection.start.col, 1, 'ContextMenu.columnLeft');
  13. },
  14. disabled: function disabled() {
  15. var selected = (0, _utils.getValidSelection)(this);
  16. if (!selected) {
  17. return true;
  18. }
  19. if (!this.isColumnModificationAllowed()) {
  20. return true;
  21. }
  22. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  23. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  24. var onlyOneColumn = this.countCols() === 1;
  25. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  26. },
  27. hidden: function hidden() {
  28. return !this.getSettings().allowInsertColumn;
  29. }
  30. };
  31. }