2024-12-13 14:06:24 -05:00
|
|
|
window.wp=window.wp||{},((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"),m=w.find(".switch-tmce"),f=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=((e,t)=>{var n=t.cursorStart,t=t.cursorEnd,r=y(e,n);return 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))&&(t=r.gtPos),(r=S(e,n))&&!r.showAsPlainText&&(n=r.urlAtStartOfContent?r.endIndex:r.startIndex),(r=S(e,t))&&!r.showAsPlainText&&(t=r.urlAtEndOfContent?r.startIndex:r.endIndex),{cursorStart:n,cursorEnd:t}})(o.value,{cursorStart:o.selectionStart,cursorEnd:o.selectionEnd}),c=s.cursorStart,l=c!==(s=s.cursorEnd)?"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"),f.attr("aria-pressed",!1),m.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=(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"),f.attr("aria-pressed",!0),m.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=(e=>{var t,n=(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[];for(var r,i=u.shortcode.
|