clearColumn.js 856 B

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