Srikanth kante
Srikanth kante

Reputation: 131

How to Insert text at the cursor position at a particular ckeditor?

I have added a custom plugin that inserts the current date at the cursor position in ckeditor when I click on my InsertDate button which is not part of the ckeditor toolbar buttons. Now the question is I have multiple ckeditor in my page, so now I am typing something in the second ckeditor and I just want to insert the current time so I clicked on the insertDate button, but it is inserting the text in the first ckeditor which is not expected.is there any way how to handle this situation.i want to know the recently focused ckeditor so that I can identify the particular ckeditor using the id and can insert the text.

tried using the focusmanager.hasfocus method but as soon as I click on the insertDate button the ckeditor loses the focus.is there any way we can get the reference of the recent focus editor.

Upvotes: 0

Views: 1114

Answers (1)

v kay
v kay

Reputation: 67

$.fn.insertAtCaret = function (myValue) {
    myValue = myValue.trim();
    CKEDITOR.instances['idofeditor'].insertText(myValue);
};

Upvotes: 1

Related Questions