2021-09-08 19:29:58 -04:00
|
|
|
window.wp=window.wp||{},function(l,g){g.editor=g.editor||{},window.switchEditors=new function(){var h,v,t={};function e(){!h&&window.tinymce&&(h=window.tinymce,(v=h.$)(document).on("click",function(e){e=v(e.target);e.hasClass("wp-switch-editor")&&n(e.attr("data-wp-editor-id"),e.hasClass("switch-tmce")?"tmce":"html")}))}function b(e){e=v(".mce-toolbar-grp",e.getContainer())[0],e=e&&e.clientHeight;return e&&10<e&&e<200?parseInt(e,10):30}function n(e,t){t=t||"toggle";var n,r,i,a,o,c,p,s,d,l,g=h.get(e=e||"content"),u=v("#wp-"+e+"-wrap"),w=v("#"+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],d=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}),c=d.cursorStart,p=d.cursorEnd,l=c!==p?"range":"single",s=null,a=y(v,"").attr("data-mce-type","bookmark"),"range"==l&&(d=o.value.slice(c,p),l=a.clone().addClass("mce_SELRES_end"),s=[d,l[0].outerHTML].join("")),o.value=[o.value.slice(0,c),a.clone().addClass("mce_SELRES_start")[0].outerHTML,s,o.value.slice(p)].join("")),g?(g.show(),!h.Env.iOS&&m&&50<(m=m-b(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+b(g)-14)&&m<5e3&&(f.style.height=m+"px"),f=null,g.getParam("wp_keep_scroll_position")&&(f=function(e){var t=e.getWin().getSelection();if(t&&!(t.rangeCount<1)){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;return 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),{start:e,end:i}}}(g)),g.hide(),f&&(g=g,(f=f)&&(n=g.getElement(),r=f.start,i=f.end||f.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++){var i=
|