notebookEditor.ts 19.6 KB
Newer Older
P
Peng Lyu 已提交
1 2 3 4 5 6 7 8 9 10 11
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import 'vs/css!./notebook';
import * as DOM from 'vs/base/browser/dom';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IStorageService } from 'vs/platform/storage/common/storage';
P
Peng Lyu 已提交
12
import { NotebookEditorInput, ICell, NotebookEditorModel, IOutput } from 'vs/workbench/contrib/notebook/browser/notebookEditorInput';
P
Peng Lyu 已提交
13 14 15 16
import { EditorOptions } from 'vs/workbench/common/editor';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
P
Peng Lyu 已提交
17
import { CodeEditorWidget, ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditorWidget';
P
Peng Lyu 已提交
18 19 20 21 22
import * as marked from 'vs/base/common/marked/marked';
import { IModelService } from 'vs/editor/common/services/modelService';
import { URI } from 'vs/base/common/uri';
import { IModeService } from 'vs/editor/common/services/modeService';
import { deepClone } from 'vs/base/common/objects';
P
Peng Lyu 已提交
23
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
P
Peng Lyu 已提交
24
import { getExtraColor } from 'vs/workbench/contrib/welcome/walkThrough/common/walkThroughUtils';
P
Peng Lyu 已提交
25 26 27
import { textLinkForeground, textLinkActiveForeground, focusBorder, textPreformatForeground, contrastBorder, textBlockQuoteBackground, textBlockQuoteBorder, editorBackground, foreground } from 'vs/platform/theme/common/colorRegistry';
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { WorkbenchList } from 'vs/platform/list/browser/listService';
28 29
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { getZoomLevel } from 'vs/base/browser/browser';
P
Peng Lyu 已提交
30 31 32 33
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Action } from 'vs/base/common/actions';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IEditorContributionDescription } from 'vs/editor/browser/editorExtensions';
P
Peng Lyu 已提交
34 35 36 37
import { MenuPreventer } from 'vs/workbench/contrib/codeEditor/browser/menuPreventer';
import { SuggestController } from 'vs/editor/contrib/suggest/suggestController';
import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2';
import { TabCompletionController } from 'vs/workbench/contrib/snippets/browser/tabCompletion';
P
Peng Lyu 已提交
38
import { handleANSIOutput } from 'vs/workbench/contrib/notebook/browser/output';
P
Peng Lyu 已提交
39 40 41

const $ = DOM.$;

P
Peng Lyu 已提交
42 43

interface NotebookHandler {
P
Peng Lyu 已提交
44
	insertEmptyNotebookCell(cell: ICell | IOutput, direction: 'above' | 'below'): void;
P
Peng Lyu 已提交
45
	deleteNotebookCell(cell: ICell): void;
P
Peng Lyu 已提交
46 47
}

P
Peng Lyu 已提交
48 49
interface CellRenderTemplate {
	cellContainer: HTMLElement;
P
Peng Lyu 已提交
50 51
	menuContainer?: HTMLElement;
	outputContainer?: HTMLElement;
52
	renderer?: marked.Renderer; // TODO this can be cached
53
	editor?: CodeEditorWidget;
P
Peng Lyu 已提交
54 55
}

P
Peng Lyu 已提交
56
export class NotebookCellListDelegate implements IListVirtualDelegate<ICell | IOutput> {
57
	private _lineHeight: number;
P
Peng Lyu 已提交
58 59 60
	constructor(
		@IConfigurationService private readonly configurationService: IConfigurationService
	) {
61 62 63
		const editorOptions = this.configurationService.getValue<IEditorOptions>('editor');

		this._lineHeight = BareFontInfo.createFromRawSettings(editorOptions, getZoomLevel()).lineHeight;
P
Peng Lyu 已提交
64 65
	}

P
Peng Lyu 已提交
66
	getHeight(element: ICell | IOutput): number {
67
		if (element.cell_type === 'markdown') {
P
Peng Lyu 已提交
68 69
			return 100;
		} else {
P
Peng Lyu 已提交
70
			return Math.max(element.source.length + 1, 5) * this._lineHeight + 16;
P
Peng Lyu 已提交
71 72 73
		}
	}

P
Peng Lyu 已提交
74 75
	hasDynamicHeight(element: ICell | IOutput): boolean {
		return true;
P
Peng Lyu 已提交
76 77
	}

P
Peng Lyu 已提交
78 79
	getTemplateId(element: ICell | IOutput): string {

80
		if (element.cell_type === 'markdown') {
P
Peng Lyu 已提交
81 82 83 84 85 86 87
			return MarkdownCellRenderer.TEMPLATE_ID;
		} else {
			return CodeCellRenderer.TEMPLATE_ID;
		}
	}
}

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
class AbstractCellRenderer {
	constructor(
		private handler: NotebookHandler,
		private contextMenuService: IContextMenuService
	) { }

