@@ -564,11 +564,11 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
564564 * @param f Transaction to execute
565565 * @param undoable Whether to track the change in the action history or not (default `true`)
566566 */
567- transact ( f : ( ) => void , undoable = true ) : void {
567+ transact ( f : ( ) => void , undoable = true , origin : any = null ) : void {
568568 ! this . notebook || this . notebook . disableDocumentWideUndoRedo
569569 ? this . ymodel . doc == null
570570 ? f ( )
571- : this . ymodel . doc . transact ( f , undoable ? this : null )
571+ : this . ymodel . doc . transact ( f , undoable ? this : origin )
572572 : this . notebook . transact ( f , undoable ) ;
573573 }
574574
@@ -656,8 +656,13 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
656656 /**
657657 * Handle a change to the ymodel.
658658 */
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+ }
661666 } ;
662667
663668 protected _metadataChanged = new Signal < this, IMapChange > ( this ) ;
@@ -838,15 +843,20 @@ export class YCodeCell
838843 updateOutputs (
839844 start : number ,
840845 end : number ,
841- outputs : Array < nbformat . IOutput > = [ ]
846+ outputs : Array < nbformat . IOutput > = [ ] ,
847+ origin : any = null
842848 ) : void {
843849 const fin =
844850 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+ ) ;
850860 }
851861
852862 /**
0 commit comments