diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index 4d5396ac5b..fb4afe51d2 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -8,7 +8,9 @@ // Ensure the global `wp` object exists. window.wp = window.wp || {}; -(function($){ +( function( $ ) { + 'use strict'; + var views = {}, instances = {}, media = wp.media, @@ -27,6 +29,7 @@ window.wp = window.wp || {}; */ wp.mce.View = function( options ) { options = options || {}; + this.type = options.type; _.extend( this, _.pick( options, viewOptions ) ); this.initialize.apply( this, arguments ); }; @@ -35,22 +38,67 @@ window.wp = window.wp || {}; initialize: function() {}, getHtml: function() {}, render: function() { - var html = this.getHtml(); - // Search all tinymce editor instances and update the placeholders + this.setContent( + '
' + + '' + message + '
' + + '' + media.find( 'source' ).eq(0).prop( 'src' ) + '
' ); return; } else { media.closest( '.wpview-wrap' ).removeClass( 'wont-play' ); - if ( firefox ) { + if ( this.ua.is( 'ff' ) ) { media.prop( 'preload', 'metadata' ); } else { media.prop( 'preload', 'none' ); @@ -508,6 +550,7 @@ window.wp = window.wp || {}; state: ['playlist-edit', 'video-playlist-edit'], View: _.extend( {}, wp.media.mixin, { template: media.template( 'editor-playlist' ), + overlay: true, initialize: function( options ) { this.players = []; @@ -531,7 +574,7 @@ window.wp = window.wp || {}; this.dfd = this.attachments.more().done( _.bind( this.render, this ) ); }, - setPlaylist: function( event, element ) { + setPlaylist: function( event, editor, element ) { if ( ! this.data.tracks ) { return; } @@ -634,60 +677,161 @@ window.wp = window.wp || {}; /** * TinyMCE handler for the embed shortcode */ - wp.mce.views.register( 'embed', { - View: _.extend( {}, wp.media.mixin, { - template: media.template( 'editor-embed' ), - initialize: function( options ) { - this.players = []; - this.content = options.content; - this.parsed = false; - this.shortcode = options.shortcode; - _.bindAll( this, 'setHtml', 'setNode', 'fetch' ); - $( this ).on( 'ready', this.setNode ); - }, - unbind: function() { - var self = this; - _.each( this.players, function ( player ) { - player.pause(); - self.removePlayer( player ); - } ); - this.players = []; - }, - setNode: function ( e, node ) { - this.node = node; - if ( this.parsed ) { - this.parseMediaShortcodes(); - } else { - this.fetch(); - } - }, - fetch: function () { - wp.ajax.send( 'parse-embed', { - data: { - post_ID: $( '#post_ID' ).val(), - content: this.shortcode.string() - } - } ).done( this.setHtml ); - }, - setHtml: function ( content ) { - this.parsed = content; - $( this.node ).html( this.getHtml() ); - this.parseMediaShortcodes(); - }, - parseMediaShortcodes: function () { - var self = this; - $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).each( function ( i, element ) { - self.players.push( new MediaElementPlayer( element, self.mejsSettings ) ); - } ); - }, - getHtml: function() { - if ( ! this.parsed ) { - return ''; - } - return this.template({ content: this.parsed }); + wp.mce.embedView = _.extend( {}, wp.media.mixin, { + overlay: true, + initialize: function( options ) { + this.players = []; + this.content = options.content; + this.fetching = false; + this.parsed = false; + this.original = options.url || options.shortcode.string(); + + if ( options.url ) { + this.shortcode = '[embed]' + options.url + '[/embed]'; + } else { + this.shortcode = options.shortcode.string(); } - } ), - edit: function() {} + + _.bindAll( this, 'setHtml', 'setNode', 'fetch' ); + $( this ).on( 'ready', this.setNode ); + }, + unbind: function() { + var self = this; + _.each( this.players, function ( player ) { + player.pause(); + self.removePlayer( player ); + } ); + this.players = []; + }, + setNode: function () { + if ( this.parsed ) { + this.setHtml( this.parsed ); + this.parseMediaShortcodes(); + } else if ( ! this.fetching ) { + this.fetch(); + } + }, + fetch: function () { + var self = this; + + this.fetching = true; + + wp.ajax.send( 'parse-embed', { + data: { + post_ID: $( '#post_ID' ).val(), + content: this.shortcode + } + } ) + .done( function( content ) { + self.fetching = false; + + if ( content.substring( 0, ( '' + + '' + + '' + + '' + + '' + + '' + + content + + '' + + '' + ); + iframeDoc.close(); + + resize = function() { + $( iframe ).height( $( iframeDoc ).height() ); + }; + + if ( MutationObserver ) { + new MutationObserver( _.debounce( function() { + resize(); + }, 100 ) ) + .observe( iframeDoc.body, { + attributes: true, + childList: true, + subtree: true + } ); + } else { + for ( i = 1; i < 6; i++ ) { + setTimeout( resize, i * 700 ); + } + } + } else { + this.setContent( content ); + } + + this.parseMediaShortcodes(); + }, + parseMediaShortcodes: function () { + var self = this; + $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).each( function ( i, element ) { + self.players.push( new MediaElementPlayer( element, self.mejsSettings ) ); + } ); + }, + getHtml: function() { + return ''; + } + } ); + + wp.mce.views.register( 'embed', { + View: wp.mce.embedView + } ); + + wp.mce.views.register( 'embedURL', { + toView: function( content ) { + var re = /(?:^|)(https?:\/\/[^\s"]+?)(?:<\/p>\s*|$)/gi, + match = re.exec( tinymce.trim( content ) ); + + if ( ! match ) { + return; + } + + return { + index: match.index, + content: match[0], + options: { + url: match[1] + } + }; + }, + View: wp.mce.embedView } ); }(jQuery)); diff --git a/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index af7abb6e9e..923ff11259 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){var b={},c={},d=wp.media,e=["encodedText"];wp.mce=wp.mce||{},wp.mce.View=function(a){a=a||{},_.extend(this,_.pick(a,e)),this.initialize.apply(this,arguments)},_.extend(wp.mce.View.prototype,{initialize:function(){},getHtml:function(){},render:function(){var b=this.getHtml();_.each(tinymce.editors,function(c){var d=this;c.plugins.wpview&&a(c.getDoc()).find('[data-wpview-text="'+this.encodedText+'"]').each(function(c,e){var f=a(e);f.html(b).append(''),a(d).trigger("ready",e)})},this)},unbind:function(){}}),wp.mce.View.extend=Backbone.View.extend,wp.mce.views={register:function(a,c){var d={shortcode:a,View:{},toView:function(a){var b=wp.shortcode.next(this.shortcode,a);if(b)return{index:b.index,content:b.content,options:{shortcode:b.shortcode}}}};c=_.defaults(c,d),c.View=wp.mce.View.extend(c.View),b[a]=c},get:function(a){return b[a]},unregister:function(a){delete b[a]},unbind:function(){_.each(c,function(a){a.unbind()})},toViews:function(a){var c,d=[{content:a}];return _.each(b,function(a,b){c=d.slice(),d=[],_.each(c,function(c){var e,f=c.content;if(c.processed)return void d.push(c);for(;f&&(e=a.toView(f));)e.index&&d.push({content:f.substring(0,e.index)}),d.push({content:wp.mce.views.toView(b,e.content,e.options),processed:!0}),f=f.slice(e.index+e.content.length);f&&d.push({content:f})})}),_.pluck(d,"content").join("")},toView:function(a,b,d){var e,f,g=wp.mce.views.get(a),h=window.encodeURIComponent(b);return g?(wp.mce.views.getInstance(h)||(f=d,f.encodedText=h,e=new g.View(f),c[h]=e),wp.html.string({tag:"div",attrs:{"class":"wpview-wrap wpview-type-"+a,"data-wpview-text":h,"data-wpview-type":a,contenteditable:"false"},content:" "})):b},refreshView:function(a,b){var d,e,f,g=window.encodeURIComponent(b);f=wp.mce.views.getInstance(g),f||(e=a.toView(b),d=e.options,d.encodedText=g,f=new a.View(d),c[g]=f),wp.mce.views.render()},getInstance:function(a){return c[a]},render:function(){_.each(c,function(a){a.render()})},edit:function(b){var c=a(b).data("wpview-type"),d=wp.mce.views.get(c);d&&d.edit(b)}},wp.mce.views.register("gallery",{View:{template:d.template("editor-gallery"),postID:a("#post_ID").val(),initialize:function(a){this.shortcode=a.shortcode,this.fetch()},fetch:function(){this.attachments=wp.media.gallery.attachments(this.shortcode,this.postID),this.dfd=this.attachments.more().done(_.bind(this.render,this))},getHtml:function(){var a,b=this.shortcode.attrs.named,c=!1;if(!this.dfd||"pending"!==this.dfd.state()||this.attachments.length)return this.attachments.length&&(c=this.attachments.toJSON(),_.each(c,function(a){a.sizes&&(a.sizes.thumbnail?a.thumbnail=a.sizes.thumbnail:a.sizes.full&&(a.thumbnail=a.sizes.full))})),a={attachments:c,columns:b.columns?parseInt(b.columns,10):3},this.template(a)}},edit:function(b){var c,d,e=wp.media.gallery,f=this;d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=e.edit(d),c.state("gallery-edit").on("update",function(d){var g=e.shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(g)),wp.mce.views.refreshView(f,g),c.detach()})}}),wp.mce.av={loaded:!1,View:_.extend({},wp.media.mixin,{initialize:function(b){this.players=[],this.shortcode=b.shortcode,_.bindAll(this,"setPlayer","pausePlayers"),a(this).on("ready",this.setPlayer),a("body").on("click",".wp-switch-editor",this.pausePlayers),a(document).on("media:edit",this.pausePlayers)},setPlayer:function(b,c){if(c){var d,e=this,f=this.ua.is("ff"),g=".wp-"+this.shortcode.tag+"-shortcode";if(d=a(c).find(g),!this.isCompatible(d))return d.closest(".wpview-wrap").addClass("wont-play"),d.parent().hasClass("wpview-wrap")||d.parent().replaceWith(d),void d.replaceWith("
"+d.find("source").eq(0).prop("src")+"
");d.closest(".wpview-wrap").removeClass("wont-play"),f?d.prop("preload","metadata"):d.prop("preload","none"),d=wp.media.view.MediaDetails.prepareSrc(d.get(0)),setTimeout(function(){wp.mce.av.loaded=!0,e.players.push(new MediaElementPlayer(d,e.mejsSettings))},wp.mce.av.loaded?10:500)}},getHtml:function(){var a=this.shortcode.attrs.named;return a.content=this.shortcode.content,this.template({model:_.defaults(a,wp.media[this.shortcode.tag].defaults)})},unbind:function(){this.unsetPlayers()}}),edit:function(b){var c,d,e,f=wp.media[this.shortcode],g=this;a(document).trigger("media:edit"),d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=f.edit(d),c.on("close",function(){c.detach()}),e=function(d){var e=wp.media[g.shortcode].shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(e)),wp.mce.views.refreshView(g,e),c.detach()},_.isArray(g.state)?_.each(g.state,function(a){c.state(a).on("update",e)}):c.state(g.state).on("update",e),c.open()}},wp.mce.views.register("video",_.extend({},wp.mce.av,{state:"video-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-video")})})),wp.mce.views.register("audio",_.extend({},wp.mce.av,{state:"audio-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-audio")})})),wp.mce.views.register("playlist",_.extend({},wp.mce.av,{state:["playlist-edit","video-playlist-edit"],View:_.extend({},wp.media.mixin,{template:d.template("editor-playlist"),initialize:function(b){this.players=[],this.data={},this.attachments=[],this.shortcode=b.shortcode,a("body").on("click",".wp-switch-editor",this.pausePlayers),a(document).on("media:edit",this.pausePlayers),this.fetch(),a(this).on("ready",this.setPlaylist)},fetch:function(){this.attachments=wp.media.playlist.attachments(this.shortcode),this.dfd=this.attachments.more().done(_.bind(this.render,this))},setPlaylist:function(b,c){this.data.tracks&&this.players.push(new WPPlaylistView({el:a(c).find(".wp-playlist").get(0),metadata:this.data}).player)},getHtml:function(){var a,b,c=this.shortcode.attrs.named,e=wp.media.playlist,f=[];if(!this.dfd||"pending"!==this.dfd.state()||this.attachments.length)return _.each(e.defaults,function(a,b){c[b]=e.coerce(c,b)}),a={type:c.type,style:c.style,tracklist:c.tracklist,tracknumbers:c.tracknumbers,images:c.images,artists:c.artists},this.attachments.length?(b=this.attachments.toJSON(),_.each(b,function(b){var e={},g={},h={src:b.url,type:b.mime,title:b.title,caption:b.caption,description:b.description,meta:b.meta};"video"===c.type?(e.width=b.width,e.height=b.height,d.view.settings.contentWidth?(g.width=d.view.settings.contentWidth-22,g.height=Math.ceil(e.height*g.width/e.width),a.width||(a.width=g.width,a.height=g.height)):a.width||(a.width=b.width,a.height=b.height),h.dimensions={original:e,resized:_.isEmpty(g)?e:g}):a.width=400,h.image=b.image,h.thumb=b.thumb,f.push(h)}),a.tracks=f,this.data=a,this.template(a)):this.template(a)},unbind:function(){this.unsetPlayers()}})})),wp.mce.views.register("embed",{View:_.extend({},wp.media.mixin,{template:d.template("editor-embed"),initialize:function(b){this.players=[],this.content=b.content,this.parsed=!1,this.shortcode=b.shortcode,_.bindAll(this,"setHtml","setNode","fetch"),a(this).on("ready",this.setNode)},unbind:function(){var a=this;_.each(this.players,function(b){b.pause(),a.removePlayer(b)}),this.players=[]},setNode:function(a,b){this.node=b,this.parsed?this.parseMediaShortcodes():this.fetch()},fetch:function(){wp.ajax.send("parse-embed",{data:{post_ID:a("#post_ID").val(),content:this.shortcode.string()}}).done(this.setHtml)},setHtml:function(b){this.parsed=b,a(this.node).html(this.getHtml()),this.parseMediaShortcodes()},parseMediaShortcodes:function(){var b=this;a(".wp-audio-shortcode, .wp-video-shortcode",this.node).each(function(a,c){b.players.push(new MediaElementPlayer(c,b.mejsSettings))})},getHtml:function(){return this.parsed?this.template({content:this.parsed}):""}}),edit:function(){}})}(jQuery); \ No newline at end of file +window.wp=window.wp||{},function(a){"use strict";var b={},c={},d=wp.media,e=["encodedText"];wp.mce=wp.mce||{},wp.mce.View=function(a){a=a||{},this.type=a.type,_.extend(this,_.pick(a,e)),this.initialize.apply(this,arguments)},_.extend(wp.mce.View.prototype,{initialize:function(){},getHtml:function(){},render:function(){this.setContent(''+a+"
"+e.find("source").eq(0).prop("src")+"
"))},getHtml:function(){var a=this.shortcode.attrs.named;return a.content=this.shortcode.content,this.template({model:_.defaults(a,wp.media[this.shortcode.tag].defaults)})},unbind:function(){this.unsetPlayers()}}),edit:function(b){var c,d,e,f=wp.media[this.shortcode],g=this;a(document).trigger("media:edit"),d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=f.edit(d),c.on("close",function(){c.detach()}),e=function(d){var e=wp.media[g.shortcode].shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(e)),wp.mce.views.refreshView(g,e),c.detach()},_.isArray(g.state)?_.each(g.state,function(a){c.state(a).on("update",e)}):c.state(g.state).on("update",e),c.open()}},wp.mce.views.register("video",_.extend({},wp.mce.av,{state:"video-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-video")})})),wp.mce.views.register("audio",_.extend({},wp.mce.av,{state:"audio-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-audio")})})),wp.mce.views.register("playlist",_.extend({},wp.mce.av,{state:["playlist-edit","video-playlist-edit"],View:_.extend({},wp.media.mixin,{template:d.template("editor-playlist"),overlay:!0,initialize:function(b){this.players=[],this.data={},this.attachments=[],this.shortcode=b.shortcode,a("body").on("click",".wp-switch-editor",this.pausePlayers),a(document).on("media:edit",this.pausePlayers),this.fetch(),a(this).on("ready",this.setPlaylist)},fetch:function(){this.attachments=wp.media.playlist.attachments(this.shortcode),this.dfd=this.attachments.more().done(_.bind(this.render,this))},setPlaylist:function(b,c,d){this.data.tracks&&this.players.push(new WPPlaylistView({el:a(d).find(".wp-playlist").get(0),metadata:this.data}).player)},getHtml:function(){var a,b,c=this.shortcode.attrs.named,e=wp.media.playlist,f=[];if(!this.dfd||"pending"!==this.dfd.state()||this.attachments.length)return _.each(e.defaults,function(a,b){c[b]=e.coerce(c,b)}),a={type:c.type,style:c.style,tracklist:c.tracklist,tracknumbers:c.tracknumbers,images:c.images,artists:c.artists},this.attachments.length?(b=this.attachments.toJSON(),_.each(b,function(b){var e={},g={},h={src:b.url,type:b.mime,title:b.title,caption:b.caption,description:b.description,meta:b.meta};"video"===c.type?(e.width=b.width,e.height=b.height,d.view.settings.contentWidth?(g.width=d.view.settings.contentWidth-22,g.height=Math.ceil(e.height*g.width/e.width),a.width||(a.width=g.width,a.height=g.height)):a.width||(a.width=b.width,a.height=b.height),h.dimensions={original:e,resized:_.isEmpty(g)?e:g}):a.width=400,h.image=b.image,h.thumb=b.thumb,f.push(h)}),a.tracks=f,this.data=a,this.template(a)):this.template(a)},unbind:function(){this.unsetPlayers()}})})),wp.mce.embedView=_.extend({},wp.media.mixin,{overlay:!0,initialize:function(b){this.players=[],this.content=b.content,this.fetching=!1,this.parsed=!1,this.original=b.url||b.shortcode.string(),this.shortcode=b.url?"[embed]"+b.url+"[/embed]":b.shortcode.string(),_.bindAll(this,"setHtml","setNode","fetch"),a(this).on("ready",this.setNode)},unbind:function(){var a=this;_.each(this.players,function(b){b.pause(),a.removePlayer(b)}),this.players=[]},setNode:function(){this.parsed?(this.setHtml(this.parsed),this.parseMediaShortcodes()):this.fetching||this.fetch()},fetch:function(){var b=this;this.fetching=!0,wp.ajax.send("parse-embed",{data:{post_ID:a("#post_ID").val(),content:this.shortcode}}).done(function(a){b.fetching=!1,"'+b+""),d.close(),f=function(){a(c).height(a(d).height())},g)new g(_.debounce(function(){f()},100)).observe(d.body,{attributes:!0,childList:!0,subtree:!0});else for(e=1;6>e;e++)setTimeout(f,700*e);else this.setContent(b);this.parseMediaShortcodes()},parseMediaShortcodes:function(){var b=this;a(".wp-audio-shortcode, .wp-video-shortcode",this.node).each(function(a,c){b.players.push(new MediaElementPlayer(c,b.mejsSettings))})},getHtml:function(){return""}}),wp.mce.views.register("embed",{View:wp.mce.embedView}),wp.mce.views.register("embedURL",{toView:function(a){var b=/(?:^|)(https?:\/\/[^\s"]+?)(?:<\/p>\s*|$)/gi,c=b.exec(tinymce.trim(a));if(c)return{index:c.index,content:c[0],options:{url:c[1]}}},View:wp.mce.embedView})}(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 fba3bfc012..be11d0663c 100644
--- a/wp-includes/js/tinymce/plugins/wpview/plugin.js
+++ b/wp-includes/js/tinymce/plugins/wpview/plugin.js
@@ -158,6 +158,8 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
// matching view patterns, and transform the matches into
// view wrappers.
editor.on( 'BeforeSetContent', function( event ) {
+ var node;
+
if ( ! event.content ) {
return;
}
@@ -166,15 +168,17 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
wp.mce.views.unbind( editor );
}
+ node = editor.selection.getNode();
+
+ // When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
+ if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) &&
+ ( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) {
+ return;
+ }
+
event.content = wp.mce.views.toViews( event.content );
});
- editor.on( 'PastePreProcess', function( event ) {
- if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/im ) ) {
- event.content = '[embed]' + event.content + '[/embed]';
- }
- } );
-
// When the editor's content has been updated and the DOM has been
// processed, render the views in the document.
editor.on( 'SetContent', function( event ) {
diff --git a/wp-includes/js/tinymce/plugins/wpview/plugin.min.js b/wp-includes/js/tinymce/plugins/wpview/plugin.min.js
index 36864c951f..3c6e67ca9f 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){for(;a&&"BODY"!==a.nodeName;){if(c(a))return a;a=a.parentNode}}function c(a){return a&&/\bwpview-wrap\b/.test(a.className)}function d(){return a.dom.create("p",{"data-wpview-pad":1},tinymce.Env.ie&&tinymce.Env.ie<11?"":'
')}function e(c){return c=b("string"==typeof c?a.dom.get(c):c),c?window.decodeURIComponent(a.dom.getAttrib(c,"data-wpview-text")||""):""}function f(c,d){return c=b("string"==typeof c?a.dom.get(c):c),c?(a.dom.setAttrib(c,"data-wpview-text",window.encodeURIComponent(d||"")),!0):!1}function g(a){a.stopPropagation()}function h(b){var c,d=a.dom;b!==l&&(i(),l=b,d.setAttrib(b,"data-mce-selected",1),c=d.create("div",{"class":"wpview-clipboard",contenteditable:"true"},e(b)),b.insertBefore(c,b.firstChild),d.bind(c,"beforedeactivate focusin focusout",g),d.bind(l,"beforedeactivate focusin focusout",g),a.getBody().focus(),a.selection.select(c,!0),a.nodeChanged())}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",g),c.setAttrib(l,"data-mce-selected",null)),l=null}function j(b,d){for(var e=a.getBody(),f="previous"===d?"previousSibling":"nextSibling";b&&b.parentNode!==e;){if(b[f])return!1;b=b.parentNode}return c(b[f])?(h(b[f]),!0):!1}function k(a){return a.replace(/(
"+window.decodeURIComponent(b)+"
":""}))}),a.on("keydown",function(e){var f,g,j=e.keyCode,k=a.getBody();if(l){if(e.metaKey||e.ctrlKey||j>=112&&123>=j)return void((e.metaKey||e.ctrlKey)&&88===j&&(o=l));if(f=b(a.selection.getNode()),f!==l)return void i();j===m.LEFT||j===m.UP?(i(),c(f.previousSibling)?h(f.previousSibling):f.previousSibling?(a.selection.select(f.previousSibling,!0),a.selection.collapse()):(g=d(),k.insertBefore(g,k.firstChild),a.selection.setCursorLocation(k.firstChild,0))):j===m.RIGHT||j===m.DOWN?(i(),c(f.nextSibling)?h(f.nextSibling):f.nextSibling?a.selection.setCursorLocation(f.nextSibling,0):(g=d(),k.appendChild(g),a.selection.setCursorLocation(k.lastChild,0))):(j===m.DELETE||j===m.BACKSPACE)&&a.dom.remove(l),e.preventDefault()}}),a.on("keydown",function(b){var c,d,e=b.keyCode,f=a.dom,g=a.selection.getRng(),h=g.startContainer,i=a.getBody();if(h&&h!==i&&!b.metaKey&&!b.ctrlKey)if(e===m.UP||e===m.LEFT){if(e===m.LEFT&&(!g.collapsed||0!==g.startOffset))return;if(!(c=f.getParent(h,f.isBlock)))return;j(c,"previous")&&b.preventDefault()}else if(e===m.DOWN||e===m.RIGHT){if(!(c=f.getParent(h,f.isBlock)))return;if(e===m.RIGHT){if(d=g.endContainer,!g.collapsed||0===g.startOffset&&d.length||d.nextSibling||3===d.nodeType&&g.startOffset!==d.length)return;for(;d&&d!==c&&d!==i;){if(d.nextSibling)return;d=d.parentNode}}j(c,"next")&&b.preventDefault()}}),a.on("keyup",function(b){var e,f,g=b.keyCode,h=a.getBody();o&&(a.dom.remove(o),o=!1),(g===m.DELETE||g===m.BACKSPACE)&&(c(h.lastChild)&&(e=d(),h.appendChild(e),2===h.childNodes.length&&a.selection.setCursorLocation(e,0)),f=a.selection.getRng(),h.firstChild===f.startContainer&&f.collapsed===!0&&c(f.startContainer.nextSibling)&&0===f.startOffset&&a.dom.remove(f.startContainer))}),{getViewText:e,setViewText:f}}); \ No newline at end of file +tinymce.PluginManager.add("wpview",function(a){function b(a){for(;a&&"BODY"!==a.nodeName;){if(c(a))return a;a=a.parentNode}}function c(a){return a&&/\bwpview-wrap\b/.test(a.className)}function d(){return a.dom.create("p",{"data-wpview-pad":1},tinymce.Env.ie&&tinymce.Env.ie<11?"":'"+window.decodeURIComponent(b)+"
":""}))}),a.on("keydown",function(e){var f,g,j=e.keyCode,k=a.getBody();if(l){if(e.metaKey||e.ctrlKey||j>=112&&123>=j)return void((e.metaKey||e.ctrlKey)&&88===j&&(o=l));if(f=b(a.selection.getNode()),f!==l)return void i();j===m.LEFT||j===m.UP?(i(),c(f.previousSibling)?h(f.previousSibling):f.previousSibling?(a.selection.select(f.previousSibling,!0),a.selection.collapse()):(g=d(),k.insertBefore(g,k.firstChild),a.selection.setCursorLocation(k.firstChild,0))):j===m.RIGHT||j===m.DOWN?(i(),c(f.nextSibling)?h(f.nextSibling):f.nextSibling?a.selection.setCursorLocation(f.nextSibling,0):(g=d(),k.appendChild(g),a.selection.setCursorLocation(k.lastChild,0))):(j===m.DELETE||j===m.BACKSPACE)&&a.dom.remove(l),e.preventDefault()}}),a.on("keydown",function(b){var c,d,e=b.keyCode,f=a.dom,g=a.selection.getRng(),h=g.startContainer,i=a.getBody();if(h&&h!==i&&!b.metaKey&&!b.ctrlKey)if(e===m.UP||e===m.LEFT){if(e===m.LEFT&&(!g.collapsed||0!==g.startOffset))return;if(!(c=f.getParent(h,f.isBlock)))return;j(c,"previous")&&b.preventDefault()}else if(e===m.DOWN||e===m.RIGHT){if(!(c=f.getParent(h,f.isBlock)))return;if(e===m.RIGHT){if(d=g.endContainer,!g.collapsed||0===g.startOffset&&d.length||d.nextSibling||3===d.nodeType&&g.startOffset!==d.length)return;for(;d&&d!==c&&d!==i;){if(d.nextSibling)return;d=d.parentNode}}j(c,"next")&&b.preventDefault()}}),a.on("keyup",function(b){var e,f,g=b.keyCode,h=a.getBody();o&&(a.dom.remove(o),o=!1),(g===m.DELETE||g===m.BACKSPACE)&&(c(h.lastChild)&&(e=d(),h.appendChild(e),2===h.childNodes.length&&a.selection.setCursorLocation(e,0)),f=a.selection.getRng(),h.firstChild===f.startContainer&&f.collapsed===!0&&c(f.startContainer.nextSibling)&&0===f.startOffset&&a.dom.remove(f.startContainer))}),{getViewText:e,setViewText:f}}); \ 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 ff9cc08e2b..4d3fcfea41 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/media-template.php b/wp-includes/media-template.php index 7ef4f041e3..1fdcb7f0a9 100644 --- a/wp-includes/media-template.php +++ b/wp-includes/media-template.php @@ -994,9 +994,6 @@ function wp_print_media_templates() { - -