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