CoreFiles by mySites.guru
joomla-editor-none.js33 lines, 1,116 bytes, from Joomla_4.0.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha2
md5
97ad52872c00f9d4df0c5a39c38117c6
sha1
21b7448eaf82b6f0f7a0562922dbd399b35b6e45
sha256
62136e4c114227849ff05d8b7f2e0fa2afd3d8f998efc80c38f253452d5fcd04
customElements.define('joomla-editor-none', class extends HTMLElement {
	connectedCallback() {
		this.insertAtCursor = this.insertAtCursor.bind(this);

		const that = this;
		/** Register Editor */
		Joomla.editors.instances[that.childNodes[0].id] = {
			'id': that.childNodes[0].id,
			'element':  that,
			'getValue': () => { return that.childNodes[0].value; },
			'setValue': (text) => { return that.childNodes[0].value = text; },
			'replaceSelection': (text) => { return that.insertAtCursor(text); },
			'onSave': () => {}
		};
	}

	disconnectedCallback() {
		/** Remove from the Joomla API */
		delete Joomla.editors.instances[this.childNodes[0].id];
	}

	insertAtCursor(myValue) {
		if (this.childNodes[0].selectionStart || this.childNodes[0].selectionStart === 0) {
			const startPos = this.childNodes[0].selectionStart;
			const endPos = this.childNodes[0].selectionEnd;
			this.childNodes[0].value = this.childNodes[0].value.substring(0, startPos)
				+ myValue
				+ this.childNodes[0].value.substring(endPos, this.childNodes[0].value.length);
		} else {
			this.childNodes[0].value += myValue;
		}
	}
});

The same content is in 2 releases, Joomla 4.0.0-alpha3 to 4.0.0-alpha5. See them all, or every version of this file.