@@ -17,6 +17,7 @@ export class EditComponentJsonComponent {
1717 componentContentJSONString : string ;
1818 @Input ( )
1919 componentId : string ;
20+ nodeChangedSubscription : Subscription ;
2021 @Input ( )
2122 nodeId : string ;
2223 showJSONAuthoring : boolean = false ;
@@ -28,9 +29,7 @@ export class EditComponentJsonComponent {
2829 }
2930
3031 ngOnInit ( ) {
31- const authoringComponentContent = this . ProjectService . getComponentByNodeIdAndComponentId (
32- this . nodeId , this . componentId ) ;
33- this . componentContentJSONString = angular . toJson ( authoringComponentContent , 4 ) ;
32+ this . setComponentContentJsonString ( )
3433 this . jsonChangedSubscription = this . jsonChanged
3534 . pipe (
3635 debounceTime ( 1000 ) ,
@@ -44,10 +43,20 @@ export class EditComponentJsonComponent {
4443 this . NotificationService . showJSONInvalidMessage ( ) ;
4544 }
4645 } ) ;
46+ this . nodeChangedSubscription = this . ProjectService . nodeChanged$ . subscribe ( ( ) => {
47+ this . setComponentContentJsonString ( ) ;
48+ } ) ;
4749 }
4850
4951 ngOnDestory ( ) {
5052 this . jsonChangedSubscription . unsubscribe ( ) ;
53+ this . nodeChangedSubscription . unsubscribe ( ) ;
54+ }
55+
56+ setComponentContentJsonString ( ) {
57+ const authoringComponentContent = this . ProjectService . getComponentByNodeIdAndComponentId (
58+ this . nodeId , this . componentId ) ;
59+ this . componentContentJSONString = angular . toJson ( authoringComponentContent , 4 ) ;
5160 }
5261
5362 toggleJSONView ( ) : void {
0 commit comments