- md5
- f6cc62bb7ce48ea72fd613984ab4860f
- sha1
- ac5877302919d48154ad524863ecbd9f9f177d64
- sha256
- febf7c6db48e9db67ac73bf5351c1ccd170b6fbbb9921f22888f9f17da6b26dc
"use strict";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 a=this.getAttribute("editor"),b=document.createElement("script");b.src=`${this.host}/${a}`,b.id="cm-editor",b.setAttribute("async",!1),document.head.insertBefore(b,this.file)}}static get observedAttributes(){return["options"]}get options(){return JSON.parse(this.getAttribute("options"))}set options(a){this.setAttribute("options",a)}attributeChangedCallback(a,b,c){switch(a){case"options":b&&c!==b&&this.refresh(this.element);break;default:}}connectedCallback(){const a=this;this.checkElement("CodeMirror").then(()=>{if(!document.head.querySelector("#cm-addons")){const a=this.getAttribute("addons"),b=document.createElement("script");b.src=`${this.host}/${a}`,b.id="cm-addons",b.setAttribute("async",!1),document.head.insertBefore(b,this.file)}this.checkElement("CodeMirror","findModeByName").then(()=>{window.CodeMirror.modeURL=this.getAttribute("mod-path"),window.CodeMirror.defineInitHook(b=>{const c=window.CodeMirror.findModeByName(b.options.mode||"")||window.CodeMirror.findModeByName(b.options.mode||"")||window.CodeMirror.findModeByExtension(b.options.mode||"");window.CodeMirror.autoLoadMode(b,c?c.mode:b.options.mode),c&&b.setOption("mode",c.mode);const d={"Ctrl-Q":a.toggleFullScreen,[a.getAttribute("fs-combo")]:a.toggleFullScreen,Esc:a.closeFullScreen};b.addKeyMap(d),b.on("gutterClick",(a,b,c)=>{if("CodeMirror-markergutter"!==c)return;const d=a.lineInfo(b),e=!!d.gutterMarkers&&!!d.gutterMarkers["CodeMirror-markergutter"];a.setGutterMarker(b,"CodeMirror-markergutter",e?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(a){this.instance=window.CodeMirror.fromTextArea(a,this.options)}rafAsync(){return new Promise(a=>requestAnimationFrame(a))}async checkElement(a,b){if(b)for(;"function"!=typeof window[a][b];)await this.rafAsync();else for(;"function"!=typeof window[a];)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 a=document.createElement("div");return a.className="CodeMirror-markergutter-mark",a}});
No other release has this exact content. See every version of this file.