|
@@ -855,7 +855,8 @@ describe( 'Range', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'move inside the range', () => {
|
|
it( 'move inside the range', () => {
|
|
|
- range.end.offset = 6;
|
|
|
|
|
|
|
+ range = new Range( range.start, range.end.getShiftedTo( 6 ) );
|
|
|
|
|
+
|
|
|
const start = new Position( root, [ 3 ] );
|
|
const start = new Position( root, [ 3 ] );
|
|
|
const target = new Position( root, [ 5 ] );
|
|
const target = new Position( root, [ 5 ] );
|
|
|
const delta = getMoveDelta( start, 1, target, 1 );
|
|
const delta = getMoveDelta( start, 1, target, 1 );
|
|
@@ -977,8 +978,10 @@ describe( 'Range', () => {
|
|
|
|
|
|
|
|
describe( 'by SplitDelta', () => {
|
|
describe( 'by SplitDelta', () => {
|
|
|
it( 'split inside range', () => {
|
|
it( 'split inside range', () => {
|
|
|
- range.start = new Position( root, [ 0, 2 ] );
|
|
|
|
|
- range.end = new Position( root, [ 0, 4 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 2 ] ),
|
|
|
|
|
+ new Position( root, [ 0, 4 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const delta = getSplitDelta( new Position( root, [ 0, 3 ] ), new Element( 'p' ), 3, 1 );
|
|
const delta = getSplitDelta( new Position( root, [ 0, 3 ] ), new Element( 'p' ), 3, 1 );
|
|
|
|
|
|
|
@@ -990,8 +993,10 @@ describe( 'Range', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'split at the beginning of multi-element range', () => {
|
|
it( 'split at the beginning of multi-element range', () => {
|
|
|
- range.start = new Position( root, [ 0, 4 ] );
|
|
|
|
|
- range.end = new Position( root, [ 1, 2 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 4 ] ),
|
|
|
|
|
+ new Position( root, [ 1, 2 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const delta = getSplitDelta( new Position( root, [ 0, 4 ] ), new Element( 'p' ), 3, 1 );
|
|
const delta = getSplitDelta( new Position( root, [ 0, 4 ] ), new Element( 'p' ), 3, 1 );
|
|
|
|
|
|
|
@@ -1003,8 +1008,10 @@ describe( 'Range', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'split inside range which starts at the beginning of split element', () => {
|
|
it( 'split inside range which starts at the beginning of split element', () => {
|
|
|
- range.start = new Position( root, [ 0, 0 ] );
|
|
|
|
|
- range.end = new Position( root, [ 0, 4 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 0 ] ),
|
|
|
|
|
+ new Position( root, [ 0, 4 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const delta = getSplitDelta( new Position( root, [ 0, 3 ] ), new Element( 'p' ), 3, 1 );
|
|
const delta = getSplitDelta( new Position( root, [ 0, 3 ] ), new Element( 'p' ), 3, 1 );
|
|
|
|
|
|
|
@@ -1016,8 +1023,10 @@ describe( 'Range', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'split inside range which end is at the end of split element', () => {
|
|
it( 'split inside range which end is at the end of split element', () => {
|
|
|
- range.start = new Position( root, [ 0, 3 ] );
|
|
|
|
|
- range.end = new Position( root, [ 0, 6 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 3 ] ),
|
|
|
|
|
+ new Position( root, [ 0, 6 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const delta = getSplitDelta( new Position( root, [ 0, 4 ] ), new Element( 'p' ), 2, 1 );
|
|
const delta = getSplitDelta( new Position( root, [ 0, 4 ] ), new Element( 'p' ), 2, 1 );
|
|
|
|
|
|
|
@@ -1029,8 +1038,10 @@ describe( 'Range', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'split element which has collapsed range at the end', () => {
|
|
it( 'split element which has collapsed range at the end', () => {
|
|
|
- range.start = new Position( root, [ 0, 6 ] );
|
|
|
|
|
- range.end = new Position( root, [ 0, 6 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 6 ] ),
|
|
|
|
|
+ new Position( root, [ 0, 6 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const delta = getSplitDelta( new Position( root, [ 0, 3 ] ), new Element( 'p' ), 3, 1 );
|
|
const delta = getSplitDelta( new Position( root, [ 0, 3 ] ), new Element( 'p' ), 3, 1 );
|
|
|
|
|
|
|
@@ -1044,8 +1055,10 @@ describe( 'Range', () => {
|
|
|
|
|
|
|
|
describe( 'by MergeDelta', () => {
|
|
describe( 'by MergeDelta', () => {
|
|
|
it( 'merge element with collapsed range', () => {
|
|
it( 'merge element with collapsed range', () => {
|
|
|
- range.start = new Position( root, [ 1, 0 ] );
|
|
|
|
|
- range.end = new Position( root, [ 1, 0 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 1, 0 ] ),
|
|
|
|
|
+ new Position( root, [ 1, 0 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const delta = getMergeDelta( new Position( root, [ 1 ] ), 3, 3, 1 );
|
|
const delta = getMergeDelta( new Position( root, [ 1 ] ), 3, 3, 1 );
|
|
|
|
|
|
|
@@ -1106,8 +1119,10 @@ describe( 'Range', () => {
|
|
|
describe( 'by WrapDelta', () => {
|
|
describe( 'by WrapDelta', () => {
|
|
|
it( 'maintans start position when wrapping element in which the range starts and ends', () => {
|
|
it( 'maintans start position when wrapping element in which the range starts and ends', () => {
|
|
|
// <p>f[o]o</p><p>bar</p>
|
|
// <p>f[o]o</p><p>bar</p>
|
|
|
- range.start = new Position( root, [ 0, 1 ] );
|
|
|
|
|
- range.end = new Position( root, [ 0, 2 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 1 ] ),
|
|
|
|
|
+ new Position( root, [ 0, 2 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const wrapRange = new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
|
|
const wrapRange = new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
|
|
|
const wrapElement = new Element( 'w' );
|
|
const wrapElement = new Element( 'w' );
|
|
@@ -1123,8 +1138,10 @@ describe( 'Range', () => {
|
|
|
|
|
|
|
|
it( 'maintans start position when wrapping element in which the range starts but not ends', () => {
|
|
it( 'maintans start position when wrapping element in which the range starts but not ends', () => {
|
|
|
// <p>f[oo</p><p>b]ar</p>
|
|
// <p>f[oo</p><p>b]ar</p>
|
|
|
- range.start = new Position( root, [ 0, 1 ] );
|
|
|
|
|
- range.end = new Position( root, [ 1, 1 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 1 ] ),
|
|
|
|
|
+ new Position( root, [ 1, 1 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const wrapRange = new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
|
|
const wrapRange = new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
|
|
|
const wrapElement = new Element( 'w' );
|
|
const wrapElement = new Element( 'w' );
|
|
@@ -1140,8 +1157,10 @@ describe( 'Range', () => {
|
|
|
|
|
|
|
|
it( 'maintans end position when wrapping element in which the range ends but not starts', () => {
|
|
it( 'maintans end position when wrapping element in which the range ends but not starts', () => {
|
|
|
// <p>f[oo</p><p>b]ar</p>
|
|
// <p>f[oo</p><p>b]ar</p>
|
|
|
- range.start = new Position( root, [ 0, 1 ] );
|
|
|
|
|
- range.end = new Position( root, [ 1, 1 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 1 ] ),
|
|
|
|
|
+ new Position( root, [ 1, 1 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const wrapRange = new Range( new Position( root, [ 1 ] ), new Position( root, [ 2 ] ) );
|
|
const wrapRange = new Range( new Position( root, [ 1 ] ), new Position( root, [ 2 ] ) );
|
|
|
const wrapElement = new Element( 'w' );
|
|
const wrapElement = new Element( 'w' );
|
|
@@ -1159,8 +1178,10 @@ describe( 'Range', () => {
|
|
|
describe( 'by UnwrapDelta', () => {
|
|
describe( 'by UnwrapDelta', () => {
|
|
|
it( 'maintans start position when wrapping element in which the range starts and ends', () => {
|
|
it( 'maintans start position when wrapping element in which the range starts and ends', () => {
|
|
|
// <w><p>f[o]o</p></w><p>bar</p>
|
|
// <w><p>f[o]o</p></w><p>bar</p>
|
|
|
- range.start = new Position( root, [ 0, 0, 1 ] );
|
|
|
|
|
- range.end = new Position( root, [ 0, 0, 2 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 0, 1 ] ),
|
|
|
|
|
+ new Position( root, [ 0, 0, 2 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const unwrapPosition = new Position( root, [ 0 ] );
|
|
const unwrapPosition = new Position( root, [ 0 ] );
|
|
|
const delta = getUnwrapDelta( unwrapPosition, 1, 1 );
|
|
const delta = getUnwrapDelta( unwrapPosition, 1, 1 );
|
|
@@ -1175,8 +1196,10 @@ describe( 'Range', () => {
|
|
|
|
|
|
|
|
it( 'maintans start position when wrapping element in which the range starts but not ends', () => {
|
|
it( 'maintans start position when wrapping element in which the range starts but not ends', () => {
|
|
|
// <w><p>f[oo</p></w><p>b]ar</p>
|
|
// <w><p>f[oo</p></w><p>b]ar</p>
|
|
|
- range.start = new Position( root, [ 0, 0, 1 ] );
|
|
|
|
|
- range.end = new Position( root, [ 1, 1 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 0, 1 ] ),
|
|
|
|
|
+ new Position( root, [ 1, 1 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const unwrapPosition = new Position( root, [ 0 ] );
|
|
const unwrapPosition = new Position( root, [ 0 ] );
|
|
|
const delta = getUnwrapDelta( unwrapPosition, 1, 1 );
|
|
const delta = getUnwrapDelta( unwrapPosition, 1, 1 );
|
|
@@ -1194,8 +1217,10 @@ describe( 'Range', () => {
|
|
|
|
|
|
|
|
it( 'maintans end position when wrapping element in which the range ends but not starts', () => {
|
|
it( 'maintans end position when wrapping element in which the range ends but not starts', () => {
|
|
|
// <p>f[oo</p><w><p>b]ar</p></w>
|
|
// <p>f[oo</p><w><p>b]ar</p></w>
|
|
|
- range.start = new Position( root, [ 0, 1 ] );
|
|
|
|
|
- range.end = new Position( root, [ 1, 0, 1 ] );
|
|
|
|
|
|
|
+ range = new Range(
|
|
|
|
|
+ new Position( root, [ 0, 1 ] ),
|
|
|
|
|
+ new Position( root, [ 1, 0, 1 ] )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const unwrapPosition = new Position( root, [ 1 ] );
|
|
const unwrapPosition = new Position( root, [ 1 ] );
|
|
|
const delta = getUnwrapDelta( unwrapPosition, 1, 1 );
|
|
const delta = getUnwrapDelta( unwrapPosition, 1, 1 );
|