	showContextMenu(element: ICell, x: number, y: number) {
		const actions: Action[] = [];
		const insertAbove = new Action(
			'workbench.notebook.code.insertCellAbove',
			'Insert Code Cell Above',
			undefined,
			true,
			async () => {
				this.handler.insertEmptyNotebookCell(element, 'above');
			}
		);

		const insertBelow = new Action(
			'workbench.notebook.code.insertCellBelow',
			'Insert Code Cell Below',
			undefined,
			true,
			async () => {
				this.handler.insertEmptyNotebookCell(element, 'below');
			}
		);

P
Peng Lyu 已提交
116 117 118 119 120 121 122 123 124 125
		const deleteCell = new Action(
			'workbench.notebook.deleteCell',
			'Delete Cell',
			undefined,
			true,
			async () => {
				this.handler.deleteNotebookCell(element);
			}
		);

126 127
		actions.push(insertAbove);
		actions.push(insertBelow);
P
Peng Lyu 已提交
128
		actions.push(deleteCell);
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144

		this.contextMenuService.showContextMenu({
			getAnchor: () => {
				return {
					x,
					y
				};
			},
			getActions: () => {
				return actions;
			},
			autoSelectFirstItem: true
		});
	}
}

P
Peng Lyu 已提交
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
export class OutputCellRenderer extends AbstractCellRenderer implements IListRenderer<ICell | IOutput, CellRenderTemplate> {
	static readonly TEMPLATE_ID = 'output_cell';

	constructor(
		handler: NotebookHandler,
		@IContextMenuService contextMenuService: IContextMenuService
	) {
		super(handler, contextMenuService);
	}

	get templateId() {
		return OutputCellRenderer.TEMPLATE_ID;
	}

	renderTemplate(container: HTMLElement): CellRenderTemplate {
		const innerContent = document.createElement('div');
		DOM.addClasses(innerContent, 'cell', 'output');
		const renderer = new marked.Renderer();
		container.appendChild(innerContent);

		const action = document.createElement('div');
		DOM.addClasses(action, 'menu', 'codicon-settings-gear', 'codicon');
		container.appendChild(action);

		return {
			cellContainer: innerContent,
			menuContainer: action,
			renderer: renderer
		};
	}

	renderElement(element: IOutput, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
		if (element.output_type === 'stream') {
			templateData.cellContainer.innerText = element.text;
P
Peng Lyu 已提交
179 180 181 182 183
		} else if (element.output_type === 'error') {
			const evalue = document.createElement('div');
			DOM.addClasses(evalue, 'error_message');
			evalue.innerText = element.evalue;
			templateData.cellContainer.appendChild(evalue);
P
Peng Lyu 已提交
184 185 186 187 188 189 190 191 192
		}
	}

	disposeTemplate(templateData: CellRenderTemplate): void {
		// throw nerendererw Error('Method not implemented.');
	}
}

export class MarkdownCellRenderer extends AbstractCellRenderer implements IListRenderer<ICell | IOutput, CellRenderTemplate> {
P
Peng Lyu 已提交
193
	static readonly TEMPLATE_ID = 'markdown_cell';
194
	private disposables: Map<HTMLElement, IDisposable> = new Map();
P
Peng Lyu 已提交
195 196

	constructor(
197 198
		handler: NotebookHandler,
		@IContextMenuService contextMenuService: IContextMenuService
P
Peng Lyu 已提交
199
	) {
200
		super(handler, contextMenuService);
P
Peng Lyu 已提交
201
	}
P
Peng Lyu 已提交
202 203 204 205 206 207 208 209 210 211 212

	get templateId() {
		return MarkdownCellRenderer.TEMPLATE_ID;
	}

