Hi, I created a custom plugin for ckeditor that uses the addRichCombo to display my predefined responses from mssql database.
I allow users to use CKEditor to create the responses so they may consist of some html tags with quote signs etc. Every time CKEditor loads up, it loads all of the responses to the dropdown menu (addRichCombo) and if a user choose one of them, the response is copied to the CKEditor textarea. However, there are two problems:
1. Predefined response with no quote signs: when the text is pasted to the textarea it shows the HTML tags, it doesn't convert them automatically like it suppose to: For example:
<p> TEST2</p><p> TEST2</p> instead of
TEST2
TEST2
2. Responses with quote signs: they don't copy to the textarea when clicked and the response in the dropdown looks like below:
THANKS
" href="javascript:void('
HEllo,
please
do not call us anymore
THANKS
')" onclick="CKEDITOR.tools.callFunction(59,'
This is my plugin code:
<?
include("../../../_config/config.php");
?>
CKEDITOR.plugins.add('responses',
{
init: function(editor)
{
var pluginName = 'responses';
var config = editor.config,
lang = editor.lang.responses;
var tags = '<? echo pull_up_responses(); ?>';
var tags = tags.split( '#' );
var styles = {};
for ( var i = 0 ; i < tags.length ; i++ )
{
var tag = tags[ i ];
}
CKEDITOR.dialog.add(pluginName, this.path + 'dialogs/responses.js');
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.ui.addRichCombo('responses',
{
label : 'Response',
className : 'cke_format',
panel :
{
css : editor.skin.editor.css.concat( config.contentsCss ),
voiceLabel : lang.panelVoiceLabel
},
init : function()
{
this.startGroup('Predifinied responses');
for ( var i = 0 ; i < tags.length ; i++ )
{
var tag = tags[ i ];
this.add( tag, tag, tag );
}
},
onClick : function( value )
{
editor.insertText( value );
}
});
}
});
I allow users to use CKEditor to create the responses so they may consist of some html tags with quote signs etc. Every time CKEditor loads up, it loads all of the responses to the dropdown menu (addRichCombo) and if a user choose one of them, the response is copied to the CKEditor textarea. However, there are two problems:
1. Predefined response with no quote signs: when the text is pasted to the textarea it shows the HTML tags, it doesn't convert them automatically like it suppose to: For example:
<p> TEST2</p><p> TEST2</p> instead of
TEST2
TEST2
2. Responses with quote signs: they don't copy to the textarea when clicked and the response in the dropdown looks like below:
THANKS
" href="javascript:void('
HEllo,
please
do not call us anymore
THANKS
')" onclick="CKEDITOR.tools.callFunction(59,'
This is my plugin code:
<?
include("../../../_config/config.php");
?>
CKEDITOR.plugins.add('responses',
{
init: function(editor)
{
var pluginName = 'responses';
var config = editor.config,
lang = editor.lang.responses;
var tags = '<? echo pull_up_responses(); ?>';
var tags = tags.split( '#' );
var styles = {};
for ( var i = 0 ; i < tags.length ; i++ )
{
var tag = tags[ i ];
}
CKEDITOR.dialog.add(pluginName, this.path + 'dialogs/responses.js');
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.ui.addRichCombo('responses',
{
label : 'Response',
className : 'cke_format',
panel :
{
css : editor.skin.editor.css.concat( config.contentsCss ),
voiceLabel : lang.panelVoiceLabel
},
init : function()
{
this.startGroup('Predifinied responses');
for ( var i = 0 ; i < tags.length ; i++ )
{
var tag = tags[ i ];
this.add( tag, tag, tag );
}
},
onClick : function( value )
{
editor.insertText( value );
}
});
}
});