Explorar o código

Export body collection to the separate file.

Piotr Jasiun %!s(int64=6) %!d(string=hai) anos
pai
achega
4a4102f108

+ 41 - 0
packages/ckeditor5-ui/src/editorui/bodycollection.js

@@ -0,0 +1,41 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module ui/editorui/BodyCollection
+ */
+
+/* globals document */
+
+import Template from '../template';
+import ViewCollection from '../viewcollection';
+
+export default class BodyCollection extends ViewCollection {
+	render() {
+		this._bodyCollectionContainer = new Template( {
+			tag: 'div',
+			attributes: {
+				class: [
+					'ck',
+					'ck-reset_all',
+					'ck-body',
+					'ck-rounded-corners'
+				],
+				dir: this.locale.uiLanguageDirection,
+			},
+			children: this
+		} ).render();
+
+		document.body.appendChild( this._bodyCollectionContainer );
+	}
+
+	destroy() {
+		super.destroy();
+
+		if ( this._bodyCollectionContainer ) {
+			this._bodyCollectionContainer.remove();
+		}
+	}
+}

+ 4 - 30
packages/ckeditor5-ui/src/editorui/editoruiview.js

@@ -7,10 +7,8 @@
  * @module ui/editorui/editoruiview
  * @module ui/editorui/editoruiview
  */
  */
 
 
-/* globals document */
-
 import View from '../view';
 import View from '../view';
-import Template from '../template';
+import BodyCollection from './bodycollection';
 
 
 import '../../theme/components/editorui/editorui.css';
 import '../../theme/components/editorui/editorui.css';
 
 
@@ -35,7 +33,7 @@ export default class EditorUIView extends View {
 		 * @readonly
 		 * @readonly
 		 * @member {module:ui/viewcollection~ViewCollection} #body
 		 * @member {module:ui/viewcollection~ViewCollection} #body
 		 */
 		 */
-		this.body = this.createCollection();
+		this.body = new BodyCollection( locale );
 
 
 		/**
 		/**
 		 * The element holding elements of the 'body' region.
 		 * The element holding elements of the 'body' region.
@@ -51,39 +49,15 @@ export default class EditorUIView extends View {
 	render() {
 	render() {
 		super.render();
 		super.render();
 
 
-		this._renderBodyCollection();
+		this.body.render();
 	}
 	}
 
 
 	/**
 	/**
 	 * @inheritDoc
 	 * @inheritDoc
 	 */
 	 */
 	destroy() {
 	destroy() {
-		this._bodyCollectionContainer.remove();
+		this.body.destroy();
 
 
 		return super.destroy();
 		return super.destroy();
 	}
 	}
-
-	/**
-	 * Creates and appends to `<body>` the {@link #body} collection container.
-	 *
-	 * @private
-	 */
-	_renderBodyCollection() {
-		const locale = this.locale;
-		const bodyElement = this._bodyCollectionContainer = new Template( {
-			tag: 'div',
-			attributes: {
-				class: [
-					'ck',
-					'ck-reset_all',
-					'ck-body',
-					'ck-rounded-corners'
-				],
-				dir: locale.uiLanguageDirection,
-			},
-			children: this.body
-		} ).render();
-
-		document.body.appendChild( bodyElement );
-	}
 }
 }