Notebooks: Ensure WYSIWYG Mode for Keyboard Shortcuts (#14416)

* Ensure WYSIWYG Mode for kb shortcuts

* Move logic down to cell model
This commit is contained in:
Chris LaFreniere
2021-02-25 16:57:06 -08:00
committed by GitHub
parent e761eb12ef
commit dbc655a8f5
3 changed files with 24 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
import * as notebookUtils from 'sql/workbench/services/notebook/browser/models/notebookUtils';
import { CellTypes, CellType, NotebookChangeType } from 'sql/workbench/services/notebook/common/contracts';
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
import { ICellModel, IOutputChangedEvent, CellExecutionState, ICellModelOptions, ITableUpdatedEvent } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { ICellModel, IOutputChangedEvent, CellExecutionState, ICellModelOptions, ITableUpdatedEvent, CellEditModes } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
@@ -878,6 +878,19 @@ export class CellModel extends Disposable implements ICellModel {
}
}
public get currentMode(): CellEditModes {
if (this._cellType === CellTypes.Code) {
return CellEditModes.CODE;
}
if (this._showMarkdown && this._showPreview) {
return CellEditModes.SPLIT;
} else if (this._showMarkdown && !this._showPreview) {
return CellEditModes.MARKDOWN;
}
// defaulting to WYSIWYG
return CellEditModes.WYSIWYG;
}
private setLanguageFromContents(cell: nb.ICellContents): void {
if (cell.cell_type === CellTypes.Markdown) {
this._language = 'markdown';

View File

@@ -530,6 +530,7 @@ export interface ICellModel {
sendChangeToNotebook(change: NotebookChangeType): void;
cellSourceChanged: boolean;
readonly savedConnectionName: string | undefined;
readonly currentMode: CellEditModes;
}
export interface IModelFactory {
@@ -585,3 +586,10 @@ export interface INotebookContentsEditable {
nbformat: number;
nbformat_minor: number;
}
export enum CellEditModes {
'CODE',
'MARKDOWN',
'SPLIT',
'WYSIWYG'
}