@@ -563,12 +563,14 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
563
563
*
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
+ * @param origin Transaction origin; if set to 'silent-change' and {@link undoable} is false,
567
+ * it won't emit model {@link changed}.
566
568
*/
567
- transact ( f : ( ) => void , undoable = true ) : void {
569
+ transact ( f : ( ) => void , undoable = true , origin : any = null ) : void {
568
570
! this . notebook || this . notebook . disableDocumentWideUndoRedo
569
571
? this . ymodel . doc == null
570
572
? f ( )
571
- : this . ymodel . doc . transact ( f , undoable ? this : null )
573
+ : this . ymodel . doc . transact ( f , undoable ? this : origin )
572
574
: this . notebook . transact ( f , undoable ) ;
573
575
}
574
576
@@ -656,8 +658,13 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
656
658
/**
657
659
* Handle a change to the ymodel.
658
660
*/
659
- private _modelObserver = ( events : Y . YEvent < any > [ ] ) => {
660
- this . _changed . emit ( this . getChanges ( events ) ) ;
661
+ private _modelObserver = (
662
+ events : Y . YEvent < any > [ ] ,
663
+ transaction : Y . Transaction
664
+ ) => {
665
+ if ( transaction . origin !== 'silent-change' ) {
666
+ this . _changed . emit ( this . getChanges ( events ) ) ;
667
+ }
661
668
} ;
662
669
663
670
protected _metadataChanged = new Signal < this, IMapChange > ( this ) ;
@@ -783,14 +790,19 @@ export class YCodeCell
783
790
updateOutputs (
784
791
start : number ,
785
792
end : number ,
786
- outputs : Array < nbformat . IOutput > = [ ]
793
+ outputs : Array < nbformat . IOutput > = [ ] ,
794
+ origin : any = null
787
795
) : void {
788
796
const fin =
789
797
end < this . _youtputs . length ? end - start : this . _youtputs . length - start ;
790
- this . transact ( ( ) => {
791
- this . _youtputs . delete ( start , fin ) ;
792
- this . _youtputs . insert ( start , outputs ) ;
793
- } , false ) ;
798
+ this . transact (
799
+ ( ) => {
800
+ this . _youtputs . delete ( start , fin ) ;
801
+ this . _youtputs . insert ( start , outputs ) ;
802
+ } ,
803
+ false ,
804
+ origin
805
+ ) ;
794
806
}
795
807
796
808
/**
0 commit comments