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
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b17b3cb
tinymce initialization, use addScriptOptions and tinymce-init.js
Fedik de5e16f
Finalize tinymce-init.js
Fedik 20cb7bc
Sync. Merge branch 'master' into tinymce-scriptoptions
Fedik 6081963
Small improve for code duplication
Fedik 0eb5b98
Allow multiple editors with diferent options
Fedik f9fc424
Setup default options for the editor script only once
Fedik aba6e40
Minified version of tinymce-init
Fedik 7b4b16c
code style
Fedik bc785a3
Sync. Merge branch 'master' into tinymce-scriptoptions
Fedik 1fb5519
Sync. Merge branch 'master' into tinymce-scriptoptions
Fedik 7804f39
Improve a bit
Fedik 71b8a85
Sync. Merge branch 'master' into tinymce-scriptoptions
Fedik File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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){ | ||
Joomla.setupEditorsTinyMCE(row); | ||
}) | ||
}); | ||
|
||
}(tinyMCE, Joomla, jQuery, window, document)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 💯