columnRight.js 972 B

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