Ticket #31412: 31412.10.patch
File 31412.10.patch, 1.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/mce-view.js
163 163 /** 164 164 * Get a view instance. 165 165 * 166 * @param {(String|HTMLElement)} object The textual representation of the view or the view node. 167 */ 168 getInstance: function( object ) { 169 if ( typeof object === 'string' ) { 170 return instances[ encodeURIComponent( object ) ]; 171 } 172 173 return instances[ $( object ).data( 'wpview-text' ) ]; 174 }, 175 176 /** 177 * Given a view node, get the view's text. 178 * 166 179 * @param {String} text The textual representation of the view. 167 180 */ 168 get Instance: function( text) {169 return instances[ encodeURIComponent( text ) ];181 getText: function( node ) { 182 return decodeURIComponent( $( node ).data( 'wpview-text' ) || '' ); 170 183 }, 171 184 172 185 /** … … 188 201 * @param {HTMLElement} node The view node to update. 189 202 */ 190 203 update: function( text, editor, node ) { 191 var oldText = decodeURIComponent( $( node ).data( 'wpview-text' ) ), 192 instance = this.getInstance( oldText ); 204 var instance = this.getInstance( node ); 193 205 194 206 if ( instance ) { 195 207 instance.update( text, editor, node ); … … 203 215 * @param {HTMLElement} node The view node to edit. 204 216 */ 205 217 edit: function( editor, node ) { 206 var text = decodeURIComponent( $( node ).data( 'wpview-text' ) ), 207 instance = this.getInstance( text ); 218 var instance = this.getInstance( node ); 208 219 209 220 if ( instance && instance.edit ) { 210 instance.edit( text, function( text ) {221 instance.edit( instance.text, function( text ) { 211 222 instance.update( text, editor, node ); 212 223 } ); 213 224 }