Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #99 from ckeditor/t/ckeditor5/416d
Browse files Browse the repository at this point in the history
Feature: Enabled automatic items grouping in the main editor toolbar when there is not enough space to display them in a single row (see ckeditor/ckeditor5#416).
  • Loading branch information
jodator authored Oct 15, 2019
2 parents 6acb49e + e439ed1 commit 4d20b70
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 30 deletions.
4 changes: 3 additions & 1 deletion src/classiceditoruiview.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export default class ClassicEditorUIView extends BoxedEditorUIView {
* @readonly
* @member {module:ui/toolbar/toolbarview~ToolbarView}
*/
this.toolbar = new ToolbarView( locale );
this.toolbar = new ToolbarView( locale, {
shouldGroupWhenFull: true
} );

/**
* Editable UI view.
Expand Down
60 changes: 31 additions & 29 deletions tests/classiceditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,38 +164,40 @@ describe( 'ClassicEditorUI', () => {
} );
} );

describe( 'view.toolbar#items', () => {
it( 'are filled with the config.toolbar (specified as an Array)', () => {
return VirtualClassicTestEditor
.create( '', {
toolbar: [ 'foo', 'bar' ]
} )
.then( editor => {
const items = editor.ui.view.toolbar.items;

expect( items.get( 0 ).name ).to.equal( 'foo' );
expect( items.get( 1 ).name ).to.equal( 'bar' );

return editor.destroy();
} );
} );
describe( 'view.toolbar', () => {
describe( '#items', () => {
it( 'are filled with the config.toolbar (specified as an Array)', () => {
return VirtualClassicTestEditor
.create( '', {
toolbar: [ 'foo', 'bar' ]
} )
.then( editor => {
const items = editor.ui.view.toolbar.items;

expect( items.get( 0 ).name ).to.equal( 'foo' );
expect( items.get( 1 ).name ).to.equal( 'bar' );

return editor.destroy();
} );
} );

it( 'are filled with the config.toolbar (specified as an Object)', () => {
return VirtualClassicTestEditor
.create( '', {
toolbar: {
items: [ 'foo', 'bar' ],
viewportTopOffset: 100
}
} )
.then( editor => {
const items = editor.ui.view.toolbar.items;
it( 'are filled with the config.toolbar (specified as an Object)', () => {
return VirtualClassicTestEditor
.create( '', {
toolbar: {
items: [ 'foo', 'bar' ],
viewportTopOffset: 100
}
} )
.then( editor => {
const items = editor.ui.view.toolbar.items;

expect( items.get( 0 ).name ).to.equal( 'foo' );
expect( items.get( 1 ).name ).to.equal( 'bar' );
expect( items.get( 0 ).name ).to.equal( 'foo' );
expect( items.get( 1 ).name ).to.equal( 'bar' );

return editor.destroy();
} );
return editor.destroy();
} );
} );
} );
} );

Expand Down
4 changes: 4 additions & 0 deletions tests/classiceditoruiview.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ describe( 'ClassicEditorUIView', () => {
it( 'is put into the "stickyPanel.content" collection', () => {
expect( view.stickyPanel.content.get( 0 ) ).to.equal( view.toolbar );
} );

it( 'has automatic items grouping enabled', () => {
expect( view.toolbar.options.shouldGroupWhenFull ).to.be.true;
} );
} );

describe( '#editable', () => {
Expand Down

0 comments on commit 4d20b70

Please sign in to comment.