PDA

View Full Version : CKeditor javascript API


ErnestA
10-05-2011, 03:03 AM
I've got the hang of creating my own custom BBCodes with buttons in CKeditor, but I'm a bit stumped with something else I'm trying to do. I've added a few extra fields input type fields to the editor window which get populated automatically with some vBulletin variables (attachment ids). BBCodes buttons are nice, but all they do is add the opening and closing BBCode tags, the user must manually fill the rest in. What I'd like to do is make a simple javascript button which takes the value of the input field I've created and inserts it into the current cursor position of the editor. Does anyone know where I can find the correct functions and methods to do this with the vBulletin / ckEditor? It's really a simple piece of Javascript code, but a bit challenging when you don't know anything about interfacing to the editor.

I found the following reference on ckEditor's site:

CKEDITOR.instances.editor1.insertText( ' line1 \n\n line2' );

But I can't find where and how vBulletin is creating an instance of the editor and what the instance is named...

Any help is greatly appreciated.

Thanks,

Ernest A.

ErnestA
10-07-2011, 05:16 PM
OK, so I edited one of my templates and added the following code

<button onclick="vB_Editor['{vb:raw editorid}'].insertText('This is a test to insert text');">InsertText</button>

But this just submits my post instead of adding the text to the editor... I think I'm on the right track with referencing the instance of the editor... But without documentation it's kinda hard... I'd really appreciate it if someone could throw me some breadcrumbs here .

Thanks,

fromtheflames
10-08-2011, 09:35 AM
Hi,

I suggest you to use the method I've explained here (https://vborg.vbsupport.ru/showthread.php?p=2254275) to load the templates function (http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Templates) already present in ckeditor.

Follow that steps, create the plugin and the files .js that contains the templates you want to use; examples are in default.js files in /clientscript/ckeditor/plugins/templates/templates/ dir

Ask if you need help

thomas

--

mmm reading the problem again, it seems that my solution is too far from what you ask

I'm not a js expert, I cannot help you as well

killer_t
11-16-2011, 04:56 PM
I've the same request!