|
@@ -27,16 +27,24 @@ describe( 'InlineEditorUI', () => {
|
|
|
editorElement = document.createElement( 'div' );
|
|
editorElement = document.createElement( 'div' );
|
|
|
document.body.appendChild( editorElement );
|
|
document.body.appendChild( editorElement );
|
|
|
|
|
|
|
|
- editor = new ClassicTestEditor( editorElement, {
|
|
|
|
|
|
|
+ return ClassicTestEditor.create( editorElement, {
|
|
|
toolbar: [ 'foo', 'bar' ]
|
|
toolbar: [ 'foo', 'bar' ]
|
|
|
- } );
|
|
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( newEditor => {
|
|
|
|
|
+ editor = newEditor;
|
|
|
|
|
|
|
|
- view = new InlineEditorUIView( editor.locale );
|
|
|
|
|
- ui = new InlineEditorUI( editor, view );
|
|
|
|
|
- editable = editor.editing.view.getRoot();
|
|
|
|
|
|
|
+ view = new InlineEditorUIView( editor.locale );
|
|
|
|
|
+ ui = new InlineEditorUI( editor, view );
|
|
|
|
|
+ editable = editor.editing.view.getRoot();
|
|
|
|
|
|
|
|
- ui.componentFactory.add( 'foo', viewCreator( 'foo' ) );
|
|
|
|
|
- ui.componentFactory.add( 'bar', viewCreator( 'bar' ) );
|
|
|
|
|
|
|
+ ui.componentFactory.add( 'foo', viewCreator( 'foo' ) );
|
|
|
|
|
+ ui.componentFactory.add( 'bar', viewCreator( 'bar' ) );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ afterEach( () => {
|
|
|
|
|
+ editorElement.remove();
|
|
|
|
|
+ editor.destroy();
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'constructor()', () => {
|
|
describe( 'constructor()', () => {
|
|
@@ -65,6 +73,35 @@ describe( 'InlineEditorUI', () => {
|
|
|
expect( view.panel.isVisible ).to.be.true;
|
|
expect( view.panel.isVisible ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'doesn\'t set the view#viewportTopOffset, if not specified in the config', () => {
|
|
|
|
|
+ expect( view.viewportTopOffset ).to.equal( 0 );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'sets view#viewportTopOffset, if specified', () => {
|
|
|
|
|
+ editorElement = document.createElement( 'div' );
|
|
|
|
|
+ document.body.appendChild( editorElement );
|
|
|
|
|
+
|
|
|
|
|
+ return ClassicTestEditor.create( editorElement, {
|
|
|
|
|
+ toolbar: {
|
|
|
|
|
+ items: [ 'foo', 'bar' ],
|
|
|
|
|
+ viewportTopOffset: 100
|
|
|
|
|
+ }
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( editor => {
|
|
|
|
|
+ view = new InlineEditorUIView( editor.locale );
|
|
|
|
|
+ ui = new InlineEditorUI( editor, view );
|
|
|
|
|
+ editable = editor.editing.view.getRoot();
|
|
|
|
|
+
|
|
|
|
|
+ ui.componentFactory.add( 'foo', viewCreator( 'foo' ) );
|
|
|
|
|
+ ui.componentFactory.add( 'bar', viewCreator( 'bar' ) );
|
|
|
|
|
+
|
|
|
|
|
+ expect( view.viewportTopOffset ).to.equal( 100 );
|
|
|
|
|
+
|
|
|
|
|
+ editorElement.remove();
|
|
|
|
|
+ return editor.destroy();
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
// https://github.com/ckeditor/ckeditor5-editor-inline/issues/4
|
|
// https://github.com/ckeditor/ckeditor5-editor-inline/issues/4
|
|
|
it( 'pin() is called on editor.editable.view#render', () => {
|
|
it( 'pin() is called on editor.editable.view#render', () => {
|
|
|
const spy = sinon.spy( view.panel, 'pin' );
|
|
const spy = sinon.spy( view.panel, 'pin' );
|
|
@@ -133,11 +170,40 @@ describe( 'InlineEditorUI', () => {
|
|
|
sinon.assert.calledOnce( spy );
|
|
sinon.assert.calledOnce( spy );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'fills view.toolbar#items with editor config', () => {
|
|
|
|
|
- const spy = testUtils.sinon.spy( view.toolbar, 'fillFromConfig' );
|
|
|
|
|
|
|
+ describe( 'view.toolbar#items', () => {
|
|
|
|
|
+ it( 'are filled with the config.toolbar (specified as an Array)', () => {
|
|
|
|
|
+ const spy = testUtils.sinon.spy( view.toolbar, 'fillFromConfig' );
|
|
|
|
|
|
|
|
- ui.init();
|
|
|
|
|
- sinon.assert.calledWithExactly( spy, editor.config.get( 'toolbar' ), ui.componentFactory );
|
|
|
|
|
|
|
+ ui.init();
|
|
|
|
|
+ sinon.assert.calledWithExactly( spy, editor.config.get( 'toolbar' ), ui.componentFactory );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'are filled with the config.toolbar (specified as an Object)', () => {
|
|
|
|
|
+ editorElement = document.createElement( 'div' );
|
|
|
|
|
+ document.body.appendChild( editorElement );
|
|
|
|
|
+
|
|
|
|
|
+ return ClassicTestEditor.create( editorElement, {
|
|
|
|
|
+ toolbar: {
|
|
|
|
|
+ items: [ 'foo', 'bar' ],
|
|
|
|
|
+ viewportTopOffset: 100
|
|
|
|
|
+ }
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( editor => {
|
|
|
|
|
+ view = new InlineEditorUIView( editor.locale );
|
|
|
|
|
+ ui = new InlineEditorUI( editor, view );
|
|
|
|
|
+
|
|
|
|
|
+ ui.componentFactory.add( 'foo', viewCreator( 'foo' ) );
|
|
|
|
|
+ ui.componentFactory.add( 'bar', viewCreator( 'bar' ) );
|
|
|
|
|
+
|
|
|
|
|
+ const spy = testUtils.sinon.spy( view.toolbar, 'fillFromConfig' );
|
|
|
|
|
+
|
|
|
|
|
+ ui.init();
|
|
|
|
|
+ sinon.assert.calledWithExactly( spy,
|
|
|
|
|
+ editor.config.get( 'toolbar.items' ),
|
|
|
|
|
+ ui.componentFactory
|
|
|
|
|
+ );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'initializes keyboard navigation between view#toolbar and view#editable', () => {
|
|
it( 'initializes keyboard navigation between view#toolbar and view#editable', () => {
|