r102605 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102604‎ | r102605 | r102606 >
Date:23:38, 9 November 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed prepareRemove to work again after getNodeFromOffset was changed.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js
@@ -1029,14 +1029,26 @@
10301030 */
10311031 function canMerge( range ) {
10321032 var node1 = doc.getNodeFromOffset( range.start );
1033 - var node2 = doc.getNodeFromOffset( range.end - 1 );
 1033+ var node2 = doc.getNodeFromOffset( range.end );
10341034 // This is the simple rule we are following for now -- same type & same parent = can merge.
10351035 // So you can merge adjacent paragraphs, or listitems. And you can't merge a paragraph into
10361036 // a table row. There may be other rules we will want in here later, for instance, special
10371037 // casing merging a listitem into a paragraph.
10381038 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+ )
10411053 );
10421054 }
10431055
@@ -1105,7 +1117,6 @@
11061118 if ( range.end < doc.data.length ) {
11071119 tx.pushRetain( doc.data.length - range.end );
11081120 }
1109 -
11101121 tx.optimize();
11111122 return tx;
11121123 };

Status & tagging log