536b49a6812d204ee4f5abaefea490c065b009b2fa1af100ea5352dd5e4b78fccde3810a006c3bfcb4a1376aa1a4675e12aecbc9e6e6a9fc4b05ef684cc46b 913 B

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