|
|
@@ -5,15 +5,15 @@
|
|
|
|
|
|
import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
|
|
|
import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
-import ContextualToolbar from '@ckeditor/ckeditor5-ui/src/toolbar/contextual/contextualtoolbar';
|
|
|
+import BalloonToolbar from '@ckeditor/ckeditor5-ui/src/toolbar/balloon/balloontoolbar';
|
|
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
|
|
|
import Image from '../src/image';
|
|
|
import View from '@ckeditor/ckeditor5-ui/src/view';
|
|
|
|
|
|
describe( 'Image integration', () => {
|
|
|
- describe( 'with the ContextualToolbar', () => {
|
|
|
- let balloon, contextualToolbar, newEditor, editorElement;
|
|
|
+ describe( 'with the BalloonToolbar', () => {
|
|
|
+ let balloon, balloonToolbar, newEditor, editorElement;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
editorElement = global.document.createElement( 'div' );
|
|
|
@@ -21,19 +21,19 @@ describe( 'Image integration', () => {
|
|
|
|
|
|
return ClassicTestEditor
|
|
|
.create( editorElement, {
|
|
|
- plugins: [ Image, ContextualToolbar, Paragraph ]
|
|
|
+ plugins: [ Image, BalloonToolbar, Paragraph ]
|
|
|
} )
|
|
|
.then( editor => {
|
|
|
newEditor = editor;
|
|
|
balloon = newEditor.plugins.get( 'ContextualBalloon' );
|
|
|
- contextualToolbar = newEditor.plugins.get( 'ContextualToolbar' );
|
|
|
+ balloonToolbar = newEditor.plugins.get( 'BalloonToolbar' );
|
|
|
const button = new View();
|
|
|
|
|
|
button.element = global.document.createElement( 'div' );
|
|
|
|
|
|
// There must be at least one toolbar items which is not disabled to show it.
|
|
|
// https://github.com/ckeditor/ckeditor5-ui/issues/269
|
|
|
- contextualToolbar.toolbarView.items.add( button );
|
|
|
+ balloonToolbar.toolbarView.items.add( button );
|
|
|
|
|
|
newEditor.editing.view.isFocused = true;
|
|
|
newEditor.editing.view.getDomRoot().focus();
|
|
|
@@ -45,25 +45,25 @@ describe( 'Image integration', () => {
|
|
|
return newEditor.destroy();
|
|
|
} );
|
|
|
|
|
|
- it( 'should prevent the ContextualToolbar from being displayed when an image is selected', () => {
|
|
|
+ it( 'should prevent the BalloonToolbar from being displayed when an image is selected', () => {
|
|
|
// When image is selected along with text.
|
|
|
setModelData( newEditor.model, '<paragraph>fo[o</paragraph><image alt="alt text" src="foo.png"></image>]' );
|
|
|
|
|
|
- contextualToolbar.show();
|
|
|
+ balloonToolbar.show();
|
|
|
|
|
|
- // ContextualToolbar should be visible.
|
|
|
- expect( balloon.visibleView ).to.equal( contextualToolbar.toolbarView );
|
|
|
+ // BalloonToolbar should be visible.
|
|
|
+ expect( balloon.visibleView ).to.equal( balloonToolbar.toolbarView );
|
|
|
|
|
|
// When only image is selected.
|
|
|
setModelData( newEditor.model, '<paragraph>foo</paragraph>[<image alt="alt text" src="foo.png"></image>]' );
|
|
|
|
|
|
- contextualToolbar.show();
|
|
|
+ balloonToolbar.show();
|
|
|
|
|
|
- // ContextualToolbar should not be visible.
|
|
|
+ // BalloonToolbar should not be visible.
|
|
|
expect( balloon.visibleView ).to.be.null;
|
|
|
} );
|
|
|
|
|
|
- it( 'should listen to ContextualToolbar#show event with the high priority', () => {
|
|
|
+ it( 'should listen to BalloonToolbar#show event with the high priority', () => {
|
|
|
const highestPrioritySpy = sinon.spy();
|
|
|
const highPrioritySpy = sinon.spy();
|
|
|
const normalPrioritySpy = sinon.spy();
|
|
|
@@ -71,11 +71,11 @@ describe( 'Image integration', () => {
|
|
|
// Select an image
|
|
|
setModelData( newEditor.model, '<paragraph>foo</paragraph>[<image alt="alt text" src="foo.png"></image>]' );
|
|
|
|
|
|
- newEditor.listenTo( contextualToolbar, 'show', highestPrioritySpy, { priority: 'highest' } );
|
|
|
- newEditor.listenTo( contextualToolbar, 'show', highPrioritySpy, { priority: 'high' } );
|
|
|
- newEditor.listenTo( contextualToolbar, 'show', normalPrioritySpy, { priority: 'normal' } );
|
|
|
+ newEditor.listenTo( balloonToolbar, 'show', highestPrioritySpy, { priority: 'highest' } );
|
|
|
+ newEditor.listenTo( balloonToolbar, 'show', highPrioritySpy, { priority: 'high' } );
|
|
|
+ newEditor.listenTo( balloonToolbar, 'show', normalPrioritySpy, { priority: 'normal' } );
|
|
|
|
|
|
- contextualToolbar.show();
|
|
|
+ balloonToolbar.show();
|
|
|
|
|
|
sinon.assert.calledOnce( highestPrioritySpy );
|
|
|
sinon.assert.notCalled( highPrioritySpy );
|