48d02dabdcecdd351788dbc301dbdd5863fe2a6a4fdaec6731be1541b233e7ba67deb43c87b5d1d1dc056b7a9aada03c3d732e2b24450359a3e26ecc5b7935 920 B

1234567891011121314151617181920212223242526272829303132
  1. import {getValidSelection} from './../utils';
  2. export const KEY = 'col_right';
  3. export default function columnRightItem() {
  4. return {
  5. key: KEY,
  6. name: 'Insert column on the right',
  7. callback(key, selection) {
  8. this.alter('insert_col', selection.end.col + 1, 1, 'ContextMenu.columnRight');
  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. }