瀏覽代碼

Fix: It will be possible to configure toolbar offset without overriding preconfigured toolbar items. See ckeditor/ckeditor5#572.

Piotrek Koszuliński 8 年之前
父節點
當前提交
8299761e87

+ 13 - 11
packages/ckeditor5-build-classic/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' ]

+ 13 - 11
packages/ckeditor5-build-classic/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',

+ 47 - 0
packages/ckeditor5-build-classic/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 = '<p>Some text inside a paragraph.</p>';
 
@@ -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 );
+				} );
+		} );
+	} );
 } );