@@ -109,18 +109,57 @@ angular.module("umbraco")
109
109
//listen to both change and blur and also on our own 'saving' event. I think this will be best because a
110
110
//timer might end up using unwanted cpu and we'd still have to listen to our saving event in case they clicked
111
111
//save before the timeout elapsed.
112
- editor . on ( 'change' , function ( e ) {
112
+
113
+ //this doesnt actually work...
114
+ //editor.on('change', function (e) {
115
+ // angularHelper.safeApply($scope, function () {
116
+ // $scope.model.value = editor.getContent();
117
+ // });
118
+ //});
119
+
120
+ //when we leave the editor (maybe)
121
+ editor . on ( 'blur' , function ( e ) {
122
+ editor . save ( ) ;
123
+ angularHelper . safeApply ( $scope , function ( ) {
124
+ $scope . model . value = editor . getContent ( ) ;
125
+ } ) ;
126
+ } ) ;
127
+
128
+ //when buttons modify content
129
+ editor . on ( 'ExecCommand' , function ( e ) {
130
+ editor . save ( ) ;
113
131
angularHelper . safeApply ( $scope , function ( ) {
114
132
$scope . model . value = editor . getContent ( ) ;
115
133
} ) ;
116
134
} ) ;
117
135
118
- editor . on ( 'blur' , function ( e ) {
136
+ // Update model on keypress
137
+ editor . on ( 'KeyUp' , function ( e ) {
138
+ editor . save ( ) ;
139
+ angularHelper . safeApply ( $scope , function ( ) {
140
+ $scope . model . value = editor . getContent ( ) ;
141
+ } ) ;
142
+ } ) ;
143
+
144
+ // Update model on change, i.e. copy/pasted text, plugins altering content
145
+ editor . on ( 'SetContent' , function ( e ) {
146
+ if ( ! e . initial ) {
147
+ editor . save ( ) ;
119
148
angularHelper . safeApply ( $scope , function ( ) {
120
149
$scope . model . value = editor . getContent ( ) ;
121
150
} ) ;
151
+ }
152
+ } ) ;
153
+
154
+
155
+ editor . on ( 'ObjectResized' , function ( e ) {
156
+ var qs = "?width=" + e . width + "px&height=" + e . height + "px" ;
157
+ var srcAttr = $ ( e . target ) . attr ( "src" ) ;
158
+ var path = srcAttr . split ( "?" ) [ 0 ] ;
159
+ $ ( e . target ) . attr ( "data-mce-src" , path + qs ) ;
122
160
} ) ;
123
-
161
+
162
+
124
163
//Create the insert media plugin
125
164
tinyMceService . createMediaPicker ( editor , $scope ) ;
126
165
@@ -165,7 +204,6 @@ angular.module("umbraco")
165
204
166
205
//listen for formSubmitting event (the result is callback used to remove the event subscription)
167
206
var unsubscribe = $scope . $on ( "formSubmitting" , function ( ) {
168
-
169
207
//TODO: Here we should parse out the macro rendered content so we can save on a lot of bytes in data xfer
170
208
// we do parse it out on the server side but would be nice to do that on the client side before as well.
171
209
$scope . model . value = tinyMceEditor . getContent ( ) ;
0 commit comments