notebookBrowser.ts 4.0 KB
Newer Older
R
rebornix 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
R
rebornix 已提交
9 10
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel';
import { OutputRenderer } from 'vs/workbench/contrib/notebook/browser/view/output/outputRenderer';
R
rebornix 已提交
11
import { IOutput, CellKind, IRenderOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
R
rebornix 已提交
12
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
R
rebornix 已提交
13 14
import { NotebookViewModel, IModelDecorationsChangeAccessor } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
import { FindMatch } from 'vs/editor/common/model';
R
rebornix 已提交
15 16

export const KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED = new RawContextKey<boolean>('notebookFindWidgetFocused', false);
R
rebornix 已提交
17

R
rebornix 已提交
18 19 20 21 22 23
export interface NotebookLayoutInfo {
	width: number;
	height: number;
	fontInfo: BareFontInfo;
}

24
export interface INotebookEditor {
R
rebornix 已提交
25
	viewType: string | undefined;
R
rebornix 已提交
26
	viewModel: NotebookViewModel | undefined;
R
rebornix 已提交
27
	insertEmptyNotebookCell(cell: CellViewModel, type: CellKind, direction: 'above' | 'below'): Promise<void>;
R
rebornix 已提交
28 29 30
	deleteNotebookCell(cell: CellViewModel): void;
	editNotebookCell(cell: CellViewModel): void;
	saveNotebookCell(cell: CellViewModel): void;
R
rebornix 已提交
31 32
	focusNotebookCell(cell: CellViewModel, focusEditor: boolean): void;
	getActiveCell(): CellViewModel | undefined;
33
	layoutNotebookCell(cell: CellViewModel, height: number): void;
34
	createInset(cell: CellViewModel, output: IOutput, shadowContent: string, offset: number): void;
R
rebornix 已提交
35
	removeInset(output: IOutput): void;
36
	triggerScroll(event: IMouseWheelEvent): void;
R
rebornix 已提交
37
	getLayoutInfo(): NotebookLayoutInfo;
R
rebornix 已提交
38
	getOutputRenderer(): OutputRenderer;
R
rebornix 已提交
39 40 41 42 43

	/**
	 * Reveal cell into viewport.
	 * If `offset` is provided, `top(cell) + offset` will be scrolled into view.
	 */
R
rebornix 已提交
44
	revealInView(cell: CellViewModel, offset?: number): void;
R
rebornix 已提交
45 46 47 48 49

	/**
	 * Reveal cell into viewport center.
	 * If `offset` is provided, `top(cell) + offset` will be scrolled into view.
	 */
R
rebornix 已提交
50
	revealInCenter(cell: CellViewModel, offset?: number): void;
R
rebornix 已提交
51 52 53 54 55

	/**
	 * Reveal cell into viewport center if cell is currently out of the viewport.
	 * If `offset` is provided, `top(cell) + offset` will be scrolled into view.
	 */
R
rebornix 已提交
56
	revealInCenterIfOutsideViewport(cell: CellViewModel, offset?: number): void;
R
rebornix 已提交
57

R
rebornix 已提交
58 59 60 61 62 63 64 65 66 67 68 69
	/**
	 * Reveal a line in notebook cell into viewport center.
	 * If `offset` is provided, `top(cell) + offset` will be scrolled into view.
	 */
	revealLineInCenter(cell: CellViewModel, line: number): void;

	/**
	 * Reveal a line in notebook cell into viewport center.
	 * If `offset` is provided, `top(cell) + offset` will be scrolled into view.
	 */
	revealLineInCenterIfOutsideViewport(cell: CellViewModel, line: number): void;

R
rebornix 已提交
70 71 72 73
	/**
	 * Change the decorations on cells.
	 * The notebook is virtualized and this method should be called to create/delete editor decorations safely.
	 */
R
rebornix 已提交
74
	changeDecorations(callback: (changeAccessor: IModelDecorationsChangeAccessor) => any): any;
R
rebornix 已提交
75 76 77 78
	focus(): void;
	showFind(): void;
	hideFind(): void;
	focusNext(nextMatch: CellFindMatch, matchIndex: number): void;
R
rebornix 已提交
79 80 81 82 83 84 85 86 87 88
}

export interface CellRenderTemplate {
	container: HTMLElement;
	cellContainer: HTMLElement;
	menuContainer?: HTMLElement;
	editingContainer?: HTMLElement;
	outputContainer?: HTMLElement;
	editor?: CodeEditorWidget;
}
R
rebornix 已提交
89 90 91 92 93 94 95 96 97

export interface IOutputTransformContribution {
	/**
	 * Dispose this contribution.
	 */
	dispose(): void;

	render(output: IOutput, container: HTMLElement, preferredMimeType: string | undefined): IRenderOutput;
}
R
rebornix 已提交
98 99 100 101 102 103

export interface CellFindMatch {
	cell: CellViewModel;
	matches: FindMatch[];
}