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

1 line
8.0 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{},function(l,s){s.editor=s.editor||{},window.switchEditors=new function(){var c,o,t={};function e(){!c&&window.tinymce&&(c=window.tinymce,(o=c.$)(document).on("click",function(e){e=o(e.target);e.hasClass("wp-switch-editor")&&n(e.attr("data-wp-editor-id"),e.hasClass("switch-tmce")?"tmce":"html")}))}function d(e){e=o(".mce-toolbar-grp",e.getContainer())[0],e=e&&e.clientHeight;return e&&10<e&&e<200?parseInt(e,10):30}function n(e,t){e=e||"content",t=t||"toggle";var n,i=c.get(e),r=o("#wp-"+e+"-wrap"),a=o("#"+e),p=a[0];if("tmce"===(t="toggle"===t?i&&!i.isHidden()?"html":"tmce":t)||"tinymce"===t){if(i&&!i.isHidden())return!1;void 0!==window.QTags&&window.QTags.closeAllTags(e),n=parseInt(p.style.height,10)||0,i?(i.show(),!c.Env.iOS&&n&&50<(n=n-d(i)+14)&&n<5e3&&i.theme.resizeTo(null,n)):c.init(window.tinyMCEPreInit.mceInit[e]),r.removeClass("html-active").addClass("tmce-active"),a.attr("aria-hidden",!0),window.setUserSetting("editor","tinymce")}else if("html"===t){if(i&&i.isHidden())return!1;i?(c.Env.iOS||(n=(t=i.iframeElement)?parseInt(t.style.height,10):0)&&50<(n=n+d(i)-14)&&n<5e3&&(p.style.height=n+"px"),i.hide()):a.css({display:"",visibility:""}),r.removeClass("tmce-active").addClass("html-active"),a.attr("aria-hidden",!1),window.setUserSetting("editor","html")}}function i(e){var t="blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure",n=t+"|div|p",i=t+"|pre",r=!1,t=!1,a=[];return e?(-1!==(e=-1!==e.indexOf("<script")||-1!==e.indexOf("<style")?e.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g,function(e){return a.push(e),"<wp-preserve>"}):e).indexOf("<pre")&&(r=!0,e=e.replace(/<pre[^>]*>[\s\S]+?<\/pre>/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")&&(t=!0,e=e.replace(/\[caption[\s\S]+?\[\/caption\]/g,function(e){return e.replace(/<br([^>]*)>/g,"<wp-temp-br$1>").replace(/[\r\n\t]+/,"")})),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*</("+n+")>\\s*","g"),"</$1>\n")).replace(new RegExp("\\s*<((?:"+n+")(?: [^>]*)?)>","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,function(e,t){return t&&-1!==t.indexOf("\n")?"\n\n":"\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*<((?:"+i+")(?: [^>]*)?)\\s*>","g"),"\n<$1>")).replace(new RegExp("\\s*</("+i+")>\\s*","g"),"</$1>\n")).replace(/<((li|dt|dd)[^>]*)>/g," \t<$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]+$/,""),r&&(e=e.replace(/<wp-line-break>/g,"\n")),t&&(e=e.replace(/<wp-temp-br([^>]*)>/g,"<br$1>")),e=a.length?e.replace(/<wp-preserve>/g,function(){return a.shift()}):e):""}function r(e){var t=!1,n=!1,i="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.replace(/\r\n|\r/g,"\n")).indexOf("\n")?e:(-1===(e=(e=-1!==e.indexOf("<object")?e.replace(/<object[\s\S]+?<\/object>/g,function(e){return e.replace(/\n+/g,"")}):e).replace(/<[^<>]+>/g,function(e){return e.replace(/[\n\t ]+/g," ")})).indexOf("<pre")&&-1===e.indexOf("<script")||(t=!0,e=e.replace(/<(pre|script)[^>]*>[\s\S]*?<\/\1>/g,function(e){return e.replace(/