I have a custom plugin that do some stuff and at the end of it’s processing it should create a link in HTML using the selected text (the selected HTML, actually) if some text is currently selected. The selected HTML formating must be preserved (i.e. the HTML tags and attributes must not be lost) and the link must be created around all the elements.
In the FCKEditor (old version of CKEDITOR) it was possible to do:
FCK.CreateLink("mylink");
What solved my problem was something like:
It created the link in the selected elements keeping all the formating.