2021-02-23 11:45:19 -05:00
|
|
|
window.wp=window.wp||{},function(g,u){u.editor=u.editor||{},window.switchEditors=new function(){var h,b,t={};function e(){!h&&window.tinymce&&(h=window.tinymce,(b=h.$)(document).on("click",function(e){e=b(e.target);e.hasClass("wp-switch-editor")&&n(e.attr("data-wp-editor-id"),e.hasClass("switch-tmce")?"tmce":"html")}))}function v(e){e=b(".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,r,i,a,o,c,p,s,d,l,g=h.get(e),u=b("#wp-"+e+"-wrap"),w=b("#"+e),f=w[0];if("tmce"===(t="toggle"===t?g&&!g.isHidden()?"html":"tmce":t)||"tinymce"===t){if(g&&!g.isHidden())return!1;void 0!==window.QTags&&window.QTags.closeAllTags(e);var m=parseInt(f.style.height,10)||0;!(g?g.getParam("wp_keep_scroll_position"):window.tinyMCEPreInit.mceInit[e]&&window.tinyMCEPreInit.mceInit[e].wp_keep_scroll_position)||(a=w)&&a.length&&(o=a[0],c=function(e,t){var n=t.cursorStart,r=t.cursorEnd,t=x(e,n);t&&(n=-1!==["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(t.tagType)?t.ltPos:t.gtPos);t=x(e,r);t&&(r=t.gtPos);t=E(e,n);t&&!t.showAsPlainText&&(n=t.urlAtStartOfContent?t.endIndex:t.startIndex);e=E(e,r);e&&!e.showAsPlainText&&(r=e.urlAtEndOfContent?e.startIndex:e.endIndex);return{cursorStart:n,cursorEnd:r}}(o.value,{cursorStart:o.selectionStart,cursorEnd:o.selectionEnd}),p=c.cursorStart,s=c.cursorEnd,d=p!==s?"range":"single",l=null,a=y(b,"").attr("data-mce-type","bookmark"),"range"==d&&(c=o.value.slice(p,s),d=a.clone().addClass("mce_SELRES_end"),l=[c,d[0].outerHTML].join("")),o.value=[o.value.slice(0,p),a.clone().addClass("mce_SELRES_start")[0].outerHTML,l,o.value.slice(s)].join("")),g?(g.show(),!h.Env.iOS&&m&&50<(m=m-v(g)+14)&&m<5e3&&g.theme.resizeTo(null,m),g.getParam("wp_keep_scroll_position")&&S(g)):h.init(window.tinyMCEPreInit.mceInit[e]),u.removeClass("html-active").addClass("tmce-active"),w.attr("aria-hidden",!0),window.setUserSetting("editor","tinymce")}else if("html"===t){if(g&&g.isHidden())return!1;g?(h.Env.iOS||(m=(t=g.iframeElement)?parseInt(t.style.height,10):0)&&50<(m=m+v(g)-14)&&m<5e3&&(f.style.height=m+"px"),m=null,g.getParam("wp_keep_scroll_position")&&(m=function(e){var t=e.getWin().getSelection();if(!t||t.rangeCount<1)return;var n="SELRES_"+Math.random(),r=y(e.$,n),i=r.clone().addClass("mce_SELRES_start"),a=r.clone().addClass("mce_SELRES_end"),o=t.getRangeAt(0),c=o.startContainer,p=o.startOffset,r=o.cloneRange();0<e.$(c).parents(".mce-offscreen-selection").length?(c=e.$("[data-mce-selected]")[0],i.attr("data-mce-object-selection","true"),a.attr("data-mce-object-selection","true"),e.$(c).before(i[0]),e.$(c).after(a[0])):(r.collapse(!1),r.insertNode(a[0]),r.setStart(c,p),r.collapse(!0),r.insertNode(i[0]),o.setStartAfter(i[0]),o.setEndBefore(a[0]),t.removeAllRanges(),t.addRange(o));e.on("GetContent",_);o=$(e.getContent());e.off("GetContent",_),i.remove(),a.remove();e=new RegExp('<span[^>]*\\s*class="mce_SELRES_start"[^>]+>\\s*'+n+"[^<]*<\\/span>(\\s*)"),i=new RegExp('(\\s*)<span[^>]*\\s*class="mce_SELRES_end"[^>]+>\\s*'+n+"[^<]*<\\/span>"),a=o.match(e),n=o.match(i);if(!a)return null;e=a.index,o=a[0].length,i=null;n&&(-1!==a[0].indexOf("data-mce-object-selection")&&(o-=a[1].length),a=n.index,-1!==n[0].indexOf("data-mce-object-selection")&&(a-=n[1].length),i=a-o);return{start:e,end:i}}(g)),g.hide(),m&&(g=g,(m=m)&&(n=g.getElement(),r=m.start,i=m.end||m.start,n.focus&&setTimeout(function(){n.setSelectionRange(r,i),n.blur&&n.blur(),n.focus()},100)))):w.css({display:"",visibility:""}),u.removeClass("tmce-active").addClass("html-active"),w.attr("aria-hidden",!1),window.setUserSetting("editor","html")}}function x(e,t){var n=e.lastIndexOf("<",t-1);if(e.lastIndexOf(">",t)<n||">"===e.substr(t,1)){var r=e.substr(n),t=r.match(/<\s*(\/)?(\w+|\!-{2}.*-{2})/);if(!t)return null;e=t[2];return{ltPos:n,gtPos:n+r.indexOf(">")+1,tagType:e,isClosingTag:!!t[1]}}return null}function E(e,t){for(var n=function(e){var t,n=function(e){var t=e.match(/\[+([\w_-])+/g),n=[];if(t)for(var r=0;r<t.length;r++){v
|