The forum operates in read-only mode. Please head to StackOverflow for support.
CKEDITOR.plugins.add( 'tokens', { requires : ['richcombo'], //, 'styles' ], init : function( editor ) { var config = editor.config, lang = editor.lang.format; // Gets the list of tags from the settings. var tags = []; //new Array(); //this.add('value', 'drop_text', 'drop_label'); tags[0]=["[contact_name]", "Name", "Name"]; tags[1]=["[contact_email]", "email", "email"]; tags[2]=["[contact_user_name]", "User name", "User name"]; // Create style objects for all defined styles. editor.ui.addRichCombo( 'tokens', { label : "Insert tokens", title :"Insert tokens", voiceLabel : "Insert tokens", className : 'cke_format', multiSelect : false, panel : { css : [ config.contentsCss, CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ], voiceLabel : lang.panelVoiceLabel }, init : function() { this.startGroup( "Tokens" ); //this.add('value', 'drop_text', 'drop_label'); for (var this_tag in tags){ this.add(tags[this_tag][0], tags[this_tag][1], tags[this_tag][2]); } }, onClick : function( value ) { editor.focus(); editor.fire( 'saveSnapshot' ); editor.insertHtml(value); editor.fire( 'saveSnapshot' ); } }); } });
CKEDITOR.replace( 'editor_id',{ toolbar : [ ['tokens','Styles', 'Format', 'Bold', 'Italic'],['Undo','Redo'] ], extraPlugins: 'tokens' } );
bingo! I got it to work...thanks
CKEDITOR.editorConfig = function( config ) { config.toolbar = 'MyToolbar'; config.toolbar_MyToolbar = [ ['Source','-','NewPage','Preview'], ['Cut','Copy','Paste','PasteText','PasteFromWord'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','HorizontalRule','SpecialChar'], '/', ['NumberedList','BulletedList'], ['Subscript','Superscript'], ['Bold','Italic','Underline','Strike','-','Format','FontSize','-','TextColor','BGColor'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','Outdent','Indent','tokens'] ]; config.contentsCss = '/admin/styles/editor.css'; config.enterMode = CKEDITOR.ENTER_BR; config.extraPlugins = 'tokens'; config.width = '99%'; config.height = '400px'; config.resize_enabled = true; config.toolbarCanCollapse = false; config.undoStackSize = 50; };
<textarea name="Brev"></textarea> <script type="text/javascript"> CKEDITOR.replace( 'Brev', { toolbar : 'MyToolbar', extraPlugins : 'tokens', } ); </script>
javascript:void('[hot dog's buns]')
var badstring = "'"; var goodstring = "\'"; tags[i]=["[" + sample[i].replace(badstring,goodstring) + "]", sample[i], sample[i];
editor.insertHtml(value.replace(/'/g,"\'"));
var badstring = "'"; var goodstring = "\\'"; tags[i]=["[" + sample[i].replace(badstring,goodstring) + "]", sample[i], sample[i];
javascript:void('[hot dog/'s buns]')
@kuba, It works perfect. Thanks for sharing.
I have below question if some can please help.
how can i enable multiple select from the dropdown so that i can added multiple options in editor at once. setting "multiSelect" as true is not working though.
"multiSelect: true,"
Please help. Thanks.
Thank you! Have been looking for a plugin like this for a long time!
Re: Custom drop down
To make it work create a tokens folder in plugins, then save this in plugin.js.
Plugin.js:
Then to make the drop down appear you need to use the extraPugins option:
Re: Custom drop down
could you post a screenshot? i followed the steps you described below, but no success...
Re: Custom drop down
are you getting any errors?
Re: Custom drop down
maybe i am missing something, so any additional info you can provide would be helpful.
Re: Custom drop down
Just realised slight problem with it if you put quotes in the html you want to paste - will have a think about that one.
Also if you are using a config file you need to do this:
config.extraPlugins = 'tokens';
Attachments:
Re: Custom drop down
bingo! I got it to work...thanks
Re: Custom drop down
Re: Custom drop down
Re: Custom drop down
and did you need for example to reset it? i mean assign different tokens or even clear that list?
Re: Custom drop down
i'm trying to install this extra plugin but i'm having some trouble.
i have made the folder "tokens" and uploaded it to plugins. pasted the code into the plugins.js.
My "config.js" file looks like this
And my editor looks like this
I get an error that looks like this:
Message: 'onLoad' is null or not an object
Line: 20
Sign: 1557
Kode: 0
URI: admin/ckeditor/ckeditor.js
What am i doing wrong?
Re: Custom drop down
It fails at insertHtml, which ends up trying to send something containing a single quote in the middle:
I end up with a syntax error in CKEDITOR.tools.callFunction(187).
I've tried to replace any single quotes with escaped single quotes in various spots, without success.
I tried to do the replace inside the insertHtml() call:
no luck.
If I try to double-escape the single quote...
it looks promising...
but just fails and throws this error:
TypeError: o is null
ckeditor.js, line 149
Any suggestions?
@kuba, It works perfect.
@kuba, It works perfect. Thanks for sharing.
I have below question if some
I have below question if some can please help.
how can i enable multiple select from the dropdown so that i can added multiple options in editor at once. setting "multiSelect" as true is not working though.
"multiSelect: true,"
Please help. Thanks.
Thank you! Have been looking
Thank you! Have been looking for a plugin like this for a long time!