提交 ee1a39e1 编写于 作者: R Rob Lourens

Fix sizing cell incorrectly for webview outputs

- webview outputs are not "hasDynamicHeight"
- The "else if" condition got flipped around in the last change
上级 8bfdb0f8
...@@ -325,7 +325,7 @@ export class CodeCell extends Disposable { ...@@ -325,7 +325,7 @@ export class CodeCell extends Disposable {
if (renderedOutput.renderResult.type !== RenderOutputType.None) { if (renderedOutput.renderResult.type !== RenderOutputType.None) {
// Show inset in webview, or render output that isn't rendered // Show inset in webview, or render output that isn't rendered
// TODO@roblou skipHeightInit flag is a hack - the webview only sends the real height once. Don't wipe it out here. // TODO@roblou skipHeightInit flag is a hack - the webview only sends the real height once. Don't wipe it out here.
this.renderOutput(currOutput, index, undefined, true); this.renderOutput(currOutput, index, undefined);
} else { } else {
// Anything else, just update the height // Anything else, just update the height
this.viewCell.updateOutputHeight(index, renderedOutput.element.clientHeight); this.viewCell.updateOutputHeight(index, renderedOutput.element.clientHeight);
...@@ -430,7 +430,7 @@ export class CodeCell extends Disposable { ...@@ -430,7 +430,7 @@ export class CodeCell extends Disposable {
); );
} }
private renderOutput(currOutput: IProcessedOutput, index: number, beforeElement?: HTMLElement, skipHeightInit = false) { private renderOutput(currOutput: IProcessedOutput, index: number, beforeElement?: HTMLElement) {
if (!this.outputResizeListeners.has(currOutput)) { if (!this.outputResizeListeners.has(currOutput)) {
this.outputResizeListeners.set(currOutput, new DisposableStore()); this.outputResizeListeners.set(currOutput, new DisposableStore());
} }
...@@ -510,42 +510,40 @@ export class CodeCell extends Disposable { ...@@ -510,42 +510,40 @@ export class CodeCell extends Disposable {
outputItemDiv.style.position = 'absolute'; outputItemDiv.style.position = 'absolute';
} }
if (!skipHeightInit) { if (outputHasDynamicHeight(result)) {
if (outputHasDynamicHeight(result)) { this.viewCell.selfSizeMonitoring = true;
this.viewCell.selfSizeMonitoring = true;
const clientHeight = outputItemDiv.clientHeight;
const clientHeight = outputItemDiv.clientHeight; const dimension = {
const dimension = { width: this.viewCell.layoutInfo.editorWidth,
width: this.viewCell.layoutInfo.editorWidth, height: clientHeight
height: clientHeight };
}; const elementSizeObserver = getResizesObserver(outputItemDiv, dimension, () => {
const elementSizeObserver = getResizesObserver(outputItemDiv, dimension, () => { if (this.templateData.outputContainer && document.body.contains(this.templateData.outputContainer!)) {
if (this.templateData.outputContainer && document.body.contains(this.templateData.outputContainer!)) { const height = Math.ceil(elementSizeObserver.getHeight());
const height = Math.ceil(elementSizeObserver.getHeight());
if (clientHeight === height) {
if (clientHeight === height) { return;
return;
}
const currIndex = this.viewCell.outputs.indexOf(currOutput);
if (currIndex < 0) {
return;
}
this.viewCell.updateOutputHeight(currIndex, height);
this.relayoutCell();
} }
});
elementSizeObserver.startObserving(); const currIndex = this.viewCell.outputs.indexOf(currOutput);
this.outputResizeListeners.get(currOutput)!.add(elementSizeObserver); if (currIndex < 0) {
this.viewCell.updateOutputHeight(index, clientHeight); return;
} else if (result.type !== RenderOutputType.None) { // no-op if it's a webview }
const clientHeight = Math.ceil(outputItemDiv.clientHeight);
this.viewCell.updateOutputHeight(index, clientHeight); this.viewCell.updateOutputHeight(currIndex, height);
this.relayoutCell();
const top = this.viewCell.getOutputOffsetInContainer(index); }
outputItemDiv.style.top = `${top}px`; });
} elementSizeObserver.startObserving();
this.outputResizeListeners.get(currOutput)!.add(elementSizeObserver);
this.viewCell.updateOutputHeight(index, clientHeight);
} else if (result.type === RenderOutputType.None) { // no-op if it's a webview
const clientHeight = Math.ceil(outputItemDiv.clientHeight);
this.viewCell.updateOutputHeight(index, clientHeight);
const top = this.viewCell.getOutputOffsetInContainer(index);
outputItemDiv.style.top = `${top}px`;
} }
} }
......
...@@ -313,7 +313,7 @@ export interface IRenderOutputViaExtension { ...@@ -313,7 +313,7 @@ export interface IRenderOutputViaExtension {
export type IInsetRenderOutput = IRenderPlainHtmlOutput | IRenderOutputViaExtension; export type IInsetRenderOutput = IRenderPlainHtmlOutput | IRenderOutputViaExtension;
export type IRenderOutput = IRenderNoOutput | IInsetRenderOutput; export type IRenderOutput = IRenderNoOutput | IInsetRenderOutput;
export const outputHasDynamicHeight = (o: IRenderOutput) => o.type === RenderOutputType.Extension || o.hasDynamicHeight; export const outputHasDynamicHeight = (o: IRenderOutput) => o.type !== RenderOutputType.Extension && o.hasDynamicHeight;
export type NotebookCellTextModelSplice = [ export type NotebookCellTextModelSplice = [
number /* start */, number /* start */,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册