diff --git a/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts b/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts index 5a675c6a46..50d617fbcd 100644 --- a/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/codeCell.component.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { OnInit, Component, Input, Inject, forwardRef, ChangeDetectorRef, SimpleChange, OnChanges } from '@angular/core'; +import { OnInit, Component, Input, Inject, forwardRef, ChangeDetectorRef, SimpleChange, OnChanges, HostListener } from '@angular/core'; import { CellView } from 'sql/workbench/parts/notebook/cellViews/interfaces'; import { ICellModel } from 'sql/workbench/parts/notebook/models/modelInterfaces'; import { NotebookModel } from 'sql/workbench/parts/notebook/models/notebookModel'; @@ -25,6 +25,12 @@ export class CodeCellComponent extends CellView implements OnInit, OnChanges { this._activeCellId = value; } + @HostListener('document:keydown.escape', ['$event']) + handleKeyboardEvent() { + this.cellModel.active = false; + this._model.activeCell = undefined; + } + private _model: NotebookModel; private _activeCellId: string; diff --git a/src/sql/workbench/parts/notebook/cellViews/textCell.component.ts b/src/sql/workbench/parts/notebook/cellViews/textCell.component.ts index 932cf02883..7473f3c706 100644 --- a/src/sql/workbench/parts/notebook/cellViews/textCell.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/textCell.component.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/css!./textCell'; -import { OnInit, Component, Input, Inject, forwardRef, ElementRef, ChangeDetectorRef, OnDestroy, ViewChild, OnChanges, SimpleChange } from '@angular/core'; +import { OnInit, Component, Input, Inject, forwardRef, ElementRef, ChangeDetectorRef, OnDestroy, ViewChild, OnChanges, SimpleChange, HostListener } from '@angular/core'; import * as path from 'path'; import { localize } from 'vs/nls'; @@ -52,6 +52,15 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { } } + @HostListener('document:keydown.escape', ['$event']) + handleKeyboardEvent() { + if (this.isEditMode) { + this.toggleEditMode(false); + } + this.cellModel.active = false; + this._model.activeCell = undefined; + } + private _content: string; private isEditMode: boolean; private _sanitizer: ISanitizer;