If some text is selected, the link is made. However the selected text/link gets moved to the start of the alinea. If no text is selected, the link is placed at the right position.
My current code:
Any suggestions?
My current code:
var temp = new CKEDITOR.dom.element( 'span' );
temp.append(editor.getSelection().getRanges()[ 0 ].cloneContents());
if(temp.getText() == "")
{
editor.insertHtml('<a href=\"' + file_link + '\">' + file_link + '</a>');
}
else
{
editor.insertHtml('<a href=\"' + file_link + '\">' + temp.getText() + '</a>');
}Any suggestions?

Re: Inserting html around selected text
Re: Inserting html around selected text
// Apply style. var style = new CKEDITOR.style( { element : 'a', attributes : attributes } ); style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why. style.apply( editor.document );