How to get the cursor position in CKEditor

Hi

I have a usecase of inserting selected value from combo box into the CKEditor’s selected cursor position. I searched the API and forum but could not get any info on how to get cursor position. Or is there any other way of doing this? I found some code in a blog to do this in Javascript which is not useful though.

Any help appreciated on this.

Thanks in advance.

Hi

I have a similar usecase and need the methods get-/setCursorPosition(). Furthermore the method setSelectionRange(int pos, int length) would be useful for me. I have tried it with the
Vaadin wrapper for Tinymce
but the methods aren’t implemented too.
Maybe David Wall could say something about the possibilities.

Greets

Well, perhaps someone in Team Vaadin can help since they should know best how to transfer the state of a client widget to the server.

As I understand it, the server-side cannot really pull information from the client, so you can’t ask for the current position without having the current position already pushed from the client to the server. But perhaps I’m wrong.

I know, for example, that I have a hack to get the CKEditor version string, but it works by including that value in first response back to the server, where it’s then cached so the server-side API can then provide a value.

I am not a CKEditor programmer, and only did the integration part to meet our immediate needs. But I do know that you can call editorInstance.getSelection() to retrieve the currently selected text in the editor (and even the position ranges), but I don’t know per se if you can get/set the current position using the editor APIs.

So, if anybody wants to add code that will do this, I’ll be happy to incorporate it into the add-on.

If not, we can consider it, but we’d need pointers on the following two items:

  1. How to request information like that be sent from the client to the server. I presume we might be able to to specify whether such information is wanted or not, and then any time the client will send information to the server, it could include this information. You certainly wouldn’t want a listener that told you each time the position changed as it would cause too much communications with the server.

  2. What API in CKEditor can be used to get/set the values of interest. Maybe the CKEditor forum folks have some ideas or the original poster has javascript that does it that we can review.