clearColumn.js 951 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. exports.__esModule = true;
  3. exports.KEY = undefined;
  4. exports.default = clearColumnItem;
  5. var _utils = require('./../utils');
  6. var KEY = exports.KEY = 'clear_column';
  7. function clearColumnItem() {
  8. return {
  9. key: KEY,
  10. name: 'Clear column',
  11. callback: function callback(key, selection) {
  12. var column = selection.start.col;
  13. if (this.countRows()) {
  14. this.populateFromArray(0, column, [[null]], Math.max(selection.start.row, selection.end.row), column, 'ContextMenu.clearColumn');
  15. }
  16. },
  17. disabled: function disabled() {
  18. var selected = (0, _utils.getValidSelection)(this);
  19. if (!selected) {
  20. return true;
  21. }
  22. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  23. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  24. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  25. }
  26. };
  27. }