mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
Notebooks: Add setting for default text cell edit behavior (#12245)
* Add setting for default text cell edit behavior * string updates
This commit is contained in:
@@ -68,6 +68,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
private _showMarkdown: boolean = false;
|
||||
private _cellSourceChanged: boolean = false;
|
||||
private _gridDataConversionComplete: Promise<void>[] = [];
|
||||
private _defaultToWYSIWYG: boolean;
|
||||
|
||||
constructor(cellData: nb.ICellContents,
|
||||
private _options: ICellModelOptions,
|
||||
@@ -95,15 +96,7 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
// if the fromJson() method was already called and _cellGuid was previously set, don't generate another UUID unnecessarily
|
||||
this._cellGuid = this._cellGuid || generateUuid();
|
||||
this.createUri();
|
||||
if (this._configurationService) {
|
||||
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);
|
||||
}
|
||||
}));
|
||||
}
|
||||
this.populatePropertiesFromSettings();
|
||||
}
|
||||
|
||||
public equals(other: ICellModel) {
|
||||
@@ -167,6 +160,9 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
|
||||
public set isEditMode(isEditMode: boolean) {
|
||||
this._isEditMode = isEditMode;
|
||||
if (this._isEditMode) {
|
||||
this.showMarkdown = !this._defaultToWYSIWYG;
|
||||
}
|
||||
this._onCellModeChanged.fire(this._isEditMode);
|
||||
// Note: this does not require a notebook update as it does not change overall state
|
||||
}
|
||||
@@ -326,6 +322,9 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
this._onCellMarkdownChanged.fire(this._showMarkdown);
|
||||
}
|
||||
|
||||
public get defaultToWYSIWYG(): boolean {
|
||||
return this._defaultToWYSIWYG;
|
||||
}
|
||||
|
||||
public get cellSourceChanged(): boolean {
|
||||
return this._cellSourceChanged;
|
||||
@@ -853,4 +852,23 @@ export class CellModel extends Disposable implements ICellModel {
|
||||
}
|
||||
this._future = undefined;
|
||||
}
|
||||
|
||||
private populatePropertiesFromSettings() {
|
||||
if (this._configurationService) {
|
||||
const enableWYSIWYGByDefaultKey = 'notebook.setRichTextViewByDefault';
|
||||
this._defaultToWYSIWYG = this._configurationService.getValue(enableWYSIWYGByDefaultKey);
|
||||
if (!this._defaultToWYSIWYG) {
|
||||
this.showMarkdown = true;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,6 +483,7 @@ export interface ICellModel {
|
||||
isEditMode: boolean;
|
||||
showPreview: boolean;
|
||||
showMarkdown: boolean;
|
||||
defaultToWYSIWYG: boolean;
|
||||
readonly onCellPreviewModeChanged: Event<boolean>;
|
||||
readonly onCellMarkdownModeChanged: Event<boolean>;
|
||||
sendChangeToNotebook(change: NotebookChangeType): void;
|
||||
|
||||
Reference in New Issue
Block a user