|
|
@@ -4,7 +4,7 @@
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * @module ui/editorui/BodyCollection
|
|
|
+ * @module ui/editorui/bodycollection
|
|
|
*/
|
|
|
|
|
|
/* globals document */
|
|
|
@@ -14,8 +14,35 @@ import ViewCollection from '../viewcollection';
|
|
|
|
|
|
import createElement from '@ckeditor/ckeditor5-utils/src/dom/createelement';
|
|
|
|
|
|
+/**
|
|
|
+ * This is the special {@link module:ui/viewcollection~ViewCollection ViewCollection} dedicated to elements that are detached
|
|
|
+ * from the DOM structure of the editor, like panels, icons, etc.
|
|
|
+ *
|
|
|
+ * CKEditor creates the body collection as {@link module:ui/editorui/editoruiview~EditorUIView#body editor.ui.view.body} property.
|
|
|
+ * Any plugin can add a {@link module:ui/view~View view} to this collection. The editor will detach and destroy this collection
|
|
|
+ * when the editor will be {@link module:core/editor/editor~Editor#destroy destroyed}.
|
|
|
+ *
|
|
|
+ * If you need to control the live cycle of the body collection on your own, you can create your own instance of this class.
|
|
|
+ *
|
|
|
+ * Body collection will render itself automatically in the DOM body element as soon as you call {@link ~BodyCollection#attachToDOM}.
|
|
|
+ * If you create multiple body collections this class will create a special wrapper element in the DOM to limit the number of
|
|
|
+ * elements created directly in the body and remove it when the last body collection will be
|
|
|
+ * {@link ~BodyCollection#detachFromDOM detached}.
|
|
|
+ *
|
|
|
+ * @extends module:ui/viewcollection~ViewCollection
|
|
|
+ */
|
|
|
export default class BodyCollection extends ViewCollection {
|
|
|
+ /**
|
|
|
+ * Attaches the body collection to the DOM body element. You need to execute this method to render the content of
|
|
|
+ * the body collection.
|
|
|
+ */
|
|
|
attachToDOM() {
|
|
|
+ /**
|
|
|
+ * The element holding elements of the 'body' region.
|
|
|
+ *
|
|
|
+ * @protected
|
|
|
+ * @member {HTMLElement} #_bodyCollectionContainer
|
|
|
+ */
|
|
|
this._bodyCollectionContainer = new Template( {
|
|
|
tag: 'div',
|
|
|
attributes: {
|
|
|
@@ -40,6 +67,10 @@ export default class BodyCollection extends ViewCollection {
|
|
|
wrapper.appendChild( this._bodyCollectionContainer );
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Detach the collection from the DOM structure. Use this method when you do not need to use the body collection
|
|
|
+ * anymore to clean-up the DOM structure.
|
|
|
+ */
|
|
|
detachFromDOM() {
|
|
|
super.destroy();
|
|
|
|