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

Commit

Permalink
Merge 7653462 into be7f15d
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Oct 3, 2019
2 parents be7f15d + 7653462 commit dacf52e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
5 changes: 5 additions & 0 deletions src/decouplededitorui.js
Expand Up @@ -115,13 +115,18 @@ export default class DecoupledEditorUI extends EditorUI {
const toolbar = view.toolbar;

toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );
toolbar.shouldGroupWhenFull = true;

enableToolbarKeyboardFocus( {
origin: editor.editing.view,
originFocusTracker: this.focusTracker,
originKeystrokeHandler: editor.keystrokes,
toolbar
} );

this.on( 'update', () => {
toolbar.updateGroupedItems();
} );
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/decouplededitoruiview.js
Expand Up @@ -10,7 +10,6 @@
import EditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/editoruiview';
import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
import ToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarview';
import Template from '@ckeditor/ckeditor5-ui/src/template';

/**
* The decoupled editor UI view. It is a virtual view providing an inline
Expand Down Expand Up @@ -55,7 +54,7 @@ export default class DecoupledEditorUIView extends EditorUIView {
// Because of the above, make sure the toolbar supports rounded corners.
// Also, make sure the toolbar has the proper dir attribute because its ancestor may not have one
// and some toolbar item styles depend on this attribute.
Template.extend( this.toolbar.template, {
this.toolbar.extendTemplate( {
attributes: {
class: [
'ck-reset_all',
Expand Down
60 changes: 33 additions & 27 deletions tests/decouplededitorui.js
Expand Up @@ -136,38 +136,44 @@ describe( 'DecoupledEditorUI', () => {
} );
} );

describe( 'view.toolbar#items', () => {
it( 'are filled with the config.toolbar (specified as an Array)', () => {
return VirtualDecoupledTestEditor
.create( '', {
toolbar: [ 'foo', 'bar' ]
} )
.then( editor => {
const items = editor.ui.view.toolbar.items;
describe( 'view.toolbar', () => {
it( 'has automatic items grouping enabled', () => {
expect( view.toolbar.shouldGroupWhenFull ).to.be.true;
} );

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

return editor.destroy();
} );
} );
expect( items.get( 0 ).name ).to.equal( 'foo' );
expect( items.get( 1 ).name ).to.equal( 'bar' );

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

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

return editor.destroy();
} );
expect( items.get( 0 ).name ).to.equal( 'foo' );
expect( items.get( 1 ).name ).to.equal( 'bar' );

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

Expand Down

0 comments on commit dacf52e

Please sign in to comment.