Changeset 12 for trunk


Ignore:
Timestamp:
02/15/05 03:54:50 (15 years ago)
Author:
gogo
Message:

Change the method of inserting a space in strategic locations.
See ticket:9

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/core.html

    r1 r12  
    1313</script> 
    1414<script type="text/javascript" src="../htmlarea.js"></script> 
    15 <script type="text/javascript" src="../htmlarea_css.js"></script> 
    1615 
    1716<style type="text/css"> 
  • trunk/htmlarea.js

    r11 r12  
    21472147  // Insert a space in certain locations, this is just to make editing a little 
    21482148  // easier (to "get out of" tags), it's not essential. 
     2149  // TODO: Make this work for IE? 
     2150  // TODO: Perhaps should use a plain space character, I'm not sure. 
    21492151  if(HTMLArea.is_gecko) 
    21502152  { 
    21512153    var s = this._getSelection(); 
    2152     if(s && s.isCollapsed && s.anchorNode && s.anchorNode.nodeType == 3) 
    2153     { 
    2154       if(s.anchorOffset == s.anchorNode.length) 
    2155       { 
    2156         if(HTMLArea.isBlockElement(s.anchorNode.parentNode)) 
    2157         { 
    2158           if(s.anchorNode.data != '\xA0' && !s.anchorNode.nextSibling) 
    2159           { 
    2160             s.anchorNode.parentNode.insertBefore(this._doc.createTextNode('\xA0'), s.anchorNode.nextSibling); 
    2161           } 
    2162         } 
    2163         else 
    2164         { 
    2165           if(!s.anchorNode.parentNode.nextSibling) 
    2166           { 
    2167             s.anchorNode.parentNode.parentNode.insertBefore(this._doc.createTextNode('\xA0'), s.anchorNode.parentNode.nextSibling); 
    2168           } 
    2169         } 
     2154    // If the last character in the last text node of the parent tag 
     2155    if(s && s.isCollapsed && s.anchorNode 
     2156         && s.anchorNode.parentNode.tagName.toLowerCase() != 'body' 
     2157         && s.anchorNode.nodeType == 3 && s.anchorOffset == s.anchorNode.length 
     2158         && ! 
     2159          (   s.anchorNode.parentNode.nextSibling 
     2160           && s.anchorNode.parentNode.nextSibling.nodeType == 3 
     2161          ) 
     2162      ) 
     2163    { 
     2164      // Insert hair-width-space after the close tag if there isn't another text node on the other side 
     2165      // It could also work with zero-width-space (\u200B) but I don't like it so much. 
     2166      // Perhaps this won't work well in various character sets and we should use plain space (20)? 
     2167      try 
     2168      { 
     2169        s.anchorNode.parentNode.parentNode.insertBefore 
     2170          (this._doc.createTextNode('\u200A'), s.anchorNode.parentNode.nextSibling); 
     2171      } 
     2172      catch(e) 
     2173      { 
     2174        // Disregard 
    21702175      } 
    21712176    } 
     
    21792184  } 
    21802185 
    2181 }; 
     2186} 
    21822187 
    21832188/** Returns a node after which we can insert other nodes, in the current 
     
    29682973    catch(e) { if (this.config.debug) { alert(e + "\n\nby execCommand(" + cmdID + ");"); } } 
    29692974  } 
     2975 
    29702976  this.updateToolbar(); 
    29712977  return false; 
Note: See TracChangeset for help on using the changeset viewer.