Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js |
— | — | @@ -1029,14 +1029,26 @@ |
1030 | 1030 | */ |
1031 | 1031 | function canMerge( range ) { |
1032 | 1032 | var node1 = doc.getNodeFromOffset( range.start ); |
1033 | | - var node2 = doc.getNodeFromOffset( range.end - 1 ); |
| 1033 | + var node2 = doc.getNodeFromOffset( range.end ); |
1034 | 1034 | // This is the simple rule we are following for now -- same type & same parent = can merge. |
1035 | 1035 | // So you can merge adjacent paragraphs, or listitems. And you can't merge a paragraph into |
1036 | 1036 | // a table row. There may be other rules we will want in here later, for instance, special |
1037 | 1037 | // casing merging a listitem into a paragraph. |
1038 | 1038 | return ( |
1039 | | - ( ( node1 && node2 ) && ( node1.getElementType() === node2.getElementType() ) ) && |
1040 | | - ( node1.getParent() === node2.getParent() ) |
| 1039 | + // [<p>a</p><p>b</p>] |
| 1040 | + ( |
| 1041 | + node1 && |
| 1042 | + node2 && |
| 1043 | + node1.getElementType() === node2.getElementType() && |
| 1044 | + node1.getParent() === node2.getParent() |
| 1045 | + ) || |
| 1046 | + // [<p>a</p>]<p>b</p> |
| 1047 | + ( |
| 1048 | + node1 && |
| 1049 | + node2 && |
| 1050 | + node1 === node2 && |
| 1051 | + range.start < range.end |
| 1052 | + ) |
1041 | 1053 | ); |
1042 | 1054 | } |
1043 | 1055 | |
— | — | @@ -1105,7 +1117,6 @@ |
1106 | 1118 | if ( range.end < doc.data.length ) { |
1107 | 1119 | tx.pushRetain( doc.data.length - range.end ); |
1108 | 1120 | } |
1109 | | - |
1110 | 1121 | tx.optimize(); |
1111 | 1122 | return tx; |
1112 | 1123 | }; |