CoreFiles by mySites.guru
joomla-editor-codemirror.min.js1 lines, 3,147 bytes, from Joomla_4.0.0-beta4-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta3
md5
97708759cc31909be76ca038c902062e
sha1
2216ba0b11abb2a8e62c561c1b0619a161371444
sha256
175dce96302a42b136b67ecca57f5921df62b2b2774fe721c17414733fd7a2f8
"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(()=>""===this.instance?void(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&&c.mime&&b.setOption("mode",c.mime);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.constructor.makeMarker())}),"fieldset"===this.parentNode.tagName.toLowerCase()&&(this.parentNode.style.minWidth=0)}),this.instance=window.CodeMirror.fromTextArea(this.element,this.options),this.instance.disable=a=>this.instance.setOption("readOnly",!!a&&"nocursor"),Joomla.editors.instances[this.element.id]=this.instance):void(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"));const a=document.getElementById("header");a&&a.classList.toggle("hidden")}closeFullScreen(){this.instance.getOption("fullScreen"),this.instance.setOption("fullScreen",!1);const a=document.getElementById("header");a&&a.classList.remove("hidden")}static makeMarker(){const a=document.createElement("div");return a.className="CodeMirror-markergutter-mark",a}});

The same content is in 4 releases, Joomla 4.0.0-beta4 to 4.0.0-beta7. See them all, or every version of this file.