|
@@ -9,6 +9,7 @@ import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictest
|
|
|
import Image from '../../src/image';
|
|
import Image from '../../src/image';
|
|
|
import ImageTextAlternativeEditing from '../../src/imagetextalternative/imagetextalternativeediting';
|
|
import ImageTextAlternativeEditing from '../../src/imagetextalternative/imagetextalternativeediting';
|
|
|
import ImageTextAlternativeUI from '../../src/imagetextalternative/imagetextalternativeui';
|
|
import ImageTextAlternativeUI from '../../src/imagetextalternative/imagetextalternativeui';
|
|
|
|
|
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
|
|
import View from '@ckeditor/ckeditor5-ui/src/view';
|
|
import View from '@ckeditor/ckeditor5-ui/src/view';
|
|
|
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
|
|
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
|
|
@@ -24,7 +25,7 @@ describe( 'ImageTextAlternativeUI', () => {
|
|
|
|
|
|
|
|
return ClassicTestEditor
|
|
return ClassicTestEditor
|
|
|
.create( editorElement, {
|
|
.create( editorElement, {
|
|
|
- plugins: [ ImageTextAlternativeEditing, ImageTextAlternativeUI, Image ]
|
|
|
|
|
|
|
+ plugins: [ ImageTextAlternativeEditing, ImageTextAlternativeUI, Image, Paragraph ]
|
|
|
} )
|
|
} )
|
|
|
.then( newEditor => {
|
|
.then( newEditor => {
|
|
|
editor = newEditor;
|
|
editor = newEditor;
|
|
@@ -169,11 +170,52 @@ describe( 'ImageTextAlternativeUI', () => {
|
|
|
const editableFocusSpy = sinon.spy( editor.editing.view, 'focus' );
|
|
const editableFocusSpy = sinon.spy( editor.editing.view, 'focus' );
|
|
|
const buttonFocusSpy = sinon.spy( form.saveButtonView, 'focus' );
|
|
const buttonFocusSpy = sinon.spy( form.saveButtonView, 'focus' );
|
|
|
|
|
|
|
|
|
|
+ form.focusTracker.isFocused = true;
|
|
|
|
|
+
|
|
|
form.fire( 'submit' );
|
|
form.fire( 'submit' );
|
|
|
|
|
|
|
|
expect( buttonFocusSpy.calledBefore( editableFocusSpy ) ).to.equal( true );
|
|
expect( buttonFocusSpy.calledBefore( editableFocusSpy ) ).to.equal( true );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ // https://github.com/ckeditor/ckeditor5-image/issues/299
|
|
|
|
|
+ it( 'should not blur url input element before hiding the view when view was not focused', () => {
|
|
|
|
|
+ setData( model, '[<image src="" alt="foo bar"></image>]' );
|
|
|
|
|
+
|
|
|
|
|
+ editor.ui.componentFactory.create( 'imageTextAlternative' ).fire( 'execute' );
|
|
|
|
|
+
|
|
|
|
|
+ const buttonFocusSpy = sinon.spy( form.saveButtonView, 'focus' );
|
|
|
|
|
+
|
|
|
|
|
+ form.focusTracker.isFocused = false;
|
|
|
|
|
+
|
|
|
|
|
+ form.fire( 'cancel' );
|
|
|
|
|
+
|
|
|
|
|
+ sinon.assert.notCalled( buttonFocusSpy );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should be removed from balloon when is in not visible stack', () => {
|
|
|
|
|
+ setData( model, '<paragraph>foo</paragraph>[<image src="" alt="foo bar"></image>]' );
|
|
|
|
|
+
|
|
|
|
|
+ editor.ui.componentFactory.create( 'imageTextAlternative' ).fire( 'execute' );
|
|
|
|
|
+
|
|
|
|
|
+ const customView = new View();
|
|
|
|
|
+
|
|
|
|
|
+ balloon.add( {
|
|
|
|
|
+ view: customView,
|
|
|
|
|
+ position: { target: {} },
|
|
|
|
|
+ stackId: 'custom'
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ balloon.showStack( 'custom' );
|
|
|
|
|
+
|
|
|
|
|
+ model.change( writer => {
|
|
|
|
|
+ const root = model.document.getRoot();
|
|
|
|
|
+
|
|
|
|
|
+ writer.setSelection( root.getChild( 0 ), 0 );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ expect( balloon.hasView( form ) ).to.equal( false );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
describe( 'integration with the editor selection (ui#update event)', () => {
|
|
describe( 'integration with the editor selection (ui#update event)', () => {
|
|
|
it( 'should re-position the form', () => {
|
|
it( 'should re-position the form', () => {
|
|
|
setData( model, '[<image src=""></image>]' );
|
|
setData( model, '[<image src=""></image>]' );
|