	renderTemplate(container: HTMLElement): CellRenderTemplate {
		const innerContent = document.createElement('div');
		DOM.addClasses(innerContent, 'cell', 'markdown');
		const renderer = new marked.Renderer();
		container.appendChild(innerContent);

P
Peng Lyu 已提交
213 214 215 216
		const action = document.createElement('div');
		DOM.addClasses(action, 'menu', 'codicon-settings-gear', 'codicon');
		container.appendChild(action);

P
Peng Lyu 已提交
217 218
		return {
			cellContainer: innerContent,
P
Peng Lyu 已提交
219
			menuContainer: action,
P
Peng Lyu 已提交
220 221 222 223
			renderer: renderer
		};
	}

P
Peng Lyu 已提交
224
	renderElement(element: ICell | IOutput, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
225
		templateData.cellContainer.innerHTML = marked(element.source.join(''), { renderer: templateData.renderer });
P
Peng Lyu 已提交
226
		let disposable = this.disposables.get(templateData.menuContainer!);
227 228 229

		if (disposable) {
			disposable.dispose();
P
Peng Lyu 已提交
230
			this.disposables.delete(templateData.menuContainer!);
231
		}
P
Peng Lyu 已提交
232

P
Peng Lyu 已提交
233 234
		let listener = DOM.addStandardDisposableListener(templateData.menuContainer!, 'mousedown', e => {
			const { top, height } = DOM.getDomNodePagePosition(templateData.menuContainer!);
P
Peng Lyu 已提交
235 236
			e.preventDefault();

237
			this.showContextMenu(element, e.posx, top + height);
P
Peng Lyu 已提交
238 239
		});

P
Peng Lyu 已提交
240
		this.disposables.set(templateData.menuContainer!, listener);
P
Peng Lyu 已提交
241 242 243 244 245 246 247
	}

	disposeTemplate(templateData: CellRenderTemplate): void {
		// throw nerendererw Error('Method not implemented.');
	}
}

P
Peng Lyu 已提交
248
export class CodeCellRenderer extends AbstractCellRenderer implements IListRenderer<ICell | IOutput, CellRenderTemplate> {
P
Peng Lyu 已提交
249 250
	static readonly TEMPLATE_ID = 'code_cell';
	private editorOptions: IEditorOptions;
P
Peng Lyu 已提交
251
	private widgetOptions: ICodeEditorWidgetOptions;
P
Peng Lyu 已提交
252
	private disposables: Map<ICell, IDisposable> = new Map();
P
Peng Lyu 已提交
253 254

	constructor(
255 256
		handler: NotebookHandler,
		@IContextMenuService contextMenuService: IContextMenuService,
P
Peng Lyu 已提交
257 258 259
		@IConfigurationService private readonly configurationService: IConfigurationService,
		@IInstantiationService private readonly instantiationService: IInstantiationService,
		@IModelService private readonly modelService: IModelService,
P
Peng Lyu 已提交
260 261
		@IModeService private readonly modeService: IModeService,
		@IThemeService private readonly themeService: IThemeService
P
Peng Lyu 已提交
262
	) {
263 264
		super(handler, contextMenuService);

P
Peng Lyu 已提交
265
		const language = 'python';
P
Peng Lyu 已提交
266 267 268 269 270 271 272 273 274 275 276 277
		const editorOptions = deepClone(this.configurationService.getValue<IEditorOptions>('editor', { overrideIdentifier: language }));
		this.editorOptions = {
			...editorOptions,
			scrollBeyondLastLine: false,
			scrollbar: {
				verticalScrollbarSize: 14,
				horizontal: 'auto',
				useShadows: true,
				verticalHasArrows: false,
				horizontalHasArrows: false
			},
			overviewRulerLanes: 3,
P
Peng Lyu 已提交
278
			fixedOverflowWidgets: false,
P
Peng Lyu 已提交
279 280 281 282
			lineNumbersMinChars: 1,
			minimap: { enabled: false },
		};

P
Peng Lyu 已提交
283
		this.widgetOptions = this.getSimpleCodeEditorWidgetOptions();
P
Peng Lyu 已提交
284 285 286 287 288 289 290 291 292 293
	}

	get templateId() {
		return CodeCellRenderer.TEMPLATE_ID;
	}

