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>');
I get the selected text and it has the hyperlink as it should in FF but in IE (6.0 here at the office) I get:
<a href="www.google.com">[object Object]</a>
pasted back into the code editor. Does anyone have any suggestions. I am a beginner/intermediate at this. I had a plug in under the old FCKEditor that simulated a windows File/Open dialog window. It shows a list of directories using ASP's Filesystemobject to allow users to select pages and files from the list. an onclick updates the text input's url.
I saw a limited tutorial on leveraging the iframedialog for old plugins here: http://blog.tommed.co.uk/2009/09/07/how ... -v3-plugin
It seemed to have what I needed but could not figure out how to get selected text from the editor into the plugin dialog for me to manipulate. So..... I have gone back to square one trying to leverage the normal-built in CKEDITOR.dialog object....
If anyone can help I would really appreciate it... I have wasted 2 1/2 days looking for documentation, posts, or any other thread of information to figure this out....
Thanks in advance!
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();