You won't be able to get the cursor position on the server side very easily, but you can create a simple button which will handle it all on the client side with some JavaScript.
Something like this perhaps could be added to your button:
public class InsertAtCursorPositionBehaviour extends AttributeModifier
{
public InsertAtCursorPositionBehaviour(final String content, final TextArea<?> textArea)
{
super("onclick", Model.of(getInsertJavaScript(content, textArea)));
}
private static String getInsertJavaScript(final String content, final TextArea<?> textArea)
{
textArea.setOutputMarkupId(true);
final StringBuilder jsBuilder = new StringBuilder();
jsBuilder.append("tinyMCE.get('");
jsBuilder.append(textArea.getMarkupId());
jsBuilder.append("').execCommand('mceInsertContent', false, '");
jsBuilder.append(content);
jsBuilder.append("');");
return jsBuilder.toString();
}
}
The string is the content to insert and the TextArea is the tinymce text area. Referring to the text area directly allows the possibility of having more than one per page.
If the content to insert is on the client side, it might be nice to embed the button into tiny mce itself. Take a look these custom options you could use: http://www.tinymce.com/tryit/button.php