	renderTemplate(container: HTMLElement): CellRenderTemplate {
		const innerContent = document.createElement('div');
		DOM.addClasses(innerContent, 'cell', 'code');
		container.appendChild(innerContent);
294 295 296 297 298 299
		const editor = this.instantiationService.createInstance(CodeEditorWidget, innerContent, {
			...this.editorOptions,
			dimension: {
				width: 0,
				height: 0
			}
P
Peng Lyu 已提交
300
		}, {});
P
Peng Lyu 已提交
301 302 303
		const action = document.createElement('div');
		DOM.addClasses(action, 'menu', 'codicon-settings-gear', 'codicon');
		container.appendChild(action);
P
Peng Lyu 已提交
304

P
Peng Lyu 已提交
305 306 307 308
		const outputContainer = document.createElement('div');
		DOM.addClasses(outputContainer, 'output');
		container.appendChild(outputContainer);

P
Peng Lyu 已提交
309
		return {
310
			cellContainer: innerContent,
P
Peng Lyu 已提交
311
			menuContainer: action,
P
Peng Lyu 已提交
312
			outputContainer: outputContainer,
313
			editor
P
Peng Lyu 已提交
314 315 316
		};
	}

317
	renderElement(element: ICell, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
P
Peng Lyu 已提交
318 319
		const innerContent = templateData.cellContainer;
		const width = innerContent.clientWidth;
320
		const lineNum = element.source.length;
P
Peng Lyu 已提交
321
		const totalHeight = Math.max(lineNum + 1, 5) * 21;
322
		const resource = URI.parse(`notebookcell-${index}-${Date.now()}.py`);
P
Peng Lyu 已提交
323

324
		const model = this.modelService.createModel(element.source.join(''), this.modeService.createByFilepathOrFirstLine(resource), resource, false);
325 326 327 328 329
		templateData.editor?.setModel(model);
		templateData.editor?.layout(
			{
				width: width,
				height: totalHeight
P
Peng Lyu 已提交
330
			}
331
		);
P
Peng Lyu 已提交
332

P
Peng Lyu 已提交
333 334
		let listener = DOM.addStandardDisposableListener(templateData.menuContainer!, 'mousedown', e => {
			const { top, height } = DOM.getDomNodePagePosition(templateData.menuContainer!);
P
Peng Lyu 已提交
335 336
			e.preventDefault();

337
			this.showContextMenu(element, e.posx, top + height);
P
Peng Lyu 已提交
338 339 340 341
		});

		this.disposables.set(element, listener);

P
Peng Lyu 已提交
342 343 344 345 346 347 348 349 350 351
		if (templateData.outputContainer) {
			templateData.outputContainer!.innerHTML = '';
		}

		if (element.outputs.length > 0) {
			for (let i = 0; i < element.outputs.length; i++) {
				const outputNode = document.createElement('div');
				if (element.outputs[i].output_type === 'stream') {
					outputNode.innerText = element.outputs[i].text;
				} else {
P
Peng Lyu 已提交
352 353 354 355
					const evalue = document.createElement('div');
					DOM.addClasses(evalue, 'error_message');
					evalue.innerText = element.outputs[i].evalue;
					outputNode.appendChild(evalue);
P
Peng Lyu 已提交
356
					const traceback = document.createElement('pre');
P
Peng Lyu 已提交
357 358 359 360 361 362 363
					DOM.addClasses(traceback, 'traceback');
					if (element.outputs[i].traceback) {
						for (let j = 0; j < element.outputs[i].traceback.length; j++) {
							traceback.appendChild(handleANSIOutput(element.outputs[i].traceback[j], this.themeService));
							outputNode.appendChild(traceback);
						}
					}
P
Peng Lyu 已提交
364 365 366 367 368 369
				}

				templateData.outputContainer?.appendChild(outputNode);
			}
		}

P
Peng Lyu 已提交
370 371 372 373 374
	}

	disposeTemplate(templateData: CellRenderTemplate): void {
		// throw nerendererw Error('Method not implemented.');
	}
P
Peng Lyu 已提交
375

P
Peng Lyu 已提交
376 377 378 379 380 381 382 383 384 385

