Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fixed: Fixed conditions in Range#_getTransformedByDocumentChange to b…
Browse files Browse the repository at this point in the history
…e more precise.
  • Loading branch information
scofalik committed Mar 6, 2017
1 parent 65e1b63 commit 81bdf6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/model/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,25 +477,25 @@ export default class Range {
} else if ( deltaType == 'wrap' ) {
// Range intersects (at the start) with wrapped element (<p>ab</p>).
// <p>a[b</p><p>c]d</p> -> <p>a[b</p><w></w><p>c]d</p> -> [<w>]<p>a(b</p>){</w><p>c}d</p> -> <w><p>a[b</p></w><p>c]d</p>
if ( sourceRange.containsPosition( this.start ) && !sourceRange.containsPosition( this.end ) ) {
if ( sourceRange.containsPosition( this.start ) && this.containsPosition( sourceRange.end ) ) {
return [ new Range( ranges[ 2 ].start, ranges[ 1 ].end ) ];
}
// Range intersects (at the end) with wrapped element (<p>cd</p>).
// <p>a[b</p><p>c]d</p> -> <p>a[b</p><p>c]d</p><w></w> -> <p>a[b</p>]<w>{<p>c}d</p></w> -> <p>a[b</p><w><p>c]d</p></w>
else if ( sourceRange.containsPosition( this.end ) && !sourceRange.containsPosition( this.start ) ) {
else if ( sourceRange.containsPosition( this.end ) && this.containsPosition( sourceRange.start ) ) {
return [ new Range( ranges[ 0 ].start, ranges[ 1 ].end ) ];
}
} else if ( deltaType == 'unwrap' ) {
// Range intersects (at the beginning) with unwrapped element (<w></w>).
// <w><p>a[b</p></w><p>c]d</p> -> <p>a{b</p>}<w>[</w><p>c]d</p> -> <p>a[b</p><w></w><p>c]d</p>
// <w></w> is removed in next operation, but the remove does not mess up ranges.
if ( sourceRange.containsPosition( this.start ) && !sourceRange.containsPosition( this.end ) ) {
if ( sourceRange.containsPosition( this.start ) && this.containsPosition( sourceRange.end ) ) {
return [ new Range( ranges[ 1 ].start, ranges[ 0 ].end ) ];
}
// Range intersects (at the end) with unwrapped element (<w></w>).
// <p>a[b</p><w><p>c]d</p></w> -> <p>a[b</p>](<p>c)d</p>{<w>}</w> -> <p>a[b</p><p>c]d</p><w></w>
// <w></w> is removed in next operation, but the remove does not mess up ranges.
else if ( sourceRange.containsPosition( this.end ) && !sourceRange.containsPosition( this.start ) ) {
else if ( sourceRange.containsPosition( this.end ) && this.containsPosition( sourceRange.start ) ) {
return [ new Range( ranges[ 0 ].start, ranges[ 2 ].end ) ];
}
}
Expand Down

0 comments on commit 81bdf6d

Please sign in to comment.