WordPress/wp-admin/js/editor.min.js

1 line
5.9 KiB
JavaScript

window.switchEditors={switchto:function(e){var t=e.id,r=t.length,e=t.substr(0,r-5),r=t.substr(r-4);this.go(e,r)},go:function(e,t){var r,n,p,i,a=tinymce.DOM;function c(){var e=a.select(".mce-toolbar-grp",r.getContainer())[0],e=e&&e.clientHeight;return e&&10<e&&e<200?parseInt(e,10):30}if(e=e||"content",t=t||"toggle",r=tinymce.get(e),n="wp-"+e+"-wrap",p=a.get(e),"tmce"===(t="toggle"===t?r&&!r.isHidden()?"html":"tmce":t)||"tinymce"===t){if(r&&!r.isHidden())return!1;"undefined"!=typeof QTags&&QTags.closeAllTags(e),i=p?parseInt(p.style.height,10):0,tinyMCEPreInit.mceInit[e]&&tinyMCEPreInit.mceInit[e].wpautop&&(p.value=this.wpautop(p.value)),r?(r.show(),!tinymce.Env.iOS&&i&&50<(i=i-c()+14)&&i<5e3&&r.theme.resizeTo(null,i)):tinymce.init(tinyMCEPreInit.mceInit[e]),a.removeClass(n,"html-active"),a.addClass(n,"tmce-active"),a.setAttrib(p,"aria-hidden",!0),setUserSetting("editor","tinymce")}else if("html"===t){if(r&&r.isHidden())return!1;r?(tinymce.Env.iOS||(i=(t=a.get(e+"_ifr"))?parseInt(t.style.height,10):0)&&50<(i=i+c()-14)&&i<5e3&&(p.style.height=i+"px"),r.hide()):(tinyMCEPreInit.mceInit[e]&&tinyMCEPreInit.mceInit[e].wpautop&&(p.value=this.pre_wpautop(p.value)),a.setStyles(p,{display:"",visibility:""})),a.removeClass(n,"tmce-active"),a.addClass(n,"html-active"),a.setAttrib(p,"aria-hidden",!1),setUserSetting("editor","html")}return!1},_wp_Nop:function(e){var t,r,n=!1,p=!1;return-1===e.indexOf("<pre")&&-1===e.indexOf("<script")||(n=!0,e=e.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(e){return(e=(e=e.replace(/<br ?\/?>(\r\n|\n)?/g,"<wp-line-break>")).replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"<wp-line-break>")).replace(/\r?\n/g,"<wp-line-break>")})),-1!==e.indexOf("[caption")&&(p=!0,e=e.replace(/\[caption[\s\S]+?\[\/caption\]/g,function(e){return e.replace(/<br([^>]*)>/g,"<wp-temp-br$1>").replace(/[\r\n\t]+/,"")})),t="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset",r="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset",e=(e=(e=(e=(e=-1!==(e=-1!==(e=-1!==(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(new RegExp("\\s*</("+t+")>\\s*","g"),"</$1>\n")).replace(new RegExp("\\s*<((?:"+t+")(?: [^>]*)?)>","g"),"\n<$1>")).replace(/(<p [^>]+>.*?)<\/p>/g,"$1</p#>")).replace(/<div( [^>]*)?>\s*<p>/gi,"<div$1>\n\n")).replace(/\s*<p>/gi,"")).replace(/\s*<\/p>\s*/gi,"\n\n")).replace(/\n[\s\u00a0]+\n/g,"\n\n")).replace(/\s*<br ?\/?>\s*/gi,"\n")).replace(/\s*<div/g,"\n<div")).replace(/<\/div>\s*/g,"</div>\n")).replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n")).replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption")).replace(new RegExp("\\s*<((?:"+r+")(?: [^>]*)?)\\s*>","g"),"\n<$1>")).replace(new RegExp("\\s*</("+r+")>\\s*","g"),"</$1>\n")).replace(/<li([^>]*)>/g,"\t<li$1>")).indexOf("<option")?(e=e.replace(/\s*<option/g,"\n<option")).replace(/\s*<\/select>/g,"\n</select>"):e).indexOf("<hr")?e.replace(/\s*<hr( [^>]*)?>\s*/g,"\n\n<hr$1>\n\n"):e).indexOf("<object")?e.replace(/<object[\s\S]+?<\/object>/g,function(e){return e.replace(/[\r\n]+/g,"")}):e).replace(/<\/p#>/g,"</p>\n")).replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g,"\n$1")).replace(/^\s+/,"")).replace(/[\s\u00a0]+$/,""),n&&(e=e.replace(/<wp-line-break>/g,"\n")),e=p?e.replace(/<wp-temp-br([^>]*)>/g,"<br$1>"):e},_wp_Autop:function(e){var t=!1,r=!1,n="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary";return-1===(e=(e=-1!==e.indexOf("<object")?e.replace(/<object[\s\S]+?<\/object>/g,function(e){return e.replace(/[\r\n]+/g,"")}):e).replace(/<[^<>]+>/g,function(e){return e.replace(/[\r\n]+/g," ")})).indexOf("<pre")&&-1===e.indexOf("<script")||(t=!0,e=e.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(e){return e.replace(/(\r\n|\n)/g,"<wp-line-break>")})),-1!==e.indexOf("[caption")&&(r=!0,e=e.replace(/\[caption[\s\S]+?\[\/caption\]/g,function(e){return(e=(e=e.replace(/<br([^>]*)>/g,"<wp-temp-br$1>")).replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g,function(e){return e.replace(/[\r\n\t]+/," ")})).replace(/\s*\n\s*/g,"<wp-temp-br />")})),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e+="\n\n").replace(/<br \/>\s*<br \/>/gi,"\n\n")).replace(new RegExp("(<(?:"+n+")(?: [^>]*)?>)","gi"),"\n$1")).replace(new RegExp("(</(?:"+n+")>)","gi"),"$1\n\n")).replace(/<hr( [^>]*)?>/gi,"<hr$1>\n\n")).replace(/\s*<option/gi,"<option")).replace(/<\/option>\s*/gi,"</option>")).replace(/\r\n|\r/g,"\n")).replace(/\n\s*\n+/g,"\n\n")).replace(/([\s\S]+?)\n\n/g,"<p>$1</p>\n")).replace(/<p>\s*?<\/p>/gi,"")).replace(new RegExp("<p>\\s*(</?(?:"+n+")(?: [^>]*)?>)\\s*</p>","gi"),"$1")).replace(/<p>(<li.+?)<\/p>/gi,"$1")).replace(/<p>\s*<blockquote([^>]*)>/gi,"<blockquote$1><p>")).replace(/<\/blockquote>\s*<\/p>/gi,"</p></blockquote>")).replace(new RegExp("<p>\\s*(</?(?:"+n+")(?: [^>]*)?>)","gi"),"$1")).replace(new RegExp("(</?(?:"+n+")(?: [^>]*)?>)\\s*</p>","gi"),"$1")).replace(/\s*\n/gi,"<br />\n")).replace(new RegExp("(</?(?:"+n+")[^>]*>)\\s*<br />","gi"),"$1")).replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi,"$1")).replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi,"[caption$1[/caption]")).replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g,function(e,t,r){return r.match(/<p( [^>]*)?>/)?e:t+"<p>"+r+"</p>"}),t&&(e=e.replace(/<wp-line-break>/g,"\n")),e=r?e.replace(/<wp-temp-br([^>]*)>/g,"<br$1>"):e},pre_wpautop:function(e){var t={o:this,data:e,unfiltered:e},e="undefined"!=typeof jQuery;return e&&jQuery("body").trigger("beforePreWpautop",[t]),t.data=this._wp_Nop(t.data),e&&jQuery("body").trigger("afterPreWpautop",[t]),t.data},wpautop:function(e){var t={o:this,data:e,unfiltered:e},e="undefined"!=typeof jQuery;return e&&jQuery("body").trigger("beforeWpautop",[t]),t.data=this._wp_Autop(t.data),e&&jQuery("body").trigger("afterWpautop",[t]),t.data}};