Преглед изворни кода

Implemented body region and a base EditorUIView.

Piotrek Koszuliński пре 10 година
родитељ
комит
6973828e41

+ 10 - 6
packages/ckeditor5-ui/src/editorui.js → packages/ckeditor5-ui/src/editorui/editorui.js

@@ -5,15 +5,17 @@
 
 'use strict';
 
-import Controller from './ui/controller.js';
-import utils from './utils.js';
-import ObservableMixin from './observablemixin.js';
-import ComponentFactory from './ui/componentfactory.js';
+import Controller from '../ui/controller.js';
+import ControllerCollection from '../ui/controllercollection.js';
+import ComponentFactory from '../ui/componentfactory.js';
+import ObservableMixin from '../observablemixin.js';
+import utils from '../utils.js';
 
 /**
  * Base class for the editor main view controllers.
  *
  * @memberOf core
+ * @class core.editorui.EditorUI
  * @extends core.ui.Controller
  * @mixes core.ObservableMixin
  */
@@ -24,15 +26,17 @@ export default class EditorUI extends Controller {
 
 		/**
 		 * @readonly
-		 * @member {core.Editor} core.EditorUI.editor
+		 * @member {core.Editor} core.EditorUI#editor
 		 */
 		this.editor = editor;
 
 		/**
 		 * @readonly
-		 * @type {core.ui.ComponentFactory}
+		 * @member {core.ui.ComponentFactory} core.EditorUI#featureComponents
 		 */
 		this.featureComponents = new ComponentFactory( editor );
+
+		this.collections.add( new ControllerCollection( 'body' ) );
 	}
 }
 

+ 56 - 0
packages/ckeditor5-ui/src/editorui/editoruiview.js

@@ -0,0 +1,56 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import View from '../ui/view.js';
+
+/**
+ * Base class for the editor main views.
+ *
+ * @class core.editorui.EditorUIView
+ * @extends core.ui.View
+ */
+
+export default class EditorUIView extends View {
+	constructor( model ) {
+		super( model );
+
+		this._createBodyRegion();
+
+		/**
+		 * The element holding elements of the 'body' region.
+		 *
+		 * @private
+		 * @type HTMLElement
+		 * @property _bodyRegionContainer
+		 */
+	}
+
+	destroy() {
+		this._bodyRegionContainer.remove();
+		this._bodyRegionContainer = null;
+	}
+
+	/**
+	 * Creates and appends to `<body>` the 'body' region container.
+	 *
+	 * @private
+	 */
+	_createBodyRegion() {
+		const bodyElement = document.createElement( 'div' );
+		document.body.appendChild( bodyElement );
+
+		this.applyTemplateToElement( bodyElement, {
+			attributes: {
+				class: 'ck-body'
+			}
+		} );
+
+		this._bodyRegionContainer = bodyElement;
+
+		this.register( 'body', () => bodyElement );
+	}
+}

+ 1 - 1
packages/ckeditor5-ui/src/ui/toolbar/toolbarview.js

@@ -27,7 +27,7 @@ export default class ToolbarView extends View {
 		this.template = {
 			tag: 'div',
 			attributes: {
-				class: 'ck-toolbar'
+				class: [ 'ck-toolbar' ]
 			}
 		};
 

+ 1 - 1
packages/ckeditor5-ui/tests/editorui.js → packages/ckeditor5-ui/tests/editorui/editorui.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import Editor from '/ckeditor5/core/editor.js';
-import EditorUI from '/ckeditor5/core/editorui.js';
+import EditorUI from '/ckeditor5/core/editorui/editorui.js';
 
 describe( 'EditorUI', () => {
 	let editor, editorUI;