Notebooks: Hide link and image buttons in text cell toolbar in WYSIWYG mode (#12240)

* hide link and image buttons in WYSIWYG mode

* defined taskbar actions

* rename arrays
This commit is contained in:
Lucy Zhang
2020-09-11 15:55:06 -07:00
committed by GitHub
parent 3d81da9762
commit f99adf3de4
2 changed files with 39 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ import * as DOM from 'vs/base/browser/dom';
import { Component, Input, Inject, ViewChild, ElementRef } from '@angular/core';
import { localize } from 'vs/nls';
import { ICellModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { ITaskbarContent, Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { TransformMarkdownAction, MarkdownButtonType, ToggleViewAction } from 'sql/workbench/contrib/notebook/browser/markdownToolbarActions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -42,6 +42,9 @@ export class MarkdownToolbarComponent {
public splitViewButton = localize('splitViewButton', "View as Split");
public markdownButton = localize('markdownButton', "View as Markdown");
private _taskbarContent: Array<ITaskbarContent>;
private _wysiwygTaskbarContent: Array<ITaskbarContent>;
@Input() public cellModel: ICellModel;
private _actionBar: Taskbar;
_toggleTextViewAction: ToggleViewAction;
@@ -98,7 +101,7 @@ export class MarkdownToolbarComponent {
dropdownMenuActionViewItem.render(buttonDropdownContainer);
dropdownMenuActionViewItem.setActionContext(this);
this._actionBar.setContent([
this._taskbarContent = [
{ action: boldButton },
{ action: italicButton },
{ action: underlineButton },
@@ -112,7 +115,34 @@ export class MarkdownToolbarComponent {
{ action: this._toggleTextViewAction },
{ action: this._toggleSplitViewAction },
{ action: this._toggleMarkdownViewAction }
]);
];
this._wysiwygTaskbarContent = [
{ action: boldButton },
{ action: italicButton },
{ action: underlineButton },
{ action: highlightButton },
{ action: codeButton },
{ action: listButton },
{ action: orderedListButton },
{ element: buttonDropdownContainer },
{ action: this._toggleTextViewAction },
{ action: this._toggleSplitViewAction },
{ action: this._toggleMarkdownViewAction }
];
// Hide link and image buttons in WYSIWYG mode
if (this.cellModel.showPreview && !this.cellModel.showMarkdown) {
this._actionBar.setContent(this._wysiwygTaskbarContent);
} else {
this._actionBar.setContent(this._taskbarContent);
}
}
public hideLinkAndImageButtons() {
this._actionBar.setContent(this._wysiwygTaskbarContent);
}
public showLinkAndImageButtons() {
this._actionBar.setContent(this._taskbarContent);
}
public removeActiveClassFromModeActions() {

View File

@@ -541,6 +541,12 @@ export class ToggleViewAction extends Action {
this.class += ' active';
context.cellModel.showPreview = this.showPreview;
context.cellModel.showMarkdown = this.showMarkdown;
// Hide link and image buttons in WYSIWYG mode
if (this.showPreview && !this.showMarkdown) {
context.hideLinkAndImageButtons();
} else {
context.showLinkAndImageButtons();
}
return true;
}
}