提交 0ae60c45 编写于 作者: R Rob Lourens

Make markdown cell height computation simpler and fix bottom cell toolbar height discrepancy

上级 d7417482
......@@ -12,7 +12,7 @@ export const CELL_MARGIN = 20;
export const CELL_RUN_GUTTER = 32;
export const EDITOR_TOOLBAR_HEIGHT = 0;
export const BOTTOM_CELL_TOOLBAR_HEIGHT = 36;
export const BOTTOM_CELL_TOOLBAR_HEIGHT = 32;
export const CELL_STATUSBAR_HEIGHT = 22;
// Top margin of editor
......
......@@ -368,7 +368,6 @@
border-left-width: 2px;
border-left-style: solid;
top: 22px;
bottom: 36px;
visibility: hidden;
opacity: 0.6;
}
......
......@@ -94,7 +94,6 @@ export interface MarkdownCellLayoutChangeEvent {
font?: BareFontInfo;
outerWidth?: number;
totalHeight?: number;
editorHeight?: boolean;
}
export interface ICellViewModel {
......
......@@ -27,7 +27,7 @@ import { contrastBorder, editorBackground, focusBorder, foreground, registerColo
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorOptions, IEditorMemento } from 'vs/workbench/common/editor';
import { CELL_MARGIN, CELL_RUN_GUTTER, EDITOR_BOTTOM_PADDING, EDITOR_TOP_MARGIN, EDITOR_TOP_PADDING, SCROLLABLE_ELEMENT_PADDING_TOP } from 'vs/workbench/contrib/notebook/browser/constants';
import { CELL_MARGIN, CELL_RUN_GUTTER, EDITOR_BOTTOM_PADDING, EDITOR_TOP_MARGIN, EDITOR_TOP_PADDING, SCROLLABLE_ELEMENT_PADDING_TOP, BOTTOM_CELL_TOOLBAR_HEIGHT } from 'vs/workbench/contrib/notebook/browser/constants';
import { CellEditState, CellFocusMode, ICellRange, ICellViewModel, INotebookCellList, INotebookEditor, INotebookEditorContribution, INotebookEditorMouseEvent, NotebookLayoutInfo, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_RUNNABLE, NOTEBOOK_HAS_MULTIPLE_KERNELS } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
import { NotebookCellList } from 'vs/workbench/contrib/notebook/browser/view/notebookCellList';
......@@ -1405,5 +1405,5 @@ registerThemingParticipant((theme, collector) => {
collector.addRule(`.notebookOverlay .cell .run-button-container { width: ${CELL_RUN_GUTTER}px; }`);
collector.addRule(`.notebookOverlay > .cell-list-container > .cell-list-insertion-indicator { left: ${CELL_MARGIN + CELL_RUN_GUTTER}px; right: ${CELL_MARGIN}px; }`);
collector.addRule(`.notebookOverlay .cell-drag-image .cell-editor-container > div { padding: ${EDITOR_TOP_PADDING}px 16px ${EDITOR_BOTTOM_PADDING}px 16px; }`);
collector.addRule(`.notebookOverlay .monaco-list .monaco-list-row .notebook-cell-focus-indicator { left: ${CELL_MARGIN}px; }`);
collector.addRule(`.notebookOverlay .monaco-list .monaco-list-row .notebook-cell-focus-indicator { left: ${CELL_MARGIN}px; bottom: ${BOTTOM_CELL_TOOLBAR_HEIGHT}px; }`);
});
......@@ -10,9 +10,8 @@ import { renderCodicons } from 'vs/base/common/codicons';
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { ITextModel } from 'vs/editor/common/model';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { EDITOR_BOTTOM_PADDING, EDITOR_TOP_PADDING, CELL_STATUSBAR_HEIGHT } from 'vs/workbench/contrib/notebook/browser/constants';
import { EDITOR_BOTTOM_PADDING, EDITOR_TOP_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
import { CellEditState, CellFocusMode, INotebookEditor, MarkdownCellRenderTemplate, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellFoldingState } from 'vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel';
import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel';
......@@ -125,7 +124,7 @@ export class StatefullMarkdownCell extends Disposable {
this.viewCell.attachTextEditor(this.editor);
this.focusEditorIfNeeded();
this.bindEditorListeners(this.editor.getModel()!);
this.bindEditorListeners();
} else {
const width = this.viewCell.layoutInfo.editorWidth;
const lineNum = this.viewCell.lineCount;
......@@ -175,22 +174,13 @@ export class StatefullMarkdownCell extends Disposable {
this.focusEditorIfNeeded();
}
this.bindEditorListeners(model, {
width: width,
height: editorHeight
});
this.bindEditorListeners();
const clientHeight = this.markdownContainer.clientHeight;
const totalHeight = editorHeight + 32 + clientHeight + CELL_STATUSBAR_HEIGHT;
this.viewCell.totalHeight = totalHeight;
this.notebookEditor.layoutNotebookCell(this.viewCell, totalHeight);
this.viewCell.editorHeight = editorHeight;
});
}
const clientHeight = this.markdownContainer.clientHeight;
const totalHeight = editorHeight + 32 + clientHeight + CELL_STATUSBAR_HEIGHT;
this.viewCell.totalHeight = totalHeight;
this.notebookEditor.layoutNotebookCell(this.viewCell, totalHeight);
this.viewCell.editorHeight = editorHeight;
this.focusEditorIfNeeded();
this.renderedEditors.set(this.viewCell, this.editor!);
}
......@@ -288,7 +278,7 @@ export class StatefullMarkdownCell extends Disposable {
}
}
private bindEditorListeners(model: ITextModel, dimension?: IDimension) {
private bindEditorListeners() {
this.localDisposables.add(this.editor!.onDidContentSizeChange(e => {
let viewLayout = this.editor!.getLayoutInfo();
......@@ -299,9 +289,7 @@ export class StatefullMarkdownCell extends Disposable {
height: e.contentHeight
}
);
const clientHeight = this.markdownContainer.clientHeight;
this.viewCell.totalHeight = e.contentHeight + 32 + clientHeight + CELL_STATUSBAR_HEIGHT;
this.notebookEditor.layoutNotebookCell(this.viewCell, this.viewCell.layoutInfo.totalHeight);
this.viewCell.editorHeight = e.contentHeight;
}
}));
......
......@@ -8,7 +8,7 @@ import * as UUID from 'vs/base/common/uuid';
import * as editorCommon from 'vs/editor/common/editorCommon';
import * as model from 'vs/editor/common/model';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { BOTTOM_CELL_TOOLBAR_HEIGHT, CELL_MARGIN, CELL_RUN_GUTTER } from 'vs/workbench/contrib/notebook/browser/constants';
import { BOTTOM_CELL_TOOLBAR_HEIGHT, CELL_MARGIN, CELL_RUN_GUTTER, CELL_STATUSBAR_HEIGHT } from 'vs/workbench/contrib/notebook/browser/constants';
import { CellFindMatch, ICellViewModel, MarkdownCellLayoutChangeEvent, MarkdownCellLayoutInfo, NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { MarkdownRenderer } from 'vs/workbench/contrib/notebook/browser/view/renderers/mdRenderer';
import { BaseCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel';
......@@ -39,7 +39,8 @@ export class MarkdownCellViewModel extends BaseCellViewModel implements ICellVie
private _editorHeight = 0;
set editorHeight(newHeight: number) {
this._editorHeight = newHeight;
this.layoutChange({ editorHeight: true });
this.totalHeight = this._editorHeight + BOTTOM_CELL_TOOLBAR_HEIGHT + CELL_STATUSBAR_HEIGHT;
}
get editorHeight() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册