Kaynağa Gözat

#396: Update documentation for Operation.fromJSON.

Maciej Gołaszewski 9 yıl önce
ebeveyn
işleme
235e4cff1f

+ 7 - 3
packages/ckeditor5-engine/src/treemodel/operation/attributeoperation.js

@@ -143,9 +143,13 @@ export default class AttributeOperation extends Operation {
 	}
 
 	/**
-	 * @inheritDoc
+	 * Creates AttributeOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.treeModel.Document} document Document on which this operation will be applied.
+	 * @returns {engine.treeModel.operation.AttributeOperation}
 	 */
-	static fromJSON( json, doc ) {
-		return new AttributeOperation( Range.fromJSON( json.range, doc ), json.key, json.oldValue, json.newValue, json.baseVersion );
+	static fromJSON( json, document ) {
+		return new AttributeOperation( Range.fromJSON( json.range, document ), json.key, json.oldValue, json.newValue, json.baseVersion );
 	}
 }

+ 7 - 3
packages/ckeditor5-engine/src/treemodel/operation/insertoperation.js

@@ -80,9 +80,13 @@ export default class InsertOperation extends Operation {
 	}
 
 	/**
-	 * @inheritDoc
+	 * Creates InsertOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.treeModel.Document} document Document on which this operation will be applied.
+	 * @returns {engine.treeModel.operation.InsertOperation}
 	 */
-	static fromJSON( json, doc ) {
-		return new InsertOperation( Position.fromJSON( json.position, doc ), NodeList.fromJSON( json.nodeList ), json.baseVersion );
+	static fromJSON( json, document ) {
+		return new InsertOperation( Position.fromJSON( json.position, document ), NodeList.fromJSON( json.nodeList ), json.baseVersion );
 	}
 }

+ 8 - 4
packages/ckeditor5-engine/src/treemodel/operation/moveoperation.js

@@ -181,11 +181,15 @@ export default class MoveOperation extends Operation {
 	}
 
 	/**
-	 * @inheritDoc
+	 * Creates MoveOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.treeModel.Document} document Document on which this operation will be applied.
+	 * @returns {engine.treeModel.operation.MoveOperation}
 	 */
-	static fromJSON( json, doc ) {
-		let sourcePosition = Position.fromJSON( json.sourcePosition, doc );
-		let targetPosition = Position.fromJSON( json.targetPosition, doc );
+	static fromJSON( json, document ) {
+		let sourcePosition = Position.fromJSON( json.sourcePosition, document );
+		let targetPosition = Position.fromJSON( json.targetPosition, document );
 
 		return new MoveOperation( sourcePosition, json.howMany, targetPosition, json.baseVersion );
 	}

+ 3 - 6
packages/ckeditor5-engine/src/treemodel/operation/operation.js

@@ -100,17 +100,14 @@ export default class Operation {
 		return 'engine.treeModel.operation.Operation';
 	}
 
-	/*jshint unused: true*/
 	/**
-	 * Creates Element object from deserilized object, ie. from parsed JSON string.
+	 * Creates Operation object from deserilized object, i.e. from parsed JSON string.
 	 *
 	 * @param {Object} json Deserialized JSON object.
 	 * @param {engine.treeModel.Document} doc Document on which this operation will be applied.
-	 * @returns {engine.treeModel.operationOperation}
+	 * @returns {engine.treeModel.operation.Operation}
 	 */
-	static fromJSON( json, doc ) {
+	static fromJSON( json ) {
 		return new Operation( json.baseVersion );
 	}
-
-	/*jshint unused: false*/
 }

+ 8 - 4
packages/ckeditor5-engine/src/treemodel/operation/rootattributeoperation.js

@@ -137,10 +137,14 @@ export default class RootAttributeOperation extends Operation {
 	}
 
 	/**
-	 * @inheritDoc
+	 * Creates RootAttributeOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.treeModel.Document} document Document on which this operation will be applied.
+	 * @returns {engine.treeModel.operation.RootAttributeOperation}
 	 */
-	static fromJSON( json, doc ) {
-		if ( !doc.hasRoot( json.root ) ) {
+	static fromJSON( json, document ) {
+		if ( !document.hasRoot( json.root ) ) {
 			/**
 			 * Cannot create RootAttributeOperation for document. Root with specified name does not exist.
 			 *
@@ -153,6 +157,6 @@ export default class RootAttributeOperation extends Operation {
 			);
 		}
 
-		return new RootAttributeOperation( doc.getRoot( json.root ), json.key, json.oldValue, json.newValue, json.baseVersion );
+		return new RootAttributeOperation( document.getRoot( json.root ), json.key, json.oldValue, json.newValue, json.baseVersion );
 	}
 }