2021-03-03 16:16:22 -05:00
|
|
|
window.wp=window.wp||{},function(m,h){h.editor=h.editor||{},window.switchEditors=new function(){var c,p,t={};function e(){!c&&window.tinymce&&(c=window.tinymce,(p=c.$)(document).on("click",function(e){e=p(e.target);e.hasClass("wp-switch-editor")&&n(e.attr("data-wp-editor-id"),e.hasClass("switch-tmce")?"tmce":"html")}))}function s(e){e=p(".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=c.get(e),r=p("#wp-"+e+"-wrap"),i=p("#"+e),a=i[0];if("tmce"===(t="toggle"===t?n&&!n.isHidden()?"html":"tmce":t)||"tinymce"===t){if(n&&!n.isHidden())return!1;void 0!==window.QTags&&window.QTags.closeAllTags(e);var o=parseInt(a.style.height,10)||0;(n?n.getParam("wp_keep_scroll_position"):window.tinyMCEPreInit.mceInit[e]&&window.tinyMCEPreInit.mceInit[e].wp_keep_scroll_position)&&function(e){if(!e||!e.length)return;var t=e[0],n=function(e,t){var n=t.cursorStart,r=t.cursorEnd,t=d(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=d(e,r);t&&(r=t.gtPos);t=l(e,n);t&&!t.showAsPlainText&&(n=t.urlAtStartOfContent?t.endIndex:t.startIndex);e=l(e,r);e&&!e.showAsPlainText&&(r=e.urlAtEndOfContent?e.startIndex:e.endIndex);return{cursorStart:n,cursorEnd:r}}(t.value,{cursorStart:t.selectionStart,cursorEnd:t.selectionEnd}),r=n.cursorStart,i=n.cursorEnd,a=r!==i?"range":"single",o=null,e=g(p,"").attr("data-mce-type","bookmark");"range"==a&&(n=t.value.slice(r,i),a=e.clone().addClass("mce_SELRES_end"),o=[n,a[0].outerHTML].join(""));t.value=[t.value.slice(0,r),e.clone().addClass("mce_SELRES_start")[0].outerHTML,o,t.value.slice(i)].join("")}(i),n?(n.show(),!c.Env.iOS&&o&&50<(o=o-s(n)+14)&&o<5e3&&n.theme.resizeTo(null,o),n.getParam("wp_keep_scroll_position")&&u(n)):c.init(window.tinyMCEPreInit.mceInit[e]),r.removeClass("html-active").addClass("tmce-active"),i.attr("aria-hidden",!0),window.setUserSetting("editor","tinymce")}else if("html"===t){if(n&&n.isHidden())return!1;n?(c.Env.iOS||(o=(t=n.iframeElement)?parseInt(t.style.height,10):0)&&50<(o=o+s(n)-14)&&o<5e3&&(a.style.height=o+"px"),o=null,n.getParam("wp_keep_scroll_position")&&(o=function(e){var t=e.getWin().getSelection();if(!t||t.rangeCount<1)return;var n="SELRES_"+Math.random(),r=g(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",w);o=f(e.getContent());e.off("GetContent",w),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}}(n)),n.hide(),o&&function(e,t){if(!t)return;var n=e.getElement(),r=t.start,i=t.end||t.start;n.focus&&setTimeout(function(){n.setSelectionRange(r,i),n.blur&&n.blur(),n.focus()},100)}(n,o)):i.css({display:"",visibility:""}),r.removeClass("tmce-active").addClass("html-active"),i.attr("aria-hidden",!1),window.setUserSetting("editor","html")}}function d(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 l(e,t){for(var n=function(e){var t,n=function(e){var t=e.match(/\[+([\w_-])+/g),n=[];if(t)for
|