Ticket #31412: 31412.11.patch
File 31412.11.patch, 2.6 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 } … … 218 229 * A Backbone-like View constructor intended for use when rendering a TinyMCE View. 219 230 * The main difference is that the TinyMCE View is not tied to a particular DOM node. 220 231 * 221 * @param {Object} Options.232 * @param {Object} options Options. 222 233 */ 223 234 wp.mce.View = function( options ) { 224 235 _.extend( this, options ); -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
107 107 clipboard = dom.create( 'div', { 108 108 'class': 'wpview-clipboard', 109 109 'contenteditable': 'true' 110 }, decodeURIComponent( editor.dom.getAttrib( viewNode, 'data-wpview-text' )) );110 }, wp.mce.views.getText( viewNode ) ); 111 111 112 112 editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard ); 113 113