3190: Code and Text cells from tool bar (#3191)

* 3190: Code and Text cells from tool bar

* 3190: Adding images under media folder and to css
This commit is contained in:
Raj
2018-11-12 11:41:02 -08:00
committed by GitHub
parent a2bbf3f44e
commit 0a486a280d
9 changed files with 49 additions and 13 deletions

View File

@@ -31,7 +31,7 @@ import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { AddCellAction, KernelsDropdown, AttachToDropdown } from 'sql/parts/notebook/notebookActions';
import { KernelsDropdown, AttachToDropdown, AddCellAction } from 'sql/parts/notebook/notebookActions';
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
@@ -80,7 +80,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
}
public get modelRegistered(): Promise<NotebookModel> {
return this._modelRegisteredDeferred.promise;
return this._modelRegisteredDeferred.promise;
}
protected get cells(): ReadonlyArray<ICellModel> {
@@ -103,11 +103,17 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
}
}
//Add cell based on cell type
public addCell(cellType: CellType)
{
this._model.addCell(cellType);
}
public onKeyDown(event) {
switch (event.key) {
case 'ArrowDown':
case 'ArrowRight':
let nextIndex = (this.findCellIndex(this._activeCell) + 1)%this.cells.length;
let nextIndex = (this.findCellIndex(this._activeCell) + 1) % this.cells.length;
this.selectCell(this.cells[nextIndex]);
break;
case 'ArrowUp':
@@ -176,7 +182,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
}
findCellIndex(cellModel: ICellModel): number {
return this._model.cells.findIndex((cell) => cell.id === cellModel.id);
return this._model.cells.findIndex((cell) => cell.id === cellModel.id);
}
private setViewInErrorState(error: any): any {
@@ -188,7 +194,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
protected initActionBar() {
let kernelInfoText = document.createElement('div');
kernelInfoText.className ='notebook-info-label';
kernelInfoText.className = 'notebook-info-label';
kernelInfoText.innerText = 'Kernel: ';
let kernelsDropdown = new KernelsDropdown(this.contextViewService, this.modelRegistered);
@@ -204,9 +210,15 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
attachSelectBoxStyler(attachToDropdown, this.themeService);
let attachToInfoText = document.createElement('div');
attachToInfoText.className ='notebook-info-label';
attachToInfoText.className = 'notebook-info-label';
attachToInfoText.innerText = 'Attach To: ';
let addCodeCellButton = new AddCellAction('notebook.AddCodeCell', localize('code', 'Code'), 'notebook-info-button');
addCodeCellButton.cellType = CellTypes.Code;
let addTextCellButton = new AddCellAction('notebook.AddTextCell',localize('text', 'Text'), 'notebook-info-button');
addTextCellButton.cellType = CellTypes.Markdown;
let taskbar = <HTMLElement>this.toolbar.nativeElement;
this._actionBar = new Taskbar(taskbar, this.contextMenuService);
this._actionBar.context = this;
@@ -214,7 +226,9 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
{ element: kernelInfoText },
{ element: kernelsDropdownTemplateContainer },
{ element: attachToInfoText },
{ element: attachToDropdownTemplateContainer }
{ element: attachToDropdownTemplateContainer },
{ action: addCodeCellButton},
{ action: addTextCellButton}
]);
}