diff --git a/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.ts b/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.ts index d2f8fe10881f1..2d11b839ffd01 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.ts @@ -4,39 +4,42 @@ *--------------------------------------------------------------------------------------------*/ import * as DOM from 'vs/base/browser/dom'; -import { Disposable } from 'vs/base/common/lifecycle'; import { ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; +import { CellViewModelStateChangeEvent } from 'vs/workbench/contrib/notebook/browser/notebookViewEvents'; +import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart'; +import { BaseCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon'; -export class CellDecorations extends Disposable { +export class CellDecorations extends CellPart { constructor( - rootContainer: HTMLElement, - decorationContainer: HTMLElement, - element: ICellViewModel + readonly rootContainer: HTMLElement, + readonly decorationContainer: HTMLElement, ) { super(); + } + renderCell(element: ICellViewModel, templateData: BaseCellRenderTemplate): void { const removedClassNames: string[] = []; - rootContainer.classList.forEach(className => { + this.rootContainer.classList.forEach(className => { if (/^nb\-.*$/.test(className)) { removedClassNames.push(className); } }); removedClassNames.forEach(className => { - rootContainer.classList.remove(className); + this.rootContainer.classList.remove(className); }); - decorationContainer.innerText = ''; + this.decorationContainer.innerText = ''; const generateCellTopDecorations = () => { - decorationContainer.innerText = ''; + this.decorationContainer.innerText = ''; element.getCellDecorations().filter(options => options.topClassName !== undefined).forEach(options => { - decorationContainer.append(DOM.$(`.${options.topClassName!}`)); + this.decorationContainer.append(DOM.$(`.${options.topClassName!}`)); }); }; - this._register(element.onCellDecorationsChanged((e) => { + templateData.elementDisposables.add(element.onCellDecorationsChanged((e) => { const modified = e.added.find(e => e.topClassName) || e.removed.find(e => e.topClassName); if (modified) { @@ -46,4 +49,13 @@ export class CellDecorations extends Disposable { generateCellTopDecorations(); } + + prepareLayout(): void { + } + + updateInternalLayoutNow(element: ICellViewModel): void { + } + + updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void { + } } diff --git a/src/vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon.ts b/src/vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon.ts index 444cae7b626f4..f8f35de3a858b 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon.ts @@ -98,7 +98,6 @@ export interface BaseCellRenderTemplate { instantiationService: IInstantiationService; container: HTMLElement; cellContainer: HTMLElement; - decorationContainer: HTMLElement; readonly templateDisposables: DisposableStore; readonly elementDisposables: DisposableStore; currentRenderedCell?: ICellViewModel; diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts index 463d3b3b1b1ae..539c77be9bab0 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts @@ -106,7 +106,6 @@ abstract class AbstractCellRenderer { } protected commonRenderElement(element: ICellViewModel, templateData: BaseCellRenderTemplate): void { - templateData.elementDisposables.add(new CellDecorations(templateData.rootContainer, templateData.decorationContainer, element)); } } @@ -170,12 +169,15 @@ export class MarkupCellRenderer extends AbstractCellRenderer implements IListRen const foldedCellHint = templateDisposables.add(scopedInstaService.createInstance(FoldedCellHint, this.notebookEditor, DOM.append(container, $('.notebook-folded-hint')))); const focusIndicator = templateDisposables.add(new CellFocusIndicator(this.notebookEditor, titleToolbar, focusIndicatorTop, focusIndicatorLeft, focusIndicatorRight, focusIndicatorBottom)); + const cellDecorationsPart = templateDisposables.add(new CellDecorations(rootContainer, decorationContainer)); + const cellParts = [ betweenCellToolbar, titleToolbar, statusBar, focusIndicator, foldedCellHint, + cellDecorationsPart, templateDisposables.add(new CollapsedCellInput(this.notebookEditor, cellInputCollapsedContainer)), templateDisposables.add(new CellFocusPart(container, undefined, this.notebookEditor)), templateDisposables.add(new CellDragAndDropPart(container)), @@ -187,7 +189,6 @@ export class MarkupCellRenderer extends AbstractCellRenderer implements IListRen cellInputCollapsedContainer, instantiationService: scopedInstaService, container, - decorationContainer, cellContainer: innerContent, editorPart, editorContainer, @@ -319,6 +320,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende this.notebookEditor)); const focusIndicatorPart = templateDisposables.add(new CellFocusIndicator(this.notebookEditor, titleToolbar, focusIndicatorTop, focusIndicatorLeft, focusIndicatorRight, focusIndicatorBottom)); + const cellDecorationsPart = templateDisposables.add(new CellDecorations(rootContainer, decorationContainer)); const cellParts = [ focusIndicatorPart, templateDisposables.add(scopedInstaService.createInstance(BetweenCellToolbar, this.notebookEditor, titleToolbarContainer, bottomCellToolbarContainer)), @@ -326,6 +328,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende progressBar, titleToolbar, runToolbar, + cellDecorationsPart, templateDisposables.add(new CellExecutionPart(this.notebookEditor, executionOrderLabel)), templateDisposables.add(this.instantiationService.createInstance(CollapsedCellOutput, this.notebookEditor, cellOutputCollapsedContainer)), templateDisposables.add(new CollapsedCellInput(this.notebookEditor, cellInputCollapsedContainer)), @@ -341,7 +344,6 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende cellOutputCollapsedContainer, instantiationService: scopedInstaService, container, - decorationContainer, cellContainer, statusBar, focusSinkElement,