Hello,
first of all: Sorry for my english, but i try my best! ![]()
I'm trying to add a Plugin, which generates and inserts some text, to the CKeditor and everything works fine, but I want to use my Plugin also when I select the Source Button. When I press the Source Button most of the Buttons are disabled and the insertText() function doesn't work anymore.
What i want to know:
1. Is there a pararameter or something to prevent that my Button is disabled, when I select the Source Button.
2. Is there already a function to insert Text when Source is selected, why isn't it possible with insertText() ?
3. Is there a possibility to find out weather the Source Button is selected or not?
Thanks for your help! ![]()
Thu, 09/08/2011 - 09:59
#1

Re: Enable Button and insertText() on Sourcecode
I solved the Problem with 1. you can add
modes : { wysiwyg : 1, source : 1 },to your command and the Button stays enabled.

But I'm still searching for 2. an 3.!
Re: Enable Button and insertText() on Sourcecode
3: check editor.mode
Re: Enable Button and insertText() on Sourcecode
Thanks for your answer! I think my Code isn't really good, but it works!

I post it here, because maybe somebody can use it!
if(CKEDITOR.instances[Itemname].mode=='wysiwyg'){ CKEDITOR.instances[Itemname].insertText(TextToInsert); } else{ var input = document.getElementsByClassName('cke_source cke_enable_context_menu')[0]; input.focus(); if(typeof input.selectionStart != 'undefined') { /* Einfügen des Formatierungscodes */ var start = input.selectionStart; var end = input.selectionEnd; input.value = input.value.substr(0, start) + TextToInsert + input.value.substr(end); /* Anpassen der Cursorposition */ var pos; pos = start+TextToInsert.length; input.selectionStart = pos; input.selectionEnd = pos; } }Re: Enable Button and insertText() on Sourcecode