Added code to enable disable split cell icon (#17331)

* Added code to enable diable split cell icon

* adding back the deleted code

* refactored

* minimized lines

* simplified code

* minor change

* minor change

* Addressed PR

* Addressed PR

* removing unused enum value
This commit is contained in:
rajeshka
2021-10-11 09:47:25 -07:00
committed by GitHub
parent af58a52004
commit f5331e3d69
4 changed files with 16 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ import Severity from 'vs/base/common/severity';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { CellEditModes, MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
const moreActionsLabel = localize('moreActionsLabel', "More");
export class EditCellAction extends ToggleableAction {
@@ -78,6 +78,11 @@ export class SplitCellAction extends CellActionBase {
context.model?.splitCell(context.cell.cellType, this.notebookService, index);
return Promise.resolve();
}
public setListener(context: CellContext) {
this._register(context.cell.onCurrentEditModeChanged(currentMode => {
this.enabled = currentMode === CellEditModes.WYSIWYG ? false : true;
}));
}
}
export class MoveCellAction extends CellActionBase {

View File

@@ -60,6 +60,8 @@ export class CellToolbarComponent {
this._actionBar.context = context;
let splitCellButton = this.instantiationService.createInstance(SplitCellAction, 'notebook.SplitCellAtCursor', this.buttonSplitCell, 'masked-icon icon-split-cell');
splitCellButton.setListener(context);
splitCellButton.enabled = this.cellModel.cellType !== 'markdown';
let addCellsButton = this.instantiationService.createInstance(AddCellAction, 'notebook.AddCodeCell', localize('codeCellsPreview', "Add cell"), 'masked-pseudo code');