@@ -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,10 @@ 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 = ( events : Y . YEvent < any > [ ] , transaction : Y . Transaction ) => {
660+ if ( transaction . origin !== 'modeldb' ) {
661+ this . _changed . emit ( this . getChanges ( events ) ) ;
662+ }
661663 } ;
662664
663665 protected _metadataChanged = new Signal < this, IMapChange > ( this ) ;
@@ -838,15 +840,16 @@ export class YCodeCell
838840 updateOutputs (
839841 start : number ,
840842 end : number ,
841- outputs : Array < nbformat . IOutput > = [ ]
843+ outputs : Array < nbformat . IOutput > = [ ] ,
844+ origin : any = null
842845 ) : void {
843846 const fin =
844847 end < this . _youtputs . length ? end - start : this . _youtputs . length - start ;
845848 this . transact ( ( ) => {
846849 this . _youtputs . delete ( start , fin ) ;
847850 const newOutputs = this . createOutputs ( outputs ) ;
848851 this . _youtputs . insert ( start , newOutputs ) ;
849- } , false ) ;
852+ } , false , origin ) ;
850853 }
851854
852855 /**
0 commit comments