diff --git a/src/decouplededitor.js b/src/decouplededitor.js index eef5c2c..aaf55b9 100644 --- a/src/decouplededitor.js +++ b/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' ); diff --git a/tests/decouplededitor.js b/tests/decouplededitor.js index 433f5a9..b96d651 100644 --- a/tests/decouplededitor.js +++ b/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 );