diff --git a/extensions/notebook-test/src/notebookProvider.ts b/extensions/notebook-test/src/notebookProvider.ts index 8213bb7c2e80d1dd432016d3fc74209abed2d4a0..c3147402b4d162cc77e6ce433f320f6e9c8c0388 100644 --- a/extensions/notebook-test/src/notebookProvider.ts +++ b/extensions/notebook-test/src/notebookProvider.ts @@ -8,7 +8,7 @@ import * as path from 'path'; declare var TextEncoder: any; -const mjAPI = require("mathjax-node-svg2png"); +const mjAPI = require("mathjax-node"); mjAPI.config({ MathJax: { // traditional MathJax configuration diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index bd964cc681ed881316af8ac0dd07c65ea21a8ba6..bed59f224e9a6025cb22171efab70999695dc863 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -1518,106 +1518,6 @@ export interface IWebviewPanelOptions { readonly retainContextWhenHidden?: boolean; } -/** - * @internal - */ - -export interface INotebookSelectors { - readonly filenamePattern?: string; -} - -/** - * @internal - */ -export interface IStreamOutput { - output_type: 'stream'; - text: string; -} - -/** - * @internal - */ -export interface IErrorOutput { - output_type: 'error'; - /** - * Exception Name - */ - ename?: string; - /** - * Exception Value - */ - evalue?: string; - /** - * Exception call stacks - */ - traceback?: string[]; -} - -/** - * @internal - */ -export interface IDisplayOutput { - output_type: 'display_data'; - /** - * { mime_type: value } - */ - data: { string: string }; -} - -/** - * @internal - */ -export interface IGenericOutput { - output_type: string; -} - -/** - * @internal - */ -export type IOutput = IStreamOutput | any; - -/** - * @internal - */ -export interface ICell { - handle: number; - source: string[]; - language: string; - cell_type: 'markdown' | 'code'; - outputs: IOutput[]; - onDidChangeOutputs?: Event; - isDirty: boolean; -} - -/** - * @internal - */ -export interface LanguageInfo { - file_extension: string; -} - -/** - * @internal - */ -export interface IMetadata { - language_info: LanguageInfo; -} - -/** - * @internal - */ -export interface INotebook { - handle: number; - // metadata: IMetadata; - readonly uri: URI; - languages: string[]; - cells: ICell[]; - onDidChangeCells?: Event; - onDidChangeDirtyState: Event; - onWillDispose(listener: () => void): IDisposable; - save(): Promise; -} - export interface CodeLens { range: IRange; id?: string; diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 19b04ba13abe663ebd2200f2818f196bd0435700..1ac80c09fb93ca369d5f14faea45dab3e552e112 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1431,7 +1431,7 @@ declare module 'vscode' { * @returns HTML fragment. We can probably return `CellOutput` instead of string ? */ render(document: NotebookDocument, cell: NotebookCell, output: CellOutput): string; - dependencies?: Uri[]; + preloads?: Uri[]; } namespace window { diff --git a/src/vs/workbench/api/browser/mainThreadNotebook.ts b/src/vs/workbench/api/browser/mainThreadNotebook.ts index ab92e0723ca4db800c84d27587d3c7cc82f30900..76156846a1a315580ed0730fc6d3472300da3217 100644 --- a/src/vs/workbench/api/browser/mainThreadNotebook.ts +++ b/src/vs/workbench/api/browser/mainThreadNotebook.ts @@ -8,9 +8,9 @@ import { MainContext, MainThreadNotebookShape, NotebookExtensionDescription, IEx import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { URI, UriComponents } from 'vs/base/common/uri'; import { INotebookService, IMainNotebookController } from 'vs/workbench/contrib/notebook/browser/notebookService'; -import { INotebook, ICell, IOutput } from 'vs/editor/common/modes'; import { Emitter, Event } from 'vs/base/common/event'; import { IMarkdownString } from 'vs/base/common/htmlContent'; +import { ICell, IOutput, INotebook, INotebookMimeTypeSelector } from 'vs/workbench/contrib/notebook/common/notebook'; export class MainThreadCell implements ICell { private _onDidChangeOutputs = new Emitter(); @@ -183,6 +183,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook @extHostNamedCustomer(MainContext.MainThreadNotebook) export class MainThreadNotebooks extends Disposable implements MainThreadNotebookShape { private readonly _notebookProviders = new Map(); + private readonly _renderers = new Map(); private readonly _proxy: ExtHostNotebookShape; constructor( @@ -196,6 +197,14 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo })); } + $registerNotebookRenderer(extension: NotebookExtensionDescription, selectors: INotebookMimeTypeSelector, handle: number): Promise { + throw new Error('Method not implemented.'); + } + + $unregisterNotebookRenderer(handle: number): Promise { + throw new Error('Method not implemented.'); + } + async $registerNotebookProvider(extension: NotebookExtensionDescription, viewType: string): Promise { let controller = new MainThreadNotebookController(this._proxy, this, viewType); this._notebookProviders.set(viewType, controller); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index ec08e2d518dc413ef7a33a1d895442f4e205292c..292cdab32961c7af78bdffdb21a7841674082d63 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -50,6 +50,7 @@ import { ExtensionActivationReason } from 'vs/workbench/api/common/extHostExtens import { TunnelDto } from 'vs/workbench/api/common/extHostTunnelService'; import { TunnelOptions } from 'vs/platform/remote/common/tunnel'; import { TimelineItem, TimelineProviderDescriptor, TimelineChangeEvent, TimelineItemWithSource } from 'vs/workbench/contrib/timeline/common/timeline'; +import { INotebook, ICell, INotebookMimeTypeSelector } from 'vs/workbench/contrib/notebook/common/notebook'; export interface IEnvironment { isExtensionDevelopmentDebug: boolean; @@ -627,10 +628,12 @@ export interface ExtHostWebviewsShape { export interface MainThreadNotebookShape extends IDisposable { $registerNotebookProvider(extension: NotebookExtensionDescription, viewType: string): Promise; $unregisterNotebookProvider(viewType: string): Promise; + $registerNotebookRenderer(extension: NotebookExtensionDescription, selectors: INotebookMimeTypeSelector, handle: number): Promise; + $unregisterNotebookRenderer(handle: number): Promise; $createNotebookDocument(handle: number, viewType: string, resource: UriComponents): Promise; - $updateNotebook(viewType: string, resource: UriComponents, notebook: modes.INotebook): Promise; - $updateNotebookCells(viewType: string, resource: UriComponents, cells: modes.ICell[]): Promise; - $updateNotebookCell(viewType: string, resource: UriComponents, cell: modes.ICell): Promise; + $updateNotebook(viewType: string, resource: UriComponents, notebook: INotebook): Promise; + $updateNotebookCells(viewType: string, resource: UriComponents, cells: ICell[]): Promise; + $updateNotebookCell(viewType: string, resource: UriComponents, cell: ICell): Promise; $updateNotebookLanguages(viewType: string, resource: UriComponents, languages: string[]): Promise; } @@ -1457,7 +1460,7 @@ export interface ExtHostNotebookShape { $executeNotebook(viewType: string, uri: URI): Promise; $executeNotebookCell(viewType: string, uri: URI, cellHandle: number): Promise; $latexRenderer(viewType: string, value: string): Promise; - $createRawCell(viewType: string, uri: URI, index: number, language: string, type: 'markdown' | 'code'): Promise; + $createRawCell(viewType: string, uri: URI, index: number, language: string, type: 'markdown' | 'code'): Promise; $deleteCell(viewType: string, uri: URI, index: number): Promise; $saveNotebook(viewType: string, uri: URI): Promise; $updateActiveEditor(viewType: string, uri: URI): Promise; diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index 6f0f56c45f7a1554a434d4668d4bf541b43f6c19..bc7e59402f22d17b073b6b42428fda36d19ab0e7 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -12,10 +12,9 @@ import { DisposableStore } from 'vs/base/common/lifecycle'; import { readonly } from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors'; -import { ICell } from 'vs/editor/common/modes'; -// import { ExtHostDocumentData } from 'vs/workbench/api/common/extHostDocumentData'; import * as extHostTypeConverter from 'vs/workbench/api/common/extHostTypeConverters'; import { IMarkdownString } from 'vs/base/common/htmlContent'; +import { ICell } from 'vs/workbench/contrib/notebook/common/notebook'; export class ExtHostCell implements vscode.NotebookCell { @@ -101,7 +100,7 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument { } else { return output; } - }) + }); } this._proxy.$updateNotebookCell(this.viewType, this.uri, { @@ -152,7 +151,7 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument { } else { return output; } - }) + }); } return { @@ -162,9 +161,9 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument { cell_type: cell.cell_type, outputs: outputs, isDirty: false - } + }; } - )); + )); } insertRawCell(index: number, cell: ExtHostCell) { @@ -187,7 +186,7 @@ export class ExtHostNotebookDocument implements vscode.NotebookDocument { } else { return output; } - }) + }); } this._proxy.$updateNotebookCell(this.viewType, this.uri, { @@ -302,6 +301,9 @@ export class ExtHostNotebookEditor implements vscode.NotebookEditor { } export class ExtHostNotebookOutputRenderer { + private static _handlePool: number = 0; + readonly handle = ExtHostNotebookOutputRenderer._handlePool++; + constructor( private filter: vscode.NotebookOutputSelector, private renderer: vscode.NotebookOutputRenderer @@ -332,7 +334,7 @@ export class ExtHostNotebookOutputRenderer { } render(document: ExtHostNotebookDocument, cell: ExtHostCell, output: vscode.CellOutput): vscode.CellDisplayOutput { - let html = this.renderer.render(document ,cell, output); + let html = this.renderer.render(document, cell, output); return { output_type: 'display_data', @@ -357,7 +359,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN private readonly _notebookProviders = new Map(); private readonly _documents = new Map(); private readonly _editors = new Map(); - private readonly _notebookOutputRenderers: ExtHostNotebookOutputRenderer[] = []; + private readonly _notebookOutputRenderers = new Map(); constructor(mainContext: IMainContext, private _documentsAndEditors: ExtHostDocumentsAndEditors) { @@ -377,16 +379,19 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN filter: vscode.NotebookOutputSelector, renderer: vscode.NotebookOutputRenderer ): vscode.Disposable { - this._notebookOutputRenderers.push(new ExtHostNotebookOutputRenderer(filter, renderer)); + let extHostRenderer = new ExtHostNotebookOutputRenderer(filter, renderer); + this._notebookOutputRenderers.set(extHostRenderer.handle, extHostRenderer); + this._proxy.$registerNotebookRenderer({ id: extension.identifier, location: extension.extensionLocation }, filter, extHostRenderer.handle); return new VSCodeDisposable(() => { - - }) + this._notebookOutputRenderers.delete(extHostRenderer.handle); + this._proxy.$unregisterNotebookRenderer(extHostRenderer.handle); + }); } findBestMatchedRenderer(output: vscode.CellOutput): ExtHostNotebookOutputRenderer | undefined { - for (let i = 0; i < this._notebookOutputRenderers.length; i++) { - if (this._notebookOutputRenderers[i].matches(output)) { - return this._notebookOutputRenderers[i]; + for (let renderer of this._notebookOutputRenderers) { + if (renderer[1].matches(output)) { + return renderer[1]; } } diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 0b4c5aa4acb1170c910171317cae8858ea906f35..e667272690a5df4c5b89fd22a7fc4441fd60f5dd 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -25,7 +25,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { InputFocusedContextKey, InputFocusedContext } from 'vs/platform/contextkey/common/contextkeys'; import { KeyCode } from 'vs/base/common/keyCodes'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; -import { NotebookHandler } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; +import { NotebookHandler } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; Registry.as(EditorExtensions.Editors).registerEditor( EditorDescriptor.create( diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts index 5bf3f33ff7a2b11b77dc3f042613b25199d657cf..ed441cf594f923e6799c6df07ed2e6bb200ebb3c 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts @@ -31,10 +31,10 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { getZoomLevel } from 'vs/base/browser/browser'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INotebook } from 'vs/editor/common/modes'; import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { NotebookHandler, CELL_MARGIN } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; import { IOpenerService } from 'vs/platform/opener/common/opener'; +import { INotebook, CELL_MARGIN } from 'vs/workbench/contrib/notebook/common/notebook'; +import { NotebookHandler } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; const $ = DOM.$; const NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'NotebookEditorViewState'; @@ -280,7 +280,7 @@ export class NotebookEditor extends BaseEditor implements NotebookHandler { let viewState = this.loadTextEditorViewState(input); this.notebook = model.getNotebook(); this.viewType = input.viewType; - this.viewCells = this.notebook.cells.map(cell => { + this.viewCells = this.notebook!.cells.map(cell => { const isEditing = viewState && viewState.editingCells[cell.handle]; return new CellViewModel(input.viewType!, this.notebook!.handle, cell, !!isEditing, this.modelService, this.modeService, this.openerService, this.notebookService, this.themeService); }); diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorInput.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorInput.ts index 9948d06a6ab216f53e2a5aa860f79cc08dc2df2e..61a43a36a76632d14ba86ae21bb97f7120f05d94 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorInput.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorInput.ts @@ -7,8 +7,8 @@ import { EditorInput, EditorModel, IEditorInput, GroupIdentifier, ISaveOptions } import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ITextModel } from 'vs/editor/common/model'; import { Emitter, Event } from 'vs/base/common/event'; -import { INotebook, ICell } from 'vs/editor/common/modes'; import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebookService'; +import { INotebook, ICell } from 'vs/workbench/contrib/notebook/common/notebook'; export class NotebookEditorModel extends EditorModel { private _dirty = false; diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/interfaces.ts b/src/vs/workbench/contrib/notebook/browser/notebookHandler.ts similarity index 98% rename from src/vs/workbench/contrib/notebook/browser/renderers/interfaces.ts rename to src/vs/workbench/contrib/notebook/browser/notebookHandler.ts index ba624d575a74c17a0f1b30ca9f6b14ecd9344614..fbebd398d67425c3ab8f1bb73568f8a9b1c68e47 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/interfaces.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookHandler.ts @@ -3,14 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + import * as DOM from 'vs/base/browser/dom'; import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent'; import { BareFontInfo } from 'vs/editor/common/config/fontInfo'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/renderers/cellViewModel'; -export const CELL_MARGIN = 24; - export interface NotebookHandler { viewType: string | undefined; insertEmptyNotebookCell(listIndex: number | undefined, cell: CellViewModel, type: 'markdown' | 'code', direction: 'above' | 'below'): Promise; diff --git a/src/vs/workbench/contrib/notebook/browser/notebookService.ts b/src/vs/workbench/contrib/notebook/browser/notebookService.ts index 8d0c36572d41e5e439f361dfb3f82d5072e499de..1f72e986d34905365081ba882759e0c43cf049fd 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookService.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookService.ts @@ -5,13 +5,13 @@ import { Disposable, IDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { INotebook, ICell } from 'vs/editor/common/modes'; import { URI } from 'vs/base/common/uri'; import { notebookExtensionPoint } from 'vs/workbench/contrib/notebook/browser/extensionPoint'; import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider'; import { NotebookExtensionDescription } from 'vs/workbench/api/common/extHost.protocol'; import { Emitter, Event } from 'vs/base/common/event'; import { IMarkdownString } from 'vs/base/common/htmlContent'; +import { INotebook, ICell } from 'vs/workbench/contrib/notebook/common/notebook'; function MODEL_ID(resource: URI): string { return resource.toString(); diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/cellRenderer.ts b/src/vs/workbench/contrib/notebook/browser/renderers/cellRenderer.ts index 5d0d5c00ba640c316cf22d4167326f94f32be534..15b1abb547a15e552007afbfad6c06eccb0d8644 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/cellRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/renderers/cellRenderer.ts @@ -17,12 +17,12 @@ import { getZoomLevel } from 'vs/base/browser/browser'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { Action } from 'vs/base/common/actions'; import { DisposableStore } from 'vs/base/common/lifecycle'; -import { NotebookHandler, CellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; import { StatefullMarkdownCell } from 'vs/workbench/contrib/notebook/browser/renderers/markdownCell'; import { CellViewModel } from './cellViewModel'; import { CodeCell } from 'vs/workbench/contrib/notebook/browser/renderers/codeCell'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; +import { CellRenderTemplate, NotebookHandler } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; export class NotebookCellListDelegate implements IListVirtualDelegate { private _lineHeight: number; diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/cellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/renderers/cellViewModel.ts index cdbe1e6c46e0649c3c70939945a21a0d6cd427ec..bc50991eb6efa260acd87e014268105014acb98d 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/cellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/renderers/cellViewModel.ts @@ -9,12 +9,12 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { ITextModel } from 'vs/editor/common/model'; import { IModeService } from 'vs/editor/common/services/modeService'; import { Emitter } from 'vs/base/common/event'; -import { ICell } from 'vs/editor/common/modes'; import * as UUID from 'vs/base/common/uuid'; import { MarkdownRenderer } from 'vs/workbench/contrib/notebook/browser/renderers/mdRenderer'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebookService'; import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ICell } from 'vs/workbench/contrib/notebook/common/notebook'; export class CellViewModel extends Disposable { private _textModel: ITextModel | null = null; diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/codeCell.ts b/src/vs/workbench/contrib/notebook/browser/renderers/codeCell.ts index ad7d61e003814979182d1a5904b55183e132d371..12836efbf408bf6473f4fb6ee2e0ec5b74764783 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/codeCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/renderers/codeCell.ts @@ -5,13 +5,14 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/renderers/cellViewModel'; -import { CellRenderTemplate, NotebookHandler, CELL_MARGIN } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/renderers/sizeObserver'; import { MimeTypeRenderer } from 'vs/workbench/contrib/notebook/browser/renderers/outputRenderer'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; +import { CELL_MARGIN } from 'vs/workbench/contrib/notebook/common/notebook'; +import { CellRenderTemplate, NotebookHandler } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; export class CodeCell extends Disposable { constructor( diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/contentWidget.ts b/src/vs/workbench/contrib/notebook/browser/renderers/contentWidget.ts index 1dd5607830ea3d5a58ff57499beace0f263d31a0..056f615233f1e98235f746dd566670f86fa8616f 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/contentWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/renderers/contentWidget.ts @@ -13,7 +13,8 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { URI } from 'vs/base/common/uri'; import { WebviewResourceScheme } from 'vs/workbench/contrib/webview/common/resourceLoader'; import * as path from 'vs/base/common/path'; -import { NotebookHandler, CELL_MARGIN } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; +import { CELL_MARGIN } from 'vs/workbench/contrib/notebook/common/notebook'; +import { NotebookHandler } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; export interface IDimentionMessage { type: 'dimension'; diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/markdownCell.ts b/src/vs/workbench/contrib/notebook/browser/renderers/markdownCell.ts index d09834a0ffa63620db6168a65905f182f90858b1..ff400cc64d850c09dbafc88f3a9a18a5a0c035d7 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/markdownCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/renderers/markdownCell.ts @@ -6,10 +6,11 @@ import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/renderers/cellViewModel'; -import { CellRenderTemplate, NotebookHandler, CELL_MARGIN } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/renderers/sizeObserver'; +import { CELL_MARGIN } from 'vs/workbench/contrib/notebook/common/notebook'; +import { NotebookHandler, CellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; export class StatefullMarkdownCell extends Disposable { private editor: CodeEditorWidget | null = null; diff --git a/src/vs/workbench/contrib/notebook/browser/renderers/outputRenderer.ts b/src/vs/workbench/contrib/notebook/browser/renderers/outputRenderer.ts index 914c7e44fb97a1ac8efaf5cf2672a9d46704ac76..7676eaa10b18f1db05df46293401722f84fe4783 100644 --- a/src/vs/workbench/contrib/notebook/browser/renderers/outputRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/renderers/outputRenderer.ts @@ -8,15 +8,15 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { RGBA, Color } from 'vs/base/common/color'; import { ansiColorIdentifiers } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; import { isArray } from 'vs/base/common/types'; -import { IOutput } from 'vs/editor/common/modes'; import * as marked from 'vs/base/common/marked/marked'; -import { NotebookHandler } from 'vs/workbench/contrib/notebook/browser/renderers/interfaces'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { IModelService } from 'vs/editor/common/services/modelService'; import { URI } from 'vs/base/common/uri'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IModeService } from 'vs/editor/common/services/modeService'; +import { IOutput } from 'vs/workbench/contrib/notebook/common/notebook'; +import { NotebookHandler } from 'vs/workbench/contrib/notebook/browser/notebookHandler'; export function registerMineTypeRenderer(types: string[], renderer: IMimeRenderer) { types.forEach(type => { diff --git a/src/vs/workbench/contrib/notebook/common/notebook.ts b/src/vs/workbench/contrib/notebook/common/notebook.ts new file mode 100644 index 0000000000000000000000000000000000000000..a015297fc423e68ff2e6dac12ecd5b1502819c42 --- /dev/null +++ b/src/vs/workbench/contrib/notebook/common/notebook.ts @@ -0,0 +1,117 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Event } from 'vs/base/common/event'; +import { IDisposable } from 'vs/base/common/lifecycle'; +import { URI } from 'vs/base/common/uri'; + +export interface INotebookMimeTypeSelector { + type: string; + subTypes?: string[]; +} + +/** + * @internal + */ + +export interface INotebookSelectors { + readonly filenamePattern?: string; +} + +/** + * @internal + */ +export interface IStreamOutput { + output_type: 'stream'; + text: string; +} + +/** + * @internal + */ +export interface IErrorOutput { + output_type: 'error'; + /** + * Exception Name + */ + ename?: string; + /** + * Exception Value + */ + evalue?: string; + /** + * Exception call stacks + */ + traceback?: string[]; +} + +/** + * @internal + */ +export interface IDisplayOutput { + output_type: 'display_data'; + /** + * { mime_type: value } + */ + data: { string: string }; +} + +/** + * @internal + */ +export interface IGenericOutput { + output_type: string; +} + +/** + * @internal + */ +export type IOutput = IStreamOutput | any; + +/** + * @internal + */ +export interface ICell { + handle: number; + source: string[]; + language: string; + cell_type: 'markdown' | 'code'; + outputs: IOutput[]; + onDidChangeOutputs?: Event; + isDirty: boolean; +} + +/** + * @internal + */ +export interface LanguageInfo { + file_extension: string; +} + +/** + * @internal + */ +export interface IMetadata { + language_info: LanguageInfo; +} + +/** + * @internal + */ +export interface INotebook { + handle: number; + // metadata: IMetadata; + readonly uri: URI; + languages: string[]; + cells: ICell[]; + onDidChangeCells?: Event; + onDidChangeDirtyState: Event; + onWillDispose(listener: () => void): IDisposable; + save(): Promise; +} + + +export const CELL_MARGIN = 24; +