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

Commit

Permalink
Merge pull request #46 from ckeditor/t/ckeditor5/1477
Browse files Browse the repository at this point in the history
Other: Adjustments to new editor initialization 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.
  • Loading branch information
Piotr Jasiun authored Jan 29, 2019
2 parents 4108ddc + b8615c9 commit 9536767
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
5 changes: 1 addition & 4 deletions src/inlineeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ export default class InlineEditor extends Editor {

return editor.data.init( initialData );
} )
.then( () => {
editor.fire( 'dataReady' );
editor.fire( 'ready' );
} )
.then( () => editor.fire( 'ready' ) )
.then( () => editor )
);
} );
Expand Down
30 changes: 4 additions & 26 deletions tests/inlineeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,13 @@ describe( 'InlineEditor', () => {
const fired = [];

function spy( evt ) {
fired.push( evt.name );
fired.push( `${ evt.name }-${ evt.source.constructor.name.toLowerCase() }` );
}

class EventWatcher extends Plugin {
init() {
this.editor.on( 'pluginsReady', spy );
this.editor.ui.on( 'ready', spy );
this.editor.on( 'dataReady', spy );
this.editor.data.on( 'ready', spy );
this.editor.on( 'ready', spy );
}
}
Expand All @@ -209,29 +208,8 @@ describe( 'InlineEditor', () => {
plugins: [ EventWatcher ]
} )
.then( newEditor => {
expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] );

editor = newEditor;
} );
} );

it( 'fires dataReady once data is loaded', () => {
let data;

class EventWatcher extends Plugin {
init() {
this.editor.on( 'dataReady', () => {
data = this.editor.getData();
} );
}
}

return InlineEditor
.create( editorElement, {
plugins: [ EventWatcher, Paragraph, Bold ]
} )
.then( newEditor => {
expect( data ).to.equal( '<p><strong>foo</strong> bar</p>' );
expect( fired ).to.deep.equal( [
'ready-inlineeditorui', 'ready-datacontroller', 'ready-inlineeditor' ] );

editor = newEditor;
} );
Expand Down
1 change: 0 additions & 1 deletion tests/inlineeditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ class VirtualInlineTestEditor extends VirtualTestEditor {
editor.initPlugins()
.then( () => {
editor.ui.init();
editor.fire( 'dataReady' );
editor.fire( 'ready' );
} )
.then( () => editor )
Expand Down

0 comments on commit 9536767

Please sign in to comment.