/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { Registry } from 'vs/platform/registry/common/platform'; import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } from 'vs/workbench/browser/editor'; import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor'; import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/browser/notebookEditorInput'; import { Action } from 'vs/base/common/actions'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; Registry.as(EditorExtensions.Editors).registerEditor( EditorDescriptor.create( NotebookEditor, NotebookEditor.ID, 'Notebook Editor' ), [ new SyncDescriptor(NotebookEditorInput) ] ); export class NotebookAction extends Action { public static readonly ID = 'workbench.action.showNotebook'; public static readonly LABEL = nls.localize('notebookSample', "Notebook Playground"); constructor( id: string, label: string, @IEditorService private readonly editorService: IEditorService, @IInstantiationService private readonly instantiationService: IInstantiationService ) { super(id, label); } public run(): Promise { const input = this.instantiationService.createInstance(NotebookEditorInput); return this.editorService.openEditor(input, { pinned: true }) .then(() => void (0)); } } Registry.as(Extensions.WorkbenchActions) .registerWorkbenchAction( SyncActionDescriptor.create(NotebookAction, NotebookAction.ID, NotebookAction.LABEL), 'Help: Notebook Playground', nls.localize('help', "Notebook Playground"));