- md5
- ba12f6383bd915ca4ef666d2ffb5424b
- sha1
- c96c8dd14482f14b03f09e0606821e772cbd69f8
- sha256
- 28f34310d701c2bdd692b6dd88d79d854a4c20bd8afb975e42823e1eee9b71cd
customElements.define("joomla-editor-codemirror",class extends HTMLElement{constructor(){if(super(),this.instance="",this.cm="",this.host=window.location.origin,this.element=this.querySelector("textarea"),this.refresh=this.refresh.bind(this),this.toggleFullScreen=this.toggleFullScreen.bind(this),this.closeFullScreen=this.closeFullScreen.bind(this),!document.head.querySelector("#cm-editor")){const e=this.getAttribute("editor"),t=document.createElement("script");t.src=`${this.host}/${e}`,t.id="cm-editor",t.setAttribute("async",!1),document.head.insertBefore(t,this.file)}}static get observedAttributes(){return["options"]}get options(){return JSON.parse(this.getAttribute("options"))}set options(e){this.setAttribute("options",e)}attributeChangedCallback(e,t,o){switch(e){case"options":t&&o!==t&&this.refresh(this.element)}}connectedCallback(){const e=this;this.checkElement("CodeMirror").then(()=>{if(!document.head.querySelector("#cm-addons")){const e=this.getAttribute("addons"),t=document.createElement("script");t.src=`${this.host}/${e}`,t.id="cm-addons",t.setAttribute("async",!1),document.head.insertBefore(t,this.file)}this.checkElement("CodeMirror","findModeByName").then(()=>{window.CodeMirror.modeURL=this.getAttribute("mod-path"),window.CodeMirror.defineInitHook(t=>{const o=window.CodeMirror.findModeByName(t.options.mode||"")||window.CodeMirror.findModeByName(t.options.mode||"")||window.CodeMirror.findModeByExtension(t.options.mode||"");window.CodeMirror.autoLoadMode(t,o?o.mode:t.options.mode),o&&t.setOption("mode",o.mode);const r={"Ctrl-Q":e.toggleFullScreen,[e.getAttribute("fs-combo")]:e.toggleFullScreen,Esc:e.closeFullScreen};t.addKeyMap(r),t.on("gutterClick",(e,t,o)=>{if("CodeMirror-markergutter"!==o)return;const r=e.lineInfo(t),i=!!r.gutterMarkers&&!!r.gutterMarkers["CodeMirror-markergutter"];e.setGutterMarker(t,"CodeMirror-markergutter",i?null:this.makeMarker())}),"fieldset"===this.parentNode.tagName.toLowerCase()&&(this.parentNode.style.minWidth=0)}),this.instance=window.CodeMirror.fromTextArea(this.element,this.options),Joomla.editors.instances[this.element.id]=this.instance})})}disconnectedCallback(){delete Joomla.editors.instances[this.element.id]}refresh(e){this.instance=window.CodeMirror.fromTextArea(e,this.options)}rafAsync(){return new Promise(e=>requestAnimationFrame(e))}async checkElement(e,t){if(t)for(;"function"!=typeof window[e][t];)await this.rafAsync();else for(;"function"!=typeof window[e];)await this.rafAsync();return!0}toggleFullScreen(){this.instance.setOption("fullScreen",!this.instance.getOption("fullScreen"))}closeFullScreen(){this.instance.getOption("fullScreen"),this.instance.setOption("fullScreen",!1)}static makeMarker(){const e=document.createElement("div");return e.className="CodeMirror-markergutter-mark",e}});
No other release has this exact content. See every version of this file.