1
votes

I have the code below

<script>
$(document).ready(function(){
  //function showChar(){
    shortcut.add("Ctrl+F1", function() 
      document.activeElement.id.value +="text";
  });
  var counter=0;
    setInterval(function() {
    for(int i=0;i<4;i++){
                var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counter);
                newTextBoxDiv.after().html('<div><label style="float:left;"></label></div><pre><textarea name="textbox' + counter + '" id="textbox"  ><%=rsta2.getString("data")%></textarea></pre>');
                newTextBoxDiv.appendTo("#TextBoxesGroup");
                counter++;
                }
CKEDITOR.replace( 'textbox'+i+'',
                    {
                toolbar :
                    [
                        ['Source'],
                        ['Bold','Italic','Underline','Strike'],
                    ],
                        height: 300,
                        width: 700
                    });  


    },1000);
 });
</script>
<div id='TextBoxesGroup'>
  <div id="TextBoxDiv0">
  </div>
  </div>

The above code(minus the ckeditor part of the code) adds 4 textareas,depending on which textarea is active when I press ctrl+f1 text is added to that particular textarea.But when I replace textarea with ckeditor the shortcut keys dont work.What should I do?

UPDATE This is the closest I have got.The Jfiddle is below

http://jsfiddle.net/S3MY6/45/

Here I can add text to only 1 editor provider I specify the id,But I want to add it to the active one.So I had tried this

var xy=CKEDITOR.currentInstance.name;
     //alert(xy);
 xy.insertText('html here.');

But it threw an error saying object editor1 has no insertTest().But when I alert xy I get the proper editor id/name. Please help

UPDATE2

I have got it to work right now with this JFiddle. http://jsfiddle.net/S3MY6/49/

But I get snapshot shortcut also along with it.I just want to add text

2

2 Answers

0
votes

On your updated fiddle i replaced var xy=CKEDITOR.instances.editor1 with var xy=CKEDITOR.currentInstance and it worked.

http://jsfiddle.net/8mVM3/

0
votes

My previous answer will help you understand why the value of textarea has no impact on what you see in CKEditor and how to deal with it.

Anyway, I'm sure you will find editor.insertHtml() (and insertText) helpful for your task.