@@ -346,59 +346,64 @@ export class CellOutput extends React.Component<ICellOutputProps> {
346
346
347
347
// tslint:disable-next-line: max-func-body-length
348
348
private renderOutputs ( outputs : nbformat . IOutput [ ] ) : JSX . Element [ ] {
349
- return outputs . map ( this . renderOutput ) ;
349
+ return [ this . renderOutput ( outputs ) ] ;
350
350
}
351
351
352
- private renderOutput = ( output : nbformat . IOutput , index : number ) : JSX . Element => {
353
- const transformed = this . transformOutput ( output ) ;
354
- let mimetype = transformed . mimeType ;
355
-
356
- // If that worked, use the transform
357
- if ( mimetype ) {
358
- // Get the matching React.Component for that mimetype
359
- const Transform = transforms [ mimetype ] ;
360
-
361
- // Create a default set of properties
362
- const style : React . CSSProperties = {
363
- } ;
364
-
365
- // Create a scrollbar style if necessary
366
- if ( transformed . renderWithScrollbars && this . props . maxTextSize ) {
367
- style . overflowX = 'auto' ;
368
- style . overflowY = 'auto' ;
369
- style . maxHeight = ` ${ this . props . maxTextSize } px` ;
370
- }
371
-
372
- let className = transformed . isText ? 'cell-output-text' : 'cell-output-html' ;
373
- className = transformed . isError ? ` ${ className } cell-output-error` : className ;
374
-
375
- // If we are not theming plots then wrap them in a white span
376
- if ( transformed . outputSpanClassName ) {
377
- return (
378
- < div role = 'group' key = { index } onDoubleClick = { transformed . doubleClick } onClick = { this . click } className = { className } style = { style } >
379
- < span className = { transformed . outputSpanClassName } >
352
+ private renderOutput = ( outputs : nbformat . IOutput [ ] ) : JSX . Element => {
353
+ const buffer : JSX . Element [ ] = [ ] ;
354
+ const transformedList = outputs . map ( this . transformOutput ) ;
355
+
356
+ transformedList . forEach ( transformed => {
357
+ let mimetype = transformed . mimeType ;
358
+
359
+ // If that worked, use the transform
360
+ if ( mimetype ) {
361
+ // Get the matching React.Component for that mimetype
362
+ const Transform = transforms [ mimetype ] ;
363
+
364
+ let className = transformed . isText ? 'cell-output-text' : 'cell-output-html' ;
365
+ className = transformed . isError ? ` ${ className } cell-output-error` : className ;
366
+
367
+ // If we are not theming plots then wrap them in a white span
368
+ if ( transformed . outputSpanClassName ) {
369
+ buffer . push (
370
+ < div role = 'group' onDoubleClick = { transformed . doubleClick } onClick = { this . click } className = { className } >
371
+ < span className = { transformed . outputSpanClassName } >
372
+ { transformed . extraButton }
373
+ < Transform data = { transformed . data } />
374
+ </ span >
375
+ </ div >
376
+ ) ;
377
+ } else {
378
+ buffer . push (
379
+ < div role = 'group' onDoubleClick = { transformed . doubleClick } onClick = { this . click } className = { className } >
380
380
{ transformed . extraButton }
381
381
< Transform data = { transformed . data } />
382
- </ span >
383
- </ div >
384
- ) ;
382
+ </ div >
383
+ ) ;
384
+ }
385
385
} else {
386
- return (
387
- < div role = 'group' key = { index } onDoubleClick = { transformed . doubleClick } onClick = { this . click } className = { className } style = { style } >
388
- { transformed . extraButton }
389
- < Transform data = { transformed . data } />
390
- </ div >
391
- ) ;
386
+ if ( transformed . data ) {
387
+ const keys = Object . keys ( transformed . data ) ;
388
+ mimetype = keys . length > 0 ? keys [ 0 ] : 'unknown' ;
389
+ } else {
390
+ mimetype = 'unknown' ;
391
+ }
392
+ const str : string = this . getUnknownMimeTypeFormatString ( ) . format ( mimetype ) ;
393
+ buffer . push ( < div > { str } </ div > ) ;
392
394
}
393
- }
395
+ } ) ;
394
396
395
- if ( output . data ) {
396
- const keys = Object . keys ( output . data ) ;
397
- mimetype = keys . length > 0 ? keys [ 0 ] : 'unknown' ;
398
- } else {
399
- mimetype = 'unknown' ;
397
+ // Create a default set of properties
398
+ const style : React . CSSProperties = {
399
+ } ;
400
+
401
+ // Create a scrollbar style if necessary
402
+ if ( transformedList . some ( transformed => transformed . renderWithScrollbars ) && this . props . maxTextSize ) {
403
+ style . overflowY = 'auto' ;
404
+ style . maxHeight = `${ this . props . maxTextSize } px` ;
400
405
}
401
- const str : string = this . getUnknownMimeTypeFormatString ( ) . format ( mimetype ) ;
402
- return < div key = { index } > { str } </ div > ;
406
+
407
+ return < div style = { style } > { buffer } </ div > ;
403
408
}
404
409
}
0 commit comments