|
|
@@ -392,7 +392,7 @@ describe( 'widget utils', () => {
|
|
|
expect( pos.path ).to.deep.equal( [ 1 ] );
|
|
|
} );
|
|
|
|
|
|
- it( 'returns position before block if in the middle of that block', () => {
|
|
|
+ it( 'returns position before block if in the middle of that block (collapsed selection)', () => {
|
|
|
setData( model, '<paragraph>x</paragraph><paragraph>f[]oo</paragraph><paragraph>y</paragraph>' );
|
|
|
|
|
|
const pos = findOptimalInsertionPosition( doc.selection, model );
|
|
|
@@ -400,6 +400,14 @@ describe( 'widget utils', () => {
|
|
|
expect( pos.path ).to.deep.equal( [ 1 ] );
|
|
|
} );
|
|
|
|
|
|
+ it( 'returns position before block if in the middle of that block (non-collapsed selection)', () => {
|
|
|
+ setData( model, '<paragraph>x</paragraph><paragraph>f[o]o</paragraph><paragraph>y</paragraph>' );
|
|
|
+
|
|
|
+ const pos = findOptimalInsertionPosition( doc.selection, model );
|
|
|
+
|
|
|
+ expect( pos.path ).to.deep.equal( [ 1 ] );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'returns position after block if at the end of that block', () => {
|
|
|
setData( model, '<paragraph>x</paragraph><paragraph>foo[]</paragraph><paragraph>y</paragraph>' );
|
|
|
|
|
|
@@ -425,5 +433,18 @@ describe( 'widget utils', () => {
|
|
|
|
|
|
expect( pos.path ).to.deep.equal( [ 3 ] );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'returns position before block selection is on inline element', () => {
|
|
|
+ model.schema.register( 'placeholder', {
|
|
|
+ allowWhere: '$text',
|
|
|
+ isInline: true
|
|
|
+ } );
|
|
|
+
|
|
|
+ setData( model, '<paragraph>x</paragraph><paragraph>f[<placeholder></placeholder>]oo</paragraph><paragraph>y</paragraph>' );
|
|
|
+
|
|
|
+ const pos = findOptimalInsertionPosition( doc.selection, model );
|
|
|
+
|
|
|
+ expect( pos.path ).to.deep.equal( [ 1 ] );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|