@@ -41,19 +41,21 @@ value('froalaConfig', {})
41
41
42
42
//Instruct ngModel how to update the froala editor
43
43
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?
46
44
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?
47
47
element . froalaEditor ( 'undo.reset' ) ;
48
48
element . froalaEditor ( 'undo.saveStep' ) ;
49
49
}
50
50
} ;
51
51
52
52
ngModel . $isEmpty = function ( value ) {
53
- if ( ! value ) return true ;
53
+ if ( ! value ) {
54
+ return true ;
55
+ }
54
56
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 ;
57
59
} ;
58
60
} ;
59
61
@@ -67,6 +69,11 @@ value('froalaConfig', {})
67
69
ctrl . listeningEvents . push ( 'keyup' ) ;
68
70
}
69
71
72
+ ctrl . registerEventsWithCallbacks ( 'froalaEditor.initialized' , function ( ) {
73
+ ctrl . editorInitialized = true ;
74
+ ngModel . $render ( ) ;
75
+ } ) ;
76
+
70
77
// Register events provided in the options
71
78
// Registering events before initializing the editor will bind the initialized event correctly.
72
79
for ( var eventName in ctrl . options . events ) {
@@ -83,17 +90,7 @@ value('froalaConfig', {})
83
90
if ( scope . froalaOptions ) {
84
91
scope . froalaOptions . froalaEditor = ctrl . froalaEditor ;
85
92
}
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
- }
94
93
}
95
-
96
-
97
94
} ;
98
95
99
96
ctrl . initListeners = function ( ) {
0 commit comments