芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/media.3/plg_editors_codemirror/js/joomla-editor-codemirror.min.js
class CodemirrorEditor extends HTMLElement{constructor(){super(),this.instance="",this.host=window.location.origin,this.element=this.querySelector("textarea"),this.refresh=this.refresh.bind(this)}static get observedAttributes(){return["options"]}get options(){return JSON.parse(this.getAttribute("options"))}set options(t){this.setAttribute("options",t)}attributeChangedCallback(t,e,i){switch(t){case"options":e&&i!==e&&this.refresh(this.element)}}async connectedCallback(){const t=this.getAttribute("editor"),e=this.getAttribute("addons");await import(`${this.host}/${t}`),this.options.keyMapUrl&&await import(`${this.host}/${this.options.keyMapUrl}`),await import(`${this.host}/${e}`);const i=this;window.CodeMirror.modeURL=this.getAttribute("mod-path"),window.CodeMirror.defineInitHook((t=>{const e=window.CodeMirror.findModeByName(t.options.mode||"")||window.CodeMirror.findModeByExtension(t.options.mode||"");window.CodeMirror.autoLoadMode(t,"object"==typeof e?e.mode:t.options.mode),e&&e.mime&&(["text/x-php","application/x-httpd-php","application/x-httpd-php-open"].includes(e.mime)?t.setOption("mode","php"):t.setOption("mode",e.mime));const o=()=>{i.instance.setOption("fullScreen",!i.instance.getOption("fullScreen"));const t=document.getElementById("subhead");if(t){document.getElementById("header").classList.toggle("hidden"),t.classList.toggle("hidden"),i.instance.display.wrapper.style.top=`${t.getBoundingClientRect().height}px`}},n={"Ctrl-Q":o,[i.getAttribute("fs-combo")]:o,Esc:()=>{if(i.instance.getOption("fullScreen"),i.instance.setOption("fullScreen",!1),!i.instance.getOption("fullScreen")){const t=document.getElementById("subhead");if(t){const e=document.getElementById("header");t.classList.toggle("hidden"),e.classList.toggle("hidden"),i.instance.display.wrapper.style.top=`${t.getBoundingClientRect().height}px`}}}};t.addKeyMap(n);t.on("gutterClick",((t,e,i)=>{if("CodeMirror-markergutter"!==i)return;const o=t.lineInfo(e),n=!!o.gutterMarkers&&!!o.gutterMarkers["CodeMirror-markergutter"];t.setGutterMarker(e,"CodeMirror-markergutter",n?null:(()=>{const t=document.createElement("div");return t.className="CodeMirror-markergutter-mark",t})())})),"fieldset"===i.parentNode.tagName.toLowerCase()&&(i.parentNode.style.minWidth=0)})),this.instance=window.CodeMirror.fromTextArea(this.element,this.options),this.instance.disable=t=>this.setOption("readOnly",!!t&&"nocursor"),Joomla.editors.instances[this.element.id]=this.instance}disconnectedCallback(){delete Joomla.editors.instances[this.element.id]}refresh(t){this.instance.fromTextArea(t,this.options)}}customElements.define("joomla-editor-codemirror",CodemirrorEditor);