|
@@ -9,6 +9,7 @@
|
|
|
|
|
|
|
|
import Selection from '/ckeditor5/engine/view/selection.js';
|
|
import Selection from '/ckeditor5/engine/view/selection.js';
|
|
|
import Range from '/ckeditor5/engine/view/range.js';
|
|
import Range from '/ckeditor5/engine/view/range.js';
|
|
|
|
|
+import Document from '/ckeditor5/engine/view/document.js';
|
|
|
import Element from '/ckeditor5/engine/view/element.js';
|
|
import Element from '/ckeditor5/engine/view/element.js';
|
|
|
import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
|
|
import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
|
|
|
|
|
|
|
@@ -408,4 +409,28 @@ describe( 'Selection', () => {
|
|
|
expect( fireSpy.notCalled ).to.be.true;
|
|
expect( fireSpy.notCalled ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ describe( 'getEditableElement', () => {
|
|
|
|
|
+ it( 'should return null if no ranges in selection', () => {
|
|
|
|
|
+ expect( selection.getEditableElement() ).to.be.null;
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should return null if selection is placed in container that is not EditableElement', () => {
|
|
|
|
|
+ selection.addRange( range1 );
|
|
|
|
|
+
|
|
|
|
|
+ expect( selection.getEditableElement() ).to.be.null;
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should return EditableElement when selection is placed inside', () => {
|
|
|
|
|
+ const viewDocument = new Document();
|
|
|
|
|
+ const selection = viewDocument.selection;
|
|
|
|
|
+ const root = viewDocument.createRoot( 'div' );
|
|
|
|
|
+ const element = new Element( 'p' );
|
|
|
|
|
+ root.appendChildren( element );
|
|
|
|
|
+
|
|
|
|
|
+ selection.addRange( Range.createFromParentsAndOffsets( element, 0, element, 0 ) );
|
|
|
|
|
+
|
|
|
|
|
+ expect( selection.getEditableElement() ).to.equal( root );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|