mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-13 22:26:06 +01:00
a64be2cd83
This updates the 4.4 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy. Because older branches use (really) old versions of NodeJS, the local Docker environment cannot be backported since the needed dependencies will not run on these older versions (see #48301). This also blocks the ability to move automated testing over to GitHub Actions (see #50401). This also replaces the `npm-shrinkwrap.json` with a `package-lock.json` file. Lock files were not supported in earlier versions of NPM, but can now be used. In addition to backporting the package updates that happened after branching 4.4, dependencies that were removed in future releases have also been updated to their latest versions. Props desrosj, dd32, netweb, jorbin. Merges [35859,35862,36860-36865,36935,36978-36979,37017,37019-37020,37212,37612,38111,38688,39110,39113-39119,39478,42460-42461,42463,42887,43320,43323,43977,44219,44233,44728,45321,45765,46404,46408-46409,47404,47867-47869,47872-47873,48705,49636,49933,49937,49939,50017,50126,50176,50185,50192] to the 4.4 branch. See #52341. Built from https://develop.svn.wordpress.org/branches/4.4@50210 git-svn-id: http://core.svn.wordpress.org/branches/4.4@49881 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
9.3 KiB
JavaScript
1 line
9.3 KiB
JavaScript
!function(n,a,t,v){"use strict";var c={},o={};a.mce=a.mce||{},a.mce.views={register:function(e,t){c[e]=a.mce.View.extend(_.extend(t,{type:e}))},unregister:function(e){delete c[e]},get:function(e){return c[e]},unbind:function(){_.each(o,function(e){e.unbind()})},setMarkers:function(e){var a,t,r=[{content:e}],d=this;return _.each(c,function(s,o){t=r.slice(),r=[],_.each(t,function(e){var t,n,i=e.content;if(e.processed)r.push(e);else{for(;i&&(t=s.prototype.match(i));)t.index&&r.push({content:i.substring(0,t.index)}),n=(a=d.createInstance(o,t.content,t.options)).loader?".":a.text,r.push({content:a.ignore?n:'<p data-wpview-marker="'+a.encodedText+'">'+n+"</p>",processed:!0}),i=i.slice(t.index+t.content.length);i&&r.push({content:i})}})}),(e=_.pluck(r,"content").join("")).replace(/<p>\s*<p data-wpview-marker=/g,"<p data-wpview-marker=").replace(/<\/p>\s*<\/p>/g,"</p>")},createInstance:function(e,t,n,i){var s,e=this.get(e);return!i&&(s=this.getInstance(t))?s:(s=encodeURIComponent(t),n=_.extend(n||{},{text:t,encodedText:s}),o[s]=new e(n))},getInstance:function(e){return"string"==typeof e?o[encodeURIComponent(e)]:o[v(e).attr("data-wpview-text")]},getText:function(e){return decodeURIComponent(v(e).attr("data-wpview-text")||"")},render:function(t){_.each(o,function(e){e.render(t)})},update:function(e,t,n,i){var s=this.getInstance(n);s&&s.update(e,t,n,i)},edit:function(n,i){var s=this.getInstance(i);s&&s.edit&&s.edit(s.text,function(e,t){s.update(e,n,i,t)})},remove:function(e,t){var n=this.getInstance(t);n&&n.remove(e,t)}},a.mce.View=function(e){_.extend(this,e),this.initialize()},a.mce.View.extend=Backbone.View.extend,_.extend(a.mce.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(){return this.content},render:function(e,t){null!=e&&(this.content=e),e=this.getContent(),(this.loader||e)&&(t&&this.unbind(),this.replaceMarkers(),e?this.setContent(e,function(e,t,n){v(t).data("rendered",!0),this.bindNode.call(this,e,t,n)},!!t&&null):this.setLoader())},bindNode:function(){},unbindNode:function(){},unbind:function(){this.getNodes(function(e,t,n){this.unbindNode.call(this,e,t,n),v(t).trigger("wp-mce-view-unbind")},!0)},getEditors:function(t){_.each(tinymce.editors,function(e){e.plugins.wpview&&t.call(this,e)},this)},getNodes:function(n,i){this.getEditors(function(e){var t=this;v(e.getBody()).find('[data-wpview-text="'+t.encodedText+'"]').filter(function(){var e;return null==i||(e=!0===v(this).data("rendered"),i?e:!e)}).each(function(){n.call(t,e,this,v(this).find(".wpview-content").get(0))})})},getMarkers:function(n){this.getEditors(function(e){var t=this;v(e.getBody()).find('[data-wpview-marker="'+this.encodedText+'"]').each(function(){n.call(t,e,this)})})},replaceMarkers:function(){this.getMarkers(function(e,t){var n,i=t===e.selection.getNode();this.loader||v(t).text()===tinymce.DOM.decode(this.text)?(n=e.$('<div class="wpview-wrap" data-wpview-text="'+this.encodedText+'" data-wpview-type="'+this.type+'"><p class="wpview-selection-before">\xa0</p><div class="wpview-body" contenteditable="false"><div class="wpview-content wpview-type-'+this.type+'"></div></div><p class="wpview-selection-after">\xa0</p></div>'),e.$(t).replaceWith(n),i&&e.wp.setViewCursor(!1,n[0])):e.dom.setAttrib(t,"data-wpview-marker",null)})},removeMarkers:function(){this.getMarkers(function(e,t){e.dom.setAttrib(t,"data-wpview-marker",null)})},setContent:function(i,s,e){_.isObject(i)&&-1!==i.body.indexOf("<script")?this.setIframes(i.head||"",i.body,s,e):_.isString(i)&&-1!==i.indexOf("<script")?this.setIframes("",i,s,e):this.getNodes(function(e,t,n){-1!==(i=i.body||i).indexOf("<iframe")&&(i+='<div class="wpview-overlay"></div>'),n.innerHTML="",n.appendChild(_.isString(i)?e.dom.createFragment(i):i),s&&s.call(this,e,t,n)},e)},setIframes:function(p,f,m,e){var t,w=n.MutationObserver||n.WebKitMutationObserver||n.MozMutationObserver,g=this;-1!==f.indexOf("[")&&-1!==f.indexOf("]")&&(t=new RegExp("\\[\\/?(?:"+n.mceViewL10n.shortcodes.join("|")+")[^\\]]*?\\]","g"),f=f.replace(t,function(e){return e.replace(/</g,"<").replace(/>/g,">")})),this.getNodes(function(r,d,c){var l=r.dom,u="",h=r.getBody().className||"",e=r.getDoc().getElementsByTagName("head")[0];tinymce.each(l.$('link[rel="stylesheet"]',e),function(e){e.href&&-1===e.href.indexOf("skins/lightgray/content.min.css")&&-1===e.href.indexOf("skins/wordpress/wp-content.css")&&(u+=l.getOuterHTML(e))}),g.iframeHeight&&l.add(c,"div",{style:{width:"100%",height:g.iframeHeight}}),setTimeout(function(){var t,n,e,i,s;function o(){var e;s||t.contentWindow&&(e=v(t),g.iframeHeight=v(n.body).height(),e.height()!==g.iframeHeight&&(e.height(g.iframeHeight),r.nodeChanged()))}if(c.innerHTML="",t=l.add(c,"iframe",{src:tinymce.Env.ie?'javascript:""':"",frameBorder:"0",allowTransparency:"true",scrolling:"no","class":"wpview-sandbox",style:{width:"100%",display:"block"},height:g.iframeHeight}),l.add(c,"div",{"class":"wpview-overlay"}),(n=t.contentWindow.document).open(),n.write('<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'+p+u+'<style>html {background: transparent;padding: 0;margin: 0;}body#wpview-iframe-sandbox {background: transparent;padding: 1px 0 !important;margin: -1px 0 0 !important;}body#wpview-iframe-sandbox:before,body#wpview-iframe-sandbox:after {display: none;content: "";}</style></head><body id="wpview-iframe-sandbox" class="'+h+'">'+f+"</body></html>"),n.close(),g.iframeHeight&&(s=!0,setTimeout(function(){s=!1,o()},3e3)),v(t.contentWindow).on("load",o),w)(e=new w(_.debounce(o,100))).observe(n.body,{attributes:!0,childList:!0,subtree:!0}),v(d).one("wp-mce-view-unbind",function(){e.disconnect()});else for(i=1;i<6;i++)setTimeout(o,700*i);function a(){n.body.className=r.getBody().className}r.on("wp-body-class-change",a),v(d).one("wp-mce-view-unbind",function(){r.off("wp-body-class-change",a)}),m&&m.call(g,r,d,c)},50)},e)},setLoader:function(){this.setContent('<div class="loading-placeholder"><div class="dashicons dashicons-admin-media"></div><div class="wpview-loading"><ins></ins></div></div>')},setError:function(e,t){this.setContent('<div class="wpview-error"><div class="dashicons dashicons-'+(t||"no")+'"></div><p>'+e+"</p></div>")},match:function(e){e=t.next(this.type,e);if(e)return{index:e.index,content:e.content,options:{shortcode:e.shortcode}}},update:function(n,i,s,o){_.find(c,function(e,t){e=e.prototype.match(n);if(e)return v(s).data("rendered",!1),i.dom.setAttrib(s,"data-wpview-text",encodeURIComponent(n)),a.mce.views.createInstance(t,n,e.options,o).render(),i.focus(),!0})},remove:function(e,t){this.unbindNode.call(this,e,t,v(t).find(".wpview-content").get(0)),v(t).trigger("wp-mce-view-unbind"),e.dom.remove(t),e.focus()}})}(window,window.wp,window.wp.shortcode,window.jQuery),function(n,e,s,i){var t,o,a,r,d,c;function l(e){var t={};return n.tinymce?!e||-1===e.indexOf("<")&&-1===e.indexOf(">")?e:(r=r||new n.tinymce.html.Schema(t),d=d||new n.tinymce.html.DomParser(t,r),(c=c||new n.tinymce.html.Serializer(t,r)).serialize(d.parse(e,{forced_root_block:!1}))):e.replace(/<[^>]+>/g,"")}a={state:[],edit:function(e,t){var n=this.type,i=s[n].edit(e);this.pausePlayers&&this.pausePlayers(),_.each(this.state,function(e){i.state(e).on("update",function(e){t(s[n].shortcode(e).string(),"gallery"===n)})}),i.on("close",function(){i.detach()}),i.open()}},t=_.extend({},a,{state:["gallery-edit"],template:s.template("editor-gallery"),initialize:function(){var e=s.gallery.attachments(this.shortcode,s.view.settings.post.id),t=this.shortcode.attrs.named,n=this;e.more().done(function(){e=e.toJSON(),_.each(e,function(e){e.sizes&&(t.size&&e.sizes[t.size]?e.thumbnail=e.sizes[t.size]:e.sizes.thumbnail?e.thumbnail=e.sizes.thumbnail:e.sizes.full&&(e.thumbnail=e.sizes.full))}),n.render(n.template({verifyHTML:l,attachments:e,columns:t.columns?parseInt(t.columns,10):s.galleryDefaults.columns}))}).fail(function(e,t){n.setError(t)})}}),o=_.extend({},a,{action:"parse-media-shortcode",initialize:function(){var t=this;this.url&&(this.loader=!1,this.shortcode=s.embed.shortcode({url:this.text})),wp.ajax.post(this.action,{post_ID:s.view.settings.post.id,type:this.shortcode.tag,shortcode:this.shortcode.string()}).done(function(e){t.render(e)}).fail(function(e){t.url?(t.ignore=!0,t.removeMarkers()):t.setError(e.message||e.statusText,"admin-media")}),this.getEditors(function(e){e.on("wpview-selected",function(){t.pausePlayers()})})},pausePlayers:function(){this.getNodes(function(e,t,n){n=i("iframe.wpview-sandbox",n).get(0);(n=n&&n.contentWindow)&&n.mejs&&_.each(n.mejs.players,function(e){try{e.pause()}catch(e){}})})}}),a=_.extend({},o,{action:"parse-embed",edit:function(e,t){var n=s.embed.edit(e,this.url),i=this;this.pausePlayers(),n.state("embed").props.on("change:url",function(e,t){t&&e.get("url")&&(n.state("embed").metadata=e.toJSON())}),n.state("embed").on("select",function(){var e=n.state("embed").metadata;i.url?t(e.url):t(s.embed.shortcode(e).string())}),n.on("close",function(){n.detach()}),n.open()}}),e.register("gallery",_.extend({},t)),e.register("audio",_.extend({},o,{state:["audio-details"]})),e.register("video",_.extend({},o,{state:["video-details"]})),e.register("playlist",_.extend({},o,{state:["playlist-edit","video-playlist-edit"]})),e.register("embed",_.extend({},a)),e.register("embedURL",_.extend({},a,{match:function(e){e=/(^|<p>)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi.exec(e);if(e)return{index:e.index+e[1].length,content:e[2],options:{url:!0}}}}))}(window,window.wp.mce.views,window.wp.media,window.jQuery); |