mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
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:
@@ -7,7 +7,7 @@ import * as DOM from 'vs/base/browser/dom';
|
|||||||
import { Component, Input, Inject, ViewChild, ElementRef } from '@angular/core';
|
import { Component, Input, Inject, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ICellModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
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 { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||||
import { TransformMarkdownAction, MarkdownButtonType, ToggleViewAction } from 'sql/workbench/contrib/notebook/browser/markdownToolbarActions';
|
import { TransformMarkdownAction, MarkdownButtonType, ToggleViewAction } from 'sql/workbench/contrib/notebook/browser/markdownToolbarActions';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
@@ -42,6 +42,9 @@ export class MarkdownToolbarComponent {
|
|||||||
public splitViewButton = localize('splitViewButton', "View as Split");
|
public splitViewButton = localize('splitViewButton', "View as Split");
|
||||||
public markdownButton = localize('markdownButton', "View as Markdown");
|
public markdownButton = localize('markdownButton', "View as Markdown");
|
||||||
|
|
||||||
|
private _taskbarContent: Array<ITaskbarContent>;
|
||||||
|
private _wysiwygTaskbarContent: Array<ITaskbarContent>;
|
||||||
|
|
||||||
@Input() public cellModel: ICellModel;
|
@Input() public cellModel: ICellModel;
|
||||||
private _actionBar: Taskbar;
|
private _actionBar: Taskbar;
|
||||||
_toggleTextViewAction: ToggleViewAction;
|
_toggleTextViewAction: ToggleViewAction;
|
||||||
@@ -98,7 +101,7 @@ export class MarkdownToolbarComponent {
|
|||||||
dropdownMenuActionViewItem.render(buttonDropdownContainer);
|
dropdownMenuActionViewItem.render(buttonDropdownContainer);
|
||||||
dropdownMenuActionViewItem.setActionContext(this);
|
dropdownMenuActionViewItem.setActionContext(this);
|
||||||
|
|
||||||
this._actionBar.setContent([
|
this._taskbarContent = [
|
||||||
{ action: boldButton },
|
{ action: boldButton },
|
||||||
{ action: italicButton },
|
{ action: italicButton },
|
||||||
{ action: underlineButton },
|
{ action: underlineButton },
|
||||||
@@ -112,7 +115,34 @@ export class MarkdownToolbarComponent {
|
|||||||
{ action: this._toggleTextViewAction },
|
{ action: this._toggleTextViewAction },
|
||||||
{ action: this._toggleSplitViewAction },
|
{ action: this._toggleSplitViewAction },
|
||||||
{ action: this._toggleMarkdownViewAction }
|
{ 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() {
|
public removeActiveClassFromModeActions() {
|
||||||
|
|||||||
@@ -541,6 +541,12 @@ export class ToggleViewAction extends Action {
|
|||||||
this.class += ' active';
|
this.class += ' active';
|
||||||
context.cellModel.showPreview = this.showPreview;
|
context.cellModel.showPreview = this.showPreview;
|
||||||
context.cellModel.showMarkdown = this.showMarkdown;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user