Преглед на файлове

Fixed: Error thrown in ClassicEditorUIView if there's no toolbar config defined.

Aleksander Nowodziński преди 9 години
родител
ревизия
3b844497a3
променени са 2 файла, в които са добавени 8 реда и са изтрити 4 реда
  1. 6 2
      packages/ckeditor5-editor-classic/src/classiceditoruiview.js
  2. 2 2
      packages/ckeditor5-editor-classic/tests/classic.js

+ 6 - 2
packages/ckeditor5-editor-classic/src/classiceditoruiview.js

@@ -46,8 +46,12 @@ export default class ClassicEditorUIView extends BoxedEditorUIView {
 	init() {
 		this.toolbar.limiterElement = this.element;
 
-		for ( let name of this.editor.config.get( 'toolbar' ) ) {
-			this.toolbar.items.add( this.featureComponents.create( name ) );
+		const toolbarConfig = this.editor.config.get( 'toolbar' );
+
+		if ( toolbarConfig ) {
+			for ( let name of toolbarConfig ) {
+				this.toolbar.items.add( this.featureComponents.create( name ) );
+			}
 		}
 
 		return super.init();

+ 2 - 2
packages/ckeditor5-editor-classic/tests/classic.js

@@ -71,11 +71,11 @@ describe( 'ClassicEditor', () => {
 		} );
 
 		it( 'inserts editor UI next to editor element', () => {
-			expect( editor.ui.view.element.previousSibling ).to.equal( editorElement );
+			expect( editor.ui.element.previousSibling ).to.equal( editorElement );
 		} );
 
 		it( 'attaches editable UI as view\'s DOM root', () => {
-			expect( editor.editing.view.getDomRoot() ).to.equal( editor.ui.editable.view.element );
+			expect( editor.editing.view.getDomRoot() ).to.equal( editor.ui.editable.element );
 		} );
 
 		it( 'loads data from the editor element', () => {