@@ -761,13 +761,35 @@ export class YCodeCell
761
761
return JSONExt . deepCopy ( this . _youtputs . toArray ( ) ) ;
762
762
}
763
763
764
+ createOutputs ( outputs : Array < nbformat . IOutput > ) : Array < any > {
765
+ const newOutputs : Array < any > = [ ] ;
766
+ for ( const output of outputs ) {
767
+ if ( output . output_type === 'stream' ) {
768
+ const { text, ...outputWithoutText } = output ;
769
+ const _newOutput : { [ id : string ] : any } = outputWithoutText ;
770
+ const newText = new Y . Array ( ) ;
771
+ newText . push ( text as string [ ] ) ;
772
+ _newOutput [ 'text' ] = newText ;
773
+ const newOutput = new Y . Map ( ) ;
774
+ for ( const [ key , value ] of Object . entries ( _newOutput ) ) {
775
+ newOutput . set ( key , value ) ;
776
+ }
777
+ newOutputs . push ( newOutput ) ;
778
+ } else {
779
+ newOutputs . push ( output ) ;
780
+ }
781
+ }
782
+ return newOutputs ;
783
+ }
784
+
764
785
/**
765
786
* Replace all outputs.
766
787
*/
767
788
setOutputs ( outputs : Array < nbformat . IOutput > ) : void {
768
789
this . transact ( ( ) => {
769
790
this . _youtputs . delete ( 0 , this . _youtputs . length ) ;
770
- this . _youtputs . insert ( 0 , outputs ) ;
791
+ const newOutputs = this . createOutputs ( outputs ) ;
792
+ this . _youtputs . insert ( 0 , newOutputs ) ;
771
793
} , false ) ;
772
794
}
773
795
@@ -789,7 +811,8 @@ export class YCodeCell
789
811
end < this . _youtputs . length ? end - start : this . _youtputs . length - start ;
790
812
this . transact ( ( ) => {
791
813
this . _youtputs . delete ( start , fin ) ;
792
- this . _youtputs . insert ( start , outputs ) ;
814
+ const newOutputs = this . createOutputs ( outputs ) ;
815
+ this . _youtputs . insert ( start , newOutputs ) ;
793
816
} , false ) ;
794
817
}
795
818
0 commit comments