CoreFiles by mySites.guru
joomla-editor-codemirror.min.js1 lines, 2,271 bytes, from Joomla_5.0.0-rc2-Release_Candidate-Full_Package.zip
Raw History Compare with 5.0.0-rc
md5
b24d93ff2edd09fe763d120c12326481
sha1
5635583428f4b6318cd1a0abdbdb64a004f91ec6
sha256
16f47a142460723fa3b7f2f4c77dff12facd663b903b4ffff8481407116a4965
import{JoomlaEditor,JoomlaEditorDecorator}from"editor-api";import{keymap,createFromTextarea,EditorState}from"codemirror";class CodemirrorDecorator extends JoomlaEditorDecorator{getValue(){return this.instance.state.doc.toString()}setValue(t){const e=this.instance;return e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t}}),this}getSelection(){const{state:t}=this.instance;return t.sliceDoc(t.selection.main.from,t.selection.main.to)}replaceSelection(t){const e=this.instance.state.replaceSelection(t);return this.instance.dispatch(e),this}disable(t){const e=this.instance;return e.state.config.compartments.forEach(((s,o)=>{"readOnly"===o.$j_name&&e.dispatch({effects:o.reconfigure(EditorState.readOnly.of(!t))})})),this}}class CodemirrorEditor extends HTMLElement{constructor(){super(),this.toggleFullScreen=()=>{this.classList.contains("fullscreen")?this.closeFullScreen():(this.classList.add("fullscreen"),document.documentElement.scrollTop=0,document.documentElement.style.overflow="hidden")},this.closeFullScreen=()=>{this.classList.remove("fullscreen"),document.documentElement.style.overflow=""},this.interactionCallback=()=>{JoomlaEditor.setActive(this.element.id)}}get options(){return JSON.parse(this.getAttribute("options"))}get fsCombo(){return this.getAttribute("fs-combo")}async connectedCallback(){const{options:t}=this;this.fsCombo&&(t.customExtensions=t.customExtensions||[],t.customExtensions.push((()=>keymap.of([{key:this.fsCombo,run:this.toggleFullScreen},{key:"Escape",run:this.closeFullScreen}]))),this.bsModals=this.querySelectorAll(".joomla-modal.modal"),this.bsModals.forEach((t=>{document.body.appendChild(t)}))),this.element=this.querySelector("textarea"),this.instance=await createFromTextarea(this.element,t),this.jEditor=new CodemirrorDecorator(this.instance,"codemirror",this.element.id),JoomlaEditor.register(this.jEditor),this.addEventListener("click",this.interactionCallback)}disconnectedCallback(){this.instance&&(this.element.style.display="",this.instance.destroy()),JoomlaEditor.unregister(this.element.id),this.removeEventListener("click",this.interactionCallback),this.bsModals&&this.bsModals.length&&this.bsModals.forEach((t=>{this.appendChild(t)}))}}customElements.define("joomla-editor-codemirror",CodemirrorEditor);

The same content is in 6 releases, Joomla 5.0.0-beta1 to 5.0.0. See them all, or every version of this file.