@@ -564,11 +564,11 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
564
564
* @param f Transaction to execute
565
565
* @param undoable Whether to track the change in the action history or not (default `true`)
566
566
*/
567
- transact ( f : ( ) => void , undoable = true ) : void {
567
+ transact ( f : ( ) => void , undoable = true , origin : any = null ) : void {
568
568
! this . notebook || this . notebook . disableDocumentWideUndoRedo
569
569
? this . ymodel . doc == null
570
570
? f ( )
571
- : this . ymodel . doc . transact ( f , undoable ? this : null )
571
+ : this . ymodel . doc . transact ( f , undoable ? this : origin )
572
572
: this . notebook . transact ( f , undoable ) ;
573
573
}
574
574
@@ -656,8 +656,13 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
656
656
/**
657
657
* Handle a change to the ymodel.
658
658
*/
659
- private _modelObserver = ( events : Y . YEvent < any > [ ] ) => {
660
- this . _changed . emit ( this . getChanges ( events ) ) ;
659
+ private _modelObserver = (
660
+ events : Y . YEvent < any > [ ] ,
661
+ transaction : Y . Transaction
662
+ ) => {
663
+ if ( transaction . origin !== 'modeldb' ) {
664
+ this . _changed . emit ( this . getChanges ( events ) ) ;
665
+ }
661
666
} ;
662
667
663
668
protected _metadataChanged = new Signal < this, IMapChange > ( this ) ;
@@ -838,15 +843,20 @@ export class YCodeCell
838
843
updateOutputs (
839
844
start : number ,
840
845
end : number ,
841
- outputs : Array < nbformat . IOutput > = [ ]
846
+ outputs : Array < nbformat . IOutput > = [ ] ,
847
+ origin : any = null
842
848
) : void {
843
849
const fin =
844
850
end < this . _youtputs . length ? end - start : this . _youtputs . length - start ;
845
- this . transact ( ( ) => {
846
- this . _youtputs . delete ( start , fin ) ;
847
- const newOutputs = this . createOutputs ( outputs ) ;
848
- this . _youtputs . insert ( start , newOutputs ) ;
849
- } , false ) ;
851
+ this . transact (
852
+ ( ) => {
853
+ this . _youtputs . delete ( start , fin ) ;
854
+ const newOutputs = this . createOutputs ( outputs ) ;
855
+ this . _youtputs . insert ( start , newOutputs ) ;
856
+ } ,
857
+ false ,
858
+ origin
859
+ ) ;
850
860
}
851
861
852
862
/**
0 commit comments