mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 09:35:38 -05:00
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:
@@ -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';
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user