|
|
@@ -12,6 +12,7 @@ import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-util
|
|
|
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
|
|
|
|
|
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
+import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote';
|
|
|
import LinkEditing from '../src/linkediting';
|
|
|
import LinkUI from '../src/linkui';
|
|
|
import LinkFormView from '../src/ui/linkformview';
|
|
|
@@ -33,7 +34,7 @@ describe( 'LinkUI', () => {
|
|
|
|
|
|
return ClassicTestEditor
|
|
|
.create( editorElement, {
|
|
|
- plugins: [ LinkEditing, LinkUI, Paragraph ]
|
|
|
+ plugins: [ LinkEditing, LinkUI, Paragraph, BlockQuote ]
|
|
|
} )
|
|
|
.then( newEditor => {
|
|
|
editor = newEditor;
|
|
|
@@ -269,6 +270,42 @@ describe( 'LinkUI', () => {
|
|
|
expect( balloon.visibleView ).to.equal( formView );
|
|
|
} );
|
|
|
|
|
|
+ // https://github.com/ckeditor/ckeditor5-link/issues/242.
|
|
|
+ it( 'should update balloon position when is switched in rotator to a visible panel', () => {
|
|
|
+ setModelData( editor.model, '<paragraph>fo<$text linkHref="foo">o[] b</$text>ar</paragraph>' );
|
|
|
+ linkUIFeature._showUI();
|
|
|
+
|
|
|
+ const customView = new View();
|
|
|
+ const linkViewElement = editor.editing.view.document.getRoot().getChild( 0 ).getChild( 1 );
|
|
|
+ const linkDomElement = editor.editing.view.domConverter.mapViewToDom( linkViewElement );
|
|
|
+
|
|
|
+ expect( balloon.visibleView ).to.equal( actionsView );
|
|
|
+ expect( balloon.view.pin.lastCall.args[ 0 ].target ).to.equal( linkDomElement );
|
|
|
+
|
|
|
+ balloon.add( {
|
|
|
+ stackId: 'custom',
|
|
|
+ view: customView,
|
|
|
+ position: { target: {} }
|
|
|
+ } );
|
|
|
+
|
|
|
+ balloon.showStack( 'custom' );
|
|
|
+
|
|
|
+ expect( balloon.visibleView ).to.equal( customView );
|
|
|
+ expect( balloon.hasView( actionsView ) ).to.equal( true );
|
|
|
+
|
|
|
+ editor.execute( 'blockQuote' );
|
|
|
+ balloon.showStack( 'main' );
|
|
|
+
|
|
|
+ expect( balloon.visibleView ).to.equal( actionsView );
|
|
|
+ expect( balloon.hasView( customView ) ).to.equal( true );
|
|
|
+ expect( balloon.view.pin.lastCall.args[ 0 ].target ).to.not.equal( linkDomElement );
|
|
|
+
|
|
|
+ const newLinkViewElement = editor.editing.view.document.getRoot().getChild( 0 ).getChild( 0 ).getChild( 1 );
|
|
|
+ const newLinkDomElement = editor.editing.view.domConverter.mapViewToDom( newLinkViewElement );
|
|
|
+
|
|
|
+ expect( balloon.view.pin.lastCall.args[ 0 ].target ).to.equal( newLinkDomElement );
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'response to ui#update', () => {
|
|
|
let view, viewDocument;
|
|
|
|
|
|
@@ -337,6 +374,31 @@ describe( 'LinkUI', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
+ it( 'not update the position when is in not visible stack', () => {
|
|
|
+ setModelData( editor.model, '<paragraph><$text linkHref="url">f[]oo</$text></paragraph>' );
|
|
|
+
|
|
|
+ linkUIFeature._showUI();
|
|
|
+
|
|
|
+ const customView = new View();
|
|
|
+
|
|
|
+ balloon.add( {
|
|
|
+ stackId: 'custom',
|
|
|
+ view: customView,
|
|
|
+ position: { target: {} }
|
|
|
+ } );
|
|
|
+
|
|
|
+ balloon.showStack( 'custom' );
|
|
|
+
|
|
|
+ expect( balloon.visibleView ).to.equal( customView );
|
|
|
+ expect( balloon.hasView( actionsView ) ).to.equal( true );
|
|
|
+
|
|
|
+ const spy = testUtils.sinon.spy( balloon, 'updatePosition' );
|
|
|
+
|
|
|
+ editor.ui.fire( 'update' );
|
|
|
+
|
|
|
+ sinon.assert.notCalled( spy );
|
|
|
+ } );
|
|
|
+
|
|
|
// https://github.com/ckeditor/ckeditor5-link/issues/113
|
|
|
it( 'hides of the panel – editing a link, then the selection moved out of the link', () => {
|
|
|
setModelData( editor.model, '<paragraph><$text linkHref="url">f[]oo</$text>bar</paragraph>' );
|