	disposeElement(element: ICell, index: number, templateData: CellRenderTemplate, height: number | undefined): void {
		let disposable = this.disposables.get(element);

		if (disposable) {
			disposable.dispose();
			this.disposables.delete(element);
		}
	}

P
Peng Lyu 已提交
386 387 388
	getSimpleCodeEditorWidgetOptions(): ICodeEditorWidgetOptions {
		return {
			isSimpleWidget: false,
P
Peng Lyu 已提交
389 390 391 392 393 394 395
			contributions: <IEditorContributionDescription[]>[
				{ id: MenuPreventer.ID, ctor: MenuPreventer },
				{ id: SuggestController.ID, ctor: SuggestController },
				// { id: ModesHoverController.ID, ctor: ModesHoverController },
				{ id: SnippetController2.ID, ctor: SnippetController2 },
				{ id: TabCompletionController.ID, ctor: TabCompletionController },
			]
P
Peng Lyu 已提交
396 397
		};
	}
P
Peng Lyu 已提交
398 399
}

P
Peng Lyu 已提交
400 401

export class NotebookEditor extends BaseEditor implements NotebookHandler {
P
Peng Lyu 已提交
402 403 404
	static readonly ID: string = 'workbench.editor.notebook';
	private rootElement!: HTMLElement;
	private body!: HTMLElement;
P
Peng Lyu 已提交
405
	private list: WorkbenchList<ICell | IOutput> | undefined;
P
Peng Lyu 已提交
406
	private model: NotebookEditorModel | undefined;
P
Peng Lyu 已提交
407 408 409 410 411

	constructor(
		@ITelemetryService telemetryService: ITelemetryService,
		@IThemeService themeService: IThemeService,
		@IInstantiationService private readonly instantiationService: IInstantiationService,
P
Peng Lyu 已提交
412
		@IStorageService storageService: IStorageService
P
Peng Lyu 已提交
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
	) {
		super(NotebookEditor.ID, telemetryService, themeService, storageService);
	}
	get minimumWidth(): number { return 375; }
	get maximumWidth(): number { return Number.POSITIVE_INFINITY; }

	// these setters need to exist because this extends from BaseEditor
	set minimumWidth(value: number) { /*noop*/ }
	set maximumWidth(value: number) { /*noop*/ }


	protected createEditor(parent: HTMLElement): void {
		this.rootElement = DOM.append(parent, $('.notebook-editor'));
		this.createBody(this.rootElement);
	}

