|
|
@@ -3,13 +3,12 @@
|
|
|
* For licensing, see LICENSE.md.
|
|
|
*/
|
|
|
|
|
|
-import { getClosestListItem, getSelectedBlocks, getPositionBeforeBlock } from '../src/utils';
|
|
|
+import { getClosestListItem, getPositionBeforeBlock } from '../src/utils';
|
|
|
|
|
|
import Element from '@ckeditor/ckeditor5-engine/src/model/element';
|
|
|
import Text from '@ckeditor/ckeditor5-engine/src/model/text';
|
|
|
import Position from '@ckeditor/ckeditor5-engine/src/model/position';
|
|
|
import Schema from '@ckeditor/ckeditor5-engine/src/model/schema';
|
|
|
-import Selection from '@ckeditor/ckeditor5-engine/src/model/selection';
|
|
|
|
|
|
describe( 'getClosestListItem', () => {
|
|
|
const item = new Element( 'listItem', null, 'foobar' );
|
|
|
@@ -24,50 +23,6 @@ describe( 'getClosestListItem', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
-describe( 'getSelectedBlocks', () => {
|
|
|
- const paragraph1 = new Element( 'paragraph', null, '---' );
|
|
|
- const item1 = new Element( 'listItem', null, '---' );
|
|
|
- const item2 = new Element( 'listItem', null, '---' );
|
|
|
- const item3 = new Element( 'listItem', null, '---' );
|
|
|
- const paragraph2 = new Element( 'paragraph', null, '---' );
|
|
|
-
|
|
|
- const root = new Element( '$root', null, [
|
|
|
- paragraph1, item1, item2, item3, paragraph2
|
|
|
- ] );
|
|
|
-
|
|
|
- const schema = new Schema();
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
- schema.registerItem( 'listItem', '$block' );
|
|
|
-
|
|
|
- const selection = new Selection();
|
|
|
-
|
|
|
- it( 'should return just one block if selection is over one block', () => {
|
|
|
- selection.collapse( root, 2 );
|
|
|
- selection.setFocus( root, 3 );
|
|
|
-
|
|
|
- expect( getSelectedBlocks( selection, schema ) ).to.deep.equal( [ item2 ] );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should return ancestor block if selection is collapsed and not before a block', () => {
|
|
|
- selection.collapse( paragraph1, 2 );
|
|
|
-
|
|
|
- expect( getSelectedBlocks( selection, schema ) ).to.deep.equal( [ paragraph1 ] );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should return empty array for collapsed selection before a block, in a root', () => {
|
|
|
- selection.collapse( root, 1 );
|
|
|
-
|
|
|
- expect( getSelectedBlocks( selection, schema ) ).to.deep.equal( [] );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should return all blocks "touched" by the selection if it spans over multiple blocks', () => {
|
|
|
- selection.collapse( item1, 3 );
|
|
|
- selection.setFocus( root, 4 );
|
|
|
-
|
|
|
- expect( getSelectedBlocks( selection, schema ) ).to.deep.equal( [ item1, item2, item3 ] );
|
|
|
- } );
|
|
|
-} );
|
|
|
-
|
|
|
describe( 'getPositionBeforeBlock', () => {
|
|
|
const paragraph = new Element( 'paragraph', null, 'foo' );
|
|
|
const item = new Element( 'listItem', null, 'bar' );
|