Add setting to customize notebook markdown preview line height (#13923)

* add md preview line height settings

* remove if condition

* listen for configuration change

* change setting description

* only change line height outside of edit mode

* set minimum line height to 1

* combine ondidchangeconfiguration callbacks
This commit is contained in:
Lucy Zhang
2021-01-08 14:45:26 -08:00
committed by GitHub
parent df51f35be0
commit 569be8eb24
2 changed files with 13 additions and 2 deletions

View File

@@ -95,6 +95,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
private markdownRenderer: NotebookMarkdownRenderer;
private markdownResult: IMarkdownRenderResult;
private _htmlMarkdownConverter: HTMLMarkdownConverter;
private markdownPreviewLineHeight: number;
public readonly onDidClickLink = this._onDidClickLink.event;
public previewFeaturesEnabled: boolean = false;
public doubleClickEditEnabled: boolean;
@@ -110,6 +111,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
super();
this.markdownRenderer = this._instantiationService.createInstance(NotebookMarkdownRenderer);
this.doubleClickEditEnabled = this._configurationService.getValue('notebook.enableDoubleClickEdit');
this.markdownPreviewLineHeight = this._configurationService.getValue('notebook.markdownPreviewLineHeight');
this._register(toDisposable(() => {
if (this.markdownResult) {
this.markdownResult.dispose();
@@ -117,9 +119,11 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
}));
this._register(this._configurationService.onDidChangeConfiguration(e => {
this.previewFeaturesEnabled = this._configurationService.getValue('workbench.enablePreviewFeatures');
}));
this._register(this._configurationService.onDidChangeConfiguration(e => {
this.doubleClickEditEnabled = this._configurationService.getValue('notebook.enableDoubleClickEdit');
if (e.affectsConfiguration('notebook.markdownPreviewLineHeight')) {
this.markdownPreviewLineHeight = this._configurationService.getValue('notebook.markdownPreviewLineHeight');
this.updatePreview();
}
}));
}
@@ -237,6 +241,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
if (this._previewMode) {
let outputElement = <HTMLElement>this.output.nativeElement;
outputElement.innerHTML = this.markdownResult.element.innerHTML;
outputElement.style.lineHeight = this.markdownPreviewLineHeight.toString();
this.cellModel.renderedOutputTextContent = this.getRenderedTextOutput();
outputElement.focus();
}

View File

@@ -231,6 +231,12 @@ configurationRegistry.registerConfiguration({
'default': false,
'description': localize('notebook.saveConnectionName', "(Preview) Save connection name in notebook metadata.")
},
'notebook.markdownPreviewLineHeight': {
'type': 'number',
'default': 1.5,
'minimum': 1,
'description': localize('notebook.markdownPreviewLineHeight', "Controls the line height used in the notebook markdown preview. This number is relative to the font size.")
}
}
});