Ver Fonte

Docs: for the delta base class.

Piotr Jasiun há 10 anos atrás
pai
commit
d4c63b7f0a

+ 31 - 0
packages/ckeditor5-engine/src/document/delta/delta.js

@@ -7,17 +7,45 @@
 
 CKEDITOR.define( [], () => {
 	/**
+	 * Base class for all deltas.
+	 *
+	 * Delta is a single, from the user action point of view, change in the editable document, like insert, split or
+	 * rename element. Delta is composed of operations, which are unit changes need to be done to execute user action.
+	 *
+	 * Multiple deltas are grouped as a single {@link document.Transaction}.
+	 *
 	 * @class document.delta.Delta
 	 */
 	class Delta {
 		/**
+		 * Creates a delta instance.
+		 *
 		 * @constructor
 		 */
 		constructor() {
+			/**
+			 * {@link document.Transaction} which delta is a part of. This property is null by default and set by the
+			 * {@link Document.Transaction#addDelta} method.
+			 *
+			 * @readonly
+			 * @type {document.Transaction}
+			 */
 			this.transaction = null;
+
+			/**
+			 * Array of operations which compose delta.
+			 *
+			 * @readonly
+			 * @type {document.operation.Operation[]}
+			 */
 			this.operations = [];
 		}
 
+		/**
+		 * Add operation to the delta.
+		 *
+		 * @param {document.operation.Operation} operation Operation instance.
+		 */
 		addOperation( operation ) {
 			operation.delta = this;
 			this.operations.push( operation );
@@ -25,6 +53,9 @@ CKEDITOR.define( [], () => {
 			return operation;
 		}
 
+		/**
+		 * Delta provides iterator interface which will iterate over operations in the delta.
+		 */
 		[ Symbol.iterator ]() {
 			return this.operations[ Symbol.iterator ]();
 		}

+ 14 - 0
packages/ckeditor5-engine/src/document/delta/transaction-base.js

@@ -35,9 +35,23 @@ CKEDITOR.define( [ 'ckeditorerror' ], ( CKEditorError ) => {
 		 * instead.
 		 *
 		 * @constructor
+		 * @param {document.Document} doc Document which this transaction changes.
 		 */
 		constructor( doc ) {
+			/**
+			 * Document which this transaction changes.
+			 *
+			 * @readonly
+			 * @type {document.Document}
+			 */
 			this.doc = doc;
+
+			/**
+			 * Array of deltas which compose transaction.
+			 *
+			 * @readonly
+			 * @type {document.delta.Delta[]}
+			 */
 			this.deltas = [];
 		}