mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 09:35:38 -05:00
Add Markdown as a default editing option for text cells (#15540)
This commit is contained in:
@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
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 { CellTypes, CellType, NotebookChangeType, TextCellEditModes } from 'sql/workbench/services/notebook/common/contracts';
|
||||
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
||||
import { ICellModel, IOutputChangedEvent, CellExecutionState, ICellModelOptions, ITableUpdatedEvent, CellEditModes } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
@@ -77,7 +77,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
private _showPreview: boolean = true;
|
||||
private _showMarkdown: boolean = false;
|
||||
private _cellSourceChanged: boolean = false;
|
||||
private _defaultToWYSIWYG: boolean;
|
||||
private _defaultTextEditMode: string;
|
||||
private _isParameter: boolean;
|
||||
private _onParameterStateChanged = new Emitter<boolean>();
|
||||
private _isInjectedParameter: boolean;
|
||||
@@ -216,7 +216,8 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
public set isEditMode(isEditMode: boolean) {
|
||||
this._isEditMode = isEditMode;
|
||||
if (this._isEditMode) {
|
||||
this.showMarkdown = !this._defaultToWYSIWYG;
|
||||
this.showPreview = this._defaultTextEditMode !== TextCellEditModes.Markdown;
|
||||
this.showMarkdown = this._defaultTextEditMode !== TextCellEditModes.RichText;
|
||||
}
|
||||
this._onCellModeChanged.fire(this._isEditMode);
|
||||
// Note: this does not require a notebook update as it does not change overall state
|
||||
@@ -383,8 +384,8 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
this._onCellMarkdownChanged.fire(this._showMarkdown);
|
||||
}
|
||||
|
||||
public get defaultToWYSIWYG(): boolean {
|
||||
return this._defaultToWYSIWYG;
|
||||
public get defaultTextEditMode(): string {
|
||||
return this._defaultTextEditMode;
|
||||
}
|
||||
|
||||
public get cellSourceChanged(): boolean {
|
||||
@@ -1055,18 +1056,16 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
|
||||
private populatePropertiesFromSettings() {
|
||||
if (this._configurationService) {
|
||||
const enableWYSIWYGByDefaultKey = 'notebook.setRichTextViewByDefault';
|
||||
this._defaultToWYSIWYG = this._configurationService.getValue(enableWYSIWYGByDefaultKey);
|
||||
if (!this._defaultToWYSIWYG) {
|
||||
this.showMarkdown = true;
|
||||
}
|
||||
const defaultTextModeKey = 'notebook.defaultTextEditMode';
|
||||
this._defaultTextEditMode = this._configurationService.getValue(defaultTextModeKey);
|
||||
|
||||
const allowADSCommandsKey = 'notebook.allowAzureDataStudioCommands';
|
||||
this._isCommandExecutionSettingEnabled = this._configurationService.getValue(allowADSCommandsKey);
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration(allowADSCommandsKey)) {
|
||||
this._isCommandExecutionSettingEnabled = this._configurationService.getValue(allowADSCommandsKey);
|
||||
} else if (e.affectsConfiguration(enableWYSIWYGByDefaultKey)) {
|
||||
this._defaultToWYSIWYG = this._configurationService.getValue(enableWYSIWYGByDefaultKey);
|
||||
} else if (e.affectsConfiguration(defaultTextModeKey)) {
|
||||
this._defaultTextEditMode = this._configurationService.getValue(defaultTextModeKey);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ export interface ICellModel {
|
||||
isEditMode: boolean;
|
||||
showPreview: boolean;
|
||||
showMarkdown: boolean;
|
||||
defaultToWYSIWYG: boolean;
|
||||
defaultTextEditMode: string;
|
||||
readonly onCellPreviewModeChanged: Event<boolean>;
|
||||
readonly onCellMarkdownModeChanged: Event<boolean>;
|
||||
sendChangeToNotebook(change: NotebookChangeType): void;
|
||||
|
||||
Reference in New Issue
Block a user