#213 Improvement of InsertHtml for IE

Version 2.x
closed
Editor (144)
5
2013-12-18
2006-02-22
No

I've always had problems trying to insert some text
replacing the selection with IE, the text many times
didn't get inserted in exactly the place of the
selection, but just at the place where the next
character started (inside that new node, so the
insertion became nested where it shouldn't)

Just today I seem to have found a fix for that, in
FCK.InsertHtml get a reference to the range before it
is cleared and so the caret doesn't move when you
latter paste the new html in.

Although in my tests the call to oSel.clear() ; isn't
neccesary so the fix could also be to remove those two
lines.

FCK.InsertHtml = function( html )
{
FCK.Focus() ;

FCKUndo.SaveUndoStep() ;

// Gets the actual selection.
var oSel = FCK.EditorDocument.selection ;

//Alfonso-> get the range before clearing it
var oRange=oSel.createRange();

// Deletes the actual selection contents.
if ( oSel.type.toLowerCase() != "none" )
oSel.clear() ;

//Alfonso->reuse the saved range
// Insert the HTML.
oRange.pasteHTML( html ) ;
}

Discussion

  • Alfonso Martinez

    Logged In: YES
    user_id=1356422

    Sorry, that breaks inserting things when an object is selected.

    This code seems to work a little better:

    FCK.InsertHtml = function( html )
    {
    FCK.Focus() ;

    FCKUndo.SaveUndoStep() ;

    // Gets the actual selection.
    var oSel = FCK.EditorDocument.selection ;

    // Deletes the actual selection contents.
    if ( oSel.type.toLowerCase() == "control" )
    oSel.clear() ;

    // Insert the HTML.
    oSel.createRange().pasteHTML( html ) ;
    }

     
  • Frederico Caldeira Knabben

    • assigned_to: nobody --> fredck
     
  • Frederico Caldeira Knabben

    Logged In: YES
    user_id=572424

    Hi,

    This patch, or a similar implementation, has been included in
    FCKeditor and has been committed in the SVN. It will be
    available in the next release.

    For more information about the FCKeditor SVN system, please use
    the following URL:
    https://sourceforge.net/svn/?group_id=75348

    Best regards,
    FredCK
    http://www.fckeditor.net
    "Support Open Source Software... What about a donation today?"

    PS.: This is a canned response.

     
  • Frederico Caldeira Knabben

    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks