浏览代码

Fix: The data controller should be initialized in DecoupledEditor.create.

Aleksander Nowodzinski 7 年之前
父节点
当前提交
58a3f5b116

+ 1 - 1
packages/ckeditor5-editor-decoupled/src/decouplededitor.js

@@ -157,7 +157,7 @@ export default class DecoupledEditor extends Editor {
 						editor.fire( 'uiReady' );
 					} )
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.view.editableElement ) )
-					.then( () => editor.data.set( data ) )
+					.then( () => editor.data.init( data ) )
 					.then( () => {
 						editor.fire( 'dataReady' );
 						editor.fire( 'ready' );

+ 27 - 0
packages/ckeditor5-editor-decoupled/tests/decouplededitor.js

@@ -92,6 +92,33 @@ describe( 'DecoupledEditor', () => {
 				} );
 		} );
 
+		// https://github.com/ckeditor/ckeditor5-editor-decoupled/issues/3
+		it( 'initializes the data controller', () => {
+			let dataInitSpy;
+
+			class DataInitAssertPlugin extends Plugin {
+				constructor( editor ) {
+					super();
+
+					this.editor = editor;
+				}
+
+				init() {
+					dataInitSpy = sinon.spy( this.editor.data, 'init' );
+				}
+			}
+
+			return DecoupledEditor
+				.create( editorData, {
+					plugins: [ Paragraph, Bold, DataInitAssertPlugin ]
+				} )
+				.then( newEditor => {
+					sinon.assert.calledOnce( dataInitSpy );
+
+					return newEditor.destroy();
+				} );
+		} );
+
 		describe( 'ui', () => {
 			it( 'attaches editable UI as view\'s DOM root', () => {
 				expect( editor.editing.view.getDomRoot() ).to.equal( editor.ui.view.editable.element );