jInsertEditorText javascript used with editor-xtd plugin is not available
Should replace / insert text when editing article
javascript error as code is unavailable
with joomla 3.x code was in /media/editors/... -> directories gone in V4 (migrated to???)
Labels |
Added:
?
|
don't agree to comment. "jInsertEditorText" javascript is available with latest stable joomla version (3.9.20). The issue comes with version 3.10 and version 4. (#12561 describes a totally different problem).
So: will there be a replacecment for "jInsertEditorText", a solution or documentation for this or not? Some developer will (at least) need some info if code is deleted and cannot be used anymore.
// An object to hold each editor instance on page, only define if not defined.
Joomla.editors.instances = Joomla.editors.instances || {
/**
* Editors MUST register, per instance, the following:
*
* getValue Type Function
* Should return the complete data from the editor
* Example: function () { return this.element.value; }
* setValue Type Function
* Should replace the complete data of the editor
* Example: function (text) { return this.element.value = text; }
* replaceSelection Type Function
* Should replace the selected text of the editor
* If nothing selected, will insert the data at the cursor
* Example: function (text) { return insertAtCursor(this.element, text); }
*
* USAGE (jform_articletext is the editor id)
* getValue:
* Joomla.editors.instances['jform_articletext'].getValue();
* setValue:
* Joomla.editors.instances['jform_articletext'].setValue('Joomla! rocks');
* replaceSelection:
* Joomla.editors.instances['jform_articletext'].replaceSelection('Joomla! rocks')
*
* *********************************************************
* ANY INTERACTION WITH THE EDITORS SHOULD USE THE ABOVE API
* *********************************************************
*/
};
You should use the new API: Joomla.editors.instances['editor_id'].replaceSelection('Joomla! rocks')
I'm using this half-assed, paranoid(?) code in all of my xtd-plugins (select/enter something in a pop-up and insert via button). From a time when first 4-dev "releases" came up and I tested my dinosaur J3 xtd-plugins with some editors on both platforms:
/** Use the API, if editor supports it **/
if (window.parent.Joomla && window.parent.Joomla.editors && window.parent.Joomla.editors.instances && window.parent.Joomla.editors.instances.hasOwnProperty(editor))
{
window.parent.Joomla.editors.instances[editor].replaceSelection(tag);
}
else
{
window.parent.jInsertEditorText(tag, editor);
}
@ReLater im wondering who could ever wrote that paranoid code, oh wait: #14935 (comment)
Ah, f'ing auto correction of my keyboard. I wanted to type "paramount" not "paranoid" ;-)
For me it looked like one of my own paranoia what-the-hell-is-really-needed IF structures reassembled from diverse code snippets found on stackexchange ;-)
if (good && !bad)
No harm meant. It's brilliant code... because it works ...
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-08-13 09:06:01 |
Closed_By | ⇒ | jschmi102 |
It's already 4 years since this was deprecate. Here #12561 you'll find all the info you need to fix whatever is broken