@@ -200,6 +200,17 @@ export class CodeCell extends Disposable {
200
200
}
201
201
} ) ) ;
202
202
203
+ this . _register ( viewCell . onDidChangeLayout ( ( ) => {
204
+ this . outputElements . forEach ( ( value , key ) => {
205
+ const index = viewCell . outputs . indexOf ( key ) ;
206
+ if ( index >= 0 ) {
207
+ const top = this . viewCell . getOutputOffsetInContainer ( index ) ;
208
+ value . style . top = `${ top } px` ;
209
+ }
210
+ } ) ;
211
+
212
+ } ) ) ;
213
+
203
214
const updateFocusMode = ( ) => viewCell . focusMode = templateData . editor ! . hasWidgetFocus ( ) ? CellFocusMode . Editor : CellFocusMode . Container ;
204
215
this . _register ( templateData . editor ! . onDidFocusEditorWidget ( ( ) => {
205
216
updateFocusMode ( ) ;
@@ -311,15 +322,21 @@ export class CodeCell extends Disposable {
311
322
}
312
323
let pickedMimeTypeRenderer = currOutput . orderedMimeTypes ! [ currOutput . pickedMimeTypeIndex ! ] ;
313
324
325
+ const innerContainer = DOM . $ ( '.output-inner-container' ) ;
326
+ DOM . append ( outputItemDiv , innerContainer ) ;
327
+
314
328
if ( pickedMimeTypeRenderer . isResolved ) {
315
329
// html
316
- result = this . notebookEditor . getOutputRenderer ( ) . render ( { outputKind : CellOutputKind . Rich , data : { 'text/html' : pickedMimeTypeRenderer . output ! } } as any , outputItemDiv , 'text/html' ) ;
330
+ result = this . notebookEditor . getOutputRenderer ( ) . render ( { outputKind : CellOutputKind . Rich , data : { 'text/html' : pickedMimeTypeRenderer . output ! } } as any , innerContainer , 'text/html' ) ;
317
331
} else {
318
- result = this . notebookEditor . getOutputRenderer ( ) . render ( currOutput , outputItemDiv , pickedMimeTypeRenderer . mimeType ) ;
332
+ result = this . notebookEditor . getOutputRenderer ( ) . render ( currOutput , innerContainer , pickedMimeTypeRenderer . mimeType ) ;
319
333
}
320
334
} else {
321
335
// for text and error, there is no mimetype
322
- result = this . notebookEditor . getOutputRenderer ( ) . render ( currOutput , outputItemDiv , undefined ) ;
336
+ const innerContainer = DOM . $ ( '.output-inner-container' ) ;
337
+ DOM . append ( outputItemDiv , innerContainer ) ;
338
+
339
+ result = this . notebookEditor . getOutputRenderer ( ) . render ( currOutput , innerContainer , undefined ) ;
323
340
}
324
341
325
342
if ( ! result ) {
@@ -340,6 +357,8 @@ export class CodeCell extends Disposable {
340
357
this . notebookEditor . createInset ( this . viewCell , currOutput , result . shadowContent , this . viewCell . getOutputOffset ( index ) ) ;
341
358
} else {
342
359
DOM . addClass ( outputItemDiv , 'foreground' ) ;
360
+ DOM . addClass ( outputItemDiv , 'output-element' ) ;
361
+ outputItemDiv . style . position = 'absolute' ;
343
362
}
344
363
345
364
let hasDynamicHeight = result . hasDynamicHeight ;
@@ -352,10 +371,9 @@ export class CodeCell extends Disposable {
352
371
} ;
353
372
const elementSizeObserver = getResizesObserver ( outputItemDiv , dimension , ( ) => {
354
373
if ( this . templateData . outputContainer && document . body . contains ( this . templateData . outputContainer ! ) ) {
355
- let height = elementSizeObserver . getHeight ( ) + 8 * 2 ; // include padding
374
+ let height = Math . ceil ( elementSizeObserver . getHeight ( ) ) ;
356
375
357
376
if ( clientHeight === height ) {
358
- // console.log(this.viewCell.outputs);
359
377
return ;
360
378
}
361
379
@@ -375,13 +393,13 @@ export class CodeCell extends Disposable {
375
393
if ( result . shadowContent ) {
376
394
// webview
377
395
// noop
378
- // let cachedHeight = this.viewCell.getOutputHeight(currOutput);
379
396
} else {
380
397
// static output
381
-
382
- // @TODO @rebornix , if we stop checking output height, we need to evaluate it later when checking the height of output container
383
- let clientHeight = outputItemDiv . clientHeight ;
398
+ let clientHeight = Math . ceil ( outputItemDiv . clientHeight ) ;
384
399
this . viewCell . updateOutputHeight ( index , clientHeight ) ;
400
+
401
+ const top = this . viewCell . getOutputOffsetInContainer ( index ) ;
402
+ outputItemDiv . style . top = `${ top } px` ;
385
403
}
386
404
}
387
405
}
0 commit comments