vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   CKeditor javascript API (https://vborg.vbsupport.ru/showthread.php?t=271416)

ErnestA 10-05-2011 03:03 AM

CKeditor javascript API
 
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

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 to load the templates function 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!


All times are GMT. The time now is 06:51 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01058 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete