2022-04-08 16:07:18 -04: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){t=t||"toggle";var n,r,i,a,o,c,p,s,d,l,g=h.get(e=e||"content"),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&&(a=a[0],c=function(e,t){var n=t.cursorStart,t=t.cursorEnd,r=x(e,n);r&&(n=-1!==["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(r.tagType)?r.ltPos:r.gtPos);r=x(e,t);r&&(t=r.gtPos);r=E(e,n);r&&!r.showAsPlainText&&(n=r.urlAtStartOfContent?r.endIndex:r.startIndex);r=E(e,t);r&&!r.showAsPlainText&&(t=r.urlAtEndOfContent?r.startIndex:r.endIndex);return{cursorStart:n,cursorEnd:t}}(a.value,{cursorStart:a.selectionStart,cursorEnd:a.selectionEnd}),o=c.cursorStart,c=c.cursorEnd,d=o!==c?"range":"single",p=null,s=y(b,"").attr("data-mce-type","bookmark"),"range"==d&&(d=a.value.slice(o,c),l=s.clone().addClass("mce_SELRES_end"),p=[d,l[0].outerHTML].join("")),a.value=[a.value.slice(0,o),s.clone().addClass("mce_SELRES_start")[0].outerHTML,p,a.value.slice(c)].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=(d=g.iframeElement)?parseInt(d.style.height,10):0)&&50<(m=m+v(g)-14)&&m<5e3&&(f.style.height=m+"px"),l=null,g.getParam("wp_keep_scroll_position")&&(l=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"),r=r.clone().addClass("mce_SELRES_end"),a=t.getRangeAt(0),o=a.startContainer,c=a.startOffset,p=a.cloneRange(),o=(0<e.$(o).parents(".mce-offscreen-selection").length?(o=e.$("[data-mce-selected]")[0],i.attr("data-mce-object-selection","true"),r.attr("data-mce-object-selection","true"),e.$(o).before(i[0]),e.$(o).after(r[0])):(p.collapse(!1),p.insertNode(r[0]),p.setStart(o,c),p.collapse(!0),p.insertNode(i[0]),a.setStartAfter(i[0]),a.setEndBefore(r[0]),t.removeAllRanges(),t.addRange(a)),e.on("GetContent",_),$(e.getContent())),c=(e.off("GetContent",_),i.remove(),r.remove(),new RegExp('<span[^>]*\\s*class="mce_SELRES_start"[^>]+>\\s*'+n+"[^<]*<\\/span>(\\s*)")),p=new RegExp('(\\s*)<span[^>]*\\s*class="mce_SELRES_end"[^>]+>\\s*'+n+"[^<]*<\\/span>"),t=o.match(c),a=o.match(p);if(!t)return null;e=t.index,i=t[0].length,r=null;return a&&(-1!==t[0].indexOf("data-mce-object-selection")&&(i-=t[1].length),n=a.index,-1!==a[0].indexOf("data-mce-object-selection")&&(n-=a[1].length),r=n-i),{start:e,end:r}}}(g)),g.hide(),l&&(o=g,(s=l)&&(n=o.getElement(),r=s.start,i=s.end||s.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)){t=e.substr(n),e=t.match(/<\s*(\/)?(\w+|\!-{2}.*-{2})/);if(!e)return null;var r=e[2];return{ltPos:n,gtPos:n+t.indexOf(">")+1,tagType:r,isClosingTag:!!e[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++){va
|