diff --git a/src/vs/workbench/browser/parts/editor/binaryEditor.ts b/src/vs/workbench/browser/parts/editor/binaryEditor.ts index 5492f76a539..b7d65c63a78 100644 --- a/src/vs/workbench/browser/parts/editor/binaryEditor.ts +++ b/src/vs/workbench/browser/parts/editor/binaryEditor.ts @@ -14,13 +14,15 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { Dimension, size, clearNode, append, addDisposableListener, EventType, $ } from 'vs/base/browser/dom'; +import { Dimension, size, clearNode, append } from 'vs/base/browser/dom'; import { CancellationToken } from 'vs/base/common/cancellation'; import { DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { assertIsDefined, assertAllDefined } from 'vs/base/common/types'; import { ByteSize } from 'vs/platform/files/common/files'; import { IEditorOptions } from 'vs/platform/editor/common/editor'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { Link } from 'vs/platform/opener/browser/link'; export interface IOpenCallbacks { openInternal: (input: EditorInput, options: IEditorOptions | undefined) => Promise; @@ -47,7 +49,8 @@ export abstract class BaseBinaryResourceEditor extends EditorPane { private readonly callbacks: IOpenCallbacks, telemetryService: ITelemetryService, themeService: IThemeService, - @IStorageService storageService: IStorageService + @IStorageService storageService: IStorageService, + @IInstantiationService private readonly instantiationService: IInstantiationService ) { super(id, telemetryService, themeService, storageService); } @@ -98,17 +101,22 @@ export abstract class BaseBinaryResourceEditor extends EditorPane { label.textContent = localize('nativeBinaryError', "The file is not displayed in the editor because it is either binary or uses an unsupported text encoding."); binaryContainer.appendChild(label); - const link = append(label, $('a.embedded-link')); - link.setAttribute('role', 'button'); - link.textContent = localize('openAsText', "Do you want to open it anyway?"); + const link = this._register(this.instantiationService.createInstance(Link, { + label: localize('openAsText', "Do you want to open it anyway?"), + href: '' + }, { + opener: async () => { - disposables.add(addDisposableListener(link, EventType.CLICK, async () => { - await this.callbacks.openInternal(input, options); + // Open in place + await this.callbacks.openInternal(input, options); - // Signal to listeners that the binary editor has been opened in-place - this._onDidOpenInPlace.fire(); + // Signal to listeners that the binary editor has been opened in-place + this._onDidOpenInPlace.fire(); + } })); + append(label, link.el); + scrollbar.scanDomNode(); // Update metadata diff --git a/src/vs/workbench/browser/parts/editor/editorPlaceholder.ts b/src/vs/workbench/browser/parts/editor/editorPlaceholder.ts index fa71a6cddff..5fe9464079a 100644 --- a/src/vs/workbench/browser/parts/editor/editorPlaceholder.ts +++ b/src/vs/workbench/browser/parts/editor/editorPlaceholder.ts @@ -12,7 +12,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { Dimension, size, clearNode, append, addDisposableListener, EventType, $ } from 'vs/base/browser/dom'; +import { Dimension, size, clearNode, append } from 'vs/base/browser/dom'; import { CancellationToken } from 'vs/base/common/cancellation'; import { DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -22,6 +22,8 @@ import { isSingleFolderWorkspaceIdentifier, toWorkspaceIdentifier } from 'vs/pla import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IEditorOptions } from 'vs/platform/editor/common/editor'; import { EditorPaneDescriptor } from 'vs/workbench/browser/editor'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { Link } from 'vs/platform/opener/browser/link'; abstract class EditorPanePlaceholder extends EditorPane { @@ -130,7 +132,8 @@ export class WorkspaceTrustRequiredEditor extends EditorPanePlaceholder { @IThemeService themeService: IThemeService, @ICommandService private readonly commandService: ICommandService, @IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService, - @IStorageService storageService: IStorageService + @IStorageService storageService: IStorageService, + @IInstantiationService private readonly instantiationService: IInstantiationService ) { super(WorkspaceTrustRequiredEditor.ID, WorkspaceTrustRequiredEditor.LABEL, telemetryService, themeService, storageService); } @@ -141,13 +144,14 @@ export class WorkspaceTrustRequiredEditor extends EditorPanePlaceholder { localize('requiresFolderTrustText', "The file is not displayed in the editor because trust has not been granted to the folder.") : localize('requiresWorkspaceTrustText', "The file is not displayed in the editor because trust has not been granted to the workspace."); - const link = append(label, $('a.embedded-link')); - link.setAttribute('role', 'button'); - link.textContent = localize('manageTrust', "Manage Workspace Trust"); - - disposables.add(addDisposableListener(link, EventType.CLICK, async () => { - await this.commandService.executeCommand('workbench.trust.manage'); + const link = this._register(this.instantiationService.createInstance(Link, { + label: localize('manageTrust', "Manage Workspace Trust"), + href: '' + }, { + opener: () => this.commandService.executeCommand('workbench.trust.manage') })); + + append(label, link.el); } } @@ -160,7 +164,8 @@ export class UnavailableEditor extends EditorPanePlaceholder { constructor( @ITelemetryService telemetryService: ITelemetryService, @IThemeService themeService: IThemeService, - @IStorageService storageService: IStorageService + @IStorageService storageService: IStorageService, + @IInstantiationService private readonly instantiationService: IInstantiationService ) { super(UnavailableEditor.ID, UnavailableEditor.LABEL, telemetryService, themeService, storageService); } @@ -173,13 +178,14 @@ export class UnavailableEditor extends EditorPanePlaceholder { const group = this.group; const input = this.input; if (group && input) { - const link = append(label, $('a.embedded-link')); - link.setAttribute('role', 'button'); - link.textContent = localize('retry', "Try Again"); - - disposables.add(addDisposableListener(link, EventType.CLICK, () => { - group.openEditor(input, this.options); + const link = this._register(this.instantiationService.createInstance(Link, { + label: localize('retry', "Try Again"), + href: '' + }, { + opener: () => group.openEditor(input, this.options) })); + + append(label, link.el); } } } diff --git a/src/vs/workbench/browser/parts/editor/media/binaryeditor.css b/src/vs/workbench/browser/parts/editor/media/binaryeditor.css index 062b4091fd4..ed3124c33cc 100644 --- a/src/vs/workbench/browser/parts/editor/media/binaryeditor.css +++ b/src/vs/workbench/browser/parts/editor/media/binaryeditor.css @@ -12,8 +12,8 @@ box-sizing: border-box; } -.monaco-binary-resource-editor .embedded-link, -.monaco-binary-resource-editor .embedded-link:hover { +.monaco-binary-resource-editor .monaco-link, +.monaco-binary-resource-editor .monaco-link:hover { cursor: pointer; text-decoration: underline; margin-left: 5px; diff --git a/src/vs/workbench/browser/parts/editor/media/editorplaceholder.css b/src/vs/workbench/browser/parts/editor/media/editorplaceholder.css index 3d4fe46843e..4f358590538 100644 --- a/src/vs/workbench/browser/parts/editor/media/editorplaceholder.css +++ b/src/vs/workbench/browser/parts/editor/media/editorplaceholder.css @@ -12,8 +12,8 @@ box-sizing: border-box; } -.monaco-editor-pane-placeholder .embedded-link, -.monaco-editor-pane-placeholder .embedded-link:hover { +.monaco-editor-pane-placeholder .monaco-link, +.monaco-editor-pane-placeholder .monaco-link:hover { cursor: pointer; text-decoration: underline; margin-left: 5px; diff --git a/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts b/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts index 12047949b1b..4856eded54d 100644 --- a/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts +++ b/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts @@ -16,6 +16,7 @@ import { EditorResolution, IEditorOptions } from 'vs/platform/editor/common/edit import { IEditorResolverService, ResolvedStatus, ResolvedEditor } from 'vs/workbench/services/editor/common/editorResolverService'; import { isEditorInputWithOptions } from 'vs/workbench/common/editor'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; /** * An implementation of editor for binary files that cannot be displayed. @@ -29,7 +30,8 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor { @IThemeService themeService: IThemeService, @IEditorService private readonly editorService: IEditorService, @IEditorResolverService private readonly editorResolverService: IEditorResolverService, - @IStorageService storageService: IStorageService + @IStorageService storageService: IStorageService, + @IInstantiationService instantiationService: IInstantiationService ) { super( BinaryFileEditor.ID, @@ -38,7 +40,8 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor { }, telemetryService, themeService, - storageService + storageService, + instantiationService ); }