8
0
Piotrek Koszuliński 5 лет назад
Родитель
Сommit
926ce8f190

+ 1 - 1
packages/ckeditor5-engine/src/controller/datacontroller.js

@@ -47,7 +47,7 @@ export default class DataController {
 	 * Creates a data controller instance.
 	 *
 	 * @param {module:engine/model/model~Model} model Data model.
-	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
+	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
 	 */
 	constructor( model, stylesProcessor ) {
 		/**

+ 1 - 1
packages/ckeditor5-engine/src/controller/editingcontroller.js

@@ -31,7 +31,7 @@ export default class EditingController {
 	 * Creates an editing controller instance.
 	 *
 	 * @param {module:engine/model/model~Model} model Editing model.
-	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
+	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
 	 */
 	constructor( model, stylesProcessor ) {
 		/**

+ 1 - 1
packages/ckeditor5-engine/src/view/document.js

@@ -24,7 +24,7 @@ export default class Document {
 	/**
 	 * Creates a Document instance.
 	 *
-	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
+	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
 	 */
 	constructor( stylesProcessor ) {
 		/**

+ 3 - 3
packages/ckeditor5-engine/src/view/element.js

@@ -48,9 +48,9 @@ export default class Element extends Node {
 	 *
 	 * Attributes can be passed in various formats:
 	 *
-	 *		new Element( 'div', { class: 'editor', contentEditable: 'true' } ); // object
-	 *		new Element( 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
-	 *		new Element( 'div', mapOfAttributes ); // map
+	 *		new Element( viewDocument, 'div', { class: 'editor', contentEditable: 'true' } ); // object
+	 *		new Element( viewDocument, 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
+	 *		new Element( viewDocument, 'div', mapOfAttributes ); // map
 	 *
 	 * @protected
 	 * @param {module:engine/view/document~Document} document The document instance to which this element belongs.

+ 7 - 6
packages/ckeditor5-engine/src/view/node.js

@@ -17,11 +17,11 @@ import { clone } from 'lodash-es';
 import '@ckeditor/ckeditor5-utils/src/version';
 
 /**
- * Abstract tree view node class.
+ * Abstract view node class.
  *
  * This is an abstract class. Its constructor should not be used directly.
- * Use the {@link module:engine/view/element~Element} class to create view elements
- * or {@link module:engine/view/text~Text} class to create view text nodes.
+ * Use the {@link module:engine/view/downcastwriter~DowncastWriter} or {@link module:engine/view/upcastwriter~UpcastWriter}
+ * to create new instances of view nodes.
  *
  * @abstract
  */
@@ -29,11 +29,12 @@ export default class Node {
 	/**
 	 * Creates a tree view node.
 	 *
-	 * @param {module:engine/view/document~Document} document A document where the node belongs to.
+	 * @protected
+	 * @param {module:engine/view/document~Document} document The document instance to which this node belongs.
 	 */
 	constructor( document ) {
 		/**
-		 * A document where the node belongs to.
+		 * The document instance to which this node belongs.
 		 *
 		 * @readonly
 		 * @member {module:engine/view/document~Document}
@@ -119,7 +120,7 @@ export default class Node {
 	}
 
 	/**
-	 * Returns true if a node is in a tree rooted in an element of the root type.
+	 * Returns true if the node is in a tree rooted in the document (is a descendant of one of its roots).
 	 *
 	 * @returns {Boolean}
 	 */

+ 6 - 7
packages/ckeditor5-engine/src/view/placeholder.js

@@ -140,20 +140,19 @@ export function hidePlaceholder( writer, element ) {
  * {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`} in that case or make
  * sure the correct element is passed to the helper.
  *
- * @param {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment} elementOrDocumentFragment
+ * @param {module:engine/view/element~Element} element
  * @returns {Boolean}
  */
-export function needsPlaceholder( elementOrDocumentFragment ) {
-	// TODO: How to check whether the element was removed from the document?
-	if ( elementOrDocumentFragment.root.is( 'documentFragment' ) ) {
+export function needsPlaceholder( element ) {
+	if ( !element.isAttached() ) {
 		return false;
 	}
 
 	// The element is empty only as long as it contains nothing but uiElements.
-	const isEmptyish = !Array.from( elementOrDocumentFragment.getChildren() )
+	const isEmptyish = !Array.from( element.getChildren() )
 		.some( element => !element.is( 'uiElement' ) );
 
-	const doc = elementOrDocumentFragment.document;
+	const doc = element.document;
 
 	// If the element is empty and the document is blurred.
 	if ( !doc.isFocused && isEmptyish ) {
@@ -164,7 +163,7 @@ export function needsPlaceholder( elementOrDocumentFragment ) {
 	const selectionAnchor = viewSelection.anchor;
 
 	// If document is focused and the element is empty but the selection is not anchored inside it.
-	if ( isEmptyish && selectionAnchor && selectionAnchor.parent !== elementOrDocumentFragment ) {
+	if ( isEmptyish && selectionAnchor && selectionAnchor.parent !== element ) {
 		return true;
 	}
 

+ 2 - 2
packages/ckeditor5-engine/src/view/text.js

@@ -12,7 +12,7 @@ import Node from './node';
 /**
  * Tree view text node.
  *
- * The constructor of this class shouldn't be used directly. To create new Text instances
+ * The constructor of this class should not be used directly. To create a new text node instance
  * use the {@link module:engine/view/downcastwriter~DowncastWriter#createText `DowncastWriter#createText()`}
  * method when working on data downcasted from the model or the
  * {@link module:engine/view/upcastwriter~UpcastWriter#createText `UpcastWriter#createText()`}
@@ -25,7 +25,7 @@ export default class Text extends Node {
 	 * Creates a tree view text node.
 	 *
 	 * @protected
-	 * @param {module:engine/view/document~Document} document A document where the text belongs to.
+	 * @param {module:engine/view/document~Document} document The document instance to which this text node belongs.
 	 * @param {String} data The text's data.
 	 */
 	constructor( document, data ) {

+ 3 - 1
packages/ckeditor5-engine/src/view/upcastwriter.js

@@ -36,10 +36,12 @@ import Selection from './selection';
  */
 export default class UpcastWriter {
 	/**
-	 * @param {module:engine/view/document~Document} document
+	 * @param {module:engine/view/document~Document} document The view document instance in which this upcast writer operates.
 	 */
 	constructor( document ) {
 		/**
+		 * The view document instance in which this upcast writer operates.
+		 *
 		 * @readonly
 		 * @type {module:engine/view/document~Document}
 		 */

+ 1 - 1
packages/ckeditor5-engine/src/view/view.js

@@ -63,7 +63,7 @@ import env from '@ckeditor/ckeditor5-utils/src/env';
  */
 export default class View {
 	/**
-	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
+	 * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
 	 */
 	constructor( stylesProcessor ) {
 		/**