Browse Source

Docs fixes, renaming isTopLevelNode to isContainerLikeNode function in view writer.

Szymon Kupś 9 năm trước cách đây
mục cha
commit
7708d7e3c9

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

@@ -14,7 +14,8 @@ import isPlainObject from '../../utils/lib/lodash/isPlainObject.js';
  *
  * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.view.Element} need to
  * be defined by the feature developer. Creating an element you should use {@link engine.view.ContainerElement}
- * class, {@link engine.view.AttributeElement} class or {@link engine.view.EmptyElement} class.
+ * class, {@link engine.view.AttributeElement} class, {@link engine.view.EmptyElement} class or
+ * {@link engine.view.WidgetElement} class.
  *
  * Note that for view elements which are not created from model, like elements from mutations, paste or
  * {@link engine.controller.DataController#set data.set} it is not possible to define the type of the element, so

+ 6 - 6
packages/ckeditor5-engine/src/view/writer.js

@@ -190,7 +190,7 @@ export function mergeAttributes( position ) {
 	}
 
 	// When one or both nodes are top-level nodes - no attributes to merge.
-	if ( isTopLevelNode( nodeBefore ) || isTopLevelNode( nodeAfter ) ) {
+	if ( isContainerLikeNode( nodeBefore ) || isContainerLikeNode( nodeAfter ) ) {
 		return position;
 	}
 
@@ -598,7 +598,7 @@ export function rename( viewElement, newName ) {
 function getParentContainer( position ) {
 	let parent = position.parent;
 
-	while ( !isTopLevelNode( parent ) ) {
+	while ( !isContainerLikeNode( parent ) ) {
 		if ( !parent ) {
 			return undefined;
 		}
@@ -665,12 +665,12 @@ function _breakAttributes( position, forceSplitText = false ) {
 	}
 
 	// There are no attributes to break and text nodes breaking is not forced.
-	if ( !forceSplitText && positionParent instanceof Text && isTopLevelNode( positionParent.parent ) ) {
+	if ( !forceSplitText && positionParent instanceof Text && isContainerLikeNode( positionParent.parent ) ) {
 		return Position.createFromPosition( position );
 	}
 
 	// Position's parent is container, so no attributes to break.
-	if ( isTopLevelNode( positionParent ) ) {
+	if ( isContainerLikeNode( positionParent ) ) {
 		return Position.createFromPosition( position );
 	}
 
@@ -1083,12 +1083,12 @@ function validateNodesToInsert( nodes ) {
 	}
 }
 
-// Checks if node is top-level node. It might be ContainerElement, DocumentFragment or WidgetElement,
+// Checks if node is container-like. It might be ContainerElement, DocumentFragment or WidgetElement,
 // because in most cases they should be treated the same way.
 //
 // @param {engine.view.Node} node
 // @returns {Boolean} Returns `true` if node is instance of ContainerElement, DocumentFragment or WidgetElement.
-function isTopLevelNode( node ) {
+function isContainerLikeNode( node ) {
 	return node instanceof ContainerElement || node instanceof DocumentFragment || node instanceof WidgetElement;
 }