]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wpview/plugin.min.js
Wordpress 4.6
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wpview / plugin.min.js
index 4e0d998ac23066bed8489391b83fd9bd4c5b83b4..0581ce901224f50815b47d8d98b24ea4f31b0ec8 100644 (file)
@@ -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(c){return(c=b(c))?window.decodeURIComponent(a.dom.getAttrib(c,"data-wpview-text")||""):""}function e(c,d){return c=b(c),c?(a.dom.setAttrib(c,"data-wpview-text",window.encodeURIComponent(d||"")),!0):!1}function f(a){a.stopPropagation()}function g(b,c){var d=b?"before":"after",e=b?0:1;k(),a.selection.setCursorLocation(a.dom.select(".wpview-selection-"+d,c)[0],e),a.nodeChanged()}function h(b,c,d){var e=a.dom,f=e.create("p");u.ie&&u.ie<11||(f.innerHTML='<br data-mce-bogus="1">'),c?b.parentNode.insertBefore(f,b):e.insertAfter(f,b),k(),c&&d===v.ENTER?g(c,b):a.selection.setCursorLocation(f,0),a.nodeChanged()}function i(b){a.undoManager.transact(function(){h(b),a.dom.remove(b)})}function j(b){var c,e=a.dom;b&&b!==n&&(a.getBody().focus(),k(),n=b,e.setAttrib(b,"data-mce-selected",1),c=e.create("div",{"class":"wpview-clipboard",contenteditable:"true"},d(b)),a.dom.select(".wpview-body",b)[0].appendChild(c),e.bind(c,"beforedeactivate focusin focusout",f),e.bind(n,"beforedeactivate focusin focusout",f),A?a.selection.select(c):a.selection.select(c,!0),a.nodeChanged(),a.fire("wpview-selected",b))}function k(){var b,c=a.dom;n&&(b=a.dom.select(".wpview-clipboard",n)[0],c.unbind(b),c.remove(b),c.unbind(n,"beforedeactivate focusin focusout click mouseup",f),c.setAttrib(n,"data-mce-selected",null)),n=null}function l(a){return a.replace(/<div[^>]+data-wpview-text=\"([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>(?:&nbsp;|\u00a0)*<\/p><\/div>/g,"$1")}function m(a){return 47>=a&&a!==v.SPACEBAR&&a!==v.ENTER&&a!==v.DELETE&&a!==v.BACKSPACE&&(37>a||a>40)||a>=224||a>=144&&150>=a||a>=91&&93>=a||a>=112&&135>=a}var n,o,p,q,r,s,t,u=tinymce.Env,v=tinymce.util.VK,w=tinymce.dom.TreeWalker,x=!1,y=!0,z=function(){return!1},A=/iPad|iPod|iPhone/.test(navigator.userAgent);return"undefined"!=typeof wp&&wp.mce?(a.on("BeforeAddUndo",function(a){a.lastLevel&&l(a.level.content)===l(a.lastLevel.content)&&a.preventDefault()}),a.on("BeforeSetContent",function(b){var c;b.content&&(n&&i(n),c=a.selection.getNode(),(!b.content.match(/^\s*(https?:\/\/[^\s"]+)\s*$/i)||"P"===c.nodeName&&c.parentNode===a.getBody()&&a.dom.isEmpty(c))&&(b.content=wp.mce.views.toViews(b.content)))}),a.on("SetContent",function(){wp.mce.views.render()}),a.on("click",function(c){var d,e=c.clientX,f=c.clientY,h=a.getBody(),i=h.getBoundingClientRect(),j=h.firstChild,k=j.getBoundingClientRect(),l=h.lastChild,m=l.getBoundingClientRect();f<k.top&&(d=b(j))?(g(!0,d),c.preventDefault()):f>m.bottom&&(d=b(l))?(g(!1,d),c.preventDefault()):tinymce.each(a.dom.select(".wpview-wrap"),function(a){var b=a.getBoundingClientRect();return f>=b.top&&f<=b.bottom?void(e<i.left?(g(!0,a),c.preventDefault()):e>i.right&&(g(!1,a),c.preventDefault())):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 w(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(d){var e=b(d.target);if(y=!1,e){if(d.stopImmediatePropagation(),d.preventDefault(),!("touchend"!==d.type&&"mousedown"!==d.type||d.metaKey||d.ctrlKey)){if(a.dom.hasClass(d.target,"edit"))return wp.mce.views.edit(e),a.focus(),!1;if(a.dom.hasClass(d.target,"remove"))return i(e),!1}return"touchend"===d.type&&c?c=!1:j(e),!1}("touchend"===d.type||"mousedown"===d.type)&&k(),"touchend"===d.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(/<div [^>]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g,function(a,b){return b?"<p>"+window.decodeURIComponent(b)+"</p>":""}))}),a.on("keydown",function(c){var d,e,f,l,o,q,r,s=c.keyCode,t=a.dom,u=a.selection;if(n){if((c.metaKey||c.ctrlKey)&&s!==v.BACKSPACE&&86!==s||s>=112&&123>=s)return void((c.metaKey||c.ctrlKey)&&88===s&&(x=n));if(e=b(u.getNode()),e!==n)return void k();s===v.LEFT?(g(!0,e),c.preventDefault()):s===v.UP?(e.previousSibling?b(e.previousSibling)?g(!0,e.previousSibling):(k(),u.select(e.previousSibling,!0),u.collapse()):g(!0,e),c.preventDefault()):s===v.RIGHT?(g(!1,e),c.preventDefault()):s===v.DOWN?(e.nextSibling?b(e.nextSibling)?g(!1,e.nextSibling):(k(),u.setCursorLocation(e.nextSibling,0)):g(!1,e),c.preventDefault()):m(s)||(i(n),(s===v.ENTER||s===v.DELETE||s===v.BACKSPACE)&&c.preventDefault())}else{if(c.metaKey||c.ctrlKey||s>=112&&123>=s)return;if(d=u.getNode(),p=d,e=b(d),u.isCollapsed()||(o=u.getRng(),(e=b(o.endContainer))?(q=o.cloneRange(),u.select(e.previousSibling,!0),u.collapse(),r=u.getRng(),q.setEnd(r.endContainer,r.endOffset),u.setRng(q)):(e=b(o.startContainer))&&(q=o.cloneRange(),q.setStart(e.nextSibling,0),u.setRng(q))),!e)return void(c.keyCode===v.BACKSPACE&&(a.dom.isEmpty(d)?(e=b(d.previousSibling))&&(g(!1,e),a.dom.remove(d),c.preventDefault()):(o=u.getRng())&&0===o.startOffset&&0===o.endOffset&&(e=b(d.previousSibling))&&(g(!1,e),c.preventDefault())));if(!(f=t.hasClass(e,"wpview-selection-before"))&&!(l=t.hasClass(e,"wpview-selection-after")))return;if(m(s))return;l&&s===v.UP||f&&s===v.BACKSPACE?(e.previousSibling?b(e.previousSibling)?g(!1,e.previousSibling):t.isEmpty(e.previousSibling)&&s===v.BACKSPACE?t.remove(e.previousSibling):(u.select(e.previousSibling,!0),u.collapse()):g(!0,e),c.preventDefault()):!l||s!==v.DOWN&&s!==v.RIGHT?!f||s!==v.UP&&s!==v.LEFT?f&&s===v.DOWN?(e.nextSibling?b(e.nextSibling)?g(!0,e.nextSibling):u.setCursorLocation(e.nextSibling,0):g(!1,e),c.preventDefault()):l&&s===v.LEFT||f&&s===v.RIGHT?(j(e),c.preventDefault()):l&&s===v.BACKSPACE?(i(e),c.preventDefault()):l?h(e):f&&h(e,!0,s):(e.previousSibling&&(b(e.previousSibling)?g(s===v.UP,e.previousSibling):(u.select(e.previousSibling,!0),u.collapse())),c.preventDefault()):(e.nextSibling&&(b(e.nextSibling)?g(s===v.RIGHT,e.nextSibling):u.setCursorLocation(e.nextSibling,0)),c.preventDefault()),s===v.ENTER&&c.preventDefault()}}),a.on("keyup",function(){x&&(i(x),x=!1)}),a.on("focus",function(){var c;r=!0,a.dom.addClass(a.getBody(),"has-focus"),y&&(c=b(a.getBody().firstChild))&&g(!0,c),y=!1}),a.on("blur",function(){r=!1,a.dom.removeClass(a.getBody(),"has-focus")}),a.on("NodeChange",function(d){var e=a.dom,f=a.dom.select(".wpview-wrap"),h=d.element.className,i=b(d.element),j=p;if(p=!1,clearInterval(o),tinymce.each(f,function(a){a.className&&(a.className=a.className.replace(/ ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g,""))}),r&&i)if("wpview-selection-before"!==h&&"wpview-selection-after"!==h||!a.selection.isCollapsed())c(d.element,"wpview-clipboard")||q||(k(),q++,g(!0,i));else{if(q=0,k(),j===i.previousSibling)return void g(!0,i);if(j===i.nextSibling)return void g(!1,i);e.addClass(i,h),o=setInterval(function(){e.hasClass(i,"wpview-cursor-hide")?e.removeClass(i,"wpview-cursor-hide"):e.addClass(i,"wpview-cursor-hide")},500)}}),a.on("BeforeExecCommand",function(){var c,d=a.selection.getNode();d&&((t="wpview-selection-before"===d.className)||"wpview-selection-after"===d.className)&&(c=b(d))&&(h(c,t),s=c)}),a.on("ExecCommand",function(){var b,c;n&&(b=n,k(),j(b)),s&&(c=s[t?"previousSibling":"nextSibling"],c&&"P"===c.nodeName&&a.dom.isEmpty(c)&&(a.dom.remove(c),g(t,s)),s=!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())}),{getViewText:d,setViewText:e,getView:b}):{getViewText:z,setViewText:z,getView:z}});
\ No newline at end of file
+!function(a,b){a.PluginManager.add("wpview",function(c){function d(){}function e(a){return c.dom.hasClass(a,"wpview")}function f(a){function b(a,b){return"<p>"+window.decodeURIComponent(b)+"</p>"}return a?a.replace(/<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g,b).replace(/<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,b):a}return b&&b.mce&&b.mce.views?(c.on("init",function(){var a=window.MutationObserver||window.WebKitMutationObserver;a&&new a(function(){c.fire("wp-body-class-change")}).observe(c.getBody(),{attributes:!0,attributeFilter:["class"]}),c.on("wp-body-class-change",function(){var a=c.getBody().className;c.$('iframe[class="wpview-sandbox"]').each(function(b,c){if(!c.src||'javascript:""'===c.src)try{c.contentWindow.document.body.className=a}catch(d){}})})}),c.on("beforesetcontent",function(a){var d;if(a.selection||b.mce.views.unbind(),a.content){if(!a.load&&(d=c.selection.getNode(),d&&d!==c.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(a.content))){if(d=c.dom.getParent(d,"p"),!d||!/^[\s\uFEFF\u00A0]*$/.test(c.$(d).text()||""))return;d.innerHTML=""}a.content=b.mce.views.setMarkers(a.content)}}),c.on("setcontent",function(){b.mce.views.render()}),c.on("preprocess",function(a){c.$("div[data-wpview-text], p[data-wpview-marker]",a.node).each(function(a,b){b.innerHTML="."})},!0),c.on("postprocess",function(a){a.content=f(a.content)}),c.on("beforeaddundo",function(a){a.level.content=f(a.level.content)}),c.on("drop objectselected",function(a){e(a.targetClone)&&(a.targetClone=c.getDoc().createTextNode(window.decodeURIComponent(c.dom.getAttrib(a.targetClone,"data-wpview-text"))))}),c.on("pastepreprocess",function(b){var c=b.content;c&&(c=a.trim(c.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(c)&&(b.content=c))}),c.on("resolvename",function(a){e(a.target)&&(a.name=c.dom.getAttrib(a.target,"data-wpview-type")||"object")}),c.on("click keyup",function(){var a=c.selection.getNode();e(a)&&c.dom.getAttrib(a,"data-mce-selected")&&a.setAttribute("data-mce-selected","2")}),c.addButton("wp_view_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",onclick:function(){var a=c.selection.getNode();e(a)&&b.mce.views.edit(c,a)}}),c.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){c.fire("cut")}}),c.once("preinit",function(){var a;c.wp&&c.wp._createToolbar&&(a=c.wp._createToolbar(["wp_view_edit","wp_view_remove"]),c.on("wptoolbar",function(b){e(b.element)&&(b.toolbar=a)}))}),c.wp=c.wp||{},c.wp.getView=d,c.wp.setViewCursor=d,{getView:d}):{getView:d}})}(window.tinymce,window.wp);
\ No newline at end of file