Hello, I wrote a custom plugin for ckeditor that creates additional dropdown menu and collect the menu items using php. The code is below. I assign a php variable that is a string similar to this:
ITEM 1#ITEM 2#ITEM 3#ITEM 4
Then I separate the items using: var tags = tags.split( '#' ); and then I try to list them using:
this.add(tag, tag.slice(0,30), tag.slice(0,30));
Everything works well even if an ITEM includes some html characters. However an error occurs when an ITEM consist of any & signs and and basically every & sign splits the item into two. It seems like I should use some escape character functions while adding the items to the Dropdown:
this.add(tag, tag.slice(0,30), tag.slice(0,30));
Can anybody help me out with this? I would like to be able use items that includes html and special chars. Is it possible?
Best Regards;
Michael
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.slice(0,30), tag.slice(0,30));
}
},
onClick : function( value )
{
editor.insertHtml( value );
}
});
}
});
ITEM 1#ITEM 2#ITEM 3#ITEM 4
Then I separate the items using: var tags = tags.split( '#' ); and then I try to list them using:
this.add(tag, tag.slice(0,30), tag.slice(0,30));
Everything works well even if an ITEM includes some html characters. However an error occurs when an ITEM consist of any & signs and and basically every & sign splits the item into two. It seems like I should use some escape character functions while adding the items to the Dropdown:
this.add(tag, tag.slice(0,30), tag.slice(0,30));
Can anybody help me out with this? I would like to be able use items that includes html and special chars. Is it possible?
Best Regards;
Michael
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.slice(0,30), tag.slice(0,30));
}
},
onClick : function( value )
{
editor.insertHtml( value );
}
});
}
});