src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts/StatefulMarkdownCell/constructor
class StatefulMarkdownCell:	constructor(
		private readonly notebookEditor: IActiveNotebookEditor,
		private readonly viewCell: MarkupCellViewModel,
		private readonly templateData: MarkdownCellRenderTemplate,
		private editorOptions: IEditorOptions,
		private readonly renderedEditors: Map<ICellViewModel, ICodeEditor | undefined>,
		options: { useRenderer: boolean; },
		@IContextKeyService private readonly contextKeyService: IContextKeyService,
		@INotebookCellStatusBarService readonly notebookCellStatusBarService: INotebookCellStatusBarService,
		@IInstantiationService private readonly instantiationService: IInstantiationService,
	) {
		super();

		this.markdownContainer = templateData.cellContainer;
		this.editorPart = templateData.editorPart;
		this.useRenderer = options.useRenderer;

		if (this.useRenderer) {
			this.templateData.container.classList.toggle('webview-backed-markdown-cell', true);
			this.renderStrategy = new WebviewMarkdownRenderer(this.notebookEditor, this.viewCell);
		} else {
			this.renderStrategy = new BuiltinMarkdownRenderer(this.notebookEditor, this.viewCell, this.templateData.container, this.markdownContainer, () => this.editor);
		}

		this._register(this.renderStrategy);
		this._register(toDisposable(() => renderedEditors.delete(this.viewCell)));

		this._register(viewCell.onDidChangeState((e) => {
			if (e.editStateChanged) {
				this.viewUpdate();
			} else if (e.contentChanged) {
				this.viewUpdate();
			}
		}));

		this._register(viewCell.model.onDidChangeMetadata(() => {
			this.viewUpdate();
		}));

		const updateForFocusMode = () => {
			if (viewCell.focusMode === CellFocusMode.Editor) {
				this.focusEditorIfNeeded();
			}

			templateData.container.classList.toggle('cell-editor-focus', viewCell.focusMode === CellFocusMode.Editor);
		};
		this._register(viewCell.onDidChangeState((e) => {
			if (!e.focusModeChanged) {
				return;
			}

			updateForFocusMode();
		}));
		updateForFocusMode();

		this.foldingState = viewCell.foldingState;
		this.setFoldingIndicator();
		this.updateFoldingIconShowClass();

		this._register(this.notebookEditor.notebookOptions.onDidChangeOptions(e => {
			if (e.showFoldingControls) {
				this.updateFoldingIconShowClass();
			}
		}));

		this._register(viewCell.onDidChangeState((e) => {
			if (!e.foldingStateChanged) {
				return;
			}

			const foldingState = viewCell.foldingState;

			if (foldingState !== this.foldingState) {
				this.foldingState = foldingState;
				this.setFoldingIndicator();
			}
		}));

		this._register(viewCell.onDidChangeLayout((e) => {
			const layoutInfo = this.editor?.getLayoutInfo();
			if (e.outerWidth && this.viewCell.getEditState() === CellEditState.Editing && layoutInfo && layoutInfo.width !== viewCell.layoutInfo.editorWidth) {
				this.onCellEditorWidthChange();
			} else if (e.totalHeight || e.outerWidth) {
				this.relayoutCell();
			}
		}));

		if (this.useRenderer) {
			// the markdown preview's height might already be updated after the renderer calls `element.getHeight()`
			if (this.viewCell.layoutInfo.totalHeight > 0) {
				this.relayoutCell();
			}
		}

		// apply decorations

		this._register(viewCell.onCellDecorationsChanged((e) => {
			e.added.forEach(options => {
				if (options.className) {
					if (this.useRenderer) {
						this.notebookEditor.deltaCellOutputContainerClassNames(this.viewCell.id, [options.className], []);
					} else {
						templateData.rootContainer.classList.add(options.className);
					}
				}
			});

			e.removed.forEach(options => {
				if (options.className) {
					if (this.useRenderer) {
						this.notebookEditor.deltaCellOutputContainerClassNames(this.viewCell.id, [], [options.className]);
					} else {
						templateData.rootContainer.classList.remove(options.className);
					}
				}
			});
		}));

		viewCell.getCellDecorations().forEach(options => {
			if (options.className) {
				if (this.useRenderer) {
					this.notebookEditor.deltaCellOutputContainerClassNames(this.viewCell.id, [options.className], []);
				} else {
					templateData.rootContainer.classList.add(options.className);
				}
			}
		});

		this.viewUpdate();
	}