Changeset 1187


Ignore:
Timestamp:
04/20/09 21:11:55 (11 years ago)
Author:
douglas
Message:

Fix the case with empty wrapper nodes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Ticket1226/paraHandlerBest.js

    r1184 r1187  
    15311531 
    15321532    // The cursor might be at the ending edge of the wrapNode. 
     1533    // 0. Pointing inside a completely empty element <body></body> 
    15331534    // 1. Pointing to a text node <body>^This is text</body> 
    15341535    // 2. Pointing to an inline node that is the child of the wrapNode.<body>^<em>text</em></body> 
     
    15371538    // 5. Pointing to the end of the wrapNode.<body>Here is some text.^</body> 
    15381539    // 6. Pointing to a block node that is just inside of the wrapNode.<body>^<p>text</p></body> 
     1540 
     1541    // In the special case of a completely empty node, the cursor is still 
     1542    // visible, and the user expects to have two lines after hitting the enter 
     1543    // key.  We'll add two paragraphs to any of these nodes if they are empty. 
     1544    if (!wrapNode.firstChild) { 
     1545      var embedNode1 = doc.createElement('p'); 
     1546      var embedNode2 = doc.createElement('p'); 
     1547      embedNode1 = wrapNode.appendChild(embedNode1); 
     1548      embedNode2 = wrapNode.appendChild(embedNode2); 
     1549      // The unicode character below is a representation of a non-breaking 
     1550      // space we use to prevent the paragraph from having visual glitches. 
     1551      var emptyTextNode1 = doc.createTextNode('\u00a0'); 
     1552      var emptyTextNode2 = doc.createTextNode('\u00a0'); 
     1553      emptyTextNode1 = embedNode1.appendChild(emptyTextNode1); 
     1554      emptyTextNode2 = embedNode2.appendChild(emptyTextNode2); 
     1555 
     1556      Xinha._stopEvent(ev); 
     1557 
     1558      range.setStart(emptyTextNode2, 0); 
     1559      range.setEnd(emptyTextNode2, 0); 
     1560      selection.removeAllRanges(); 
     1561      selection.addRange(range); 
     1562 
     1563      return false; 
     1564    } 
     1565 
    15391566    var startNode = cursorParent; 
    15401567    for (;(startNode != wrapNode) && (startNode.parentNode != wrapNode);) 
Note: See TracChangeset for help on using the changeset viewer.