mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-20 19:56:49 +01:00
This updates the 4.3 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 change also introduces a `packager-lock.json` file to the branch. In addition to backporting the package updates that happened after branching 4.3, dependencies that were removed in future releases have also been updated to their latest versions. Props desrosj, dd32, netweb, jorbin. Merges [33726,34888,35332,35335,35363,35513,35520-35521,35538-35541,35562-35563,35859-36865,36935,36978-36980,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] to the 4.3 branch. See #52341. Built from https://develop.svn.wordpress.org/branches/4.3@50212 git-svn-id: http://core.svn.wordpress.org/branches/4.3@49882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
8.2 KiB
JavaScript
1 line
8.2 KiB
JavaScript
tinymce.PluginManager.add("wpview",function(p){var d,a,u,s,c,n,i,t,o=p.$,r=tinymce.Env,v=tinymce.util.VK,l=tinymce.dom.TreeWalker,f=!1,w=!0,g=/iPad|iPod|iPhone/.test(navigator.userAgent);function m(e){return b(e,"wpview-wrap")}function b(e,t){for(;e&&e.parentNode;){if(e.className&&-1!==(" "+e.className+" ").indexOf(" "+t+" "))return e;e=e.parentNode}return!1}function S(e){e.stopPropagation()}function C(e,t){var n=e?"before":"after",e=e?0:1;x(),p.selection.setCursorLocation(p.dom.select(".wpview-selection-"+n,t)[0],e),p.nodeChanged()}function h(e,t,n){var i=p.dom,o=i.create("p");r.ie&&r.ie<11||(o.innerHTML='<br data-mce-bogus="1">'),t?e.parentNode.insertBefore(o,e):i.insertAfter(o,e),x(),t&&n===v.ENTER?C(t,e):p.selection.setCursorLocation(o,0),p.nodeChanged()}function y(e){p.undoManager.transact(function(){h(e),wp.mce.views.remove(p,e)})}function E(e){var t,n=p.dom;e&&(e!==d&&(p.getBody().focus(),x(),d=e,n.setAttrib(e,"data-mce-selected",1),t=n.create("div",{"class":"wpview-clipboard",contenteditable:"true"},wp.mce.views.getText(e)),p.dom.select(".wpview-body",e)[0].appendChild(t),n.bind(t,"beforedeactivate focusin focusout",S),n.bind(d,"beforedeactivate focusin focusout",S),g?p.selection.select(t):p.selection.select(t,!0)),p.nodeChanged(),p.fire("wpview-selected",e))}function x(){var e,t=p.dom;d&&(e=p.dom.select(".wpview-clipboard",d)[0],t.unbind(e),t.remove(e),t.unbind(d,"beforedeactivate focusin focusout click mouseup",S),t.setAttrib(d,"data-mce-selected",null)),d=null}return"undefined"!=typeof wp&&wp.mce?(p.on("BeforeAddUndo",function(e){e.level.content&&(e.level.content=e.level.content.replace(/<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*|\.)<\/div>/g,P).replace(/<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,P))}),p.on("BeforeSetContent",function(e){var t;if(e.selection||wp.mce.views.unbind(),e.content){if(!e.load&&(d&&y(d),(t=p.selection.getNode())&&t!==p.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(e.content))){if(!(t=p.dom.getParent(t,"p"))||!/^[\s\uFEFF\u00A0]*$/.test(o(t).text()||""))return;t.innerHTML=""}e.content=wp.mce.views.setMarkers(e.content)}}),p.on("pastePreProcess",function(e){var t=e.content;t&&(t=tinymce.trim(t.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(t)&&(e.content=t))}),p.on("SetContent",function(){wp.mce.views.render()}),p.on("click",function(n){var e,t,i=n.clientX,o=n.clientY,r=p.getBody(),a=r.getBoundingClientRect(),s=r.firstChild,c=r.lastChild;s&&c&&(e=s.getBoundingClientRect(),r=c.getBoundingClientRect(),o<e.top&&(t=m(s))?(C(!0,t),n.preventDefault()):o>r.bottom&&(t=m(c))?(C(!1,t),n.preventDefault()):(i<a.left||i>a.right)&&tinymce.each(p.dom.select(".wpview-wrap"),function(e){var t=e.getBoundingClientRect();return!(o<t.top)&&(o>=t.top&&o<=t.bottom?(i<a.left?(C(!0,e),n.preventDefault()):i>a.right&&(C(!1,e),n.preventDefault()),!1):void 0)}))}),p.on("init",function(){var n=!1,i=p.selection,e=window.MutationObserver||window.WebKitMutationObserver;p.on("BeforeSetContent",function(){var e,t=m(i.getNode());t&&(!t.nextSibling||m(t.nextSibling)?(e=p.getDoc().createTextNode(""),p.dom.insertAfter(e,t)):e=new l(t.nextSibling,t.nextSibling).next(),i.select(e),i.collapse(!0))}),p.dom.bind(p.getDoc(),"touchmove",function(){n=!0}),p.on("mousedown mouseup click touchend",function(e){var t=m(e.target);if(w=!1,t)return e.stopImmediatePropagation(),e.preventDefault(),"touchend"===e.type&&n?n=!1:E(t),!1;"touchend"!==e.type&&"mousedown"!==e.type||x(),"touchend"===e.type&&n&&(n=!1)},!0),e&&new e(function(){p.fire("wp-body-class-change")}).observe(p.getBody(),{attributes:!0,attributeFilter:["class"]})}),p.on("PreProcess",function(e){D(e.node)},!0),p.on("hide",function(){wp.mce.views.unbind(),x(),D()}),p.on("PostProcess",function(e){e.content&&(e.content=e.content.replace(/<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g,P).replace(/<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,P))}),p.on("keydown",function(e){var t,n,i,o,r,a,s=e.keyCode,c=p.dom,l=p.selection;d?(e.metaKey||e.ctrlKey)&&s!==v.BACKSPACE&&86!==s||112<=s&&s<=123?(e.metaKey||e.ctrlKey)&&88===s&&(f=d):(n=m(l.getNode()))===d?s===v.LEFT?(C(!0,n),e.preventDefault()):s===v.UP?(n.previousSibling?m(n.previousSibling)?C(!0,n.previousSibling):(x(),l.select(n.previousSibling,!0),l.collapse()):C(!0,n),e.preventDefault()):s===v.RIGHT?(C(!1,n),e.preventDefault()):s===v.DOWN?(n.nextSibling?m(n.nextSibling)?C(!1,n.nextSibling):(x(),l.setCursorLocation(n.nextSibling,0)):C(!1,n),e.preventDefault()):N(s)||(y(d),s!==v.ENTER&&s!==v.DELETE&&s!==v.BACKSPACE||e.preventDefault()):x():e.metaKey||e.ctrlKey||112<=s&&s<=123||(t=l.getNode(),n=m(u=t),l.isCollapsed()||((n=m((o=l.getRng()).endContainer))?(r=o.cloneRange(),l.select(n.previousSibling,!0),l.collapse(),a=l.getRng(),r.setEnd(a.endContainer,a.endOffset),l.setRng(r)):(n=m(o.startContainer))&&((r=o.cloneRange()).setStart(n.nextSibling,0),l.setRng(r))),n?((r=c.hasClass(n,"wpview-selection-before"))||(i=c.hasClass(n,"wpview-selection-after")))&&(N(s)||(i&&s===v.UP||r&&s===v.BACKSPACE?(n.previousSibling?m(n.previousSibling)?C(!1,n.previousSibling):c.isEmpty(n.previousSibling)&&s===v.BACKSPACE?c.remove(n.previousSibling):(l.select(n.previousSibling,!0),l.collapse()):C(!0,n),e.preventDefault()):!i||s!==v.DOWN&&s!==v.RIGHT?!r||s!==v.UP&&s!==v.LEFT?r&&s===v.DOWN?(n.nextSibling?m(n.nextSibling)?C(!0,n.nextSibling):l.setCursorLocation(n.nextSibling,0):C(!1,n),e.preventDefault()):i&&s===v.LEFT||r&&s===v.RIGHT?(E(n),e.preventDefault()):i&&s===v.BACKSPACE?(y(n),e.preventDefault()):i?h(n):r&&h(n,!0,s):(n.previousSibling&&(m(n.previousSibling)?C(s===v.UP,n.previousSibling):(l.select(n.previousSibling,!0),l.collapse())),e.preventDefault()):(n.nextSibling&&(m(n.nextSibling)?C(s===v.RIGHT,n.nextSibling):l.setCursorLocation(n.nextSibling,0)),e.preventDefault()),s===v.ENTER&&e.preventDefault())):e.keyCode===v.BACKSPACE&&(p.dom.isEmpty(t)?(n=m(t.previousSibling))&&(C(!1,n),p.dom.remove(t),e.preventDefault()):(o=l.getRng())&&0===o.startOffset&&0===o.endOffset&&(n=m(t.previousSibling))&&(C(!1,n),e.preventDefault())))}),p.on("keyup",function(){f&&(y(f),f=!1)}),p.on("focus",function(){var e;c=!0,p.dom.addClass(p.getBody(),"has-focus"),w&&(e=m(p.getBody().firstChild))&&C(!0,e),w=!1}),p.on("blur",function(){c=!1,p.dom.removeClass(p.getBody(),"has-focus")}),p.on("NodeChange",function(e){var t=p.dom,n=p.dom.select(".wpview-wrap"),i=e.element.className,o=m(e.element),r=u;u=!1,clearInterval(a),tinymce.each(n,function(e){e.className&&(e.className=e.className.replace(/ ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g,""))}),c&&o&&("wpview-selection-before"!==i&&"wpview-selection-after"!==i||!p.selection.isCollapsed()?b(e.element,"wpview-clipboard")||s||(x(),s++,C(!0,o)):(s=0,x(),r!==o.previousSibling?r!==o.nextSibling?(t.addClass(o,i),a=setInterval(function(){t.hasClass(o,"wpview-cursor-hide")?t.removeClass(o,"wpview-cursor-hide"):t.addClass(o,"wpview-cursor-hide")},500)):C(!1,o):C(!0,o)))}),p.on("BeforeExecCommand",function(){var e,t=p.selection.getNode();t&&((i="wpview-selection-before"===t.className)||"wpview-selection-after"===t.className)&&(e=m(t))&&(h(e,i),n=e)}),p.on("ExecCommand",function(){var e;d&&(e=d,x(),E(e)),n&&((e=n[i?"previousSibling":"nextSibling"])&&"P"===e.nodeName&&p.dom.isEmpty(e)&&(p.dom.remove(e),C(i,n)),n=!1)}),p.on("ResolveName",function(e){p.dom.hasClass(e.target,"wpview-wrap")?(e.name=p.dom.getAttrib(e.target,"data-wpview-type")||"wpview",e.stopPropagation()):m(e.target)&&(e.preventDefault(),e.stopPropagation())}),p.addButton("wp_view_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",onclick:function(){d&&wp.mce.views.edit(p,d)}}),p.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){d&&y(d)}}),p.once("preinit",function(){p.wp&&p.wp._createToolbar&&(t=p.wp._createToolbar(["wp_view_edit","wp_view_remove"]))}),p.on("wptoolbar",function(e){d&&(e.element=d,e.toolbar=t)}),p.wp=p.wp||{},p.wp.getView=m,p.wp.setViewCursor=C,{getView:m}):{getView:function(){return!1}};function P(e,t){return"<p>"+window.decodeURIComponent(t)+"</p>"}function D(e){o("div[data-wpview-text], p[data-wpview-marker]",e).each(function(e,t){t.innerHTML="."})}function N(e){return e<=47&&e!==v.SPACEBAR&&e!==v.ENTER&&e!==v.DELETE&&e!==v.BACKSPACE&&(e<37||40<e)||224<=e||144<=e&&e<=150||91<=e&&e<=93||112<=e&&e<=135}}); |