In ck editor need sometime get selected text or image to process . This is sometime problem in normal code, but i hope this code help you which give you selected text or image . This is simple code which give you which text is select in ckeditor.

var selection = CKEDITOR.instances['content'].getSelection();
if (selection.getType() == CKEDITOR.SELECTION_ELEMENT) {
var selectedContent = selection.getSelectedElement().$.outerHTML;
} else if (selection.getType() == CKEDITOR.SELECTION_TEXT) {
if (CKEDITOR.env.ie) {
selection.unlock(true);
selectedContent = selection.getNative().createRange().text;
} else {
  selectedContent = selection.getNative();
  console.log("The selectedContent is: " + selectedContent);
 }
}

This code give you which text you select in ck editor . If you face any problem then please inform me.