Jelajahi Sumber

Update docs.

Piotr Jasiun 10 tahun lalu
induk
melakukan
cc242ada4d

+ 9 - 1
packages/ckeditor5-engine/src/document/operation/operation.js

@@ -30,6 +30,12 @@ CKEDITOR.define( [], () => {
 			 */
 			this.baseVersion = baseVersion;
 
+			/**
+			 * Operation type.
+			 *
+			 * @property {String} type
+			 */
+
 			/**
 			 * {@link Document.Delta Delta} which the operation is a part of. This property is set by the
 			 * {@link Document.Delta delta} when the operations is added to it by the
@@ -62,8 +68,10 @@ CKEDITOR.define( [], () => {
 			 * Executes the operation - modifications described by the operation attributes
 			 * will be applied to the tree model.
 			 *
-			 * @method _execute
 			 * @protected
+			 * @method _execute
+			 * @returns {Object} Information about the change. It is always the range and additional informations depending on the
+			 * operation type.
 			 */
 		}
 	}

+ 14 - 2
packages/ckeditor5-engine/src/document/position.js

@@ -220,8 +220,20 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 			return transformed;
 		}
 
-		static createFromPositionAndShift( position, shift ) {
-			let newPosition = new Position( utils.clone( position.path ), position.root );
+		/**
+		 * Returns a new position on the same level as reference position, but with offset shifted left or right.
+		 *
+		 *		 const pos = new Position( [ 1, 2, 8 ], root );
+		 *
+		 *		 Position.createFromPositionAndShift( pos, -3 ) // [ 1, 2, 5 ]
+		 *		 Position.createFromPositionAndShift( pos, 5 )  // [ 1, 2, 13 ]
+		 *
+		 * @param {document.Position} referencePosition Reference position.
+		 * @param {Number} shift Offset shift.
+		 * @returns {document.Position}
+		 */
+		static createFromPositionAndShift( referencePosition, shift ) {
+			let newPosition = new Position( utils.clone( referencePosition.path ), referencePosition.root );
 			newPosition.offset = newPosition.offset + shift;
 
 			return newPosition;