diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index 4eb876d0ae..1c6b02b485 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -322,9 +322,9 @@ window.wp = window.wp || {}; this.replaceMarkers(); if ( content ) { - this.setContent( content, function( editor, node ) { + this.setContent( content, function( editor, node, contentNode ) { $( node ).data( 'rendered', true ); - this.bindNode.call( this, editor, node ); + this.bindNode.call( this, editor, node, contentNode ); }, force ? null : false ); } else { this.setLoader(); @@ -346,8 +346,8 @@ window.wp = window.wp || {}; * Runs before their content is removed from the DOM. */ unbind: function() { - this.getNodes( function( editor, node ) { - this.unbindNode.call( this, editor, node ); + this.getNodes( function( editor, node, contentNode ) { + this.unbindNode.call( this, editor, node, contentNode ); $( node ).trigger( 'wp-mce-view-unbind' ); }, true ); }, @@ -485,7 +485,7 @@ window.wp = window.wp || {}; var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, self = this; - this.getNodes( function( editor, node, content ) { + this.getNodes( function( editor, node, contentNode ) { var dom = editor.dom, styles = '', bodyClasses = editor.getBody().className || '', @@ -504,9 +504,9 @@ window.wp = window.wp || {}; setTimeout( function() { var iframe, iframeDoc, observer, i; - content.innerHTML = ''; + contentNode.innerHTML = ''; - iframe = dom.add( content, 'iframe', { + iframe = dom.add( contentNode, 'iframe', { /* jshint scripturl: true */ src: tinymce.Env.ie ? 'javascript:""' : '', frameBorder: '0', @@ -519,7 +519,7 @@ window.wp = window.wp || {}; } } ); - dom.add( content, 'div', { 'class': 'wpview-overlay' } ); + dom.add( contentNode, 'div', { 'class': 'wpview-overlay' } ); iframeDoc = iframe.contentWindow.document; @@ -603,7 +603,7 @@ window.wp = window.wp || {}; editor.off( 'wp-body-class-change', classChange ); } ); - callback && callback.call( self, editor, node ); + callback && callback.call( self, editor, node, contentNode ); }, 50 ); }, rendered ); }, diff --git a/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index 01c7b04d35..8354db30f6 100644 --- a/wp-includes/js/mce-view.min.js +++ b/wp-includes/js/mce-view.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a,b,c){"use strict";var d={},e={};b.mce=b.mce||{},b.mce.views={register:function(a,c){d[a]=b.mce.View.extend(_.extend(c,{type:a}))},unregister:function(a){delete d[a]},get:function(a){return d[a]},unbind:function(){_.each(e,function(a){a.unbind()})},setMarkers:function(a){var b,c,e=[{content:a}],f=this;return _.each(d,function(a,d){c=e.slice(),e=[],_.each(c,function(c){var g,h=c.content;if(c.processed)return void e.push(c);for(;h&&(g=a.prototype.match(h));)g.index&&e.push({content:h.substring(0,g.index)}),b=f.createInstance(d,g.content,g.options),e.push({content:'
'+b.text+"
",processed:!0}),h=h.slice(g.index+g.content.length);h&&e.push({content:h})})}),_.pluck(e,"content").join("")},createInstance:function(a,b,c){var d,f,g=this.get(a);return b=tinymce.DOM.decode(b),d=encodeURIComponent(b),(f=this.getInstance(d))?f:(c=_.extend(c||{},{text:b,encodedText:d}),e[d]=new g(c))},getInstance:function(a){return"string"==typeof a?e[encodeURIComponent(a)]:e[c(a).attr("data-wpview-text")]},getText:function(a){return decodeURIComponent(c(a).attr("data-wpview-text")||"")},render:function(a){_.each(e,function(b){b.render(a)})},update:function(a,b,c){var d=this.getInstance(c);d&&d.update(a,b,c)},edit:function(a,b){var c=this.getInstance(b);c&&c.edit&&c.edit(c.text,function(d){c.update(d,a,b)})},remove:function(a,b){var c=this.getInstance(b);c&&c.remove(a,b)}},b.mce.View=function(a){_.extend(this,a),this.initialize()},b.mce.View.extend=Backbone.View.extend,_.extend(b.mce.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(){return this.content},render:function(a,b){null!=a&&(this.content=a),a=this.getContent(),(this.loader||a)&&(b&&this.unbind(),this.replaceMarkers(),a?this.setContent(a,function(a,b){c(b).data("rendered",!0),this.bindNode.call(this,a,b)},b?null:!1):this.setLoader())},bindNode:function(){},unbindNode:function(){},unbind:function(){this.getNodes(function(a,b){this.unbindNode.call(this,a,b),c(b).trigger("wp-mce-view-unbind")},!0)},getEditors:function(a){_.each(tinymce.editors,function(b){b.plugins.wpview&&a.call(this,b)},this)},getNodes:function(a,b){this.getEditors(function(d){var e=this;c(d.getBody()).find('[data-wpview-text="'+e.encodedText+'"]').filter(function(){var a;return null==b?!0:(a=c(this).data("rendered")===!0,b?a:!a)}).each(function(){a.call(e,d,this,c(this).find(".wpview-content").get(0))})})},getMarkers:function(a){this.getEditors(function(b){var d=this;c(b.getBody()).find('[data-wpview-marker="'+this.encodedText+'"]').each(function(){a.call(d,b,this)})})},replaceMarkers:function(){this.getMarkers(function(a,b){return c(b).text()!==this.text?void a.dom.setAttrib(b,"data-wpview-marker",null):void a.dom.replace(a.dom.createFragment('