提交 7e74dc8e 编写于 作者: R rebornix

handler -> notebookEditor

上级 55d34d79
......@@ -13,7 +13,7 @@ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookB
class ErrorTransform implements IOutputTransformContribution {
constructor(
public handler: INotebookEditor,
public editor: INotebookEditor,
@IThemeService private readonly themeService: IThemeService
) {
}
......
......@@ -20,7 +20,7 @@ class RichRenderer implements IOutputTransformContribution {
private _mdRenderer: marked.Renderer = new marked.Renderer({ gfm: true });;
constructor(
public handler: INotebookEditor,
public notebookEditor: INotebookEditor,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IModelService private readonly modelService: IModelService,
@IModeService private readonly modeService: IModeService
......@@ -50,8 +50,8 @@ class RichRenderer implements IOutputTransformContribution {
const textModel = this.modelService.createModel(str, mode, resource, false);
editor.setModel(textModel);
let width = this.handler.getListDimension()!.width;
let fontInfo = this.handler.getFontInfo();
let width = this.notebookEditor.getListDimension()!.width;
let fontInfo = this.notebookEditor.getFontInfo();
let height = Math.min(textModel.getLineCount(), 16) * (fontInfo?.lineHeight || 18);
editor.layout({
......
......@@ -9,7 +9,7 @@ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookB
class StreamRenderer implements IOutputTransformContribution {
constructor(
handler: INotebookEditor
editor: INotebookEditor
) {
}
......
......@@ -75,7 +75,7 @@ export class BackLayerWebView extends Disposable {
outputMapping: Map<string, boolean> = new Map();
preloadsCache: Map<string, boolean> = new Map();
constructor(public webviewService: IWebviewService, public notebookService: INotebookService, public notebookHandler: INotebookEditor, public environmentSerice: IEnvironmentService) {
constructor(public webviewService: IWebviewService, public notebookService: INotebookService, public notebookEditor: INotebookEditor, public environmentSerice: IEnvironmentService) {
super();
this.element = document.createElement('div');
......@@ -242,7 +242,7 @@ export class BackLayerWebView extends Disposable {
this.webview.mountTo(this.element);
this._register(this.webview.onDidWheel(e => {
this.notebookHandler.triggerScroll(e);
this.notebookEditor.triggerScroll(e);
}));
this._register(this.webview.onMessage((data: IMessage) => {
......@@ -252,10 +252,10 @@ export class BackLayerWebView extends Disposable {
let outputHeight = height === 0 ? 0 : height + 16;
if (cell) {
const lineNum = cell.lineCount;
const lineHeight = this.notebookHandler.getFontInfo()?.lineHeight ?? 18;
const lineHeight = this.notebookEditor.getFontInfo()?.lineHeight ?? 18;
const totalHeight = lineNum * lineHeight;
cell.dynamicHeight = totalHeight + 32 /* code cell padding */ + outputHeight;
this.notebookHandler.layoutNotebookCell(cell, totalHeight + 32 /* code cell padding */ + outputHeight);
this.notebookEditor.layoutNotebookCell(cell, totalHeight + 32 /* code cell padding */ + outputHeight);
}
} else if (data.type === 'scroll-ack') {
// const date = new Date();
......
......@@ -55,7 +55,7 @@ class AbstractCellRenderer {
protected editorOptions: IEditorOptions;
constructor(
protected handler: INotebookEditor,
protected notebookEditor: INotebookEditor,
private contextMenuService: IContextMenuService,
private configurationService: IConfigurationService,
language: string
......@@ -87,7 +87,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
await this.handler.insertEmptyNotebookCell(listIndex, element, 'code', 'above');
await this.notebookEditor.insertEmptyNotebookCell(listIndex, element, 'code', 'above');
}
);
actions.push(insertAbove);
......@@ -98,7 +98,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
await this.handler.insertEmptyNotebookCell(listIndex, element, 'code', 'below');
await this.notebookEditor.insertEmptyNotebookCell(listIndex, element, 'code', 'below');
}
);
actions.push(insertBelow);
......@@ -109,7 +109,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
await this.handler.insertEmptyNotebookCell(listIndex, element, 'markdown', 'above');
await this.notebookEditor.insertEmptyNotebookCell(listIndex, element, 'markdown', 'above');
}
);
actions.push(insertMarkdownAbove);
......@@ -120,7 +120,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
await this.handler.insertEmptyNotebookCell(listIndex, element, 'markdown', 'below');
await this.notebookEditor.insertEmptyNotebookCell(listIndex, element, 'markdown', 'below');
}
);
actions.push(insertMarkdownBelow);
......@@ -132,7 +132,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
this.handler.editNotebookCell(listIndex, element);
this.notebookEditor.editNotebookCell(listIndex, element);
}
);
......@@ -144,7 +144,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
this.handler.saveNotebookCell(listIndex, element);
this.notebookEditor.saveNotebookCell(listIndex, element);
}
);
......@@ -157,7 +157,7 @@ class AbstractCellRenderer {
undefined,
true,
async () => {
this.handler.deleteNotebookCell(listIndex, element);
this.notebookEditor.deleteNotebookCell(listIndex, element);
}
);
......@@ -183,12 +183,12 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
private disposables: Map<CellViewModel, DisposableStore> = new Map();
constructor(
handler: INotebookEditor,
notehookEditor: INotebookEditor,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IConfigurationService configurationService: IConfigurationService,
@IContextMenuService contextMenuService: IContextMenuService
) {
super(handler, contextMenuService, configurationService, 'markdown');
super(notehookEditor, contextMenuService, configurationService, 'markdown');
}
get templateId() {
......@@ -244,7 +244,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
this.showContextMenu(listIndex, element, e.posx, top + height);
}));
elementDisposable!.add(new StatefullMarkdownCell(this.handler, element, templateData, this.editorOptions, this.instantiationService));
elementDisposable!.add(new StatefullMarkdownCell(this.notebookEditor, element, templateData, this.editorOptions, this.instantiationService));
}
}
......@@ -265,12 +265,12 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
private disposables: Map<CellViewModel, DisposableStore> = new Map();
constructor(
protected handler: INotebookEditor,
protected notebookEditor: INotebookEditor,
@IContextMenuService contextMenuService: IContextMenuService,
@IConfigurationService configurationService: IConfigurationService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
) {
super(handler, contextMenuService, configurationService, 'python');
super(notebookEditor, contextMenuService, configurationService, 'python');
}
get templateId() {
......@@ -329,7 +329,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
this.showContextMenu(listIndex, element, e.posx, top + height);
}));
elementDisposable?.add(new CodeCell(this.handler, element, templateData, height));
elementDisposable?.add(new CodeCell(this.notebookEditor, element, templateData, height));
}
disposeTemplate(templateData: CellRenderTemplate): void {
......
......@@ -11,7 +11,7 @@ import { CellRenderTemplate, INotebookEditor } from 'vs/workbench/contrib/notebo
export class CodeCell extends Disposable {
constructor(
handler: INotebookEditor,
notebookEditor: INotebookEditor,
viewCell: CellViewModel,
templateData: CellRenderTemplate,
height: number | undefined
......@@ -19,7 +19,7 @@ export class CodeCell extends Disposable {
super();
let width;
const listDimension = handler.getListDimension();
const listDimension = notebookEditor.getListDimension();
if (listDimension) {
width = listDimension.width - CELL_MARGIN * 2;
} else {
......@@ -27,7 +27,7 @@ export class CodeCell extends Disposable {
}
const lineNum = viewCell.lineCount;
const lineHeight = handler.getFontInfo()?.lineHeight ?? 18;
const lineHeight = notebookEditor.getFontInfo()?.lineHeight ?? 18;
const totalHeight = lineNum * lineHeight;
const model = viewCell.getTextModel();
templateData.editor?.setModel(model);
......@@ -80,9 +80,9 @@ export class CodeCell extends Disposable {
if (viewCell.outputs.length) {
let outputHeight = templateData.outputContainer!.clientHeight;
handler.layoutNotebookCell(viewCell, e.contentHeight + 32 + outputHeight);
notebookEditor.layoutNotebookCell(viewCell, e.contentHeight + 32 + outputHeight);
} else {
handler.layoutNotebookCell(viewCell, e.contentHeight + 16);
notebookEditor.layoutNotebookCell(viewCell, e.contentHeight + 16);
}
}
}
......@@ -93,20 +93,20 @@ export class CodeCell extends Disposable {
let hasDynamicHeight = true;
for (let i = 0; i < viewCell.outputs.length; i++) {
let outputItemDiv = document.createElement('div');
let result = handler.getOutputRenderer().render(viewCell.outputs[i], outputItemDiv);
let result = notebookEditor.getOutputRenderer().render(viewCell.outputs[i], outputItemDiv);
templateData.outputContainer?.appendChild(outputItemDiv);
if (result) {
hasDynamicHeight = hasDynamicHeight || result?.hasDynamicHeight;
if (result.shadowContent) {
hasDynamicHeight = false;
handler.createInset(viewCell, i, result.shadowContent, totalHeight + 8);
notebookEditor.createInset(viewCell, i, result.shadowContent, totalHeight + 8);
}
}
}
if (height !== undefined && hasDynamicHeight) {
let clientHeight = templateData.outputContainer!.clientHeight;
let listDimension = handler.getListDimension();
let listDimension = notebookEditor.getListDimension();
let dimension = listDimension ? {
width: listDimension.width - CELL_MARGIN * 2,
height: clientHeight
......@@ -116,7 +116,7 @@ export class CodeCell extends Disposable {
let height = elementSizeObserver.getHeight();
if (clientHeight !== height) {
viewCell.dynamicHeight = totalHeight + 32 + height;
handler.layoutNotebookCell(viewCell, totalHeight + 32 + height);
notebookEditor.layoutNotebookCell(viewCell, totalHeight + 32 + height);
}
elementSizeObserver.dispose();
......@@ -124,7 +124,7 @@ export class CodeCell extends Disposable {
});
elementSizeObserver.startObserving();
viewCell.dynamicHeight = totalHeight + 32 + clientHeight;
handler.layoutNotebookCell(viewCell, totalHeight + 32 + clientHeight);
notebookEditor.layoutNotebookCell(viewCell, totalHeight + 32 + clientHeight);
this._register(elementSizeObserver);
}
......@@ -135,20 +135,20 @@ export class CodeCell extends Disposable {
let hasDynamicHeight = true;
for (let i = 0; i < viewCell.outputs.length; i++) {
let outputItemDiv = document.createElement('div');
let result = handler.getOutputRenderer().render(viewCell.outputs[i], outputItemDiv);
let result = notebookEditor.getOutputRenderer().render(viewCell.outputs[i], outputItemDiv);
templateData.outputContainer?.appendChild(outputItemDiv);
if (result) {
hasDynamicHeight = hasDynamicHeight || result?.hasDynamicHeight;
if (result.shadowContent) {
hasDynamicHeight = false;
handler.createInset(viewCell, i, result.shadowContent, totalHeight + 8);
notebookEditor.createInset(viewCell, i, result.shadowContent, totalHeight + 8);
}
}
}
if (height !== undefined && hasDynamicHeight) {
let clientHeight = templateData.outputContainer!.clientHeight;
let listDimension = handler.getListDimension();
let listDimension = notebookEditor.getListDimension();
let dimension = listDimension ? {
width: listDimension.width - CELL_MARGIN * 2,
height: clientHeight
......@@ -158,7 +158,7 @@ export class CodeCell extends Disposable {
let height = elementSizeObserver.getHeight();
if (clientHeight !== height) {
viewCell.dynamicHeight = totalHeight + 32 + height;
handler.layoutNotebookCell(viewCell, totalHeight + 32 + height);
notebookEditor.layoutNotebookCell(viewCell, totalHeight + 32 + height);
}
elementSizeObserver.dispose();
......
......@@ -20,7 +20,7 @@ export class StatefullMarkdownCell extends Disposable {
private localDisposables: DisposableStore;
constructor(
handler: INotebookEditor,
notebookEditor: INotebookEditor,
viewCell: CellViewModel,
templateData: CellRenderTemplate,
editorOptions: IEditorOptions,
......@@ -37,7 +37,7 @@ export class StatefullMarkdownCell extends Disposable {
if (viewCell.isEditing) {
// switch to editing mode
let width;
const listDimension = handler.getListDimension();
const listDimension = notebookEditor.getListDimension();
if (listDimension) {
width = listDimension.width - CELL_MARGIN * 2;
} else {
......@@ -45,7 +45,7 @@ export class StatefullMarkdownCell extends Disposable {
}
const lineNum = viewCell.lineCount;
const lineHeight = handler.getFontInfo()?.lineHeight ?? 18;
const lineHeight = notebookEditor.getFontInfo()?.lineHeight ?? 18;
const totalHeight = Math.max(lineNum, 1) * lineHeight;
if (this.editor) {
......@@ -84,7 +84,7 @@ export class StatefullMarkdownCell extends Disposable {
this.cellContainer.appendChild(renderedHTML);
}
handler.layoutNotebookCell(viewCell, realContentHeight + 32 + clientHeight);
notebookEditor.layoutNotebookCell(viewCell, realContentHeight + 32 + clientHeight);
}));
this.localDisposables.add(this.editor.onDidContentSizeChange(e => {
......@@ -98,7 +98,7 @@ export class StatefullMarkdownCell extends Disposable {
}
);
const clientHeight = this.cellContainer.clientHeight;
handler.layoutNotebookCell(viewCell, e.contentHeight + 32 + clientHeight);
notebookEditor.layoutNotebookCell(viewCell, e.contentHeight + 32 + clientHeight);
}
}));
......@@ -126,20 +126,20 @@ export class StatefullMarkdownCell extends Disposable {
this.cellContainer.appendChild(renderedHTML);
this.localDisposables.add(markdownRenderer.onDidUpdateRender(() => {
const clientHeight = this.cellContainer.clientHeight;
handler.layoutNotebookCell(viewCell, clientHeight);
notebookEditor.layoutNotebookCell(viewCell, clientHeight);
}));
}
}
const clientHeight = this.cellContainer.clientHeight;
handler.layoutNotebookCell(viewCell, totalHeight + 32 + clientHeight);
notebookEditor.layoutNotebookCell(viewCell, totalHeight + 32 + clientHeight);
this.editor.focus();
} else {
if (this.editor) {
// switch from editing mode
this.editingContainer!.style.display = 'none';
const clientHeight = this.cellContainer.clientHeight;
handler.layoutNotebookCell(viewCell, clientHeight);
notebookEditor.layoutNotebookCell(viewCell, clientHeight);
} else {
// first time, readonly mode
this.editingContainer!.style.display = 'none';
......@@ -153,7 +153,7 @@ export class StatefullMarkdownCell extends Disposable {
this.localDisposables.add(markdownRenderer.onDidUpdateRender(() => {
const clientHeight = this.cellContainer.clientHeight;
handler.layoutNotebookCell(viewCell, clientHeight);
notebookEditor.layoutNotebookCell(viewCell, clientHeight);
}));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册