Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Docs: Improved ContextFactory docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Sep 4, 2018
1 parent 0cc7807 commit 575ace5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/model/operation/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,21 @@ class ContextFactory {
this._relations = new Map();
}

// Rewrites information about original operation to the new operations.
// Sets "original operation" for given operations.
//
// Used when `newOps` are generated from `oldOp` (during transformation). It takes `oldOp`'s original operation and
// sets it as `newOps` original operation.
// During transformation process, operations are cloned, then changed, then processed again, sometimes broken into two
// or multiple operations. When gathering additional data it is important that all operations can be somehow linked
// so a cloned and transformed "version" still kept track of the data assigned earlier to it.
//
// It also means that if an operation is broken into multiple during transformation, all those broken "pieces" are pointing
// to the same operation as their original operation.
// The original operation object will be used as such an universal linking id. Throughout the transformation process
// all cloned operations will refer to "the original operation" when storing and reading additional data.
//
// If `takeFrom` is not set, each operation from `operations` array will be assigned itself as "the original operation".
// This should be used as an initialization step.
//
// If `takeFrom` is set, each operation from `operations` will be assigned the same original operation as assigned
// for `takeFrom` operation. This should be used to update original operations. It should be used in a way that
// `operations` are the result of `takeFrom` transformation to ensure proper "original operation propagation".
//
// @param {Array.<module:engine/model/operation/operation~Operation>} operations
// @param {module:engine/model/operation/operation~Operation|null} [takeFrom=null]
Expand Down Expand Up @@ -501,8 +509,6 @@ class ContextFactory {
// @returns {module:engine/model/operation/transform~TransformationContext}
getContext( opA, opB, aIsStrong ) {
if ( !this._useContext ) {
// Additional contextual data is `false` or `null` if additional context is not used.

return {
aIsStrong,
aWasUndone: false,
Expand Down

0 comments on commit 575ace5

Please sign in to comment.