- md5
- c360f1e1adc81dd19161ff96741de165
- sha1
- c53a78578ab20a4898efc440989658a4e6f4213b
- sha256
- ff5af8a54c72fa03d1c7cf19e47920f53253402c28876c192d0b1076c8cbe567
import{JoomlaEditor as s,JoomlaEditorDecorator as n}from"editor-api";import{keymap as r,createFromTextarea as l,EditorState as c}from"codemirror";/**
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/class a extends n{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((d,i)=>{i.$j_name==="readOnly"&&e.dispatch({effects:i.reconfigure(c.readOnly.of(!t))})}),this}}class h 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=()=>{s.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(()=>r.of([{key:this.fsCombo,run:this.toggleFullScreen},{key:"Escape",run:this.closeFullScreen}])),this.bsModals=this.querySelectorAll(".joomla-modal.modal"),this.bsModals.forEach(e=>document.body.appendChild(e))),this.element=this.querySelector("textarea"),this.instance=await l(this.element,t),this.jEditor=new a(this.instance,"codemirror",this.element.id),s.register(this.jEditor),this.addEventListener("click",this.interactionCallback)}disconnectedCallback(){this.instance&&(this.element&&this.jEditor&&this.jEditor.getValue&&(this.element.value=this.jEditor.getValue()),this.element.style.display="",this.instance.destroy(),this.instance=null),s.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",h);
The same content is in 30 releases, Joomla 5.4.7-rc1 to 6.3.0-alpha1. See them all, or every version of this file.