Closed ekaukis closed 11 years ago
We want to keep richtext editor as simple as possible.
What you can do is add manual-init
class to textarea and then add something like this to controllers javascript (or in common javascript included by controller, or all controllers):
jQuery(function()
{
var richtext_config =
{
// CUSTOM CONFIG GOES HERE
}
jQuery('body').on('contentloaded', function(e)
{
jQuery(e.target).find('.field textarea.manual-init').trigger('richtextinit', richtext_config);
});
});
Here's default config: https://github.com/cubesystems/releaf/blob/master/app/assets/javascripts/releaf/include/field.type_richtext.js#L24
NOTE: for textareas with manual-init
class TinyMCE won't be initialized automatically
NOTE2: You need to make sure you are not initializing TinyMCE for textarea.manual-init
that are templates for nested fields
It's nice to hear that you want to keep richtext editor simple as possible, but how thees too attributes "class" and "rel" could complicate texteditor? Using your suggested code for this simple feature will complicate applications using releaf. I think that this will be useful for your apps too. Don't you think?
Judging from defaults configuration hash in your linked file you just have to add two attributes for "A" tag.
extended_valid_elements : 'a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]',
"A" tag options should be updated to
a[name|href|target|title|onclick|class|rel]
It would be useful if text editor allows a tags to have class or rel attributes. This allows to create simple gallery with text editor. On public side those links would be easier to select and use with fancybox or other 3rd party library.