提交 3d53af15 编写于 作者: R rebornix

move more notebook list logic out

上级 33f008e3
......@@ -572,10 +572,6 @@ export class MouseController<T> implements IDisposable {
}
private onMouseDown(e: IListMouseEvent<T> | IListTouchEvent<T>): void {
if (e.browserEvent.target && this.list.view.domNode.contains(e.browserEvent.target as HTMLElement)) {
return;
}
if (document.activeElement !== e.browserEvent.target) {
this.list.domFocus();
}
......@@ -1120,7 +1116,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
private focus: Trait<T>;
private selection: Trait<T>;
private eventBufferer = new EventBufferer();
public view: ListView<T>;
protected view: ListView<T>;
private spliceable: ISpliceable<T>;
private styleController: IStyleController;
private typeLabelController?: TypeLabelController<T>;
......@@ -1144,7 +1140,6 @@ export class List<T> implements ISpliceable<T>, IDisposable {
get domId(): string { return this.view.domId; }
get onDidScroll(): Event<ScrollEvent> { return this.view.onDidScroll; }
get onWillScroll(): Event<ScrollEvent> { return this.view.onWillScroll; }
get onMouseClick(): Event<IListMouseEvent<T>> { return this.view.onMouseClick; }
get onMouseDblClick(): Event<IListMouseEvent<T>> { return this.view.onMouseDblClick; }
get onMouseMiddleClick(): Event<IListMouseEvent<T>> { return this.view.onMouseMiddleClick; }
......@@ -1588,14 +1583,6 @@ export class List<T> implements ISpliceable<T>, IDisposable {
}
}
getAbsoluteTop(index: number): number {
if (index < 0 || index >= this.length) {
throw new ListError(this.user, `Invalid index ${index}`);
}
return this.view.elementTop(index);
}
/**
* Returns the relative position of an element rendered in the list.
* Returns `null` if the element isn't *entirely* in the visible viewport.
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IListRenderer, IListVirtualDelegate, ListError } from 'vs/base/browser/ui/list/list';
import { Event } from 'vs/base/common/event';
import { ScrollEvent } from 'vs/base/common/scrollable';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IListService, IWorkbenchListOptions, WorkbenchList } from 'vs/platform/list/browser/listService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
export class NotebookCellList<T> extends WorkbenchList<T> {
get onWillScroll(): Event<ScrollEvent> { return this.view.onWillScroll; }
get rowsContainer(): HTMLElement {
return this.view.rowsContainer;
}
get isRendering(): boolean {
return this.view.isRendering;
}
constructor(
private listUser: string,
container: HTMLElement,
delegate: IListVirtualDelegate<T>,
renderers: IListRenderer<T, any>[],
options: IWorkbenchListOptions<T>,
@IContextKeyService contextKeyService: IContextKeyService,
@IListService listService: IListService,
@IThemeService themeService: IThemeService,
@IConfigurationService configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService
) {
super(listUser, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, keybindingService);
}
domElementAtIndex(index: number): HTMLElement | null {
return this.view.domElement(index);
}
focusView() {
this.view.domNode.focus();
}
domFocus() {
if (document.activeElement && this.view.domNode.contains(document.activeElement)) {
return;
}
super.domFocus();
}
getAbsoluteTop(index: number): number {
if (index < 0 || index >= this.length) {
throw new ListError(this.listUser, `Invalid index ${index}`);
}
return this.view.elementTop(index);
}
}
......@@ -15,7 +15,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { WorkbenchList } from 'vs/platform/list/browser/listService';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { contrastBorder, editorBackground, focusBorder, foreground, textBlockQuoteBackground, textBlockQuoteBorder, textLinkActiveForeground, textLinkForeground, textPreformatForeground } from 'vs/platform/theme/common/colorRegistry';
......@@ -37,6 +36,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IEditor } from 'vs/editor/common/editorCommon';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { Emitter, Event } from 'vs/base/common/event';
import { NotebookCellList } from 'vs/workbench/contrib/notebook/browser/notebookCellList';
const $ = DOM.$;
const NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'NotebookEditorViewState';
......@@ -54,7 +54,7 @@ class NotebookCodeEditors implements ICompositeCodeEditor {
readonly onDidChangeActiveEditor: Event<this> = this._onDidChangeActiveEditor.event;
constructor(
private _list: WorkbenchList<CellViewModel>,
private _list: NotebookCellList<CellViewModel>,
private _renderedEditors: Map<CellViewModel, ICodeEditor | undefined>
) {
_list.onFocusChange(e => this._onDidChangeActiveEditor.fire(this), undefined, this._disposables);
......@@ -114,7 +114,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
private contentWidgets!: HTMLElement;
private webview: BackLayerWebView | null = null;
private list: WorkbenchList<CellViewModel> | undefined;
private list: NotebookCellList<CellViewModel> | undefined;
private control: ICompositeCodeEditor | undefined;
private renderedEditors: Map<CellViewModel, ICodeEditor | undefined> = new Map();
private model: NotebookEditorModel | undefined;
......@@ -196,8 +196,8 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this.instantiationService.createInstance(MarkdownCellRenderer, this),
];
this.list = <WorkbenchList<CellViewModel>>this.instantiationService.createInstance(
WorkbenchList,
this.list = <NotebookCellList<CellViewModel>>this.instantiationService.createInstance(
NotebookCellList,
'NotebookCellList',
this.body,
this.instantiationService.createInstance(NotebookCellListDelegate),
......@@ -233,7 +233,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this.control = new NotebookCodeEditors(this.list, this.renderedEditors);
this.webview = new BackLayerWebView(this.webviewService, this.notebookService, this, this.environmentSerice);
this.list.view.rowsContainer.appendChild(this.webview.element);
this.list.rowsContainer.appendChild(this.webview.element);
this._register(this.list);
}
......@@ -250,7 +250,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
if (this.webview) {
this.localStore.clear();
this.list?.view.rowsContainer.removeChild(this.webview?.element);
this.list?.rowsContainer.removeChild(this.webview?.element);
this.webview?.dispose();
this.webview = null;
}
......@@ -302,7 +302,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this.webview?.clearPreloadsCache();
} else {
this.webview = new BackLayerWebView(this.webviewService, this.notebookService, this, this.environmentSerice);
this.list?.view.rowsContainer.insertAdjacentElement('afterbegin', this.webview!.element);
this.list?.rowsContainer.insertAdjacentElement('afterbegin', this.webview!.element);
}
this.model = model;
......@@ -407,7 +407,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}
};
if (this.list?.view.isRendering) {
if (this.list?.isRendering) {
// if (this.relayoutDisposable) {
// this.relayoutDisposable.dispose();
// this.relayoutDisposable = null;
......@@ -428,7 +428,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}));
});
if (this.list?.view.isRendering) {
if (this.list?.isRendering) {
// if (this.relayoutDisposable) {
// this.relayoutDisposable.dispose();
// this.relayoutDisposable = null;
......@@ -493,7 +493,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
if (focusEditor) {
} else {
let itemDOM = this.list?.view.domElement(index);
let itemDOM = this.list?.domElementAtIndex(index);
if (document.activeElement && itemDOM && itemDOM.contains(document.activeElement)) {
(document.activeElement as HTMLElement).blur();
}
......@@ -502,7 +502,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}
this.list?.setFocus([index]);
this.list?.view.domNode.focus();
this.list?.focusView();
}
async deleteNotebookCell(listIndex: number | undefined, cell: CellViewModel): Promise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册