This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -87,9 +87,7 @@ angular.module('ui.tinymce', [])
87
87
} ) ;
88
88
89
89
ngModel . $render = function ( ) {
90
- if ( ! tinyInstance ) {
91
- tinyInstance = tinymce . get ( attrs . id ) ;
92
- }
90
+ ensureInstance ( ) ;
93
91
94
92
var format = options . raw ? 'text' : 'raw' ;
95
93
@@ -103,17 +101,13 @@ angular.module('ui.tinymce', [])
103
101
104
102
attrs . $observe ( 'disabled' , function ( disabled ) {
105
103
if ( disabled ) {
106
- if ( ! tinyInstance ) {
107
- tinyInstance = tinymce . get ( attrs . id ) ;
108
- }
104
+ ensureInstance ( ) ;
109
105
110
106
if ( tinyInstance ) {
111
107
tinyInstance . getBody ( ) . setAttribute ( 'contenteditable' , false ) ;
112
108
}
113
109
} else {
114
- if ( ! tinyInstance ) {
115
- tinyInstance = tinymce . get ( attrs . id ) ;
116
- }
110
+ ensureInstance ( ) ;
117
111
118
112
if ( tinyInstance ) {
119
113
tinyInstance . getBody ( ) . setAttribute ( 'contenteditable' , true ) ;
@@ -122,12 +116,19 @@ angular.module('ui.tinymce', [])
122
116
} ) ;
123
117
124
118
scope . $on ( '$destroy' , function ( ) {
125
- if ( ! tinyInstance ) { tinyInstance = tinymce . get ( attrs . id ) ; }
119
+ ensureInstance ( ) ;
120
+
126
121
if ( tinyInstance ) {
127
122
tinyInstance . remove ( ) ;
128
123
tinyInstance = null ;
129
124
}
130
125
} ) ;
126
+
127
+ function ensureInstance ( ) {
128
+ if ( ! tinyInstance ) {
129
+ tinyInstance = tinymce . get ( attrs . id ) ;
130
+ }
131
+ }
131
132
}
132
133
} ;
133
134
} ] ) ;
You can’t perform that action at this time.
0 commit comments