|
|
@@ -145,6 +145,8 @@ describe( 'MentionUI', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should properly calculate position data', () => {
|
|
|
+ const editableElement = editingView.document.selection.editableElement;
|
|
|
+
|
|
|
setData( model, '<paragraph>foo []</paragraph>' );
|
|
|
stubSelectionRects( [ caretRect ] );
|
|
|
|
|
|
@@ -157,11 +159,13 @@ describe( 'MentionUI', () => {
|
|
|
return waitForDebounce()
|
|
|
.then( () => {
|
|
|
const pinArgument = pinSpy.firstCall.args[ 0 ];
|
|
|
- const { target, positions } = pinArgument;
|
|
|
+ const { target, positions, limiter, fitInViewport } = pinArgument;
|
|
|
|
|
|
expect( positions ).to.have.length( 4 );
|
|
|
|
|
|
- expect( pinArgument.fitInViewport ).to.be.undefined;
|
|
|
+ // Mention UI should set limiter to the editable area.
|
|
|
+ expect( limiter() ).to.equal( editingView.domConverter.mapViewToDom( editableElement ) );
|
|
|
+ expect( fitInViewport ).to.be.undefined;
|
|
|
|
|
|
expect( editor.model.markers.has( 'mention' ) ).to.be.true;
|
|
|
const mentionMarker = editor.model.markers.get( 'mention' );
|
|
|
@@ -191,18 +195,18 @@ describe( 'MentionUI', () => {
|
|
|
top: 121
|
|
|
} );
|
|
|
|
|
|
- expect( caretNorthEast( caretRect, balloonRect ) ).to.deep.equal( {
|
|
|
- left: 501,
|
|
|
- name: 'caret_ne',
|
|
|
- top: -53
|
|
|
- } );
|
|
|
-
|
|
|
expect( caretSouthWest( caretRect, balloonRect ) ).to.deep.equal( {
|
|
|
left: 301,
|
|
|
name: 'caret_sw',
|
|
|
top: 121
|
|
|
} );
|
|
|
|
|
|
+ expect( caretNorthEast( caretRect, balloonRect ) ).to.deep.equal( {
|
|
|
+ left: 501,
|
|
|
+ name: 'caret_ne',
|
|
|
+ top: -53
|
|
|
+ } );
|
|
|
+
|
|
|
expect( caretNorthWest( caretRect, balloonRect ) ).to.deep.equal( {
|
|
|
left: 301,
|
|
|
name: 'caret_nw',
|
|
|
@@ -247,6 +251,28 @@ describe( 'MentionUI', () => {
|
|
|
expect( positions[ 0 ].name ).to.equal( positionAfterFirstShow );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'does not fail if selection has no #editableElement', () => {
|
|
|
+ setData( model, '<paragraph>foo []</paragraph>' );
|
|
|
+ stubSelectionRects( [ caretRect ] );
|
|
|
+
|
|
|
+ expect( editor.model.markers.has( 'mention' ) ).to.be.false;
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.insertText( '@', doc.selection.getFirstPosition() );
|
|
|
+ } );
|
|
|
+
|
|
|
+ return waitForDebounce()
|
|
|
+ .then( () => {
|
|
|
+ const pinArgument = pinSpy.firstCall.args[ 0 ];
|
|
|
+ const { limiter } = pinArgument;
|
|
|
+
|
|
|
+ sinon.stub( editingView.document.selection, 'editableElement' ).value( null );
|
|
|
+
|
|
|
+ // Should not break;
|
|
|
+ expect( limiter() ).to.be.null;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'typing integration', () => {
|