@@ -41,19 +41,21 @@ value('froalaConfig', {})
4141
4242 //Instruct ngModel how to update the froala editor
4343 ngModel . $render = function ( ) {
44- element . froalaEditor ( 'html.set' , ngModel . $viewValue || '' , true ) ;
45- //This will reset the undo stack everytime the model changes externally. Can we fix this?
4644 if ( ctrl . editorInitialized ) {
45+ element . froalaEditor ( 'html.set' , ngModel . $viewValue || '' , true ) ;
46+ //This will reset the undo stack everytime the model changes externally. Can we fix this?
4747 element . froalaEditor ( 'undo.reset' ) ;
4848 element . froalaEditor ( 'undo.saveStep' ) ;
4949 }
5050 } ;
5151
5252 ngModel . $isEmpty = function ( value ) {
53- if ( ! value ) return true ;
53+ if ( ! value ) {
54+ return true ;
55+ }
5456
55- var isEmpty = element . froalaEditor ( 'node.isEmpty' , jQuery ( '<div>' + value + '</div>' ) . get ( 0 ) ) ;
56- return isEmpty ;
57+ var isEmpty = element . froalaEditor ( 'node.isEmpty' , jQuery ( '<div>' + value + '</div>' ) . get ( 0 ) ) ;
58+ return isEmpty ;
5759 } ;
5860 } ;
5961
@@ -67,6 +69,11 @@ value('froalaConfig', {})
6769 ctrl . listeningEvents . push ( 'keyup' ) ;
6870 }
6971
72+ ctrl . registerEventsWithCallbacks ( 'froalaEditor.initialized' , function ( ) {
73+ ctrl . editorInitialized = true ;
74+ ngModel . $render ( ) ;
75+ } ) ;
76+
7077 // Register events provided in the options
7178 // Registering events before initializing the editor will bind the initialized event correctly.
7279 for ( var eventName in ctrl . options . events ) {
@@ -83,17 +90,7 @@ value('froalaConfig', {})
8390 if ( scope . froalaOptions ) {
8491 scope . froalaOptions . froalaEditor = ctrl . froalaEditor ;
8592 }
86-
87- if ( ctrl . options . initOnClick ) {
88- ctrl . registerEventsWithCallbacks ( 'froalaEditor.initialized' , function ( ) {
89- ctrl . editorInitialized = true ;
90- } ) ;
91- } else {
92- ctrl . editorInitialized = ctrl . froalaEditor ? true : false ;
93- }
9493 }
95-
96-
9794 } ;
9895
9996 ctrl . initListeners = function ( ) {
0 commit comments