Hello,
I am really confused withe the CKEditor 3.0 implementation... I use the following code in a plugin dialog:
CKEDITOR.instances.editor1.insertHtml('<a href=\x22www.google.com\x22>' + CKEDITOR.instances.editor1.getSelection().getNative() + '</a>');
Re: getSelection() - getNative() returns [object Object]
Re: getSelection() - getNative() returns [object Object]
Make a selection in the editor (object named 'editor') and refer to it.
This will display the text under the selection:
There are also a lot of other properties of '$'
Like start_element.$.href,
start_element.$.className
start_element.$.style.fontWeight
Or to retrieve an 'onclick' event in the current selection:
I think there should be a better (more functional) way but it works!
There is a lot to be learned though...
Re: getSelection() - getNative() returns [object Object]
this will give you the selected text. but you will not get HTML tags.
Re: getSelection() - getNative() returns [object Object]
CKEDITOR.instances.instanceName.getSelection().getStartElement().getOuterHtml()
You'll get all the HTML that's selected. And it's cross-browser (unlike the actual javascript outerHTML method).
Re: getSelection() - getNative() returns [object Object]
Re: getSelection() - getNative() returns [object Object]
i really appreciate the prototype
CKEDITOR.editor.prototype.getSelectedHtml
but it does not work on IE7 and i guess also to old version.
I looked and the "getSelction" retrieve a NULL :-/
Any suggestion!
Re: getSelection() - getNative() returns [object Object]
Hope it helps you,
Cheers
Re: getSelection() - getNative() returns [object Object]
Note that the editor document should hold focus to make this function work.
Re: getSelection() - getNative() returns [object Object]
maybe in IE6,you should user
CKEDITOR.instances.txtContent.getSelection().getNative().createRange().text;
in Ff,you should use
CKEDITOR.instances.txtContent.getSelection().getNative();