@@ -94,6 +94,7 @@ angular.module('ui.tinymce', [])
94
94
// re-rendering directive
95
95
$timeout ( function ( ) {
96
96
tinymce . init ( options ) ;
97
+ toggleDisable ( scope . $eval ( attrs . ngDisabled ) ) ;
97
98
} ) ;
98
99
99
100
ngModel . $formatters . unshift ( function ( modelValue ) {
@@ -116,25 +117,13 @@ angular.module('ui.tinymce', [])
116
117
tinyInstance . getDoc ( )
117
118
) {
118
119
tinyInstance . setContent ( viewValue ) ;
120
+ // Triggering change event due to TinyMCE not firing event &
121
+ // becoming out of sync for change callbacks
119
122
tinyInstance . fire ( 'change' ) ;
120
123
}
121
124
} ;
122
125
123
- attrs . $observe ( 'disabled' , function ( disabled ) {
124
- if ( disabled ) {
125
- ensureInstance ( ) ;
126
-
127
- if ( tinyInstance ) {
128
- tinyInstance . getBody ( ) . setAttribute ( 'contenteditable' , false ) ;
129
- }
130
- } else {
131
- ensureInstance ( ) ;
132
-
133
- if ( tinyInstance ) {
134
- tinyInstance . getBody ( ) . setAttribute ( 'contenteditable' , true ) ;
135
- }
136
- }
137
- } ) ;
126
+ attrs . $observe ( 'disabled' , toggleDisable ) ;
138
127
139
128
// This block is because of TinyMCE not playing well with removal and
140
129
// recreation of instances, requiring instances to have different
@@ -166,6 +155,22 @@ angular.module('ui.tinymce', [])
166
155
tinyInstance = tinymce . get ( attrs . id ) ;
167
156
}
168
157
}
158
+
159
+ function toggleDisable ( disabled ) {
160
+ if ( disabled ) {
161
+ ensureInstance ( ) ;
162
+
163
+ if ( tinyInstance ) {
164
+ tinyInstance . getBody ( ) . setAttribute ( 'contenteditable' , false ) ;
165
+ }
166
+ } else {
167
+ ensureInstance ( ) ;
168
+
169
+ if ( tinyInstance ) {
170
+ tinyInstance . getBody ( ) . setAttribute ( 'contenteditable' , true ) ;
171
+ }
172
+ }
173
+ }
169
174
}
170
175
} ;
171
176
} ] ) ;
0 commit comments