8
0
Просмотр исходного кода

Adjustments to new `data#ready` event.

Krzysztof Krztoń 7 лет назад
Родитель
Сommit
77b289ee09

+ 3 - 9
packages/ckeditor5-core/src/editor/editor.js

@@ -297,7 +297,8 @@ export default class Editor {
 			resolve(
 				editor.initPlugins()
 					.then( () => {
-						editor.fire( 'dataReady' );
+						// Fire `data#ready` event manually as `data#init()` method is not used.
+						editor.data.fire( 'ready' );
 						editor.fire( 'ready' );
 					} )
 					.then( () => editor )
@@ -308,16 +309,9 @@ export default class Editor {
 
 mix( Editor, ObservableMixin );
 
-/**
- * Fired when the data loaded to the editor is ready. If a specific editor doesn't load
- * any data initially, this event will be fired right before {@link #event:ready}.
- *
- * @event dataReady
- */
-
 /**
  * Fired when {@link module:core/plugincollection~PluginCollection#event:ready plugins},
- * and {@link #event:dataReady data} and all additional editor components are ready.
+ * and {@link module:engine/controller/datacontroller~DataController#event:ready data} and all additional editor components are ready.
  *
  * Note: This event is most useful for plugin developers. When integrating the editor with your website or
  * application you do not have to listen to `editor#ready` because when the promise returned by the static

+ 1 - 1
packages/ckeditor5-core/src/editor/editorui.js

@@ -126,7 +126,7 @@ export default class EditorUI {
 	 * Fired when the editor UI is ready.
 	 *
 	 * Fired after {@link module:core/plugincollection~PluginCollection#event:ready} and before
-	 * {@link module:core/editor/editor~Editor#event:dataReady}.
+	 * {@link module:engine/controller/datacontroller~DataController#event:ready}.
 	 *
 	 * @event ready
 	 */

+ 1 - 1
packages/ckeditor5-core/src/plugin.js

@@ -70,7 +70,7 @@ mix( Plugin, ObservableMixin );
  *				// `listenTo()` and `editor` are available thanks to `Plugin`.
  *				// By using `listenTo()` you will ensure that the listener is removed when
  *				// the plugin is destroyed.
- *				this.listenTo( this.editor, 'dataReady', () => {
+ *				this.listenTo( this.editor.data, 'ready', () => {
  *					// Do something when the data is ready.
  *				} );
  *			}

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -123,7 +123,7 @@ describe( 'ClassicTestEditor', () => {
 				init() {
 					this.editor.plugins.on( 'ready', spy );
 					this.editor.ui.on( 'ready', spy );
-					this.editor.on( 'dataReady', spy );
+					this.editor.data.on( 'ready', spy );
 					this.editor.on( 'ready', spy );
 				}
 			}
@@ -136,7 +136,7 @@ describe( 'ClassicTestEditor', () => {
 					expect( fired ).to.deep.equal( [
 						'ready-plugincollection',
 						'ready-classictesteditorui',
-						'dataReady-classictesteditor',
+						'ready-datacontroller',
 						'ready-classictesteditor'
 					] );
 

+ 0 - 1
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -66,7 +66,6 @@ export default class ClassicTestEditor extends Editor {
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.getEditableElement() ) )
 					.then( () => editor.data.init( getDataFromElement( element ) ) )
 					.then( () => {
-						editor.fire( 'dataReady' );
 						editor.state = 'ready';
 						editor.fire( 'ready' );
 					} )

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

@@ -386,14 +386,14 @@ describe( 'Editor', () => {
 			class EventWatcher extends Plugin {
 				init() {
 					this.editor.plugins.on( 'ready', spy );
-					this.editor.on( 'dataReady', spy );
+					this.editor.data.on( 'ready', spy );
 					this.editor.on( 'ready', spy );
 				}
 			}
 
 			return Editor.create( { plugins: [ EventWatcher ] } )
 				.then( () => {
-					expect( fired ).to.deep.equal( [ 'ready-plugincollection', 'dataReady-editor', 'ready-editor' ] );
+					expect( fired ).to.deep.equal( [ 'ready-plugincollection', 'ready-datacontroller', 'ready-editor' ] );
 				} );
 		} );
 	} );