From e7fbda92d35ba5ac7ed227dadaffe85b96dee3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sat, 30 Sep 2017 20:54:51 +0200 Subject: [PATCH] Fix: It will be possible to configure toolbar offset without overriding preconfigured toolbar items. See ckeditor/ckeditor5#572. --- build-config.js | 24 +++++++++++++----------- src/ckeditor.js | 24 +++++++++++++----------- tests/ckeditor.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 22 deletions(-) diff --git a/build-config.js b/build-config.js index 86684ec9ba..2e9194f4b5 100644 --- a/build-config.js +++ b/build-config.js @@ -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' ] diff --git a/src/ckeditor.js b/src/ckeditor.js index 22cbc7a3e7..4d449f04be 100644 --- a/src/ckeditor.js +++ b/src/ckeditor.js @@ -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', diff --git a/tests/ckeditor.js b/tests/ckeditor.js index 2b325f2711..98ed018b2c 100644 --- a/tests/ckeditor.js +++ b/tests/ckeditor.js @@ -20,6 +20,7 @@ describe( 'ClassicEditor build', () => { afterEach( () => { editorElement.remove(); + editor = null; } ); describe( 'buid', () => { @@ -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 = '

Some text inside a paragraph.

'; @@ -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 ); + } ); + } ); + } ); } );