mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 09:35:38 -05:00
save lastEditMode and use that as default (#17206)
* save lastEditMode * change style to active * addActiveClassFromEditMode * add undefined to declaration * remove from public interface * private * lastEditMode to last selected mode * comments * set active in one place * rename method
This commit is contained in:
@@ -221,6 +221,7 @@ export class MarkdownToolbarComponent extends AngularDisposable {
|
||||
}
|
||||
}
|
||||
this._notebookEditor = this._notebookService.findNotebookEditor(this.cellModel?.notebookModel?.notebookUri);
|
||||
this.updateActiveViewAction();
|
||||
}
|
||||
|
||||
public async onInsertButtonClick(event: MouseEvent, type: MarkdownButtonType): Promise<void> {
|
||||
@@ -291,7 +292,7 @@ export class MarkdownToolbarComponent extends AngularDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public removeActiveClassFromModeActions() {
|
||||
private removeActiveClassFromModeActions() {
|
||||
const activeClass = ' active';
|
||||
for (let action of [this._toggleTextViewAction, this._toggleSplitViewAction, this._toggleMarkdownViewAction]) {
|
||||
if (action.class.includes(activeClass)) {
|
||||
@@ -300,6 +301,16 @@ export class MarkdownToolbarComponent extends AngularDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public updateActiveViewAction() {
|
||||
this.removeActiveClassFromModeActions();
|
||||
const activeClass = ' active';
|
||||
switch (this.cellModel.currentMode) {
|
||||
case CellEditModes.MARKDOWN: this._toggleMarkdownViewAction.class += activeClass; break;
|
||||
case CellEditModes.SPLIT: this._toggleSplitViewAction.class += activeClass; break;
|
||||
case CellEditModes.WYSIWYG: this._toggleTextViewAction.class += activeClass; break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate modal for use as callout when inserting Link or Image into markdown.
|
||||
* @param calloutStyle Style of callout passed in to determine which callout is rendered.
|
||||
|
||||
@@ -607,8 +607,6 @@ export class ToggleViewAction extends Action {
|
||||
}
|
||||
|
||||
public override async run(context: MarkdownToolbarComponent): Promise<void> {
|
||||
context.removeActiveClassFromModeActions();
|
||||
this.class += ' active';
|
||||
context.cellModel.showPreview = this.showPreview;
|
||||
context.cellModel.showMarkdown = this.showMarkdown;
|
||||
// Hide image button in WYSIWYG mode
|
||||
@@ -617,5 +615,6 @@ export class ToggleViewAction extends Action {
|
||||
} else {
|
||||
context.showLinkAndImageButtons();
|
||||
}
|
||||
context.updateActiveViewAction();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user