diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index b54470dba1..7552b221ba 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -87,6 +87,8 @@ window.wp = window.wp || {}; * and creates a new instance for every match. * * @param {String} content The string to scan. + * + * @return {String} The string with markers. */ setMarkers: function( content ) { var pieces = [ { content: content } ], @@ -298,11 +300,18 @@ 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. */ - render: function( force ) { + render: function( content, force ) { + if ( content != null ) { + this.content = content; + } + + content = this.getContent(); + // If there's nothing to render an no loader needs to be shown, stop. - if ( ! this.loader && ! this.getContent() ) { + if ( ! this.loader && ! content ) { return; } @@ -312,21 +321,33 @@ window.wp = window.wp || {}; // Replace any left over markers. this.replaceMarkers(); - if ( this.getContent() ) { - this.setContent( this.getContent(), function( editor, node ) { - $( node ).data( 'rendered', true ).trigger( 'wp-mce-view-bind' ); + if ( content ) { + this.setContent( content, function( editor, node ) { + $( node ).data( 'rendered', true ); + this.bindNode.call( this, editor, node ); }, force ? null : false ); } else { this.setLoader(); } }, + /** + * Binds a given node after its content is added to the DOM. + */ + bindNode: function() {}, + + /** + * Unbinds a given node before its content is removed from the DOM. + */ + unbindNode: function() {}, + /** * Unbinds all view nodes tied to this view instance. * Runs before their content is removed from the DOM. */ unbind: function() { this.getNodes( function( editor, node ) { + this.unbindNode.call( this, editor, node ); $( node ).trigger( 'wp-mce-view-unbind' ); }, true ); }, @@ -447,7 +468,7 @@ window.wp = window.wp || {}; contentNode.innerHTML = ''; contentNode.appendChild( _.isString( content ) ? editor.dom.createFragment( content ) : content ); - callback && callback.apply( this, arguments ); + callback && callback.call( this, editor, node, contentNode ); }, rendered ); } }, @@ -461,30 +482,27 @@ window.wp = window.wp || {}; * @param {Boolean} rendered Only set for (un)rendered nodes. Optional. */ setIframes: function( head, body, callback, rendered ) { - var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, + self = this; this.getNodes( function( editor, node, content ) { - // Seems Firefox needs a bit of time to insert/set the view nodes, + var dom = editor.dom, + styles = '', + bodyClasses = editor.getBody().className || '', + editorHead = editor.getDoc().getElementsByTagName( 'head' )[0], + iframe, iframeDoc, observer, i; + + tinymce.each( dom.$( 'link[rel="stylesheet"]', editorHead ), function( link ) { + if ( link.href && link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 && + link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 ) { + + styles += dom.getOuterHTML( link ); + } + } ); + + // Seems the browsers need a bit of time to insert/set the view nodes, // or the iframe will fail especially when switching Text => Visual. setTimeout( function() { - var dom = editor.dom, - styles = '', - bodyClasses = editor.getBody().className || '', - iframe, iframeDoc, observer, i; - - tinymce.each( dom.$( - 'link[rel="stylesheet"]', - editor.getDoc().getElementsByTagName( 'head' )[0] - ), function( link ) { - if ( - link.href && - link.href.indexOf( 'skins/lightgray/content.min.css' ) === -1 && - link.href.indexOf( 'skins/wordpress/wp-content.css' ) === -1 - ) { - styles += dom.getOuterHTML( link ); - } - } ); - content.innerHTML = ''; iframe = dom.add( content, 'iframe', { @@ -582,7 +600,7 @@ window.wp = window.wp || {}; editor.off( 'wp-body-class-change', classChange ); } ); - callback && callback.apply( this, arguments ); + callback && callback.call( self, editor, node ); }, 50 ); }, rendered ); }, @@ -664,6 +682,7 @@ window.wp = window.wp || {}; * @param {HTMLElement} node The view node to remove. */ remove: function( editor, node ) { + this.unbindNode.call( this, editor, node, $( node ).find( '.wpview-content' ).get( 0 ) ); $( node ).trigger( 'wp-mce-view-unbind' ); editor.dom.remove( node ); editor.focus(); @@ -728,12 +747,10 @@ window.wp = window.wp || {}; } } ); - self.content = self.template( { + self.render( self.template( { attachments: attachments, columns: attrs.columns ? parseInt( attrs.columns, 10 ) : wp.media.galleryDefaults.columns - } ); - - self.render(); + } ) ); } ) .fail( function( jqXHR, textStatus ) { self.setError( textStatus ); @@ -754,16 +771,13 @@ window.wp = window.wp || {}; } ); } - wp.ajax.send( this.action, { - data: { - post_ID: postID, - type: this.shortcode.tag, - shortcode: this.shortcode.string() - } + wp.ajax.post( this.action, { + post_ID: postID, + type: this.shortcode.tag, + shortcode: this.shortcode.string() } ) .done( function( response ) { - self.content = response; - self.render(); + self.render( response ); } ) .fail( function( response ) { if ( self.url ) { diff --git a/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index b8bb8aca9c..7d30c672cb 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){(this.loader||this.getContent())&&(a&&this.unbind(),this.replaceMarkers(),this.getContent()?this.setContent(this.getContent(),function(a,b){c(b).data("rendered",!0).trigger("wp-mce-view-bind")},a?null:!1):this.setLoader())},unbind:function(){this.getNodes(function(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('

 

 

'),b)})},removeMarkers:function(){this.getMarkers(function(a,b){a.dom.setAttrib(b,"data-wpview-marker",null)})},setContent:function(a,b,c){_.isObject(a)&&-1!==a.body.indexOf("'),e.innerHTML="",e.appendChild(_.isString(a)?c.dom.createFragment(a):a),b&&b.apply(this,arguments)},c)},setIframes:function(b,d,e,f){var g=a.MutationObserver||a.WebKitMutationObserver||a.MozMutationObserver;this.getNodes(function(a,f,h){setTimeout(function(){function i(){var b,d;k.contentWindow&&(b=c(k),d=c(l.body).height(),b.height()!==d&&(b.height(d),a.nodeChanged()))}function j(){l.body.className=a.getBody().className}var k,l,m,n,o=a.dom,p="",q=a.getBody().className||"";if(tinymce.each(o.$('link[rel="stylesheet"]',a.getDoc().getElementsByTagName("head")[0]),function(a){a.href&&-1===a.href.indexOf("skins/lightgray/content.min.css")&&-1===a.href.indexOf("skins/wordpress/wp-content.css")&&(p+=o.getOuterHTML(a))}),h.innerHTML="",k=o.add(h,"iframe",{src:tinymce.Env.ie?'javascript:""':"",frameBorder:"0",allowTransparency:"true",scrolling:"no","class":"wpview-sandbox",style:{width:"100%",display:"block"}}),o.add(h,"div",{"class":"wpview-overlay"}),l=k.contentWindow.document,l.open(),l.write(''+b+p+''+d+""),l.close(),g)m=new g(_.debounce(i,100)),m.observe(l.body,{attributes:!0,childList:!0,subtree:!0}),c(f).one("wp-mce-view-unbind",function(){m.disconnect()});else for(n=1;6>n;n++)setTimeout(i,700*n);a.on("wp-body-class-change",j),c(f).one("wp-mce-view-unbind",function(){a.off("wp-body-class-change",j)}),e&&e.apply(this,arguments)},50)},f)},setLoader:function(){this.setContent('
')},setError:function(a,b){this.setContent('

'+a+"

")},match:function(a){var c=b.shortcode.next(this.type,a);return c?{index:c.index,content:c.content,options:{shortcode:c.shortcode}}:void 0},update:function(a,e,f){_.find(d,function(d,g){var h=d.prototype.match(a);return h?(c(f).data("rendered",!1),e.dom.setAttrib(f,"data-wpview-text",encodeURIComponent(a)),b.mce.views.createInstance(g,a,h.options).render(),e.focus(),!0):void 0})},remove:function(a,b){c(b).trigger("wp-mce-view-unbind"),a.dom.remove(b),a.focus()}})}(window,window.wp,window.jQuery),function(a,b,c){var d,e,f,g,h=c("#post_ID").val()||0;d={state:[],edit:function(a,b){var c=wp.media[this.type],d=c.edit(a);this.pausePlayers&&this.pausePlayers(),_.each(this.state,function(a){d.state(a).on("update",function(a){b(c.shortcode(a).string())})}),d.on("close",function(){d.detach()}),d.open()}},e=_.extend({},d,{state:["gallery-edit"],template:wp.media.template("editor-gallery"),initialize:function(){var a=wp.media.gallery.attachments(this.shortcode,h),b=this.shortcode.attrs.named,c=this;a.more().done(function(){a=a.toJSON(),_.each(a,function(a){a.sizes&&(b.size&&a.sizes[b.size]?a.thumbnail=a.sizes[b.size]:a.sizes.thumbnail?a.thumbnail=a.sizes.thumbnail:a.sizes.full&&(a.thumbnail=a.sizes.full))}),c.content=c.template({attachments:a,columns:b.columns?parseInt(b.columns,10):wp.media.galleryDefaults.columns}),c.render()}).fail(function(a,b){c.setError(b)})}}),f=_.extend({},d,{action:"parse-media-shortcode",initialize:function(){var a=this;this.url&&(this.loader=!1,this.shortcode=wp.media.embed.shortcode({url:this.text})),wp.ajax.send(this.action,{data:{post_ID:h,type:this.shortcode.tag,shortcode:this.shortcode.string()}}).done(function(b){a.content=b,a.render()}).fail(function(b){a.url?a.removeMarkers():a.setError(b.message||b.statusText,"admin-media")}),this.getEditors(function(b){b.on("wpview-selected",function(){a.pausePlayers()})})},pausePlayers:function(){this.getNodes(function(a,b,d){var e=c("iframe.wpview-sandbox",d).get(0);e&&(e=e.contentWindow)&&e.mejs&&_.each(e.mejs.players,function(a){try{a.pause()}catch(b){}})})}}),g=_.extend({},f,{action:"parse-embed",edit:function(a,b){var c=wp.media.embed,d=c.edit(a,this.url),e=this,f="change:url change:width change:height";this.pausePlayers(),d.state("embed").props.on(f,function(a,b){b&&a.get("url")&&(d.state("embed").metadata=a.toJSON())}),d.state("embed").on("select",function(){var a=d.state("embed").metadata;b(e.url&&!a.width?a.url:c.shortcode(a).string())}),d.on("close",function(){d.detach()}),d.open()}}),b.register("gallery",_.extend({},e)),b.register("audio",_.extend({},f,{state:["audio-details"]})),b.register("video",_.extend({},f,{state:["video-details"]})),b.register("playlist",_.extend({},f,{state:["playlist-edit","video-playlist-edit"]})),b.register("embed",_.extend({},g)),b.register("embedURL",_.extend({},g,{match:function(a){var b=/(^|

)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi,c=b.exec(a);return c?{index:c.index+c[1].length,content:c[2],options:{url:!0}}:void 0}}))}(window,window.wp.mce.views,window.jQuery); \ No newline at end of file +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('

 

 

'),b)})},removeMarkers:function(){this.getMarkers(function(a,b){a.dom.setAttrib(b,"data-wpview-marker",null)})},setContent:function(a,b,c){_.isObject(a)&&-1!==a.body.indexOf("'),e.innerHTML="",e.appendChild(_.isString(a)?c.dom.createFragment(a):a),b&&b.call(this,c,d,e)},c)},setIframes:function(b,d,e,f){var g=a.MutationObserver||a.WebKitMutationObserver||a.MozMutationObserver,h=this;this.getNodes(function(a,f,i){var j,k,l,m,n=a.dom,o="",p=a.getBody().className||"",q=a.getDoc().getElementsByTagName("head")[0];tinymce.each(n.$('link[rel="stylesheet"]',q),function(a){a.href&&-1===a.href.indexOf("skins/lightgray/content.min.css")&&-1===a.href.indexOf("skins/wordpress/wp-content.css")&&(o+=n.getOuterHTML(a))}),setTimeout(function(){function q(){var b,d;j.contentWindow&&(b=c(j),d=c(k.body).height(),b.height()!==d&&(b.height(d),a.nodeChanged()))}function r(){k.body.className=a.getBody().className}if(i.innerHTML="",j=n.add(i,"iframe",{src:tinymce.Env.ie?'javascript:""':"",frameBorder:"0",allowTransparency:"true",scrolling:"no","class":"wpview-sandbox",style:{width:"100%",display:"block"}}),n.add(i,"div",{"class":"wpview-overlay"}),k=j.contentWindow.document,k.open(),k.write(''+b+o+''+d+""),k.close(),g)l=new g(_.debounce(q,100)),l.observe(k.body,{attributes:!0,childList:!0,subtree:!0}),c(f).one("wp-mce-view-unbind",function(){l.disconnect()});else for(m=1;6>m;m++)setTimeout(q,700*m);a.on("wp-body-class-change",r),c(f).one("wp-mce-view-unbind",function(){a.off("wp-body-class-change",r)}),e&&e.call(h,a,f)},50)},f)},setLoader:function(){this.setContent('
')},setError:function(a,b){this.setContent('

'+a+"

")},match:function(a){var c=b.shortcode.next(this.type,a);return c?{index:c.index,content:c.content,options:{shortcode:c.shortcode}}:void 0},update:function(a,e,f){_.find(d,function(d,g){var h=d.prototype.match(a);return h?(c(f).data("rendered",!1),e.dom.setAttrib(f,"data-wpview-text",encodeURIComponent(a)),b.mce.views.createInstance(g,a,h.options).render(),e.focus(),!0):void 0})},remove:function(a,b){this.unbindNode.call(this,a,b,c(b).find(".wpview-content").get(0)),c(b).trigger("wp-mce-view-unbind"),a.dom.remove(b),a.focus()}})}(window,window.wp,window.jQuery),function(a,b,c){var d,e,f,g,h=c("#post_ID").val()||0;d={state:[],edit:function(a,b){var c=wp.media[this.type],d=c.edit(a);this.pausePlayers&&this.pausePlayers(),_.each(this.state,function(a){d.state(a).on("update",function(a){b(c.shortcode(a).string())})}),d.on("close",function(){d.detach()}),d.open()}},e=_.extend({},d,{state:["gallery-edit"],template:wp.media.template("editor-gallery"),initialize:function(){var a=wp.media.gallery.attachments(this.shortcode,h),b=this.shortcode.attrs.named,c=this;a.more().done(function(){a=a.toJSON(),_.each(a,function(a){a.sizes&&(b.size&&a.sizes[b.size]?a.thumbnail=a.sizes[b.size]:a.sizes.thumbnail?a.thumbnail=a.sizes.thumbnail:a.sizes.full&&(a.thumbnail=a.sizes.full))}),c.render(c.template({attachments:a,columns:b.columns?parseInt(b.columns,10):wp.media.galleryDefaults.columns}))}).fail(function(a,b){c.setError(b)})}}),f=_.extend({},d,{action:"parse-media-shortcode",initialize:function(){var a=this;this.url&&(this.loader=!1,this.shortcode=wp.media.embed.shortcode({url:this.text})),wp.ajax.post(this.action,{post_ID:h,type:this.shortcode.tag,shortcode:this.shortcode.string()}).done(function(b){a.render(b)}).fail(function(b){a.url?a.removeMarkers():a.setError(b.message||b.statusText,"admin-media")}),this.getEditors(function(b){b.on("wpview-selected",function(){a.pausePlayers()})})},pausePlayers:function(){this.getNodes(function(a,b,d){var e=c("iframe.wpview-sandbox",d).get(0);e&&(e=e.contentWindow)&&e.mejs&&_.each(e.mejs.players,function(a){try{a.pause()}catch(b){}})})}}),g=_.extend({},f,{action:"parse-embed",edit:function(a,b){var c=wp.media.embed,d=c.edit(a,this.url),e=this,f="change:url change:width change:height";this.pausePlayers(),d.state("embed").props.on(f,function(a,b){b&&a.get("url")&&(d.state("embed").metadata=a.toJSON())}),d.state("embed").on("select",function(){var a=d.state("embed").metadata;b(e.url&&!a.width?a.url:c.shortcode(a).string())}),d.on("close",function(){d.detach()}),d.open()}}),b.register("gallery",_.extend({},e)),b.register("audio",_.extend({},f,{state:["audio-details"]})),b.register("video",_.extend({},f,{state:["video-details"]})),b.register("playlist",_.extend({},f,{state:["playlist-edit","video-playlist-edit"]})),b.register("embed",_.extend({},g)),b.register("embedURL",_.extend({},g,{match:function(a){var b=/(^|

)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi,c=b.exec(a);return c?{index:c.index+c[1].length,content:c[2],options:{url:!0}}:void 0}}))}(window,window.wp.mce.views,window.jQuery); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpview/plugin.js b/wp-includes/js/tinymce/plugins/wpview/plugin.js index 9a8b650e1c..db9db466fc 100644 --- a/wp-includes/js/tinymce/plugins/wpview/plugin.js +++ b/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -4,7 +4,8 @@ * WordPress View plugin. */ tinymce.PluginManager.add( 'wpview', function( editor ) { - var selected, + var $ = editor.$, + selected, Env = tinymce.Env, VK = tinymce.util.VK, TreeWalker = tinymce.dom.TreeWalker, @@ -153,13 +154,17 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { // Remove the content of view wrappers from HTML string function emptyViews( content ) { - return content.replace(/]+data-wpview-text=\"([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>(?: |\u00a0)*<\/p><\/div>/g, '$1' ); + content = content.replace( /]+data-wpview-text="([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*<\/div>/g, function( all, match ) { + return '

' + window.decodeURIComponent( match ) + '

'; + }); + + return content.replace( / data-wpview-marker="[^"]+"/g, '' ); } // Prevent adding undo levels on changes inside a view wrapper editor.on( 'BeforeAddUndo', function( event ) { - if ( event.lastLevel && emptyViews( event.level.content ) === emptyViews( event.lastLevel.content ) ) { - event.preventDefault(); + if ( event.level.content ) { + event.level.content = emptyViews( event.level.content ); } }); @@ -169,6 +174,10 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { editor.on( 'BeforeSetContent', function( event ) { var node; + if ( ! event.selection ) { + wp.mce.views.unbind(); + } + if ( ! event.content ) { return; } @@ -339,22 +348,30 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { } }); - editor.on( 'PreProcess', function( event ) { - // Empty the wpview wrap nodes - tinymce.each( editor.dom.select( 'div[data-wpview-text]', event.node ), function( node ) { - node.textContent = node.innerText = '\u00a0'; - }); - }); + function resetViews( rootNode ) { + // Replace view nodes + $( 'div[data-wpview-text]', rootNode ).each( function( i, node ) { + var $node = $( node ), + text = window.decodeURIComponent( $node.attr( 'data-wpview-text' ) || '' ); - editor.on( 'PostProcess', function( event ) { - if ( event.content ) { - event.content = event.content.replace( /
]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g, function( match, shortcode ) { - if ( shortcode ) { - return '

' + window.decodeURIComponent( shortcode ) + '

'; - } - return ''; // If error, remove the view wrapper - }); - } + if ( text && node.parentNode ) { + $node.replaceWith( $( editor.dom.create('p') ).text( text ) ); + } + }); + + // Remove marker attributes + $( 'p[data-wpview-marker]', rootNode ).attr( 'data-wpview-marker', null ); + } + + editor.on( 'PreProcess', function( event ) { + // Replace the view nodes with their text in the DOM clone. + resetViews( event.node ); + }, true ); + + editor.on( 'hide', function() { + // Replace the view nodes with their text directly in the editor body. + wp.mce.views.unbind(); + resetViews( editor.getBody() ); }); // Excludes arrow keys, delete, backspace, enter, space bar. diff --git a/wp-includes/js/tinymce/plugins/wpview/plugin.min.js b/wp-includes/js/tinymce/plugins/wpview/plugin.min.js index 91938b01d2..01287fb2d5 100644 --- a/wp-includes/js/tinymce/plugins/wpview/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wpview/plugin.min.js @@ -1 +1 @@ -tinymce.PluginManager.add("wpview",function(a){function b(a){return c(a,"wpview-wrap")}function c(a,b){for(;a&&a.parentNode;){if(a.className&&-1!==(" "+a.className+" ").indexOf(" "+b+" "))return a;a=a.parentNode}return!1}function d(a){a.stopPropagation()}function e(b,c){var d=b?"before":"after",e=b?0:1;i(),a.selection.setCursorLocation(a.dom.select(".wpview-selection-"+d,c)[0],e),a.nodeChanged()}function f(b,c,d){var f=a.dom,g=f.create("p");t.ie&&t.ie<11||(g.innerHTML='
'),c?b.parentNode.insertBefore(g,b):f.insertAfter(g,b),i(),c&&d===u.ENTER?e(c,b):a.selection.setCursorLocation(g,0),a.nodeChanged()}function g(b){a.undoManager.transact(function(){f(b),wp.mce.views.remove(a,b)})}function h(b){var c,e=a.dom;b&&(b!==l&&(a.getBody().focus(),i(),l=b,e.setAttrib(b,"data-mce-selected",1),c=e.create("div",{"class":"wpview-clipboard",contenteditable:"true"},wp.mce.views.getText(b)),a.dom.select(".wpview-body",b)[0].appendChild(c),e.bind(c,"beforedeactivate focusin focusout",d),e.bind(l,"beforedeactivate focusin focusout",d),z?a.selection.select(c):a.selection.select(c,!0)),a.nodeChanged(),a.fire("wpview-selected",b))}function i(){var b,c=a.dom;l&&(b=a.dom.select(".wpview-clipboard",l)[0],c.unbind(b),c.remove(b),c.unbind(l,"beforedeactivate focusin focusout click mouseup",d),c.setAttrib(l,"data-mce-selected",null)),l=null}function j(a){return a.replace(/]+data-wpview-text=\"([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>(?: |\u00a0)*<\/p><\/div>/g,"$1")}function k(a){return 47>=a&&a!==u.SPACEBAR&&a!==u.ENTER&&a!==u.DELETE&&a!==u.BACKSPACE&&(37>a||a>40)||a>=224||a>=144&&150>=a||a>=91&&93>=a||a>=112&&135>=a}var l,m,n,o,p,q,r,s,t=tinymce.Env,u=tinymce.util.VK,v=tinymce.dom.TreeWalker,w=!1,x=!0,y=function(){return!1},z=/iPad|iPod|iPhone/.test(navigator.userAgent);return"undefined"!=typeof wp&&wp.mce?(a.on("BeforeAddUndo",function(a){a.lastLevel&&j(a.level.content)===j(a.lastLevel.content)&&a.preventDefault()}),a.on("BeforeSetContent",function(b){var c;if(b.content){if(l&&g(l),!b.load&&(c=a.selection.getNode(),c&&c!==a.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(b.content))){if(c=a.dom.getParent(c,"p"),!c||!/^[\s\uFEFF\u00A0]*$/.test(c.textContent||c.innerText))return;c.innerHTML=""}b.content=wp.mce.views.setMarkers(b.content)}}),a.on("pastePreProcess",function(a){var b=a.content;b&&(b=tinymce.trim(b.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(b)&&(a.content=b))}),a.on("SetContent",function(){wp.mce.views.render()}),a.on("click",function(c){var d,f,g,h=c.clientX,i=c.clientY,j=a.getBody(),k=j.getBoundingClientRect(),l=j.firstChild,m=j.lastChild;l&&m&&(d=l.getBoundingClientRect(),f=m.getBoundingClientRect(),if.bottom&&(g=b(m))?(e(!1,g),c.preventDefault()):(hk.right)&&tinymce.each(a.dom.select(".wpview-wrap"),function(a){var b=a.getBoundingClientRect();return i=b.top&&i<=b.bottom?(hk.right&&(e(!1,a),c.preventDefault()),!1):void 0}))}),a.on("init",function(){var c=!1,d=a.selection,e=window.MutationObserver||window.WebKitMutationObserver;a.on("BeforeSetContent",function(){var c,e,f=b(d.getNode());f&&(!f.nextSibling||b(f.nextSibling)?(e=a.getDoc().createTextNode(""),a.dom.insertAfter(e,f)):(c=new v(f.nextSibling,f.nextSibling),e=c.next()),d.select(e),d.collapse(!0))}),a.dom.bind(a.getDoc(),"touchmove",function(){c=!0}),a.on("mousedown mouseup click touchend",function(a){var d=b(a.target);return x=!1,d?(a.stopImmediatePropagation(),a.preventDefault(),"touchend"===a.type&&c?c=!1:h(d),!1):(("touchend"===a.type||"mousedown"===a.type)&&i(),void("touchend"===a.type&&c&&(c=!1)))},!0),e&&new e(function(){a.fire("wp-body-class-change")}).observe(a.getBody(),{attributes:!0,attributeFilter:["class"]})}),a.on("PreProcess",function(b){tinymce.each(a.dom.select("div[data-wpview-text]",b.node),function(a){a.textContent=a.innerText=" "})}),a.on("PostProcess",function(a){a.content&&(a.content=a.content.replace(/
]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g,function(a,b){return b?"

"+window.decodeURIComponent(b)+"

":""}))}),a.on("keydown",function(c){var d,j,m,o,p,q,r,s=c.keyCode,t=a.dom,v=a.selection;if(l){if((c.metaKey||c.ctrlKey)&&s!==u.BACKSPACE&&86!==s||s>=112&&123>=s)return void((c.metaKey||c.ctrlKey)&&88===s&&(w=l));if(j=b(v.getNode()),j!==l)return void i();s===u.LEFT?(e(!0,j),c.preventDefault()):s===u.UP?(j.previousSibling?b(j.previousSibling)?e(!0,j.previousSibling):(i(),v.select(j.previousSibling,!0),v.collapse()):e(!0,j),c.preventDefault()):s===u.RIGHT?(e(!1,j),c.preventDefault()):s===u.DOWN?(j.nextSibling?b(j.nextSibling)?e(!1,j.nextSibling):(i(),v.setCursorLocation(j.nextSibling,0)):e(!1,j),c.preventDefault()):k(s)||(g(l),(s===u.ENTER||s===u.DELETE||s===u.BACKSPACE)&&c.preventDefault())}else{if(c.metaKey||c.ctrlKey||s>=112&&123>=s)return;if(d=v.getNode(),n=d,j=b(d),v.isCollapsed()||(p=v.getRng(),(j=b(p.endContainer))?(q=p.cloneRange(),v.select(j.previousSibling,!0),v.collapse(),r=v.getRng(),q.setEnd(r.endContainer,r.endOffset),v.setRng(q)):(j=b(p.startContainer))&&(q=p.cloneRange(),q.setStart(j.nextSibling,0),v.setRng(q))),!j)return void(c.keyCode===u.BACKSPACE&&(a.dom.isEmpty(d)?(j=b(d.previousSibling))&&(e(!1,j),a.dom.remove(d),c.preventDefault()):(p=v.getRng())&&0===p.startOffset&&0===p.endOffset&&(j=b(d.previousSibling))&&(e(!1,j),c.preventDefault())));if(!(m=t.hasClass(j,"wpview-selection-before"))&&!(o=t.hasClass(j,"wpview-selection-after")))return;if(k(s))return;o&&s===u.UP||m&&s===u.BACKSPACE?(j.previousSibling?b(j.previousSibling)?e(!1,j.previousSibling):t.isEmpty(j.previousSibling)&&s===u.BACKSPACE?t.remove(j.previousSibling):(v.select(j.previousSibling,!0),v.collapse()):e(!0,j),c.preventDefault()):!o||s!==u.DOWN&&s!==u.RIGHT?!m||s!==u.UP&&s!==u.LEFT?m&&s===u.DOWN?(j.nextSibling?b(j.nextSibling)?e(!0,j.nextSibling):v.setCursorLocation(j.nextSibling,0):e(!1,j),c.preventDefault()):o&&s===u.LEFT||m&&s===u.RIGHT?(h(j),c.preventDefault()):o&&s===u.BACKSPACE?(g(j),c.preventDefault()):o?f(j):m&&f(j,!0,s):(j.previousSibling&&(b(j.previousSibling)?e(s===u.UP,j.previousSibling):(v.select(j.previousSibling,!0),v.collapse())),c.preventDefault()):(j.nextSibling&&(b(j.nextSibling)?e(s===u.RIGHT,j.nextSibling):v.setCursorLocation(j.nextSibling,0)),c.preventDefault()),s===u.ENTER&&c.preventDefault()}}),a.on("keyup",function(){w&&(g(w),w=!1)}),a.on("focus",function(){var c;p=!0,a.dom.addClass(a.getBody(),"has-focus"),x&&(c=b(a.getBody().firstChild))&&e(!0,c),x=!1}),a.on("blur",function(){p=!1,a.dom.removeClass(a.getBody(),"has-focus")}),a.on("NodeChange",function(d){var f=a.dom,g=a.dom.select(".wpview-wrap"),h=d.element.className,j=b(d.element),k=n;if(n=!1,clearInterval(m),tinymce.each(g,function(a){a.className&&(a.className=a.className.replace(/ ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g,""))}),p&&j)if("wpview-selection-before"!==h&&"wpview-selection-after"!==h||!a.selection.isCollapsed())c(d.element,"wpview-clipboard")||o||(i(),o++,e(!0,j));else{if(o=0,i(),k===j.previousSibling)return void e(!0,j);if(k===j.nextSibling)return void e(!1,j);f.addClass(j,h),m=setInterval(function(){f.hasClass(j,"wpview-cursor-hide")?f.removeClass(j,"wpview-cursor-hide"):f.addClass(j,"wpview-cursor-hide")},500)}}),a.on("BeforeExecCommand",function(){var c,d=a.selection.getNode();d&&((r="wpview-selection-before"===d.className)||"wpview-selection-after"===d.className)&&(c=b(d))&&(f(c,r),q=c)}),a.on("ExecCommand",function(){var b,c;l&&(b=l,i(),h(b)),q&&(c=q[r?"previousSibling":"nextSibling"],c&&"P"===c.nodeName&&a.dom.isEmpty(c)&&(a.dom.remove(c),e(r,q)),q=!1)}),a.on("ResolveName",function(c){a.dom.hasClass(c.target,"wpview-wrap")?(c.name=a.dom.getAttrib(c.target,"data-wpview-type")||"wpview",c.stopPropagation()):b(c.target)&&(c.preventDefault(),c.stopPropagation())}),a.addButton("wp_view_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",onclick:function(){l&&wp.mce.views.edit(a,l)}}),a.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){l&&g(l)}}),a.once("preinit",function(){s=a.wp._createToolbar(["wp_view_edit","wp_view_remove"])}),a.on("wptoolbar",function(a){l&&(a.element=l,a.toolbar=s)}),a.wp=a.wp||{},a.wp.getView=b,{getView:b}):{getView:y}}); \ No newline at end of file +tinymce.PluginManager.add("wpview",function(a){function b(a){return c(a,"wpview-wrap")}function c(a,b){for(;a&&a.parentNode;){if(a.className&&-1!==(" "+a.className+" ").indexOf(" "+b+" "))return a;a=a.parentNode}return!1}function d(a){a.stopPropagation()}function e(b,c){var d=b?"before":"after",e=b?0:1;i(),a.selection.setCursorLocation(a.dom.select(".wpview-selection-"+d,c)[0],e),a.nodeChanged()}function f(b,c,d){var f=a.dom,g=f.create("p");v.ie&&v.ie<11||(g.innerHTML='
'),c?b.parentNode.insertBefore(g,b):f.insertAfter(g,b),i(),c&&d===w.ENTER?e(c,b):a.selection.setCursorLocation(g,0),a.nodeChanged()}function g(b){a.undoManager.transact(function(){f(b),wp.mce.views.remove(a,b)})}function h(b){var c,e=a.dom;b&&(b!==m&&(a.getBody().focus(),i(),m=b,e.setAttrib(b,"data-mce-selected",1),c=e.create("div",{"class":"wpview-clipboard",contenteditable:"true"},wp.mce.views.getText(b)),a.dom.select(".wpview-body",b)[0].appendChild(c),e.bind(c,"beforedeactivate focusin focusout",d),e.bind(m,"beforedeactivate focusin focusout",d),B?a.selection.select(c):a.selection.select(c,!0)),a.nodeChanged(),a.fire("wpview-selected",b))}function i(){var b,c=a.dom;m&&(b=a.dom.select(".wpview-clipboard",m)[0],c.unbind(b),c.remove(b),c.unbind(m,"beforedeactivate focusin focusout click mouseup",d),c.setAttrib(m,"data-mce-selected",null)),m=null}function j(a){return a=a.replace(/]+data-wpview-text="([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*<\/div>/g,function(a,b){return"

"+window.decodeURIComponent(b)+"

"}),a.replace(/ data-wpview-marker="[^"]+"/g,"")}function k(b){u("div[data-wpview-text]",b).each(function(b,c){var d=u(c),e=window.decodeURIComponent(d.attr("data-wpview-text")||"");e&&c.parentNode&&d.replaceWith(u(a.dom.create("p")).text(e))}),u("p[data-wpview-marker]",b).attr("data-wpview-marker",null)}function l(a){return 47>=a&&a!==w.SPACEBAR&&a!==w.ENTER&&a!==w.DELETE&&a!==w.BACKSPACE&&(37>a||a>40)||a>=224||a>=144&&150>=a||a>=91&&93>=a||a>=112&&135>=a}var m,n,o,p,q,r,s,t,u=a.$,v=tinymce.Env,w=tinymce.util.VK,x=tinymce.dom.TreeWalker,y=!1,z=!0,A=function(){return!1},B=/iPad|iPod|iPhone/.test(navigator.userAgent);return"undefined"!=typeof wp&&wp.mce?(a.on("BeforeAddUndo",function(a){a.level.content&&(a.level.content=j(a.level.content))}),a.on("BeforeSetContent",function(b){var c;if(b.selection||wp.mce.views.unbind(),b.content){if(m&&g(m),!b.load&&(c=a.selection.getNode(),c&&c!==a.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(b.content))){if(c=a.dom.getParent(c,"p"),!c||!/^[\s\uFEFF\u00A0]*$/.test(c.textContent||c.innerText))return;c.innerHTML=""}b.content=wp.mce.views.setMarkers(b.content)}}),a.on("pastePreProcess",function(a){var b=a.content;b&&(b=tinymce.trim(b.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(b)&&(a.content=b))}),a.on("SetContent",function(){wp.mce.views.render()}),a.on("click",function(c){var d,f,g,h=c.clientX,i=c.clientY,j=a.getBody(),k=j.getBoundingClientRect(),l=j.firstChild,m=j.lastChild;l&&m&&(d=l.getBoundingClientRect(),f=m.getBoundingClientRect(),if.bottom&&(g=b(m))?(e(!1,g),c.preventDefault()):(hk.right)&&tinymce.each(a.dom.select(".wpview-wrap"),function(a){var b=a.getBoundingClientRect();return i=b.top&&i<=b.bottom?(hk.right&&(e(!1,a),c.preventDefault()),!1):void 0}))}),a.on("init",function(){var c=!1,d=a.selection,e=window.MutationObserver||window.WebKitMutationObserver;a.on("BeforeSetContent",function(){var c,e,f=b(d.getNode());f&&(!f.nextSibling||b(f.nextSibling)?(e=a.getDoc().createTextNode(""),a.dom.insertAfter(e,f)):(c=new x(f.nextSibling,f.nextSibling),e=c.next()),d.select(e),d.collapse(!0))}),a.dom.bind(a.getDoc(),"touchmove",function(){c=!0}),a.on("mousedown mouseup click touchend",function(a){var d=b(a.target);return z=!1,d?(a.stopImmediatePropagation(),a.preventDefault(),"touchend"===a.type&&c?c=!1:h(d),!1):(("touchend"===a.type||"mousedown"===a.type)&&i(),void("touchend"===a.type&&c&&(c=!1)))},!0),e&&new e(function(){a.fire("wp-body-class-change")}).observe(a.getBody(),{attributes:!0,attributeFilter:["class"]})}),a.on("PreProcess",function(a){k(a.node)},!0),a.on("hide",function(){wp.mce.views.unbind(),k(a.getBody())}),a.on("keydown",function(c){var d,j,k,n,p,q,r,s=c.keyCode,t=a.dom,u=a.selection;if(m){if((c.metaKey||c.ctrlKey)&&s!==w.BACKSPACE&&86!==s||s>=112&&123>=s)return void((c.metaKey||c.ctrlKey)&&88===s&&(y=m));if(j=b(u.getNode()),j!==m)return void i();s===w.LEFT?(e(!0,j),c.preventDefault()):s===w.UP?(j.previousSibling?b(j.previousSibling)?e(!0,j.previousSibling):(i(),u.select(j.previousSibling,!0),u.collapse()):e(!0,j),c.preventDefault()):s===w.RIGHT?(e(!1,j),c.preventDefault()):s===w.DOWN?(j.nextSibling?b(j.nextSibling)?e(!1,j.nextSibling):(i(),u.setCursorLocation(j.nextSibling,0)):e(!1,j),c.preventDefault()):l(s)||(g(m),(s===w.ENTER||s===w.DELETE||s===w.BACKSPACE)&&c.preventDefault())}else{if(c.metaKey||c.ctrlKey||s>=112&&123>=s)return;if(d=u.getNode(),o=d,j=b(d),u.isCollapsed()||(p=u.getRng(),(j=b(p.endContainer))?(q=p.cloneRange(),u.select(j.previousSibling,!0),u.collapse(),r=u.getRng(),q.setEnd(r.endContainer,r.endOffset),u.setRng(q)):(j=b(p.startContainer))&&(q=p.cloneRange(),q.setStart(j.nextSibling,0),u.setRng(q))),!j)return void(c.keyCode===w.BACKSPACE&&(a.dom.isEmpty(d)?(j=b(d.previousSibling))&&(e(!1,j),a.dom.remove(d),c.preventDefault()):(p=u.getRng())&&0===p.startOffset&&0===p.endOffset&&(j=b(d.previousSibling))&&(e(!1,j),c.preventDefault())));if(!(k=t.hasClass(j,"wpview-selection-before"))&&!(n=t.hasClass(j,"wpview-selection-after")))return;if(l(s))return;n&&s===w.UP||k&&s===w.BACKSPACE?(j.previousSibling?b(j.previousSibling)?e(!1,j.previousSibling):t.isEmpty(j.previousSibling)&&s===w.BACKSPACE?t.remove(j.previousSibling):(u.select(j.previousSibling,!0),u.collapse()):e(!0,j),c.preventDefault()):!n||s!==w.DOWN&&s!==w.RIGHT?!k||s!==w.UP&&s!==w.LEFT?k&&s===w.DOWN?(j.nextSibling?b(j.nextSibling)?e(!0,j.nextSibling):u.setCursorLocation(j.nextSibling,0):e(!1,j),c.preventDefault()):n&&s===w.LEFT||k&&s===w.RIGHT?(h(j),c.preventDefault()):n&&s===w.BACKSPACE?(g(j),c.preventDefault()):n?f(j):k&&f(j,!0,s):(j.previousSibling&&(b(j.previousSibling)?e(s===w.UP,j.previousSibling):(u.select(j.previousSibling,!0),u.collapse())),c.preventDefault()):(j.nextSibling&&(b(j.nextSibling)?e(s===w.RIGHT,j.nextSibling):u.setCursorLocation(j.nextSibling,0)),c.preventDefault()),s===w.ENTER&&c.preventDefault()}}),a.on("keyup",function(){y&&(g(y),y=!1)}),a.on("focus",function(){var c;q=!0,a.dom.addClass(a.getBody(),"has-focus"),z&&(c=b(a.getBody().firstChild))&&e(!0,c),z=!1}),a.on("blur",function(){q=!1,a.dom.removeClass(a.getBody(),"has-focus")}),a.on("NodeChange",function(d){var f=a.dom,g=a.dom.select(".wpview-wrap"),h=d.element.className,j=b(d.element),k=o;if(o=!1,clearInterval(n),tinymce.each(g,function(a){a.className&&(a.className=a.className.replace(/ ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g,""))}),q&&j)if("wpview-selection-before"!==h&&"wpview-selection-after"!==h||!a.selection.isCollapsed())c(d.element,"wpview-clipboard")||p||(i(),p++,e(!0,j));else{if(p=0,i(),k===j.previousSibling)return void e(!0,j);if(k===j.nextSibling)return void e(!1,j);f.addClass(j,h),n=setInterval(function(){f.hasClass(j,"wpview-cursor-hide")?f.removeClass(j,"wpview-cursor-hide"):f.addClass(j,"wpview-cursor-hide")},500)}}),a.on("BeforeExecCommand",function(){var c,d=a.selection.getNode();d&&((s="wpview-selection-before"===d.className)||"wpview-selection-after"===d.className)&&(c=b(d))&&(f(c,s),r=c)}),a.on("ExecCommand",function(){var b,c;m&&(b=m,i(),h(b)),r&&(c=r[s?"previousSibling":"nextSibling"],c&&"P"===c.nodeName&&a.dom.isEmpty(c)&&(a.dom.remove(c),e(s,r)),r=!1)}),a.on("ResolveName",function(c){a.dom.hasClass(c.target,"wpview-wrap")?(c.name=a.dom.getAttrib(c.target,"data-wpview-type")||"wpview",c.stopPropagation()):b(c.target)&&(c.preventDefault(),c.stopPropagation())}),a.addButton("wp_view_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",onclick:function(){m&&wp.mce.views.edit(a,m)}}),a.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){m&&g(m)}}),a.once("preinit",function(){t=a.wp._createToolbar(["wp_view_edit","wp_view_remove"])}),a.on("wptoolbar",function(a){m&&(a.element=m,a.toolbar=t)}),a.wp=a.wp||{},a.wp.getView=b,{getView:b}):{getView:A}}); \ No newline at end of file diff --git a/wp-includes/js/tinymce/wp-tinymce.js.gz b/wp-includes/js/tinymce/wp-tinymce.js.gz index c5aa37256b..10997a579a 100644 Binary files a/wp-includes/js/tinymce/wp-tinymce.js.gz and b/wp-includes/js/tinymce/wp-tinymce.js.gz differ diff --git a/wp-includes/version.php b/wp-includes/version.php index 488a46151e..066df5d73e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-beta4-32021'; +$wp_version = '4.2-beta4-32022'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. @@ -18,7 +18,7 @@ $wp_db_version = 31532; * * @global string $tinymce_version */ -$tinymce_version = '4109-20150310'; +$tinymce_version = '4109-20150404'; /** * Holds the required PHP version