Changeset 676


Ignore:
Timestamp:
07/31/10 21:49:07 (23 months ago)
Author:
mr_lundis
Message:

Modified insert to use ranges instead of the InsertHTML command. Webkit-based browsers was acting funny.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wymeditor/jquery.wymeditor.js

    r673 r676  
    12711271WYMeditor.editor.prototype.insert = function(html) { 
    12721272    // Do we have a selection? 
    1273     if (this._iframe.contentWindow.getSelection().focusNode != null) { 
     1273    var selection = this._iframe.contentWindow.getSelection(), 
     1274        range, 
     1275        node; 
     1276    if (selection.focusNode != null) { 
    12741277        // Overwrite selection with provided html 
    1275         this._exec( WYMeditor.INSERT_HTML, html); 
     1278        range = selection.getRangeAt(0); 
     1279        node = range.createContextualFragment(html); 
     1280        range.deleteContents(); 
     1281        range.insertNode(node); 
    12761282    } else { 
    12771283        // Fall back to the internal paste function if there's no selection 
     
    12811287 
    12821288WYMeditor.editor.prototype.wrap = function(left, right) { 
    1283     // Do we have a selection? 
    1284     if (this._iframe.contentWindow.getSelection().focusNode != null) { 
    1285         // Wrap selection with provided html 
    1286         this._exec( WYMeditor.INSERT_HTML, left + this._iframe.contentWindow.getSelection().toString() + right); 
    1287     } 
     1289    this.insert(left + this._iframe.contentWindow.getSelection().toString() + right); 
    12881290}; 
    12891291 
    12901292WYMeditor.editor.prototype.unwrap = function() { 
    1291     // Do we have a selection? 
    1292     if (this._iframe.contentWindow.getSelection().focusNode != null) { 
    1293         // Unwrap selection 
    1294         this._exec( WYMeditor.INSERT_HTML, this._iframe.contentWindow.getSelection().toString() ); 
    1295     } 
     1293    this.insert(this._iframe.contentWindow.getSelection().toString()); 
    12961294}; 
    12971295 
Note: See TracChangeset for help on using the changeset viewer.