X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/c46e6dd20c438dddfea40c35935b877ac3e67daa..b22765f41bf0b2021b9beb9120ee0ac91fa89292:/wp-includes/js/mce-view.js diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index 86638fcf..3d2616d7 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -1,7 +1,5 @@ /* global tinymce */ -window.wp = window.wp || {}; - /* * The TinyMCE view API. * @@ -24,7 +22,7 @@ window.wp = window.wp || {}; * |- registered view * | |- ... */ -( function( window, wp, $ ) { +( function( window, wp, shortcode, $ ) { 'use strict'; var views = {}, @@ -122,7 +120,7 @@ window.wp = window.wp || {}; // Add the processed piece for the match. pieces.push( { - content: '
' + text + '
', + content: instance.ignore ? text : '' + text + '
', processed: true } ); @@ -145,22 +143,26 @@ window.wp = window.wp || {}; /** * Create a view instance. * - * @param {String} type The view type. - * @param {String} text The textual representation of the view. - * @param {Object} options Options. + * @param {String} type The view type. + * @param {String} text The textual representation of the view. + * @param {Object} options Options. + * @param {Boolean} force Recreate the instance. Optional. * * @return {wp.mce.View} The view instance. */ - createInstance: function( type, text, options ) { + createInstance: function( type, text, options, force ) { var View = this.get( type ), encodedText, instance; text = tinymce.DOM.decode( text ); - instance = this.getInstance( text ); - if ( instance ) { - return instance; + if ( ! force ) { + instance = this.getInstance( text ); + + if ( instance ) { + return instance; + } } encodedText = encodeURIComponent( text ); @@ -216,12 +218,13 @@ window.wp = window.wp || {}; * @param {String} text The new text. * @param {tinymce.Editor} editor The TinyMCE editor instance the view node is in. * @param {HTMLElement} node The view node to update. + * @param {Boolean} force Recreate the instance. Optional. */ - update: function( text, editor, node ) { + update: function( text, editor, node, force ) { var instance = this.getInstance( node ); if ( instance ) { - instance.update( text, editor, node ); + instance.update( text, editor, node, force ); } }, @@ -235,8 +238,8 @@ window.wp = window.wp || {}; var instance = this.getInstance( node ); if ( instance && instance.edit ) { - instance.edit( instance.text, function( text ) { - instance.update( text, editor, node ); + instance.edit( instance.text, function( text, force ) { + instance.update( text, editor, node, force ); } ); } }, @@ -302,8 +305,8 @@ window.wp = window.wp || {}; /** * Renders all view nodes tied to this view instance that are not yet rendered. * - * @param {String} content The content to render. Optional. - * @param {Boolean} force Rerender all view nodes tied to this view instance. + * @param {String} content The content to render. Optional. + * @param {Boolean} force Rerender all view nodes tied to this view instance. Optional. */ render: function( content, force ) { if ( content != null ) { @@ -324,9 +327,9 @@ window.wp = window.wp || {}; this.replaceMarkers(); if ( content ) { - this.setContent( content, function( editor, node, contentNode ) { + this.setContent( content, function( editor, node ) { $( node ).data( 'rendered', true ); - this.bindNode.call( this, editor, node, contentNode ); + this.bindNode.call( this, editor, node ); }, force ? null : false ); } else { this.setLoader(); @@ -348,9 +351,8 @@ window.wp = window.wp || {}; * Runs before their content is removed from the DOM. */ unbind: function() { - this.getNodes( function( editor, node, contentNode ) { - this.unbindNode.call( this, editor, node, contentNode ); - $( node ).trigger( 'wp-mce-view-unbind' ); + this.getNodes( function( editor, node ) { + this.unbindNode.call( this, editor, node ); }, true ); }, @@ -391,7 +393,7 @@ window.wp = window.wp || {}; return rendered ? data : ! data; } ) .each( function() { - callback.call( self, editor, this, $( this ).find( '.wpview-content' ).get( 0 ) ); + callback.call( self, editor, this, this /* back compat */ ); } ); } ); }, @@ -418,23 +420,18 @@ window.wp = window.wp || {}; */ replaceMarkers: function() { this.getMarkers( function( editor, node ) { + var $viewNode; + if ( ! this.loader && $( node ).text() !== this.text ) { editor.dom.setAttrib( node, 'data-wpview-marker', null ); return; } - editor.dom.replace( - editor.dom.createFragment( - '\u00a0
' + - '\u00a0
' + - '