8
0
فهرست منبع

Adjust to changes in `core/EditorWithUI`.

Krzysztof Krztoń 7 سال پیش
والد
کامیت
5eb353fc93

+ 4 - 1
packages/ckeditor5-editor-balloon/src/ballooneditor.js

@@ -18,6 +18,7 @@ import DataApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/dataapimixin
 import ElementApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/elementapimixin';
 import ElementApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/elementapimixin';
 import attachToForm from '@ckeditor/ckeditor5-core/src/editor/utils/attachtoform';
 import attachToForm from '@ckeditor/ckeditor5-core/src/editor/utils/attachtoform';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
+import log from '@ckeditor/ckeditor5-utils/src/log';
 import { isElement } from 'lodash-es';
 import { isElement } from 'lodash-es';
 
 
 /**
 /**
@@ -86,7 +87,8 @@ export default class BalloonEditor extends Editor {
 	 * @inheritDoc
 	 * @inheritDoc
 	 */
 	 */
 	get element() {
 	get element() {
-		return this.ui.view.editable.element;
+		log.warn( 'deprecated-editor-element: The editor#element is deprecated.' );
+		return this.ui.element;
 	}
 	}
 
 
 	/**
 	/**
@@ -189,6 +191,7 @@ export default class BalloonEditor extends Editor {
 				editor.initPlugins()
 				editor.initPlugins()
 					.then( () => {
 					.then( () => {
 						editor.ui.init();
 						editor.ui.init();
+						editor.ui.ready();
 						editor.fire( 'uiReady' );
 						editor.fire( 'uiReady' );
 					} )
 					} )
 					.then( () => {
 					.then( () => {

+ 7 - 0
packages/ckeditor5-editor-balloon/src/ballooneditorui.js

@@ -16,6 +16,13 @@ import enableToolbarKeyboardFocus from '@ckeditor/ckeditor5-ui/src/toolbar/enabl
  * @extends module:core/editor/editorui~EditorUI
  * @extends module:core/editor/editorui~EditorUI
  */
  */
 export default class BalloonEditorUI extends EditorUI {
 export default class BalloonEditorUI extends EditorUI {
+	/**
+	 * @inheritDoc
+	 */
+	get element() {
+		return this.view.editable.element;
+	}
+
 	/**
 	/**
 	 * Initializes the UI.
 	 * Initializes the UI.
 	 */
 	 */

+ 27 - 1
packages/ckeditor5-editor-balloon/tests/ballooneditor.js

@@ -20,6 +20,7 @@ import ElementApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/elementap
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+import log from '@ckeditor/ckeditor5-utils/src/log';
 
 
 describe( 'BalloonEditor', () => {
 describe( 'BalloonEditor', () => {
 	let editor, editorElement;
 	let editor, editorElement;
@@ -31,6 +32,8 @@ describe( 'BalloonEditor', () => {
 		editorElement.innerHTML = '<p><strong>foo</strong> bar</p>';
 		editorElement.innerHTML = '<p><strong>foo</strong> bar</p>';
 
 
 		document.body.appendChild( editorElement );
 		document.body.appendChild( editorElement );
+
+		testUtils.sinon.stub( log, 'warn' ).callsFake( () => {} );
 	} );
 	} );
 
 
 	afterEach( () => {
 	afterEach( () => {
@@ -211,6 +214,7 @@ describe( 'BalloonEditor', () => {
 			class EventWatcher extends Plugin {
 			class EventWatcher extends Plugin {
 				init() {
 				init() {
 					this.editor.on( 'pluginsReady', spy );
 					this.editor.on( 'pluginsReady', spy );
+					this.editor.ui.on( 'ready', spy );
 					this.editor.on( 'uiReady', spy );
 					this.editor.on( 'uiReady', spy );
 					this.editor.on( 'dataReady', spy );
 					this.editor.on( 'dataReady', spy );
 					this.editor.on( 'ready', spy );
 					this.editor.on( 'ready', spy );
@@ -222,7 +226,7 @@ describe( 'BalloonEditor', () => {
 					plugins: [ EventWatcher ]
 					plugins: [ EventWatcher ]
 				} )
 				} )
 				.then( newEditor => {
 				.then( newEditor => {
-					expect( fired ).to.deep.equal( [ 'pluginsReady', 'uiReady', 'dataReady', 'ready' ] );
+					expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'uiReady', 'dataReady', 'ready' ] );
 
 
 					editor = newEditor;
 					editor = newEditor;
 				} );
 				} );
@@ -271,6 +275,28 @@ describe( 'BalloonEditor', () => {
 					editor = newEditor;
 					editor = newEditor;
 				} );
 				} );
 		} );
 		} );
+
+		it( 'fires ready once UI is ready', () => {
+			let isRendered;
+
+			class EventWatcher extends Plugin {
+				init() {
+					this.editor.ui.on( 'ready', () => {
+						isRendered = this.editor.ui.view.isRendered;
+					} );
+				}
+			}
+
+			return BalloonEditor
+				.create( editorElement, {
+					plugins: [ EventWatcher ]
+				} )
+				.then( newEditor => {
+					expect( isRendered ).to.be.true;
+
+					editor = newEditor;
+				} );
+		} );
 	} );
 	} );
 
 
 	describe( 'destroy()', () => {
 	describe( 'destroy()', () => {

+ 1 - 0
packages/ckeditor5-editor-balloon/tests/ballooneditorui.js

@@ -147,6 +147,7 @@ class VirtualBalloonTestEditor extends VirtualTestEditor {
 				editor.initPlugins()
 				editor.initPlugins()
 					.then( () => {
 					.then( () => {
 						editor.ui.init();
 						editor.ui.init();
+						editor.ui.ready();
 						editor.fire( 'uiReady' );
 						editor.fire( 'uiReady' );
 						editor.fire( 'dataReady' );
 						editor.fire( 'dataReady' );
 						editor.fire( 'ready' );
 						editor.fire( 'ready' );