Skip to content

Commit

Permalink
Add notebook.editorBackground color customization (microsoft#153255)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah authored Jun 27, 2022
1 parent 3b3469d commit 17b94cf
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { IEditorProgressService, IProgressRunner } from 'vs/platform/progress/co
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { contrastBorder, diffInserted, diffRemoved, editorBackground, errorForeground, focusBorder, foreground, iconForeground, listInactiveSelectionBackground, registerColor, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, textBlockQuoteBackground, textBlockQuoteBorder, textLinkActiveForeground, textLinkForeground, textPreformatForeground, toolbarHoverBackground, transparent } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { PANEL_BORDER, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { EDITOR_PANE_BACKGROUND, PANEL_BORDER, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { debugIconStartForeground } from 'vs/workbench/contrib/debug/browser/debugColors';
import { CellEditState, CellFindMatchWithIndex, CellFocusMode, CellLayoutContext, CellRevealType, IActiveNotebookEditorDelegate, IBaseCellEditorOptions, ICellOutputViewModel, ICellViewModel, ICommonCellInfo, IDisplayOutputLayoutUpdateRequest, IFocusNotebookCellOptions, IInsetRenderOutput, IModelDecorationsChangeAccessor, INotebookDeltaDecoration, INotebookEditor, INotebookEditorContribution, INotebookEditorContributionDescription, INotebookEditorCreationOptions, INotebookEditorDelegate, INotebookEditorMouseEvent, INotebookEditorOptions, INotebookEditorViewState, INotebookViewCellsUpdateEvent, INotebookWebviewMessage, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
Expand Down Expand Up @@ -919,21 +919,21 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
transformOptimization: false, //(isMacintosh && isNative) || getTitleBarStyle(this.configurationService, this.environmentService) === 'native',
styleController: (_suffix: string) => { return this._list; },
overrideStyles: {
listBackground: editorBackground,
listActiveSelectionBackground: editorBackground,
listBackground: notebookEditorBackground,
listActiveSelectionBackground: notebookEditorBackground,
listActiveSelectionForeground: foreground,
listFocusAndSelectionBackground: editorBackground,
listFocusAndSelectionBackground: notebookEditorBackground,
listFocusAndSelectionForeground: foreground,
listFocusBackground: editorBackground,
listFocusBackground: notebookEditorBackground,
listFocusForeground: foreground,
listHoverForeground: foreground,
listHoverBackground: editorBackground,
listHoverBackground: notebookEditorBackground,
listHoverOutline: focusBorder,
listFocusOutline: focusBorder,
listInactiveSelectionBackground: editorBackground,
listInactiveSelectionBackground: notebookEditorBackground,
listInactiveSelectionForeground: foreground,
listInactiveFocusBackground: editorBackground,
listInactiveFocusOutline: editorBackground,
listInactiveFocusBackground: notebookEditorBackground,
listInactiveFocusOutline: notebookEditorBackground,
},
accessibilityProvider: {
getAriaLabel: (element) => {
Expand Down Expand Up @@ -3157,6 +3157,13 @@ export const cellEditorBackground = registerColor('notebook.cellEditorBackground
hcLight: null
}, nls.localize('notebook.cellEditorBackground', "Cell editor background color."));

export const notebookEditorBackground = registerColor('notebook.editorBackground', {
light: EDITOR_PANE_BACKGROUND,
dark: EDITOR_PANE_BACKGROUND,
hcDark: null,
hcLight: null
}, nls.localize('notebook.editorBackground', "Notebook background color."));

registerThemingParticipant((theme, collector) => {
// add css variable rules

Expand Down Expand Up @@ -3234,6 +3241,12 @@ registerThemingParticipant((theme, collector) => {
collector.addRule(`.notebookOverlay .cell-list-top-cell-toolbar-container .action-item { background-color: ${notebookBackground} }`);
}

const notebookBackgroundColor = theme.getColor(notebookEditorBackground);

if (notebookBackgroundColor) {
collector.addRule(`.monaco-workbench .notebookOverlay.notebook-editor { background-color: ${notebookBackgroundColor}; }`);
}

const editorBackgroundColor = theme.getColor(cellEditorBackground) ?? theme.getColor(editorBackground);
if (editorBackgroundColor) {
collector.addRule(`.notebookOverlay .cell .monaco-editor-background,
Expand Down

0 comments on commit 17b94cf

Please sign in to comment.