separate internal notebook editor api
This commit is contained in:
parent
96be44fe33
commit
94f8309414
|
@ -22,7 +22,7 @@ import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
|||
import { IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { getSimpleCodeEditorWidgetOptions, getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
|
||||
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput';
|
||||
import { IActiveNotebookEditor, ICellViewModel, INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { IActiveNotebookEditorDelegate, ICellViewModel, INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
||||
import { IBorrowValue, INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
|
||||
import { cellEditorBackground, NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
|
||||
|
@ -383,7 +383,7 @@ export class InteractiveEditor extends EditorPane {
|
|||
#lastCellDisposable = new DisposableStore();
|
||||
#state: ScrollingState = ScrollingState.Initial;
|
||||
|
||||
#cellAtBottom(widget: NotebookEditorWidget & IActiveNotebookEditor, cell: ICellViewModel): boolean {
|
||||
#cellAtBottom(widget: IActiveNotebookEditorDelegate, cell: ICellViewModel): boolean {
|
||||
const visibleRanges = widget.visibleRanges;
|
||||
const cellIndex = widget.getCellIndex(cell);
|
||||
if (cellIndex === Math.max(...visibleRanges.map(range => range.end))) {
|
||||
|
@ -399,7 +399,7 @@ export class InteractiveEditor extends EditorPane {
|
|||
* - receive a scroll event (scroll even already happened). If the last cell is at bottom, false, 0, true, state 1
|
||||
* - height change of the last cell, if state 0, do nothing, if state 1, scroll the last cell fully into view
|
||||
*/
|
||||
#registerExecutionScrollListener(widget: NotebookEditorWidget & IActiveNotebookEditor) {
|
||||
#registerExecutionScrollListener(widget: IActiveNotebookEditorDelegate) {
|
||||
this.#widgetDisposableStore.add(widget.textModel.onWillAddRemoveCells(e => {
|
||||
const lastViewCell = widget.cellAt(widget.getLength() - 1);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as DOM from 'vs/base/browser/dom';
|
|||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { CellEditState, IInsetRenderOutput, INotebookEditor, INotebookEditorContribution, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellEditState, IInsetRenderOutput, INotebookEditor, INotebookEditorContribution, INotebookEditorDelegate, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
||||
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
||||
import { BUILTIN_RENDERER_ID, CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
@ -76,7 +76,7 @@ class NotebookViewportContribution extends Disposable implements INotebookEditor
|
|||
const cell = this._notebookEditor.cellAt(index);
|
||||
|
||||
if (cell?.cellKind === CellKind.Markup && cell?.getEditState() === CellEditState.Preview && !cell.metadata.inputCollapsed) {
|
||||
this._notebookEditor.createMarkupPreview(cell);
|
||||
(this._notebookEditor as INotebookEditorDelegate).createMarkupPreview(cell);
|
||||
} else if (cell?.cellKind === CellKind.Code) {
|
||||
this._renderCell((cell as CodeCellViewModel));
|
||||
}
|
||||
|
|
|
@ -355,16 +355,6 @@ export interface INotebookEditorCreationOptions {
|
|||
readonly options?: NotebookOptions;
|
||||
}
|
||||
|
||||
export interface IActiveNotebookEditor extends INotebookEditor {
|
||||
_getViewModel(): NotebookViewModel;
|
||||
textModel: NotebookTextModel;
|
||||
getFocus(): ICellRange;
|
||||
cellAt(index: number): ICellViewModel;
|
||||
getCellIndex(cell: ICellViewModel): number;
|
||||
getCellIndexByHandle(handle: number): number;
|
||||
getNextVisibleCellIndex(index: number): number;
|
||||
}
|
||||
|
||||
export enum NotebookViewEventType {
|
||||
LayoutChanged = 1,
|
||||
MetadataChanged = 2,
|
||||
|
@ -400,16 +390,14 @@ export class NotebookCellStateChangedEvent {
|
|||
export type NotebookViewEvent = NotebookLayoutChangedEvent | NotebookMetadataChangedEvent | NotebookCellStateChangedEvent;
|
||||
|
||||
|
||||
export interface INotebookEditor extends ICommonNotebookEditorDelegate {
|
||||
export interface INotebookEditor {
|
||||
//#region Eventing
|
||||
readonly onDidChangeCellState: Event<NotebookCellStateChangedEvent>;
|
||||
readonly onDidChangeOptions: Event<void>;
|
||||
readonly onDidChangeViewCells: Event<INotebookViewCellsUpdateEvent>;
|
||||
readonly onDidChangeVisibleRanges: Event<void>;
|
||||
readonly onDidChangeSelection: Event<void>;
|
||||
/**
|
||||
* An event emitted when the model of this editor has changed.
|
||||
* @event
|
||||
*/
|
||||
readonly onDidChangeModel: Event<NotebookTextModel | undefined>;
|
||||
readonly onDidFocusEditorWidget: Event<void>;
|
||||
|
@ -423,8 +411,6 @@ export interface INotebookEditor extends ICommonNotebookEditorDelegate {
|
|||
//#region readonly properties
|
||||
readonly visibleRanges: ICellRange[];
|
||||
readonly textModel?: NotebookTextModel;
|
||||
readonly creationOptions: INotebookEditorCreationOptions;
|
||||
readonly isEmbedded: boolean;
|
||||
readonly isReadOnly: boolean;
|
||||
readonly notebookOptions: NotebookOptions;
|
||||
readonly isDisposed: boolean;
|
||||
|
@ -514,25 +500,11 @@ export interface INotebookEditor extends ICommonNotebookEditorDelegate {
|
|||
*/
|
||||
layoutNotebookCell(cell: ICellViewModel, height: number): Promise<void>;
|
||||
|
||||
createMarkupPreview(cell: ICellViewModel): Promise<void>;
|
||||
unhideMarkupPreviews(cells: readonly ICellViewModel[]): Promise<void>;
|
||||
hideMarkupPreviews(cells: readonly ICellViewModel[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Render the output in webview layer
|
||||
*/
|
||||
createOutput(cell: ICellViewModel, output: IInsetRenderOutput, offset: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Remove the output from the webview layer
|
||||
*/
|
||||
removeInset(output: IDisplayOutputViewModel): void;
|
||||
|
||||
/**
|
||||
* Hide the inset in the webview layer without removing it
|
||||
*/
|
||||
hideInset(output: IDisplayOutputViewModel): void;
|
||||
|
||||
readonly onDidReceiveMessage: Event<INotebookWebviewMessage>;
|
||||
|
||||
/**
|
||||
|
@ -550,13 +522,6 @@ export interface INotebookEditor extends ICommonNotebookEditorDelegate {
|
|||
*/
|
||||
removeClassName(className: string): void;
|
||||
|
||||
deltaCellOutputContainerClassNames(cellId: string, added: string[], removed: string[]): void;
|
||||
|
||||
/**
|
||||
* Trigger the editor to scroll from scroll event programmatically
|
||||
*/
|
||||
triggerScroll(event: IMouseWheelEvent): void;
|
||||
|
||||
/**
|
||||
* The range will be revealed with as little scrolling as possible.
|
||||
*/
|
||||
|
@ -660,8 +625,6 @@ export interface INotebookEditor extends ICommonNotebookEditorDelegate {
|
|||
getContribution<T extends INotebookEditorContribution>(id: string): T;
|
||||
getCellsInRange(range?: ICellRange): ReadonlyArray<ICellViewModel>;
|
||||
cellAt(index: number): ICellViewModel | undefined;
|
||||
getCellByInfo(cellInfo: ICommonCellInfo): ICellViewModel;
|
||||
getCellById(cellId: string): ICellViewModel | undefined;
|
||||
getCellByHandle(handle: number): ICellViewModel | undefined;
|
||||
getCellIndex(cell: ICellViewModel): number | undefined;
|
||||
getCellIndexByHandle(handle: number): number | undefined;
|
||||
|
@ -669,10 +632,16 @@ export interface INotebookEditor extends ICommonNotebookEditorDelegate {
|
|||
updateOutputHeight(cellInfo: ICommonCellInfo, output: IDisplayOutputViewModel, height: number, isInit: boolean, source?: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor delegate shared by the notebook editor and diff editor
|
||||
*/
|
||||
export interface ICommonNotebookEditorDelegate {
|
||||
readonly creationOptions: INotebookEditorCreationOptions;
|
||||
getCellOutputLayoutInfo(cell: IGenericCellViewModel): INotebookCellOutputLayoutInfo;
|
||||
setScrollTop(scrollTop: number): void;
|
||||
/**
|
||||
* Trigger the editor to scroll from scroll event programmatically
|
||||
*/
|
||||
triggerScroll(event: IMouseWheelEvent): void;
|
||||
getCellByInfo(cellInfo: ICommonCellInfo): IGenericCellViewModel;
|
||||
getCellById(cellId: string): IGenericCellViewModel | undefined;
|
||||
|
@ -689,6 +658,50 @@ export interface ICommonNotebookEditorDelegate {
|
|||
didEndDragMarkupCell(cellId: string): void;
|
||||
}
|
||||
|
||||
export interface IActiveNotebookEditor extends INotebookEditor {
|
||||
_getViewModel(): NotebookViewModel;
|
||||
textModel: NotebookTextModel;
|
||||
getFocus(): ICellRange;
|
||||
cellAt(index: number): ICellViewModel;
|
||||
getCellIndex(cell: ICellViewModel): number;
|
||||
getCellIndexByHandle(handle: number): number;
|
||||
getNextVisibleCellIndex(index: number): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A mix of public interface and internal one (used by internal rendering code, e.g., cellRenderer)
|
||||
*/
|
||||
export interface INotebookEditorDelegate extends INotebookEditor, Omit<ICommonNotebookEditorDelegate, 'focusNotebookCell' | 'focusNextNotebookCell'> {
|
||||
hasModel(): this is IActiveNotebookEditorDelegate;
|
||||
|
||||
readonly creationOptions: INotebookEditorCreationOptions;
|
||||
readonly onDidChangeOptions: Event<void>;
|
||||
createMarkupPreview(cell: ICellViewModel): Promise<void>;
|
||||
unhideMarkupPreviews(cells: readonly ICellViewModel[]): Promise<void>;
|
||||
hideMarkupPreviews(cells: readonly ICellViewModel[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Remove the output from the webview layer
|
||||
*/
|
||||
removeInset(output: IDisplayOutputViewModel): void;
|
||||
|
||||
/**
|
||||
* Hide the inset in the webview layer without removing it
|
||||
*/
|
||||
hideInset(output: IDisplayOutputViewModel): void;
|
||||
deltaCellOutputContainerClassNames(cellId: string, added: string[], removed: string[]): void;
|
||||
}
|
||||
|
||||
export interface IActiveNotebookEditorDelegate extends INotebookEditorDelegate, Omit<ICommonNotebookEditorDelegate, 'focusNotebookCell' | 'focusNextNotebookCell'> {
|
||||
_getViewModel(): NotebookViewModel;
|
||||
textModel: NotebookTextModel;
|
||||
getFocus(): ICellRange;
|
||||
cellAt(index: number): ICellViewModel;
|
||||
getCellIndex(cell: ICellViewModel): number;
|
||||
getCellIndexByHandle(handle: number): number;
|
||||
getNextVisibleCellIndex(index: number): number;
|
||||
}
|
||||
|
||||
export interface INotebookCellList {
|
||||
isDisposed: boolean;
|
||||
viewModel: NotebookViewModel | null;
|
||||
|
|
|
@ -20,7 +20,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
|||
import { toolbarActiveBackground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { SELECT_KERNEL_ID } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
||||
import { INotebookEditor, NOTEBOOK_EDITOR_ID } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { INotebookEditorDelegate, NOTEBOOK_EDITOR_ID } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { NotebooKernelActionViewItem } from 'vs/workbench/contrib/notebook/browser/notebookKernelActionViewItem';
|
||||
import { ActionViewWithLabel } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellActionView';
|
||||
import { GlobalToolbar, GlobalToolbarShowLabel } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
@ -58,7 +58,7 @@ export class NotebookEditorToolbar extends Disposable {
|
|||
private _pendingLayout: IDisposable | undefined;
|
||||
|
||||
constructor(
|
||||
readonly notebookEditor: INotebookEditor,
|
||||
readonly notebookEditor: INotebookEditorDelegate,
|
||||
readonly contextKeyService: IContextKeyService,
|
||||
readonly domNode: HTMLElement,
|
||||
@IInstantiationService readonly instantiationService: IInstantiationService,
|
||||
|
@ -77,7 +77,7 @@ export class NotebookEditorToolbar extends Disposable {
|
|||
|
||||
this._register(this.editorService.onDidActiveEditorChange(() => {
|
||||
if (this.editorService.activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
|
||||
const notebookEditor = this.editorService.activeEditorPane.getControl() as INotebookEditor;
|
||||
const notebookEditor = this.editorService.activeEditorPane.getControl() as INotebookEditorDelegate;
|
||||
if (notebookEditor === this.notebookEditor) {
|
||||
// this is the active editor
|
||||
this._showNotebookActionsinEditorToolbar();
|
||||
|
|
|
@ -38,7 +38,7 @@ import { contrastBorder, diffInserted, diffRemoved, editorBackground, errorForeg
|
|||
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { PANEL_BORDER } from 'vs/workbench/common/theme';
|
||||
import { debugIconStartForeground } from 'vs/workbench/contrib/debug/browser/debugColors';
|
||||
import { CellEditState, CellFocusMode, IActiveNotebookEditor, ICellOutputViewModel, ICellViewModel, ICommonCellInfo, IDisplayOutputLayoutUpdateRequest, IFocusNotebookCellOptions, IGenericCellViewModel, IInsetRenderOutput, INotebookCellList, INotebookCellOutputLayoutInfo, INotebookDeltaDecoration, INotebookEditor, INotebookEditorContribution, INotebookEditorContributionDescription, INotebookEditorCreationOptions, INotebookEditorMouseEvent, INotebookEditorOptions, NotebookCellStateChangedEvent, NotebookLayoutChangedEvent, NotebookLayoutInfo, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellEditState, CellFocusMode, IActiveNotebookEditorDelegate, ICellOutputViewModel, ICellViewModel, ICommonCellInfo, IDisplayOutputLayoutUpdateRequest, IFocusNotebookCellOptions, IGenericCellViewModel, IInsetRenderOutput, INotebookCellList, INotebookCellOutputLayoutInfo, INotebookDeltaDecoration, INotebookEditorContribution, INotebookEditorContributionDescription, INotebookEditorCreationOptions, INotebookEditorDelegate, INotebookEditorMouseEvent, INotebookEditorOptions, NotebookCellStateChangedEvent, NotebookLayoutChangedEvent, NotebookLayoutInfo, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { NotebookDecorationCSSRules, NotebookRefCountedStyleSheet } from 'vs/workbench/contrib/notebook/browser/notebookEditorDecorations';
|
||||
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
||||
import { NotebookEditorKernelManager } from 'vs/workbench/contrib/notebook/browser/notebookEditorKernelManager';
|
||||
|
@ -215,7 +215,7 @@ export function getDefaultNotebookCreationOptions() {
|
|||
};
|
||||
}
|
||||
|
||||
export class NotebookEditorWidget extends Disposable implements INotebookEditor {
|
||||
export class NotebookEditorWidget extends Disposable implements INotebookEditorDelegate {
|
||||
//#region Eventing
|
||||
private readonly _onDidChangeCellState = this._register(new Emitter<NotebookCellStateChangedEvent>());
|
||||
readonly onDidChangeCellState = this._onDidChangeCellState.event;
|
||||
|
@ -545,7 +545,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
|
|||
}, [] as ICellViewModel[]);
|
||||
}
|
||||
|
||||
hasModel(): this is IActiveNotebookEditor {
|
||||
hasModel(): this is IActiveNotebookEditorDelegate {
|
||||
return !!this._notebookViewModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { DisposableStore, dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICellViewModel, INotebookEditor, KERNEL_EXTENSIONS, NOTEBOOK_MISSING_KERNEL_EXTENSION, NOTEBOOK_HAS_OUTPUTS, NOTEBOOK_HAS_RUNNING_CELL, NOTEBOOK_INTERRUPTIBLE_KERNEL, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SELECTED, NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON, NOTEBOOK_VIEW_TYPE } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { ICellViewModel, KERNEL_EXTENSIONS, NOTEBOOK_MISSING_KERNEL_EXTENSION, NOTEBOOK_HAS_OUTPUTS, NOTEBOOK_HAS_RUNNING_CELL, NOTEBOOK_INTERRUPTIBLE_KERNEL, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SELECTED, NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON, NOTEBOOK_VIEW_TYPE, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
|
||||
import { NotebookCellExecutionState } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
|
||||
|
@ -28,7 +28,7 @@ export class NotebookEditorContextKeys {
|
|||
private readonly _cellOutputsListeners: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
private readonly _editor: INotebookEditor,
|
||||
private readonly _editor: INotebookEditorDelegate,
|
||||
@INotebookKernelService private readonly _notebookKernelService: INotebookKernelService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IExtensionService private readonly _extensionService: IExtensionService
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { CellEditState, CellFocusMode, CellViewModelStateChangeEvent, INotebookEditor, NotebookCellExecutionStateContext, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_EDITOR_FOCUSED, NOTEBOOK_CELL_EXECUTING, NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_CELL_FOCUSED, NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_INPUT_COLLAPSED, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_OUTPUT_COLLAPSED, NOTEBOOK_CELL_TYPE } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellEditState, CellFocusMode, CellViewModelStateChangeEvent, INotebookEditorDelegate, NotebookCellExecutionStateContext, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_EDITOR_FOCUSED, NOTEBOOK_CELL_EXECUTING, NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_CELL_FOCUSED, NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_INPUT_COLLAPSED, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_OUTPUT_COLLAPSED, NOTEBOOK_CELL_TYPE } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
||||
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel';
|
||||
import { NotebookCellExecutionState } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
@ -29,7 +29,7 @@ export class CellContextKeyManager extends Disposable {
|
|||
|
||||
constructor(
|
||||
private readonly contextKeyService: IContextKeyService,
|
||||
private readonly notebookEditor: INotebookEditor,
|
||||
private readonly notebookEditor: INotebookEditorDelegate,
|
||||
private element: CodeCellViewModel | MarkupCellViewModel
|
||||
) {
|
||||
super();
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as DOM from 'vs/base/browser/dom';
|
|||
import { Delayer } from 'vs/base/common/async';
|
||||
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { BaseCellRenderTemplate, expandCellRangesWithHiddenCells, ICellViewModel, INotebookCellList, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { BaseCellRenderTemplate, expandCellRangesWithHiddenCells, ICellViewModel, INotebookCellList, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { cloneNotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
|
||||
import { CellEditType, SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { cellRangesToIndexes, ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
|
||||
|
@ -42,7 +42,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
private readonly listOnWillScrollListener = this._register(new MutableDisposable());
|
||||
|
||||
constructor(
|
||||
private readonly notebookEditor: INotebookEditor,
|
||||
private readonly notebookEditor: INotebookEditorDelegate,
|
||||
insertionIndicatorContainer: HTMLElement
|
||||
) {
|
||||
super();
|
||||
|
|
|
@ -16,7 +16,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
|
|||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ActiveEditorContext } from 'vs/workbench/common/editor';
|
||||
import { INotebookCellToolbarActionContext, INotebookCommandContext, NotebookMultiCellAction, NOTEBOOK_ACTIONS_CATEGORY } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
||||
import { ICellViewModel, INotebookEditor, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { ICellViewModel, INotebookEditorDelegate, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
|
||||
import { NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { NotebookOptions } from 'vs/workbench/contrib/notebook/common/notebookOptions';
|
||||
|
@ -51,7 +51,7 @@ export class CellEditorOptions extends Disposable {
|
|||
readonly onDidChange: Event<void> = this._onDidChange.event;
|
||||
private _localDisposableStore = this._register(new DisposableStore());
|
||||
|
||||
constructor(readonly notebookEditor: INotebookEditor, readonly notebookOptions: NotebookOptions, readonly configurationService: IConfigurationService, readonly language: string) {
|
||||
constructor(readonly notebookEditor: INotebookEditorDelegate, readonly notebookOptions: NotebookOptions, readonly configurationService: IConfigurationService, readonly language: string) {
|
||||
super();
|
||||
this._register(configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('editor') || e.affectsConfiguration('notebook')) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/commo
|
|||
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
||||
import { IExtensionsViewPaneContainer, VIEWLET_ID as EXTENSION_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
||||
import { CodeCellRenderTemplate, ICellOutputViewModel, ICellViewModel, IInsetRenderOutput, INotebookEditor, IRenderOutput, JUPYTER_EXTENSION_ID, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CodeCellRenderTemplate, ICellOutputViewModel, ICellViewModel, IInsetRenderOutput, INotebookEditorDelegate, IRenderOutput, JUPYTER_EXTENSION_ID, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { mimetypeIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons';
|
||||
import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellWidgets';
|
||||
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
||||
|
@ -78,7 +78,7 @@ export class CellOutputElement extends Disposable {
|
|||
private readonly contextKeyService: IContextKeyService;
|
||||
|
||||
constructor(
|
||||
private notebookEditor: INotebookEditor,
|
||||
private notebookEditor: INotebookEditorDelegate,
|
||||
private viewCell: CodeCellViewModel,
|
||||
private outputContainer: HTMLElement,
|
||||
readonly output: ICellOutputViewModel,
|
||||
|
@ -512,7 +512,7 @@ export class CellOutputContainer extends Disposable {
|
|||
}
|
||||
|
||||
constructor(
|
||||
private notebookEditor: INotebookEditor,
|
||||
private notebookEditor: INotebookEditorDelegate,
|
||||
private viewCell: CodeCellViewModel,
|
||||
private readonly templateData: CodeCellRenderTemplate,
|
||||
private options: { limit: number; },
|
||||
|
|
|
@ -37,7 +37,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
|||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { INotebookActionContext, INotebookCellActionContext, INotebookCellToolbarActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
||||
import { DeleteCellAction } from 'vs/workbench/contrib/notebook/browser/controller/editActions';
|
||||
import { BaseCellRenderTemplate, CodeCellLayoutInfo, CodeCellRenderTemplate, EXPAND_CELL_OUTPUT_COMMAND_ID, ICellViewModel, INotebookEditor, isCodeCellRenderTemplate, MarkdownCellRenderTemplate, NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_TYPE, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { BaseCellRenderTemplate, CodeCellLayoutInfo, CodeCellRenderTemplate, EXPAND_CELL_OUTPUT_COMMAND_ID, ICellViewModel, INotebookEditorDelegate, isCodeCellRenderTemplate, MarkdownCellRenderTemplate, NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_TYPE, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CodiconActionViewItem } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellActionView';
|
||||
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys';
|
||||
import { CellDragAndDropController, DRAGGING_CLASS } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellDnd';
|
||||
|
@ -87,7 +87,7 @@ abstract class AbstractCellRenderer {
|
|||
|
||||
constructor(
|
||||
protected readonly instantiationService: IInstantiationService,
|
||||
protected readonly notebookEditor: INotebookEditor,
|
||||
protected readonly notebookEditor: INotebookEditorDelegate,
|
||||
protected readonly contextMenuService: IContextMenuService,
|
||||
protected readonly menuService: IMenuService,
|
||||
configurationService: IConfigurationService,
|
||||
|
@ -257,7 +257,7 @@ export class MarkupCellRenderer extends AbstractCellRenderer implements IListRen
|
|||
static readonly TEMPLATE_ID = 'markdown_cell';
|
||||
|
||||
constructor(
|
||||
notebookEditor: INotebookEditor,
|
||||
notebookEditor: INotebookEditorDelegate,
|
||||
dndController: CellDragAndDropController,
|
||||
private renderedEditors: Map<ICellViewModel, ICodeEditor | undefined>,
|
||||
contextKeyServiceProvider: (container: HTMLElement) => IContextKeyService,
|
||||
|
@ -582,7 +582,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
|||
static readonly TEMPLATE_ID = 'code_cell';
|
||||
|
||||
constructor(
|
||||
notebookEditor: INotebookEditor,
|
||||
notebookEditor: INotebookEditorDelegate,
|
||||
private renderedEditors: Map<ICellViewModel, ICodeEditor | undefined>,
|
||||
dndController: CellDragAndDropController,
|
||||
contextKeyServiceProvider: (container: HTMLElement) => IContextKeyService,
|
||||
|
@ -1084,7 +1084,7 @@ export class ListTopCellToolbar extends Disposable {
|
|||
private toolbar: ToolBar;
|
||||
private readonly _modelDisposables = this._register(new DisposableStore());
|
||||
constructor(
|
||||
protected readonly notebookEditor: INotebookEditor,
|
||||
protected readonly notebookEditor: INotebookEditorDelegate,
|
||||
|
||||
contextKeyService: IContextKeyService,
|
||||
insertionIndicatorContainer: HTMLElement,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { localize } from 'vs/nls';
|
|||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { CellFocusMode, CodeCellRenderTemplate, EXPAND_CELL_INPUT_COMMAND_ID, IActiveNotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellFocusMode, CodeCellRenderTemplate, EXPAND_CELL_INPUT_COMMAND_ID, IActiveNotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellOutputContainer } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellOutput';
|
||||
import { ClickTargetType } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellWidgets';
|
||||
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
||||
|
@ -31,7 +31,7 @@ export class CodeCell extends Disposable {
|
|||
private _renderedOutputCollapseState: boolean | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly notebookEditor: IActiveNotebookEditor,
|
||||
private readonly notebookEditor: IActiveNotebookEditorDelegate,
|
||||
private readonly viewCell: CodeCellViewModel,
|
||||
private readonly templateData: CodeCellRenderTemplate,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'vs
|
|||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CellEditState, CellFocusMode, MarkdownCellRenderTemplate, ICellViewModel, IActiveNotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellEditState, CellFocusMode, MarkdownCellRenderTemplate, ICellViewModel, IActiveNotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { CellFoldingState } from 'vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel';
|
||||
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
@ -38,7 +38,7 @@ export class StatefulMarkdownCell extends Disposable {
|
|||
private foldingState: CellFoldingState;
|
||||
|
||||
constructor(
|
||||
private readonly notebookEditor: IActiveNotebookEditor,
|
||||
private readonly notebookEditor: IActiveNotebookEditorDelegate,
|
||||
private readonly viewCell: MarkupCellViewModel,
|
||||
private readonly templateData: MarkdownCellRenderTemplate,
|
||||
private editorOptions: IEditorOptions,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { IListService, ListService } from 'vs/platform/list/browser/listService'
|
|||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
|
||||
import { ICellViewModel, IActiveNotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { ICellViewModel, IActiveNotebookEditorDelegate, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher';
|
||||
import { CellViewModel, NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
|
||||
import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
|
||||
|
@ -168,7 +168,7 @@ export function setupInstantiationService() {
|
|||
return instantiationService;
|
||||
}
|
||||
|
||||
function _createTestNotebookEditor(instantiationService: TestInstantiationService, cells: [source: string, lang: string, kind: CellKind, output?: IOutputDto[], metadata?: NotebookCellMetadata][]): { editor: IActiveNotebookEditor, viewModel: NotebookViewModel; } {
|
||||
function _createTestNotebookEditor(instantiationService: TestInstantiationService, cells: [source: string, lang: string, kind: CellKind, output?: IOutputDto[], metadata?: NotebookCellMetadata][]): { editor: IActiveNotebookEditorDelegate, viewModel: NotebookViewModel; } {
|
||||
|
||||
const viewType = 'notebook';
|
||||
const notebook = instantiationService.createInstance(NotebookTextModel, viewType, URI.parse('test'), cells.map(cell => {
|
||||
|
@ -190,7 +190,7 @@ function _createTestNotebookEditor(instantiationService: TestInstantiationServic
|
|||
cellList.attachViewModel(viewModel);
|
||||
const listViewInfoAccessor = new ListViewInfoAccessor(cellList);
|
||||
|
||||
const notebookEditor: IActiveNotebookEditor = new class extends mock<IActiveNotebookEditor>() {
|
||||
const notebookEditor: IActiveNotebookEditorDelegate = new class extends mock<IActiveNotebookEditorDelegate>() {
|
||||
override dispose() {
|
||||
viewModel.dispose();
|
||||
}
|
||||
|
@ -199,8 +199,8 @@ function _createTestNotebookEditor(instantiationService: TestInstantiationServic
|
|||
override _getViewModel(): NotebookViewModel {
|
||||
return viewModel;
|
||||
}
|
||||
override get textModel() { return viewModel.notebookDocument; }
|
||||
override hasModel(): this is IActiveNotebookEditor {
|
||||
override textModel = viewModel.notebookDocument;
|
||||
override hasModel(): this is IActiveNotebookEditorDelegate {
|
||||
return !!viewModel;
|
||||
}
|
||||
override getLength() { return viewModel.length; }
|
||||
|
@ -261,7 +261,7 @@ function _createTestNotebookEditor(instantiationService: TestInstantiationServic
|
|||
return { editor: notebookEditor, viewModel };
|
||||
}
|
||||
|
||||
export function createTestNotebookEditor(cells: [source: string, lang: string, kind: CellKind, output?: IOutputDto[], metadata?: NotebookCellMetadata][]): { editor: IActiveNotebookEditor, viewModel: NotebookViewModel; } {
|
||||
export function createTestNotebookEditor(cells: [source: string, lang: string, kind: CellKind, output?: IOutputDto[], metadata?: NotebookCellMetadata][]): { editor: INotebookEditorDelegate, viewModel: NotebookViewModel; } {
|
||||
return _createTestNotebookEditor(setupInstantiationService(), cells);
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ export async function withTestNotebookDiffModel<R = any>(originalCells: [source:
|
|||
return res;
|
||||
}
|
||||
|
||||
export async function withTestNotebook<R = any>(cells: [source: string, lang: string, kind: CellKind, output?: IOutputDto[], metadata?: NotebookCellMetadata][], callback: (editor: IActiveNotebookEditor, viewModel: NotebookViewModel, accessor: TestInstantiationService) => Promise<R> | R, accessor?: TestInstantiationService): Promise<R> {
|
||||
export async function withTestNotebook<R = any>(cells: [source: string, lang: string, kind: CellKind, output?: IOutputDto[], metadata?: NotebookCellMetadata][], callback: (editor: IActiveNotebookEditorDelegate, viewModel: NotebookViewModel, accessor: TestInstantiationService) => Promise<R> | R, accessor?: TestInstantiationService): Promise<R> {
|
||||
const instantiationService = accessor ?? setupInstantiationService();
|
||||
const notebookEditor = _createTestNotebookEditor(instantiationService, cells);
|
||||
|
||||
|
|
Loading…
Reference in a new issue