@@ -827,24 +827,32 @@ export class YCodeCell
827
827
/**
828
828
* Remove text from a stream output.
829
829
*/
830
- removeStreamOutput ( index : number , start : number ) : void {
831
- this . transact ( ( ) => {
832
- const output = this . _youtputs . get ( index ) ;
833
- const prevText = output . get ( 'text' ) as Y . Text ;
834
- const length = prevText . length - start ;
835
- prevText . delete ( start , length ) ;
836
- } , false ) ;
830
+ removeStreamOutput ( index : number , start : number , origin : any = null ) : void {
831
+ this . transact (
832
+ ( ) => {
833
+ const output = this . _youtputs . get ( index ) ;
834
+ const prevText = output . get ( 'text' ) as Y . Text ;
835
+ const length = prevText . length - start ;
836
+ prevText . delete ( start , length ) ;
837
+ } ,
838
+ false ,
839
+ origin
840
+ ) ;
837
841
}
838
842
839
843
/**
840
844
* Append text to a stream output.
841
845
*/
842
- appendStreamOutput ( index : number , text : string ) : void {
843
- this . transact ( ( ) => {
844
- const output = this . _youtputs . get ( index ) ;
845
- const prevText = output . get ( 'text' ) as Y . Text ;
846
- prevText . insert ( prevText . length , text ) ;
847
- } , false ) ;
846
+ appendStreamOutput ( index : number , text : string , origin : any = null ) : void {
847
+ this . transact (
848
+ ( ) => {
849
+ const output = this . _youtputs . get ( index ) ;
850
+ const prevText = output . get ( 'text' ) as Y . Text ;
851
+ prevText . insert ( prevText . length , text ) ;
852
+ } ,
853
+ false ,
854
+ origin
855
+ ) ;
848
856
}
849
857
850
858
/**
@@ -895,6 +903,19 @@ export class YCodeCell
895
903
protected getChanges ( events : Y . YEvent < any > [ ] ) : Partial < CellChange > {
896
904
const changes = super . getChanges ( events ) ;
897
905
906
+ const streamOutputEvent = events . find (
907
+ // Changes to the 'text' of a cell's stream output can be accessed like so:
908
+ // ycell['outputs'][output_idx]['text']
909
+ // This translates to an event path of: ['outputs', output_idx, 'text]
910
+ event =>
911
+ event . path . length === 3 &&
912
+ event . path [ 0 ] === 'outputs' &&
913
+ event . path [ 2 ] === 'text'
914
+ ) ;
915
+ if ( streamOutputEvent ) {
916
+ changes . streamOutputChange = streamOutputEvent . changes . delta as any ;
917
+ }
918
+
898
919
const outputEvent = events . find (
899
920
event => event . target === this . ymodel . get ( 'outputs' )
900
921
) ;
0 commit comments