Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js |
— | — | @@ -357,6 +357,23 @@ |
358 | 358 | ); |
359 | 359 | |
360 | 360 | deepEqual( |
| 361 | + documentModel.prepareRemoval( new es.Range( 15, 18 ) ), |
| 362 | + [ |
| 363 | + { 'type': 'retain', 'length': 15 }, |
| 364 | + { |
| 365 | + 'type': 'remove', |
| 366 | + 'data': [ |
| 367 | + { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } }, |
| 368 | + 'b', |
| 369 | + { 'type': '/listItem' } |
| 370 | + ] |
| 371 | + }, |
| 372 | + { 'type': 'retain', 'length': 10 } |
| 373 | + ], |
| 374 | + 'prepareRemoval removes entire elements' |
| 375 | + ); |
| 376 | + |
| 377 | + deepEqual( |
361 | 378 | documentModel.prepareInsertion( 1, ['d', 'e', 'f'] ), |
362 | 379 | [ |
363 | 380 | { 'type': 'retain', 'length': 1 }, |
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -597,16 +597,12 @@ |
598 | 598 | tx.pushRemove( removed ); |
599 | 599 | |
600 | 600 | // Retain up to the end of the document |
601 | | - tx.pushRetain( this.data.length - range.end ); |
602 | | - |
603 | | - range.normalize(); |
604 | | - |
605 | | - if ( range.start > 0 ) { |
606 | | - tx.pushRetain( range.start ); |
| 601 | + if ( range.end < this.data.length ) { |
| 602 | + tx.pushRetain( this.data.length - range.end ); |
607 | 603 | } |
608 | | - |
609 | | - var i = range.start; |
610 | | - removeData = []; |
| 604 | + |
| 605 | + /* |
| 606 | + * Loop to detect structural changes: |
611 | 607 | while ( i < range.end ) { |
612 | 608 | var data = this.data[i]; |
613 | 609 | if ( data.type !== undefined ) { |
— | — | @@ -617,7 +613,7 @@ |
618 | 614 | } |
619 | 615 | i++; |
620 | 616 | } |
621 | | - tx.pushRemove( removeData ); |
| 617 | + */ |
622 | 618 | |
623 | 619 | /* |
624 | 620 | * // Structural changes |
— | — | @@ -634,9 +630,7 @@ |
635 | 631 | i++; |
636 | 632 | } |
637 | 633 | */ |
638 | | - if ( range.end < this.data.length ) { |
639 | | - tx.pushRetain( this.data.length - range.end ); |
640 | | - } |
| 634 | + |
641 | 635 | return tx; |
642 | 636 | }; |
643 | 637 | |