Krzysztof Krztoń пре 7 година
родитељ
комит
d9da48a823

+ 0 - 11
packages/ckeditor5-editor-decoupled/src/decouplededitor.js

@@ -15,7 +15,6 @@ import DecoupledEditorUIView from './decouplededitoruiview';
 import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromelement';
 import setDataInElement from '@ckeditor/ckeditor5-utils/src/dom/setdatainelement';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
-import log from '@ckeditor/ckeditor5-utils/src/log';
 import { isElement } from 'lodash-es';
 
 /**
@@ -77,16 +76,6 @@ export default class DecoupledEditor extends Editor {
 		this.ui = new DecoupledEditorUI( this, new DecoupledEditorUIView( this.locale, this.sourceElement ) );
 	}
 
-	/**
-	 * @inheritDoc
-	 */
-	get element() {
-		log.warn( 'deprecated-editor-element: The editor#element is deprecated.' );
-		// This editor has no single "main UI element". Its editable and toolbar are exposed separately and need
-		// to be added to the DOM manually by the consumer.
-		return null;
-	}
-
 	/**
 	 * Destroys the editor instance, releasing all resources used by it.
 	 *

+ 10 - 1
packages/ckeditor5-editor-decoupled/src/decouplededitorui.js

@@ -71,7 +71,7 @@ export default class DecoupledEditorUI extends EditorUI {
 
 		this._editableElements.set( view.editable.name, view.editable.element );
 
-		this.focusTracker.add( this.view.editable.element );
+		this.focusTracker.add( view.editable.element );
 
 		this.view.toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );
 
@@ -84,4 +84,13 @@ export default class DecoupledEditorUI extends EditorUI {
 
 		this.fire( 'ready' );
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	destroy() {
+		this._view.destroy();
+
+		super.destroy();
+	}
 }

+ 1 - 28
packages/ckeditor5-editor-decoupled/tests/decouplededitor.js

@@ -44,10 +44,6 @@ describe( 'DecoupledEditor', () => {
 			expect( testUtils.isMixed( DecoupledEditor, DataApiMixin ) ).to.be.true;
 		} );
 
-		it( 'implements the EditorWithUI interface', () => {
-			expect( editor.element ).to.be.null;
-		} );
-
 		it( 'creates main root element', () => {
 			expect( editor.model.document.getRoot( 'main' ) ).to.instanceof( RootElement );
 		} );
@@ -195,7 +191,6 @@ describe( 'DecoupledEditor', () => {
 						init() {
 							this.editor.on( 'pluginsReady', spy );
 							this.editor.ui.on( 'ready', spy );
-							this.editor.on( 'uiReady', spy );
 							this.editor.on( 'dataReady', spy );
 							this.editor.on( 'ready', spy );
 						}
@@ -206,7 +201,7 @@ describe( 'DecoupledEditor', () => {
 							plugins: [ EventWatcher ]
 						} )
 						.then( newEditor => {
-							expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'uiReady', 'dataReady', 'ready' ] );
+							expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] );
 
 							return newEditor.destroy();
 						} );
@@ -234,28 +229,6 @@ describe( 'DecoupledEditor', () => {
 						} );
 				} );
 
-				it( 'fires uiReady once UI is rendered', () => {
-					let isReady;
-
-					class EventWatcher extends Plugin {
-						init() {
-							this.editor.on( 'uiReady', () => {
-								isReady = this.editor.ui.view.isRendered;
-							} );
-						}
-					}
-
-					return DecoupledEditor
-						.create( getElementOrData(), {
-							plugins: [ EventWatcher ]
-						} )
-						.then( newEditor => {
-							expect( isReady ).to.be.true;
-
-							return newEditor.destroy();
-						} );
-				} );
-
 				it( 'fires ready once UI is rendered', () => {
 					let isReady;
 

+ 8 - 1
packages/ckeditor5-editor-decoupled/tests/decouplededitorui.js

@@ -17,7 +17,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 describe( 'DecoupledEditorUI', () => {
-	let editor, view, ui;
+	let editor, view, ui, viewElement;
 
 	testUtils.createSinonSandbox();
 
@@ -31,6 +31,7 @@ describe( 'DecoupledEditorUI', () => {
 
 				ui = editor.ui;
 				view = ui.view;
+				viewElement = view.element;
 			} );
 	} );
 
@@ -151,6 +152,12 @@ describe( 'DecoupledEditorUI', () => {
 		} );
 	} );
 
+	describe( 'element()', () => {
+		it( 'returns correct element instance', () => {
+			expect( ui.element ).to.equal( viewElement );
+		} );
+	} );
+
 	describe( 'getEditableElement()', () => {
 		it( 'returns editable element (default)', () => {
 			expect( ui.getEditableElement() ).to.equal( view.editable.element );