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

1 line
8.0 KiB
JavaScript

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(/\n/g,"<wp-line-break>")})),-1!==(e=-1!==e.indexOf("<figcaption")?(e=e.replace(/\s*(<figcaption[^>]*>)/g,"$1")).replace(/<\/figcaption>\s*/g,"</figcaption>"):e).indexOf("[caption")&&(n=!0,e=e.replace(/\[caption[\s\S]+?\[\/caption\]/g,function(e){return(e=(e=e.replace(/<br([^>]*)>/g,"<wp-temp-br$1>")).replace(/<[^<>]+>/g,function(e){return e.replace(/[\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("(<(?:"+i+")(?: [^>]*)?>)","gi"),"\n\n$1")).replace(new RegExp("(</(?:"+i+")>)","gi"),"$1\n\n")).replace(/<hr( [^>]*)?>/gi,"<hr$1>\n\n")).replace(/\s*<option/gi,"<option")).replace(/<\/option>\s*/gi,"</option>")).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*(</?(?:"+i+")(?: [^>]*)?>)\\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*(</?(?:"+i+")(?: [^>]*)?>)","gi"),"$1")).replace(new RegExp("(</?(?:"+i+")(?: [^>]*)?>)\\s*</p>","gi"),"$1")).replace(/(<br[^>]*>)\s*\n/gi,"$1")).replace(/\s*\n/g,"<br />\n")).replace(new RegExp("(</?(?:"+i+")[^>]*>)\\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,n){return n.match(/<p( [^>]*)?>/)?e:t+"<p>"+n+"</p>"}),t&&(e=e.replace(/<wp-line-break>/g,"\n")),e=n?e.replace(/<wp-temp-br([^>]*)>/g,"<br$1>"):e)}function a(e){e={o:t,data:e,unfiltered:e};return l&&l("body").trigger("beforePreWpautop",[e]),e.data=i(e.data),l&&l("body").trigger("afterPreWpautop",[e]),e.data}function p(e){e={o:t,data:e,unfiltered:e};return l&&l("body").trigger("beforeWpautop",[e]),e.data=r(e.data),l&&l("body").trigger("afterWpautop",[e]),e.data}return l?l(document).ready(e):document.addEventListener?(document.addEventListener("DOMContentLoaded",e,!1),window.addEventListener("load",e,!1)):window.attachEvent&&(window.attachEvent("onload",e),document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&e()})),s.editor.autop=p,s.editor.removep=a,t={go:n,wpautop:p,pre_wpautop:a,_wp_Autop:r,_wp_Nop:i}},s.editor.initialize=function(e,t){var n,i,r,a,p,c;l&&e&&s.editor.getDefaultSettings&&(c=s.editor.getDefaultSettings(),(t=t||{tinymce:!0}).tinymce&&t.quicktags&&(i=l("#"+e),r=l("<div>").attr({"class":"wp-core-ui wp-editor-wrap tmce-active",id:"wp-"+e+"-wrap"}),a=l('<div class="wp-editor-container">'),p=l("<button>").attr({type:"button","data-wp-editor-id":e}),r.append(l('<div class="wp-editor-tools">').append(l('<div class="wp-editor-tabs">').append(p.clone().attr({id:e+"-tmce","class":"wp-switch-editor switch-tmce"}).text(window.tinymce.translate("Visual"))).append(p.attr({id:e+"-html","class":"wp-switch-editor switch-html"}).text(window.tinymce.translate("Text")))).append(a)),i.after(r),a.append(i)),window.tinymce&&t.tinymce&&("object"!=typeof t.tinymce&&(t.tinymce={}),(n=l.extend({},c.tinymce,t.tinymce)).selector="#"+e,l(document).trigger("wp-before-tinymce-init",n),window.tinymce.init(n),window.wpActiveEditor||(window.wpActiveEditor=e)),window.quicktags&&t.quicktags&&("object"!=typeof t.quicktags&&(t.quicktags={}),(n=l.extend({},c.quicktags,t.quicktags)).id=e,l(document).trigger("wp-before-quicktags-init",n),window.quicktags(n),window.wpActiveEditor||(window.wpActiveEditor=n.id)))},s.editor.remove=function(e){var t,n,i=l("#wp-"+e+"-wrap");window.tinymce&&(t=window.tinymce.get(e))&&(t.isHidden()||t.save(),t.remove()),window.quicktags&&(n=window.QTags.getInstance(e))&&n.remove(),i.length&&(i.after(l("#"+e)),i.remove())},s.editor.getContent=function(e){var t;if(l&&e)return window.tinymce&&(t=window.tinymce.get(e))&&!t.isHidden()&&t.save(),l("#"+e).val()}}(window.jQuery,window.wp);