Hello,
it is my first try with ckeditor.
I have 2 instances on a page. On a click on a button which is located outside of ckeditor, i want to paste some text in the editor textarea which has the focus.
But I can't find a way to dicide (with javascript) which instance has the focus.
I tried http://cksource.com/forums/viewtopic.php?t=16744 but the text pasted in the 2nd instance and not in this one, where the cursor is.
How do I get
oEditor
for
oEditor.insertHtml(text);
?
Regards
Ngar
Re: which instance has focus
Hi Ngar,
See my CKEditor CodeMirror plugin tutorial to see how to select a running instance.
The code that will interest you is the toolbar code.
You pass the id of the element CKEditor has replaced to the instances object. So if you have a textarea with the id of editor2, your instance can be reached using :
If you look at the MirrorUpdate function too, you will see how to perform a single function on all instances in the DOM by running through the CKEDITOR.instances array.
Thanks,
Zanpakutō
Re: which instance has focus
I have 2 textareas replaced by ckeditor.
and a Button who is not in the toolbar of ckeditor.
In the function insertCK i need to decide in which of the 2 instances the cursor war, before the button was clicked.
Otherwise - how do I define a on focus function? When the editor instance is entered a function will change the showed button.
regards
Ngar
Re: which instance has focus
Re: which instance has focus
You need to pass two parameters to your function then :
Nope. Learn how to use the API and you'll understand why that statement is incorrect.
Thanks,
Zanpakutō
Re: which instance has focus
In this way I need 2 buttons on the page 1 for each instance. But I want only 1 an JS have to decide in which area the cursor was.
I tried another solution. On entering a instance, a on focus event fired, and change the buttons.
If I use this
nothing is happend.
But if I use this
the function fired. Only the
doesn't work any more.
Without the 'CKEDITOR.add = function( editor )' the 'insertCK works fine.
What is my failure with onfocus function?
Thanks
Ngar
Re: which instance has focus
As yfrommelt said, you click outside of the editor and no editor has focus but if you update your own variable every time the editor focus is set and not unset, you can tell which one was last focused.
What you seem to be describing doesn't map out as a usable work flow to me. Either you are trying to do something spammy with CKEditor and manipulate lots of forms or you haven't thought out your whole application's implementation properly.
You essentially must write a last interacted with focus saving plugin. Other than that, I can help you much further. Sorry.
Thanks,
Zanpakutō
Re: which instance has focus
I define 2 Buttons:
The working switching code :
Here the non-working insert-function
Finally I solved my problem.
I forgot following statement in the CKEDITOR.add function:
This solution is good enough for me at this time.
Thx at all!
Regards
Ngar