Estoy intentando crear un plugin BBcode para el Ckeditor (el de VB4 solo que usado en otro sistema), por ahora tengo esto, segun tutoriales y etc... el plugin agrega correctamente el boton al editor, pero no he tenido suerte para hacer que agregue el BBCODE, no busco preformatear el bbcode con wysiwyg, si no que me inserte [spoiler\]LALALALAL[/spoiler\]....
Código Javascript
:
Ver originalCKEDITOR.plugins.add( 'spoiler',
{
init: function( editor )
{
editor.addCommand( 'insertSpoiler',
{
exec : function( editor )
{
// var timestamp = new Date();
// editor.insertHtml( 'The current date and time is: <em>' + timestamp.toString() + '</em>' );
var myEditor = CKEDITOR.instances.thepost;
var mySelection = editor.getSelection();
if (CKEDITOR.env.ie) {
mySelection.unlock(true);
theSelectedText = mySelection.getNative().createRange().text;
} else {
theSelectedText = mySelection.getNative();
}
var FormattedText = '[spoiler]'+theSelectedText+'[/spoiler]';
myEditor.insertHtml(FormattedText);
}
});
editor.ui.addButton( 'Spoiler',
{
label: 'Insert Spoiler',
command: 'insertSpoiler',
icon: this.path + 'images/spoiler.png'
} );
}
} );
Si alguien tiene nocion con este tema, me serviria demaciado
EDIT: solucionado, gracias y disculpen el thread