CoreFiles by mySites.guru
joomla-editor-codemirror.min.js1 lines, 2,825 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
5f989c984955fed0f5ac0d5d087f5789
sha1
99fd1e892b55fd8774915ffb3b96e3e656259cdb
sha256
97922cf2720b2e46c55f5c7b4ce38831bf0f34b7c4ee6bf0545f127d50e6113f
"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&&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.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}});

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