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

tinyMCE use document "scriptoptions", and allow to override tinyMCE Javascript parameters #11157

Merged
merged 12 commits into from Oct 1, 2016
2 changes: 1 addition & 1 deletion layouts/joomla/tinymce/textarea.php
Expand Up @@ -18,7 +18,7 @@
cols="<?php echo $data->cols; ?>"
rows="<?php echo $data->rows; ?>"
style="width: <?php echo $data->width; ?>; height: <?php echo $data->height; ?>;"
class="mce_editable"
class="<?php echo empty($data->class) ? 'mce_editable' : $data->class; ?>"
>
<?php echo $data->content; ?>
</textarea>
63 changes: 63 additions & 0 deletions media/editors/tinymce/js/tinymce-init.js
@@ -0,0 +1,63 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

;(function(tinyMCE, Joomla, $, window, document){
"use strict";

// This line is for Mootools b/c
window.getSize = window.getSize || function(){return {x: $(window).width(), y: $(window).height()};};

window.jInsertEditorText = function ( text, editor ) {
tinyMCE.activeEditor.execCommand('mceInsertContent', false, text);
}

/**
* Find all TinyMCE elements and initialize TinyMCE instance for each
*/
Joomla.setupEditorsTinyMCE = Joomla.setupEditorsTinyMCE || function(target){
target = target || document;
var pluginOptions = Joomla.optionsStorage.plg_editor_tinymce || {},
$editors = $(target).find('.joomla-editor-tinymce');

for(var i = 0, l = $editors.length; i < l; i++) {
Joomla.initializeEditorTinyMCE($editors[i], pluginOptions);
}
}

/**
* Initialize TinyMCE instance
*/
Joomla.initializeEditorTinyMCE = Joomla.initializeEditorTinyMCE || function (element, pluginOptions) {
var name = element ? $(element).attr('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name
tinyMCEOptions = pluginOptions ? pluginOptions.tinyMCE || {} : {},
defaultOptions = tinyMCEOptions['default'] || {},
options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name

// Avoid unexpected changes
options = jQuery.extend({}, options);

if (element) {
options.selector = null;
options.target = element;
}

if (options.setupCallbacString && !options.setup) {
options.setup = new Function('editor', options.setupCallbacString);
}

tinyMCE.init(options);
}

// Init on doomready
$(document).ready(function(){
Joomla.setupEditorsTinyMCE();

// Init in subform field
$(document).on('subform-row-add', function(event, row){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 💯

Joomla.setupEditorsTinyMCE(row);
})
});

}(tinyMCE, Joomla, jQuery, window, document));
1 change: 1 addition & 0 deletions media/editors/tinymce/js/tinymce-init.min.js

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