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

Commit e7fbda9

Browse files
committed
Fix: It will be possible to configure toolbar offset without overriding preconfigured toolbar items. See ckeditor/ckeditor5#572.
1 parent 668691f commit e7fbda9

File tree

3 files changed

+73
-22
lines changed

3 files changed

+73
-22
lines changed

build-config.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,19 @@ module.exports = {
3838

3939
// Editor config.
4040
config: {
41-
toolbar: [
42-
'headings',
43-
'bold',
44-
'italic',
45-
'link',
46-
'bulletedList',
47-
'numberedList',
48-
'blockQuote',
49-
'undo',
50-
'redo'
51-
],
41+
toolbar: {
42+
items: [
43+
'headings',
44+
'bold',
45+
'italic',
46+
'link',
47+
'bulletedList',
48+
'numberedList',
49+
'blockQuote',
50+
'undo',
51+
'redo'
52+
]
53+
},
5254

5355
image: {
5456
toolbar: [ 'imageStyleFull', 'imageStyleSide', '|', 'imageTextAlternative' ]

src/ckeditor.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ ClassicEditor.build = {
4343
ImageuploadPlugin
4444
],
4545
config: {
46-
toolbar: [
47-
'headings',
48-
'bold',
49-
'italic',
50-
'link',
51-
'bulletedList',
52-
'numberedList',
53-
'blockQuote',
54-
'undo',
55-
'redo'
56-
],
46+
toolbar: {
47+
items: [
48+
'headings',
49+
'bold',
50+
'italic',
51+
'link',
52+
'bulletedList',
53+
'numberedList',
54+
'blockQuote',
55+
'undo',
56+
'redo'
57+
]
58+
},
5759
image: {
5860
toolbar: [
5961
'imageStyleFull',

tests/ckeditor.js

+47
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe( 'ClassicEditor build', () => {
2020

2121
afterEach( () => {
2222
editorElement.remove();
23+
editor = null;
2324
} );
2425

2526
describe( 'buid', () => {
@@ -82,6 +83,17 @@ describe( 'ClassicEditor build', () => {
8283
} );
8384

8485
describe( 'plugins', () => {
86+
beforeEach( () => {
87+
return ClassicEditor.create( editorElement )
88+
.then( newEditor => {
89+
editor = newEditor;
90+
} );
91+
} );
92+
93+
afterEach( () => {
94+
return editor.destroy();
95+
} );
96+
8597
it( 'paragraph works', () => {
8698
const data = '<p>Some text inside a paragraph.</p>';
8799

@@ -153,4 +165,39 @@ describe( 'ClassicEditor build', () => {
153165
expect( editor.getData() ).to.equal( data );
154166
} );
155167
} );
168+
169+
describe( 'config', () => {
170+
afterEach( () => {
171+
return editor.destroy();
172+
} );
173+
174+
// https://github.com/ckeditor/ckeditor5/issues/572
175+
it( 'allows configure toolbar items through config.toolbar', () => {
176+
return ClassicEditor
177+
.create( editorElement, {
178+
toolbar: [ 'bold' ]
179+
} )
180+
.then( newEditor => {
181+
editor = newEditor;
182+
183+
expect( editor.ui.view.toolbar.items.length ).to.equal( 1 );
184+
} );
185+
} );
186+
187+
// https://github.com/ckeditor/ckeditor5/issues/572
188+
it( 'allows configure toolbar offset without overriding toolbar items', () => {
189+
return ClassicEditor
190+
.create( editorElement, {
191+
toolbar: {
192+
viewportTopOffset: 42
193+
}
194+
} )
195+
.then( newEditor => {
196+
editor = newEditor;
197+
198+
expect( editor.ui.view.toolbar.items.length ).to.equal( 9 );
199+
expect( editor.ui.view.stickyPanel.viewportTopOffset ).to.equal( 42 );
200+
} );
201+
} );
202+
} );
156203
} );

0 commit comments

Comments
 (0)