提交 befaab50 编写于 作者: R rebornix

ICellViewModel only visible to contrib

上级 0faba333
......@@ -3,20 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
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/viewModel/notebookCellViewModel';
import { OutputRenderer } from 'vs/workbench/contrib/notebook/browser/view/output/outputRenderer';
import { IOutput, CellKind, IRenderOutput, NotebookCellOutputsSplice } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IOutput, CellKind, IRenderOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { NotebookViewModel, IModelDecorationsChangeAccessor } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
import { FindMatch, ITextModel } from 'vs/editor/common/model';
import { FindMatch } from 'vs/editor/common/model';
import { Range } from 'vs/editor/common/core/range';
import { URI } from 'vs/base/common/uri';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { MarkdownRenderer } from 'vs/workbench/contrib/notebook/browser/view/renderers/mdRenderer';
export const KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED = new RawContextKey<boolean>('notebookFindWidgetFocused', false);
......@@ -31,36 +28,9 @@ export interface ICellViewModel {
handle: number;
uri: URI;
cellKind: CellKind;
lineCount: number;
outputs: IOutput[]
onDidChangeOutputs: Event<NotebookCellOutputsSplice[]>;
state: CellState;
onDidChangeCellState: Event<void>;
focusMode: CellFocusMode;
onDidChangeFocusMode: Event<void>;
selfSizeMonitoring: boolean;
editorHeight: number;
editorAttached: boolean;
onDidChangeEditorAttachState: Event<boolean>;
getHTML(): HTMLElement | null;
resolveTextModel(): Promise<ITextModel>;
attachTextEditor(editor: ICodeEditor): void;
detachTextEditor(): void;
setText(strs: string[]): void;
getText(): string;
updateOutputHeight(index: number, height: number): void;
getOutputOffset(index: number): number;
getOutputTotalHeight(): number;
getLineScrollTopOffset(line: number): number;
getHeight(lineHeight: number): number;
hasDynamicHeight(): boolean;
getMarkdownRenderer(): MarkdownRenderer;
revealRangeInCenter(range: Range): void;
setSelection(range: Range): void;
onDidChangeCursorSelection: Event<void>;
cursorAtBoundary(): CursorAtBoundary;
onDeselect(): void;
spliceOutputHeights(start: number, deleteCnt: number, heights: number[]): void;
}
export interface INotebookEditor {
......
......@@ -344,7 +344,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
const scrollTop = this.list?.scrollTop || 0;
const scrollHeight = this.list?.scrollHeight || 0;
this.webview!.element.style.height = `${scrollHeight}px`;
let updateItems: { cell: ICellViewModel, output: IOutput, cellTop: number }[] = [];
let updateItems: { cell: CellViewModel, output: IOutput, cellTop: number }[] = [];
if (this.webview?.insetMapping) {
this.webview?.insetMapping.forEach((value, key) => {
......@@ -373,7 +373,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}));
this.list?.splice(0, this.list?.length || 0);
this.list?.splice(0, 0, this.notebookViewModel!.viewCells);
this.list?.splice(0, 0, this.notebookViewModel!.viewCells as CellViewModel[]);
this.list?.layout();
}
......@@ -640,7 +640,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this.list?.triggerScrollFromMouseWheelEvent(event);
}
createInset(cell: ICellViewModel, output: IOutput, shadowContent: string, offset: number) {
createInset(cell: CellViewModel, output: IOutput, shadowContent: string, offset: number) {
if (!this.webview) {
return;
}
......
......@@ -16,25 +16,26 @@ import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { isMacintosh } from 'vs/base/common/platform';
import { EDITOR_TOP_PADDING, NOTEBOOK_EDITOR_CURSOR_BOUNDARY } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { Range } from 'vs/editor/common/core/range';
import { CellRevealType, CellRevealPosition, CursorAtBoundary, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellRevealType, CellRevealPosition, CursorAtBoundary } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel';
export class NotebookCellList extends WorkbenchList<ICellViewModel> implements IDisposable {
export class NotebookCellList extends WorkbenchList<CellViewModel> implements IDisposable {
get onWillScroll(): Event<ScrollEvent> { return this.view.onWillScroll; }
get rowsContainer(): HTMLElement {
return this.view.containerDomNode;
}
private _previousSelectedElements: ICellViewModel[] = [];
private _previousSelectedElements: CellViewModel[] = [];
private _localDisposableStore = new DisposableStore();
constructor(
private listUser: string,
container: HTMLElement,
delegate: IListVirtualDelegate<ICellViewModel>,
renderers: IListRenderer<ICellViewModel, any>[],
delegate: IListVirtualDelegate<CellViewModel>,
renderers: IListRenderer<CellViewModel, any>[],
contextKeyService: IContextKeyService,
options: IWorkbenchListOptions<ICellViewModel>,
options: IWorkbenchListOptions<CellViewModel>,
@IListService listService: IListService,
@IThemeService themeService: IThemeService,
@IConfigurationService configurationService: IConfigurationService,
......@@ -58,7 +59,7 @@ export class NotebookCellList extends WorkbenchList<ICellViewModel> implements I
let cursorSelectionLisener: IDisposable | null = null;
const recomputeContext = (element: ICellViewModel) => {
const recomputeContext = (element: CellViewModel) => {
switch (element.cursorAtBoundary()) {
case CursorAtBoundary.Both:
notebookEditorCursorAtBoundaryContext.set('both');
......@@ -331,7 +332,7 @@ export class NotebookCellList extends WorkbenchList<ICellViewModel> implements I
}
}
function getEditorAttachedPromise(element: ICellViewModel) {
function getEditorAttachedPromise(element: CellViewModel) {
return new Promise((resolve, reject) => {
Event.once(element.onDidChangeEditorAttachState)(state => state ? resolve() : reject());
});
......
......@@ -9,11 +9,12 @@ import * as path from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
import * as UUID from 'vs/base/common/uuid';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotebookEditor, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebookService';
import { CELL_MARGIN, IOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IWebviewService, WebviewElement } from 'vs/workbench/contrib/webview/browser/webview';
import { WebviewResourceScheme } from 'vs/workbench/contrib/webview/common/resourceLoader';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel';
export interface IDimentionMessage {
type: 'dimension';
......@@ -71,7 +72,7 @@ let version = 0;
export class BackLayerWebView extends Disposable {
element: HTMLElement;
webview: WebviewElement;
insetMapping: Map<IOutput, { outputId: string, cell: ICellViewModel, cacheOffset: number | undefined }> = new Map();
insetMapping: Map<IOutput, { outputId: string, cell: CellViewModel, cacheOffset: number | undefined }> = new Map();
reversedInsetMapping: Map<string, IOutput> = new Map();
preloadsCache: Map<string, boolean> = new Map();
localResourceRootsCache: URI[] | undefined = undefined;
......@@ -291,7 +292,7 @@ export class BackLayerWebView extends Disposable {
return webview;
}
shouldUpdateInset(cell: ICellViewModel, output: IOutput, cellTop: number) {
shouldUpdateInset(cell: CellViewModel, output: IOutput, cellTop: number) {
let outputCache = this.insetMapping.get(output)!;
let outputIndex = cell.outputs.indexOf(output);
......@@ -305,7 +306,7 @@ export class BackLayerWebView extends Disposable {
return true;
}
updateViewScrollTop(top: number, items: { cell: ICellViewModel, output: IOutput, cellTop: number }[]) {
updateViewScrollTop(top: number, items: { cell: CellViewModel, output: IOutput, cellTop: number }[]) {
let widgets: IContentWidgetTopRequest[] = items.map(item => {
let outputCache = this.insetMapping.get(item.output)!;
let id = outputCache.outputId;
......@@ -333,7 +334,7 @@ export class BackLayerWebView extends Disposable {
this.webview.sendMessage(message);
}
createInset(cell: ICellViewModel, output: IOutput, cellTop: number, offset: number, shadowContent: string, preloads: Set<number>) {
createInset(cell: CellViewModel, output: IOutput, cellTop: number, offset: number, shadowContent: string, preloads: Set<number>) {
this.updateRendererPreloads(preloads);
let initialTop = cellTop + offset;
let outputId = UUID.generateUuid();
......
......@@ -21,6 +21,7 @@ import { CodeCell } from 'vs/workbench/contrib/notebook/browser/view/renderers/c
import { StatefullMarkdownCell } from 'vs/workbench/contrib/notebook/browser/view/renderers/markdownCell';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EDITOR_TOP_PADDING, EDITOR_BOTTOM_PADDING, CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel';
export class NotebookCellListDelegate implements IListVirtualDelegate<ICellViewModel> {
private _lineHeight: number;
......@@ -31,15 +32,15 @@ export class NotebookCellListDelegate implements IListVirtualDelegate<ICellViewM
this._lineHeight = BareFontInfo.createFromRawSettings(editorOptions, getZoomLevel()).lineHeight;
}
getHeight(element: ICellViewModel): number {
getHeight(element: CellViewModel): number {
return element.getHeight(this._lineHeight);
}
hasDynamicHeight(element: ICellViewModel): boolean {
hasDynamicHeight(element: CellViewModel): boolean {
return element.hasDynamicHeight();
}
getTemplateId(element: ICellViewModel): string {
getTemplateId(element: CellViewModel): string {
if (element.cellKind === CellKind.Markdown) {
return MarkdownCellRenderer.TEMPLATE_ID;
} else {
......@@ -221,7 +222,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
return template;
}
renderElement(element: ICellViewModel, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
renderElement(element: CellViewModel, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
templateData.editingContainer!.style.display = 'none';
templateData.cellContainer.innerHTML = '';
let renderedHTML = element.getHTML();
......@@ -317,7 +318,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
return tempalte;
}
renderElement(element: ICellViewModel, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
renderElement(element: CellViewModel, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
if (height === undefined) {
return;
}
......
......@@ -8,11 +8,12 @@ import * as DOM from 'vs/base/browser/dom';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/view/renderers/sizeObserver';
import { CELL_MARGIN, IOutput, EDITOR_TOP_PADDING, EDITOR_BOTTOM_PADDING, ITransformedDisplayOutputDto, IRenderOutput, CellOutputKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellRenderTemplate, INotebookEditor, CellFocusMode, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellRenderTemplate, INotebookEditor, CellFocusMode } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { raceCancellation } from 'vs/base/common/async';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebookService';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel';
interface IMimeTypeRenderer extends IQuickPickItem {
index: number;
......@@ -23,7 +24,7 @@ export class CodeCell extends Disposable {
private outputElements = new Map<IOutput, HTMLElement>();
constructor(
private notebookEditor: INotebookEditor,
private viewCell: ICellViewModel,
private viewCell: CellViewModel,
private templateData: CellRenderTemplate,
@INotebookService private notebookService: INotebookService,
@IQuickInputService private readonly quickInputService: IQuickInputService
......
......@@ -9,9 +9,10 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/view/renderers/sizeObserver';
import { CELL_MARGIN, EDITOR_TOP_PADDING, EDITOR_BOTTOM_PADDING } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookEditor, CellRenderTemplate, CellFocusMode, CellState, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { INotebookEditor, CellRenderTemplate, CellFocusMode, CellState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { raceCancellation } from 'vs/base/common/async';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel';
export class StatefullMarkdownCell extends Disposable {
private editor: CodeEditorWidget | null = null;
......@@ -22,7 +23,7 @@ export class StatefullMarkdownCell extends Disposable {
constructor(
notebookEditor: INotebookEditor,
public viewCell: ICellViewModel,
public viewCell: CellViewModel,
templateData: CellRenderTemplate,
editorOptions: IEditorOptions,
instantiationService: IInstantiationService
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册