Hello.
I have a iframe plugin that generates a link from a cms content list. I want to add the link around the selected text when the ok button is clicked. It all works, except i can't get the selected text.
I have tried using the answer supplied here:
http://stackoverflow.com/questions/2385609/getting-selected-text-win-ckeditor-plugin
so like this:
var okListener = function(ev) { console.log(CKEDITOR); var mySelection = CKEDITOR.editor.getSelection(); if (CKEDITOR.env.ie) { mySelection.unlock(true); selectedText = mySelection.getNative().createRange().text; } else { selectedText = mySelection.getNative(); } console.log(selectedText);
But it dosn't return the text. I get error:
"37Uncaught TypeError: Object function (b,c,d,e){var f=this;f._={instanceConfig:b,element:c,data:e};f.elementMode=d||0;a.event.call(f);f._init();} has no method 'getSelection'"
I'm using the latest version of ckeditor and im creating my plugin like this:
CKEDITOR.plugins.add('tree',{ requires: ['iframedialog'], init:function(editor){ CKEDITOR.dialog.addIframe('tree_dialog', 'Content Tree', this.path + '../../../admin/contents/editor',650,400,function(){/*oniframeload*/}) var cmd = editor.addCommand('tree', {exec:tree_onclick}) cmd.modes={wysiwyg:1,source:1} cmd.canUndo=false editor.ui.addButton('tree',{ label:'Go ahead, pick a page...', command:'tree', icon:this.path+'tree.png' }) } }) function tree_onclick(editor) { editor.openDialog('tree_dialog'); }
Any suggestions how to get the selected text would be very much appreciated,
Thanks
will
Re: Getting selected text in an iframe plugin
I think you should look at - http://dev.ckeditor.com/ticket/8435#comment:3. User had similar problem in this ticket.