| | 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 | |