Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js |
— | — | @@ -668,7 +668,7 @@ |
669 | 669 | 'rollback reverses the effect of a content annotation transaction on the content' |
670 | 670 | ); |
671 | 671 | |
672 | | - var insertion = documentModel.prepareInsertion( 4, ['d'] ); |
| 672 | + var insertion = documentModel.prepareInsertion( 3, ['d'] ); |
673 | 673 | |
674 | 674 | // Test 5 |
675 | 675 | documentModel.commit( insertion ); |
— | — | @@ -678,8 +678,8 @@ |
679 | 679 | { 'type': 'paragraph' }, |
680 | 680 | 'a', |
681 | 681 | ['b', { 'type': 'bold', 'hash': '#bold' }], |
| 682 | + 'd', |
682 | 683 | ['c', { 'type': 'italic', 'hash': '#italic' }], |
683 | | - 'd', |
684 | 684 | { 'type': '/paragraph' } |
685 | 685 | ], |
686 | 686 | 'commit applies an insertion transaction to the content' |
— | — | @@ -691,8 +691,8 @@ |
692 | 692 | [ |
693 | 693 | 'a', |
694 | 694 | ['b', { 'type': 'bold', 'hash': '#bold' }], |
695 | | - ['c', { 'type': 'italic', 'hash': '#italic' }], |
696 | | - 'd' |
| 695 | + 'd', |
| 696 | + ['c', { 'type': 'italic', 'hash': '#italic' }] |
697 | 697 | ], |
698 | 698 | 'commit keeps model tree up to date' |
699 | 699 | ); |
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | } |
116 | 116 | this.cursor += op.data.length; |
117 | 117 | } |
118 | | - |
| 118 | + |
119 | 119 | function remove( op ) { |
120 | 120 | var elementLeft = es.DocumentModel.isElementOffset( this.data, this.cursor ), |
121 | 121 | elementRight = es.DocumentModel.isElementOffset( this.cursor + op.data.length ); |
— | — | @@ -126,10 +126,10 @@ |
127 | 127 | } else { |
128 | 128 | // Get the node we are removing content from |
129 | 129 | var node = this.tree.getNodeFromOffset( this.cursor ); |
| 130 | + // Remove content from linear data model |
| 131 | + this.data.splice( this.cursor, op.data.length ); |
130 | 132 | // Update model tree |
131 | 133 | node.adjustContentLength( -op.data.length ); |
132 | | - // Remove content from linear data model |
133 | | - this.data.splice( this.cursor, op.data.length ); |
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |