Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TinyMCE wrong JS field name #28321

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion media/editors/tinymce/js/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @since 3.7.0
*/
setupEditor: function ( element, pluginOptions ) {
var name = element ? element.getAttribute('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name
var name = element ? element.getAttribute('name').replace(/[^A-Za-z0-9_]+/g, '_') : 'default', // Get Editor name
tinyMCEOptions = pluginOptions ? pluginOptions.tinyMCE || {} : {},
defaultOptions = tinyMCEOptions['default'] || {},
options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name
Expand Down
2 changes: 1 addition & 1 deletion media/editors/tinymce/js/tinymce.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ public function onDisplay(
$id = $name;
}

$id = preg_replace('/(\s|[^A-Za-z0-9_])+/', '_', $id);
$nameGroup = explode('[', preg_replace('/\[\]|\]/', '', $name));
$fieldName = end($nameGroup);
$scriptOptions = array();
$id = preg_replace('/(\s|[^A-Za-z0-9_])+/', '_', $id);
$parsedFieldName = preg_replace('/[^A-Za-z0-9_]+/', '_', $name);
$scriptOptions = array();

// Check for existing options
$doc = JFactory::getDocument();
Expand Down Expand Up @@ -200,7 +199,7 @@ public function onDisplay(
$editor .= '</div>';

// Prepare the instance specific options, actually the ext-buttons
if (empty($options['tinyMCE'][$fieldName]['joomlaExtButtons']))
if (empty($options['tinyMCE'][$parsedFieldName]['joomlaExtButtons']))
{
$btns = $this->tinyButtons($id, $buttons);

Expand All @@ -212,11 +211,11 @@ public function onDisplay(
// Set editor to readonly mode
if (!empty($params['readonly']))
{
$options['tinyMCE'][$fieldName]['readonly'] = 1;
$options['tinyMCE'][$parsedFieldName]['readonly'] = 1;
}

$options['tinyMCE'][$fieldName]['joomlaMergeDefaults'] = true;
$options['tinyMCE'][$fieldName]['joomlaExtButtons'] = $btns;
$options['tinyMCE'][$parsedFieldName]['joomlaMergeDefaults'] = true;
$options['tinyMCE'][$parsedFieldName]['joomlaExtButtons'] = $btns;

$doc->addScriptOptions('plg_editor_tinymce', $options, false);
}
Expand Down