Skip to content

Commit

Permalink
Fix: It will be possible to configure toolbar offset without overridi…
Browse files Browse the repository at this point in the history
…ng preconfigured toolbar items. See ckeditor/ckeditor5#572.
  • Loading branch information
Reinmar committed Sep 30, 2017
1 parent fc12c58 commit ebcc189
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 22 deletions.
24 changes: 13 additions & 11 deletions build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ module.exports = {

// Editor config.
config: {
toolbar: [
'headings',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'blockQuote',
'undo',
'redo'
],
toolbar: {
items: [
'headings',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'blockQuote',
'undo',
'redo'
]
},

image: {
toolbar: [ 'imageStyleFull', 'imageStyleSide', '|', 'imageTextAlternative' ]
Expand Down
24 changes: 13 additions & 11 deletions src/ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ ClassicEditor.build = {
ImageuploadPlugin
],
config: {
toolbar: [
'headings',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'blockQuote',
'undo',
'redo'
],
toolbar: {
items: [
'headings',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'blockQuote',
'undo',
'redo'
]
},
image: {
toolbar: [
'imageStyleFull',
Expand Down
47 changes: 47 additions & 0 deletions tests/ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe( 'ClassicEditor build', () => {

afterEach( () => {
editorElement.remove();
editor = null;
} );

describe( 'buid', () => {
Expand Down Expand Up @@ -82,6 +83,17 @@ describe( 'ClassicEditor build', () => {
} );

describe( 'plugins', () => {
beforeEach( () => {
return ClassicEditor.create( editorElement )
.then( newEditor => {
editor = newEditor;
} );
} );

afterEach( () => {
return editor.destroy();
} );

it( 'paragraph works', () => {
const data = '<p>Some text inside a paragraph.</p>';

Expand Down Expand Up @@ -153,4 +165,39 @@ describe( 'ClassicEditor build', () => {
expect( editor.getData() ).to.equal( data );
} );
} );

describe( 'config', () => {
afterEach( () => {
return editor.destroy();
} );

// https://github.com/ckeditor/ckeditor5/issues/572
it( 'allows configure toolbar items through config.toolbar', () => {
return ClassicEditor
.create( editorElement, {
toolbar: [ 'bold' ]
} )
.then( newEditor => {
editor = newEditor;

expect( editor.ui.view.toolbar.items.length ).to.equal( 1 );
} );
} );

// https://github.com/ckeditor/ckeditor5/issues/572
it( 'allows configure toolbar offset without overriding toolbar items', () => {
return ClassicEditor
.create( editorElement, {
toolbar: {
viewportTopOffset: 42
}
} )
.then( newEditor => {
editor = newEditor;

expect( editor.ui.view.toolbar.items.length ).to.equal( 9 );
expect( editor.ui.view.stickyPanel.viewportTopOffset ).to.equal( 42 );
} );
} );
} );
} );

0 comments on commit ebcc189

Please sign in to comment.