Skip to content

Commit

Permalink
Adds notebook markup font family support (#238734)
Browse files Browse the repository at this point in the history
* edits did this heyo (nb markup font family support)

* setting description includes workbench fallback
  • Loading branch information
Yoyokrazy authored Jan 25, 2025
1 parent e5b5ec4 commit be7d0e0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1256,5 +1256,11 @@ configurationRegistry.registerConfiguration({
type: 'boolean',
default: false
},
[NotebookSetting.markupFontFamily]: {
markdownDescription: nls.localize('notebook.markupFontFamily', "Controls the font family of rendered markup in notebooks. When left blank, this will fall back to the default workbench font family."),
type: 'string',
default: '',
tags: ['notebookLayout']
},
}
});
23 changes: 18 additions & 5 deletions src/vs/workbench/contrib/notebook/browser/notebookOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface NotebookDisplayOptions { // TODO @Yoyokrazy rename to a more ge
'editor.tabSize': number;
'editor.insertSpaces': boolean;
}> | undefined;
markupFontFamily: string;
}

export interface NotebookLayoutConfiguration {
Expand Down Expand Up @@ -108,6 +109,7 @@ export interface NotebookOptionsChangeEvent {
readonly outputLinkifyFilePaths?: boolean;
readonly minimalError?: boolean;
readonly readonly?: boolean;
readonly markupFontFamily?: boolean;
}

const defaultConfigConstants = Object.freeze({
Expand Down Expand Up @@ -213,6 +215,7 @@ export class NotebookOptions extends Disposable {
const outputLineLimit = this.configurationService.getValue<number>(NotebookSetting.textOutputLineLimit) ?? 30;
const linkifyFilePaths = this.configurationService.getValue<boolean>(NotebookSetting.LinkifyOutputFilePaths) ?? true;
const minimalErrors = this.configurationService.getValue<boolean>(NotebookSetting.minimalErrorRendering);
const markupFontFamily = this.configurationService.getValue<string>(NotebookSetting.markupFontFamily);

const editorTopPadding = this._computeEditorTopPadding();

Expand Down Expand Up @@ -259,7 +262,8 @@ export class NotebookOptions extends Disposable {
outputWordWrap: outputWordWrap,
outputLineLimit: outputLineLimit,
outputLinkifyFilePaths: linkifyFilePaths,
outputMinimalError: minimalErrors
outputMinimalError: minimalErrors,
markupFontFamily
};

this._register(this.configurationService.onDidChangeConfiguration(e => {
Expand Down Expand Up @@ -426,6 +430,7 @@ export class NotebookOptions extends Disposable {
const outputWordWrap = e.affectsConfiguration(NotebookSetting.outputWordWrap);
const outputLinkifyFilePaths = e.affectsConfiguration(NotebookSetting.LinkifyOutputFilePaths);
const minimalError = e.affectsConfiguration(NotebookSetting.minimalErrorRendering);
const markupFontFamily = e.affectsConfiguration(NotebookSetting.markupFontFamily);

if (
!cellStatusBarVisibility
Expand Down Expand Up @@ -454,7 +459,8 @@ export class NotebookOptions extends Disposable {
&& !outputScrolling
&& !outputWordWrap
&& !outputLinkifyFilePaths
&& !minimalError) {
&& !minimalError
&& !markupFontFamily) {
return;
}

Expand Down Expand Up @@ -569,6 +575,10 @@ export class NotebookOptions extends Disposable {
configuration.outputMinimalError = this.configurationService.getValue<boolean>(NotebookSetting.minimalErrorRendering);
}

if (markupFontFamily) {
configuration.markupFontFamily = this.configurationService.getValue<string>(NotebookSetting.markupFontFamily);
}

this._layoutConfiguration = Object.freeze(configuration);

// trigger event
Expand Down Expand Up @@ -599,7 +609,8 @@ export class NotebookOptions extends Disposable {
outputScrolling,
outputWordWrap,
outputLinkifyFilePaths,
minimalError
minimalError,
markupFontFamily
});
}

Expand Down Expand Up @@ -814,7 +825,8 @@ export class NotebookOptions extends Disposable {
outputWordWrap: this._layoutConfiguration.outputWordWrap,
outputLineLimit: this._layoutConfiguration.outputLineLimit,
outputLinkifyFilePaths: this._layoutConfiguration.outputLinkifyFilePaths,
minimalError: this._layoutConfiguration.outputMinimalError
minimalError: this._layoutConfiguration.outputMinimalError,
markupFontFamily: this._layoutConfiguration.markupFontFamily
};
}

Expand All @@ -838,7 +850,8 @@ export class NotebookOptions extends Disposable {
outputWordWrap: this._layoutConfiguration.outputWordWrap,
outputLineLimit: this._layoutConfiguration.outputLineLimit,
outputLinkifyFilePaths: false,
minimalError: false
minimalError: false,
markupFontFamily: this._layoutConfiguration.markupFontFamily
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ interface BacklayerWebviewOptions {
readonly outputLineLimit: number;
readonly outputLinkifyFilePaths: boolean;
readonly minimalError: boolean;
readonly markupFontFamily: string;
}


Expand Down Expand Up @@ -281,6 +282,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
key: 'notebook.error.rendererFallbacksExhausted',
comment: ['$0 is a placeholder for the mime type']
}, "Could not render content for '$0'"),
'notebook-markup-font-family': this.options.markupFontFamily,
};
}

Expand Down Expand Up @@ -370,6 +372,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
font-size: var(--notebook-markup-font-size);
line-height: var(--notebook-markdown-line-height);
color: var(--theme-ui-foreground);
font-family: var(--notebook-markup-font-family);
}
#container div.preview.draggable {
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/notebook/common/notebookCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ export const NotebookSetting = {
cellFailureDiagnostics: 'notebook.cellFailureDiagnostics',
outputBackupSizeLimit: 'notebook.backup.sizeLimit',
multiCursor: 'notebook.multiCursor.enabled',
markupFontFamily: 'notebook.markupFontFamily',
} as const;

export const enum CellStatusbarAlignment {
Expand Down

0 comments on commit be7d0e0

Please sign in to comment.