Reputation: 238
I'm looking for any trick to configure my plugin with arguments in CKEditor's configuration. I have to pass some parameters that I can only pass when my view is displayed.
I want something like this (sample with jQuery adapter) :
jQuery('textarea.wysiwyg').ckeditor(function(){},{
'width' : '640px',
'resize_maxWidth' : '640px',
'extraPlugins' : 'my_plugin',
'toolbar' : [['Bold', 'Italic', '-', 'NumberedList', 'BulletedList'],['Link', 'Unlink','-','MyPlugin'],['Paste','PasteFromWord'],['Source']]
'my_plugin' : {
'param1' : 'value1',
'param2' : 'value2',
}
});
But I have'nt found yet any information about plugin configuration with CKEditor.
Upvotes: 3
Views: 4625
Reputation: 541
Pass the values to the plugin during editor initialization
jQuery('textarea.wysiwyg').ckeditor(function(){},
{
config.extraConfig : { 'param1' : 'value1', 'param2' : 'value2' }
});
and access the values in the plugin
CKEDITOR.plugins.add( 'my_plugin',
{
init: function( editor )
{
var param1 = editor.extraConfig.param1;
var param2 = editor.extraConfig.param2;
}
}
Upvotes: 1
Reputation: 238
I answer to my own question : Plugin method init receive editor as argument, editor contain config (which can be called editor.config) so you can access all configuration defined when you have created your ckeditor instance.
With my sample in my first post, you can access configuration in your plugin like this way :
CKEDITOR.plugins.add( 'my_plugin',
{
init: function( editor )
{
var param1 = editor.config.value1;
}
}
I think that it's not the best way to do because It adds some extra properties to CKEDITOR.config prototype. It could be better to have a property CKEDITOR.config.extraConfig which is a map of properties by plugins.
Upvotes: 4