8
0
Szymon Cofalik 7 лет назад
Родитель
Сommit
ec6c540ffa

+ 8 - 16
packages/ckeditor5-engine/src/model/liveposition.js

@@ -103,14 +103,10 @@ export default class LivePosition extends Position {
 	 */
 }
 
-/**
- * Binds this `LivePosition` to the {@link module:engine/model/document~Document document} that owns
- * this position's {@link module:engine/model/position~Position#root root}.
- *
- * @ignore
- * @private
- * @method module:engine/model/liveposition~LivePosition.bindWithDocument
- */
+// Binds this `LivePosition` to the {@link module:engine/model/document~Document document} that owns
+// this position's {@link module:engine/model/position~Position#root root}.
+//
+// @private
 function bindWithDocument() {
 	this.listenTo(
 		this.root.document.model,
@@ -128,14 +124,10 @@ function bindWithDocument() {
 	);
 }
 
-/**
- * Updates this position accordingly to the updates applied to the model. Bases on change events.
- *
- * @ignore
- * @private
- * @method transform
- * @param {module:engine/model/operation/operation~Operation} operation Executed operation.
- */
+// Updates this position accordingly to the updates applied to the model. Bases on change events.
+//
+// @private
+// @param {module:engine/model/operation/operation~Operation} operation Executed operation.
 function transform( operation ) {
 	const result = this.getTransformedByOperation( operation );
 

+ 15 - 27
packages/ckeditor5-engine/src/model/liverange.js

@@ -97,18 +97,14 @@ export default class LiveRange extends Range {
 	 * change range.
 	 * @param {Object} data Object with additional information about the change.
 	 * @param {null} data.deletionPosition Due to the nature of this event, this property is always set to `null`. It is passed
-	 * for compatibility with {@link module:engine/model/liverange~LiveRange#event:change:range} event.
+	 * for compatibility with the {@link module:engine/model/liverange~LiveRange#event:change:range} event.
 	 */
 }
 
-/**
- * Binds this `LiveRange` to the {@link module:engine/model/document~Document document}
- * that owns this range's {@link module:engine/model/range~Range#root root}.
- *
- * @ignore
- * @private
- * @method module:engine/model/liverange~LiveRange#bindWithDocument
- */
+// Binds this `LiveRange` to the {@link module:engine/model/document~Document document}
+// that owns this range's {@link module:engine/model/range~Range#root root}.
+//
+// @private
 function bindWithDocument() {
 	this.listenTo(
 		this.root.document.model,
@@ -126,14 +122,10 @@ function bindWithDocument() {
 	);
 }
 
-/**
- * Updates this range accordingly to the updates applied to the model. Bases on change events.
- *
- * @ignore
- * @private
- * @method transform
- * @param {module:engine/model/operation/operation~Operation} operation Executed operation.
- */
+// Updates this range accordingly to the updates applied to the model. Bases on change events.
+//
+// @private
+// @param {module:engine/model/operation/operation~Operation} operation Executed operation.
 function transform( operation ) {
 	// Transform the range by the operation. Join the result ranges if needed.
 	const ranges = this.getTransformedByOperation( operation );
@@ -169,16 +161,12 @@ function transform( operation ) {
 	}
 }
 
-/**
- * Checks whether given operation changes something inside the range (even if it does not change boundaries).
- *
- * @ignore
- * @private
- * @method doesOperationChangeRangeContent
- * @param {module:engine/model/range~Range} range Range to check.
- * @param {module:engine/model/operation/operation~Operation} operation Executed operation.
- * @returns {Boolean}
- */
+// Checks whether given operation changes something inside the range (even if it does not change boundaries).
+//
+// @private
+// @param {module:engine/model/range~Range} range Range to check.
+// @param {module:engine/model/operation/operation~Operation} operation Executed operation.
+// @returns {Boolean}
 function doesOperationChangeRangeContent( range, operation ) {
 	switch ( operation.type ) {
 		case 'insert':

Разница между файлами не показана из-за своего большого размера
+ 388 - 251
packages/ckeditor5-engine/src/model/operation/transform.js


+ 19 - 28
packages/ckeditor5-engine/src/model/operation/utils.js

@@ -200,17 +200,14 @@ export function _normalizeNodes( nodes ) {
 	return normalized;
 }
 
-/**
- * Checks if nodes before and after given index in given element are {@link module:engine/model/text~Text text nodes} and
- * merges them into one node if they have same attributes.
- *
- * Merging is done by removing two text nodes and inserting a new text node containing data from both merged text nodes.
- *
- * @ignore
- * @private
- * @param {module:engine/model/element~Element} element Parent element of nodes to merge.
- * @param {Number} index Index between nodes to merge.
- */
+// Checks if nodes before and after given index in given element are {@link module:engine/model/text~Text text nodes} and
+// merges them into one node if they have same attributes.
+//
+// Merging is done by removing two text nodes and inserting a new text node containing data from both merged text nodes.
+//
+// @private
+// @param {module:engine/model/element~Element} element Parent element of nodes to merge.
+// @param {Number} index Index between nodes to merge.
 function _mergeNodesAtIndex( element, index ) {
 	const nodeBefore = element.getChild( index - 1 );
 	const nodeAfter = element.getChild( index );
@@ -228,14 +225,11 @@ function _mergeNodesAtIndex( element, index ) {
 	}
 }
 
-/**
- * Checks if given position is in a text node, and if so, splits the text node in two text nodes, each of them
- * containing a part of original text node.
- *
- * @ignore
- * @private
- * @param {module:engine/model/position~Position} position Position at which node should be split.
- */
+// Checks if given position is in a text node, and if so, splits the text node in two text nodes, each of them
+// containing a part of original text node.
+//
+// @private
+// @param {module:engine/model/position~Position} position Position at which node should be split.
 function _splitNodeAtPosition( position ) {
 	const textNode = position.textNode;
 	const element = position.parent;
@@ -253,15 +247,12 @@ function _splitNodeAtPosition( position ) {
 	}
 }
 
-/**
- * Checks whether two given nodes have same attributes.
- *
- * @ignore
- * @private
- * @param {module:engine/model/node~Node} nodeA Node to check.
- * @param {module:engine/model/node~Node} nodeB Node to check.
- * @returns {Boolean} `true` if nodes have same attributes, `false` otherwise.
- */
+// Checks whether two given nodes have same attributes.
+//
+// @private
+// @param {module:engine/model/node~Node} nodeA Node to check.
+// @param {module:engine/model/node~Node} nodeB Node to check.
+// @returns {Boolean} `true` if nodes have same attributes, `false` otherwise.
 function _haveSameAttributes( nodeA, nodeB ) {
 	const iteratorA = nodeA.getAttributes();
 	const iteratorB = nodeB.getAttributes();

+ 17 - 7
packages/ckeditor5-engine/src/model/position.js

@@ -226,6 +226,8 @@ export default class Position {
 	/**
 	 * Checks whether this position is before or after given position.
 	 *
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
+	 *
 	 * @param {module:engine/model/position~Position} otherPosition Position to compare with.
 	 * @returns {module:engine/model/position~PositionRelation}
 	 */
@@ -285,7 +287,7 @@ export default class Position {
 	 * Returns a path to this position's parent. Parent path is equal to position {@link module:engine/model/position~Position#path path}
 	 * but without the last item.
 	 *
-	 * This method returns the parent path even if the parent does not exists.
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
 	 *
 	 * @returns {Array.<Number>} Path to the parent.
 	 */
@@ -310,6 +312,8 @@ export default class Position {
 	 * Returns the slice of two position {@link #path paths} which is identical. The {@link #root roots}
 	 * of these two paths must be identical.
 	 *
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
+	 *
 	 * @param {module:engine/model/position~Position} position The second position.
 	 * @returns {Array.<Number>} The common path.
 	 */
@@ -350,6 +354,8 @@ export default class Position {
 	 * Returns a new instance of `Position`, that has same {@link #parent parent} but it's offset
 	 * is shifted by `shift` value (can be a negative value).
 	 *
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
+	 *
 	 * @param {Number} shift Offset shift. Can be a negative value.
 	 * @returns {module:engine/model/position~Position} Shifted position.
 	 */
@@ -365,8 +371,9 @@ export default class Position {
 	/**
 	 * Checks whether this position is after given position.
 	 *
-	 * @see module:engine/model/position~Position#isBefore
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
 	 *
+	 * @see module:engine/model/position~Position#isBefore
 	 * @param {module:engine/model/position~Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if this position is after given position.
 	 */
@@ -402,6 +409,8 @@ export default class Position {
 	 *			// do A.
 	 *		}
 	 *
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
+	 *
 	 * @param {module:engine/model/position~Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if this position is before given position.
 	 */
@@ -412,6 +421,8 @@ export default class Position {
 	/**
 	 * Checks whether this position is equal to given position.
 	 *
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
+	 *
 	 * @param {module:engine/model/position~Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if positions are same.
 	 */
@@ -424,8 +435,6 @@ export default class Position {
 	 * or empty nodes in a range between them. Technically, those positions are not equal but in many cases
 	 * they are very similar or even indistinguishable.
 	 *
-	 * **Note:** this method traverses model document so it can be only used when range is up-to-date with model document.
-	 *
 	 * @param {module:engine/model/position~Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if positions touch.
 	 */
@@ -481,10 +490,9 @@ export default class Position {
 	/**
 	 * Checks if two positions are in the same parent.
 	 *
-	 * This method uses position {@link ~Position#path}s to compare position so it is safe to use it on non-existing positions
-	 * (for example during operational transformation).
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
 	 *
-	 * @param {@link ~Position} position Position to compare with.
+	 * @param {~Position} position Position to compare with.
 	 * @returns {Boolean} `true` if positions have the same parent, `false` otherwise.
 	 */
 	hasSameParentAs( position ) {
@@ -506,6 +514,8 @@ export default class Position {
 	 * For example, if `n` nodes are inserted before the position, the returned position {@link ~Position#offset} will be
 	 * increased by `n`. If the position was in a merged element, it will be accordingly moved to the new element, etc.
 	 *
+	 * This method is safe to use it on non-existing positions (for example during operational transformation).
+	 *
 	 * @param {module:engine/model/operation/operation~Operation} operation Operation to transform by.
 	 * @returns {module:engine/model/position~Position} Transformed position.
 	 */

Некоторые файлы не были показаны из-за большого количества измененных файлов