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

Commit 3bb0e40

Browse files
author
Piotr Jasiun
authored
Merge pull request #26 from ckeditor/t/ckeditor5/1477
Other: Adjustments to new editor initialisation events. BREAKING CHANGE: The `editor#dataReady` event was removed. The `editor.data#ready` event has been introduced and should be used instead. BREAKING CHANGE: The `editor#pluginsReady` event was removed. Use plugin `afterInit()` method instead.
2 parents 2b861b9 + 9c72a3f commit 3bb0e40

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

src/decouplededitor.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,7 @@ export default class DecoupledEditor extends Editor {
197197

198198
return editor.data.init( initialData );
199199
} )
200-
.then( () => {
201-
editor.fire( 'dataReady' );
202-
editor.fire( 'ready' );
203-
} )
200+
.then( () => editor.fire( 'ready' ) )
204201
.then( () => editor )
205202
);
206203
} );

tests/decouplededitor.js

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ describe( 'DecoupledEditor', () => {
7070

7171
class AsyncDataInit extends Plugin {
7272
init() {
73-
this.editor.on( 'dataReady', () => spy( 'dataReady' ) );
73+
this.editor.data.on( 'ready', () => spy( 'ready' ) );
7474

7575
this.editor.data.on( 'init', evt => {
7676
evt.stop();
7777
evt.return = new Promise( resolve => {
7878
resolver = () => {
7979
spy( 'asyncInit' );
80+
// Since we stop `init` event, `data#ready` needs to be fired manually.
81+
this.editor.data.fire( 'ready' );
8082
resolve();
8183
};
8284
} );
@@ -88,7 +90,7 @@ describe( 'DecoupledEditor', () => {
8890
plugins: [ Paragraph, Bold, AsyncDataInit ]
8991
} ).then( editor => {
9092
sinon.assert.calledWith( spy.firstCall, 'asyncInit' );
91-
sinon.assert.calledWith( spy.secondCall, 'dataReady' );
93+
sinon.assert.calledWith( spy.secondCall, 'ready' );
9294

9395
editor.destroy().then( done );
9496
} );
@@ -187,14 +189,13 @@ describe( 'DecoupledEditor', () => {
187189
const fired = [];
188190

189191
function spy( evt ) {
190-
fired.push( evt.name );
192+
fired.push( `${ evt.name }-${ evt.source.constructor.name.toLowerCase() }` );
191193
}
192194

193195
class EventWatcher extends Plugin {
194196
init() {
195-
this.editor.on( 'pluginsReady', spy );
196197
this.editor.ui.on( 'ready', spy );
197-
this.editor.on( 'dataReady', spy );
198+
this.editor.data.on( 'ready', spy );
198199
this.editor.on( 'ready', spy );
199200
}
200201
}
@@ -204,29 +205,11 @@ describe( 'DecoupledEditor', () => {
204205
plugins: [ EventWatcher ]
205206
} )
206207
.then( newEditor => {
207-
expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] );
208-
209-
return newEditor.destroy();
210-
} );
211-
} );
212-
213-
it( 'fires dataReady once data is loaded', () => {
214-
let data;
215-
216-
class EventWatcher extends Plugin {
217-
init() {
218-
this.editor.on( 'dataReady', () => {
219-
data = this.editor.getData();
220-
} );
221-
}
222-
}
223-
224-
return DecoupledEditor
225-
.create( getElementOrData(), {
226-
plugins: [ EventWatcher, Paragraph, Bold ]
227-
} )
228-
.then( newEditor => {
229-
expect( data ).to.equal( '<p><strong>foo</strong> bar</p>' );
208+
expect( fired ).to.deep.equal( [
209+
'ready-decouplededitorui',
210+
'ready-datacontroller',
211+
'ready-decouplededitor'
212+
] );
230213

231214
return newEditor.destroy();
232215
} );

tests/decouplededitorui.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ class VirtualDecoupledTestEditor extends VirtualTestEditor {
209209
editor.initPlugins()
210210
.then( () => {
211211
editor.ui.init();
212-
editor.fire( 'dataReady' );
213212
editor.fire( 'ready' );
214213
} )
215214
.then( () => editor )

0 commit comments

Comments
 (0)