Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js |
— | — | @@ -351,7 +351,7 @@ |
352 | 352 | ['c', { 'type': 'italic', 'hash': '#italic' }] |
353 | 353 | ] |
354 | 354 | }, |
355 | | - { 'type': 'retain', 'length': 25 } |
| 355 | + { 'type': 'retain', 'length': 24 } |
356 | 356 | ], |
357 | 357 | 'prepareRemoval includes the content being removed' |
358 | 358 | ); |
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -583,6 +583,26 @@ |
584 | 584 | */ |
585 | 585 | es.DocumentModel.prototype.prepareRemoval = function( range ) { |
586 | 586 | var tx = new es.Transaction(); |
| 587 | + range.normalize(); |
| 588 | + |
| 589 | + if ( range.start > 0 ) { |
| 590 | + tx.pushRetain( range.start ); |
| 591 | + } |
| 592 | + |
| 593 | + var i = range.start; |
| 594 | + removeData = []; |
| 595 | + while ( i < range.end ) { |
| 596 | + var data = this.data[i]; |
| 597 | + if ( data.type !== undefined ) { |
| 598 | + console.log( "later" ); |
| 599 | + // TODO structural |
| 600 | + } else { |
| 601 | + removeData.push( this.data[i] ); |
| 602 | + } |
| 603 | + i++; |
| 604 | + } |
| 605 | + tx.pushRemove( removeData ); |
| 606 | + |
587 | 607 | /* |
588 | 608 | * // Structural changes |
589 | 609 | * if ( The range spans structural elements ) { |
— | — | @@ -594,7 +614,13 @@ |
595 | 615 | * } else { |
596 | 616 | * Removing only content is OK, do nothing |
597 | 617 | * } |
598 | | - */ |
| 618 | + / |
| 619 | + i++; |
| 620 | + } |
| 621 | + */ |
| 622 | + if ( range.end < this.data.length ) { |
| 623 | + tx.pushRetain( this.data.length - range.end ); |
| 624 | + } |
599 | 625 | return tx; |
600 | 626 | }; |
601 | 627 | |