	private createBody(parent: HTMLElement): void {
		this.body = document.createElement('div'); //DOM.append(parent, $('.notebook-body'));
P
Peng Lyu 已提交
431 432 433
		DOM.addClass(this.body, 'cell-list-container');
		this.createCellList();
		DOM.append(parent, this.body);
P
Peng Lyu 已提交
434 435
	}

P
Peng Lyu 已提交
436 437
	private createCellList(): void {
		DOM.addClass(this.body, 'cell-list-container');
P
Peng Lyu 已提交
438

P
Peng Lyu 已提交
439
		const renders = [
P
Peng Lyu 已提交
440
			// this.instantiationService.createInstance(OutputCellRenderer, this),
P
Peng Lyu 已提交
441 442
			this.instantiationService.createInstance(MarkdownCellRenderer, this),
			this.instantiationService.createInstance(CodeCellRenderer, this)
P
Peng Lyu 已提交
443 444
		];

445
		this.list = this.instantiationService.createInstance<typeof WorkbenchList, WorkbenchList<ICell>>(
P
Peng Lyu 已提交
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
			WorkbenchList,
			'NotebookCellList',
			this.body,
			this.instantiationService.createInstance(NotebookCellListDelegate),
			renders,
			{
				setRowLineHeight: false,
				supportDynamicHeights: true,
				horizontalScrolling: false,
				keyboardSupport: false,
				mouseSupport: false,
				multipleSelectionSupport: false,
				overrideStyles: {
					listBackground: editorBackground,
					listActiveSelectionBackground: editorBackground,
					listActiveSelectionForeground: foreground,
					listFocusAndSelectionBackground: editorBackground,
					listFocusAndSelectionForeground: foreground,
					listFocusBackground: editorBackground,
					listFocusForeground: foreground,
					listHoverForeground: foreground,
					listHoverBackground: editorBackground,
468 469
					listHoverOutline: focusBorder,
					listFocusOutline: focusBorder,
470 471 472 473
					listInactiveSelectionBackground: editorBackground,
					listInactiveSelectionForeground: foreground,
					listInactiveFocusBackground: editorBackground,
					listInactiveFocusOutline: editorBackground,
P
Peng Lyu 已提交
474 475 476 477
				}
			}
		);
	}
P
Peng Lyu 已提交
478

P
Peng Lyu 已提交
479
	setInput(input: NotebookEditorInput, options: EditorOptions | undefined, token: CancellationToken): Promise<void> {
480 481 482 483 484
		return super.setInput(input, options, token)
			.then(() => {
				return input.resolve();
			})
			.then(model => {
P
Peng Lyu 已提交
485 486 487 488
				if (this.model !== undefined && this.model.textModel === model.textModel) {
					return;
				}

P
Peng Lyu 已提交
489
				this.model = model;
P
Peng Lyu 已提交
490 491
				let cells = model.getNookbook().cells;
				this.list?.splice(0, this.list?.length, cells);
492 493
				this.list?.layout();
			});
P
Peng Lyu 已提交
494 495
	}

P
Peng Lyu 已提交
496 497 498
	insertEmptyNotebookCell(cell: ICell, direction: 'above' | 'below') {
		let newCell: ICell = {
			source: [],
P
Peng Lyu 已提交
499 500
			cell_type: 'code',
			outputs: []
P
Peng Lyu 已提交
501 502 503 504 505 506 507 508 509
		};

		let index = this.model!.getNookbook().cells.indexOf(cell);
		const insertIndex = direction === 'above' ? index : index + 1;

		this.model!.getNookbook().cells.splice(insertIndex, 0, newCell);
		this.list?.splice(insertIndex, 0, [newCell]);
	}

P
Peng Lyu 已提交
510 511 512 513 514 515 516 517
	deleteNotebookCell(cell: ICell) {
		let index = this.model!.getNookbook().cells.indexOf(cell);

		this.model!.getNookbook().cells.splice(index, 1);
		this.list?.splice(index, 1);
	}


P
Peng Lyu 已提交
518 519 520
	layout(dimension: DOM.Dimension): void {
		DOM.toggleClass(this.rootElement, 'mid-width', dimension.width < 1000 && dimension.width >= 600);
		DOM.toggleClass(this.rootElement, 'narrow-width', dimension.width < 600);
521
		DOM.size(this.body, dimension.width - 20, dimension.height);
522
		this.list?.layout(dimension.height, dimension.width - 20);
P
Peng Lyu 已提交
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
	}
}

const embeddedEditorBackground = 'walkThrough.embeddedEditorBackground';

registerThemingParticipant((theme, collector) => {
	const color = getExtraColor(theme, embeddedEditorBackground, { dark: 'rgba(0, 0, 0, .4)', extra_dark: 'rgba(200, 235, 255, .064)', light: '#f4f4f4', hc: null });
	if (color) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor .monaco-editor-background,
			.monaco-workbench .part.editor > .content .notebook-editor .margin-view-overlays { background: ${color}; }`);
	}
	const link = theme.getColor(textLinkForeground);
	if (link) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor a { color: ${link}; }`);
	}
	const activeLink = theme.getColor(textLinkActiveForeground);
	if (activeLink) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor a:hover,
			.monaco-workbench .part.editor > .content .notebook-editor a:active { color: ${activeLink}; }`);
	}
	const focusColor = theme.getColor(focusBorder);
	if (focusColor) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor a:focus { outline-color: ${focusColor}; }`);
	}
	const shortcut = theme.getColor(textPreformatForeground);
	if (shortcut) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor code,
			.monaco-workbench .part.editor > .content .notebook-editor .shortcut { color: ${shortcut}; }`);
	}
	const border = theme.getColor(contrastBorder);
	if (border) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor .monaco-editor { border-color: ${border}; }`);
	}
	const quoteBackground = theme.getColor(textBlockQuoteBackground);
	if (quoteBackground) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor blockquote { background: ${quoteBackground}; }`);
	}
	const quoteBorder = theme.getColor(textBlockQuoteBorder);
	if (quoteBorder) {
		collector.addRule(`.monaco-workbench .part.editor > .content .notebook-editor blockquote { border-color: ${quoteBorder}; }`);
	}
});