-
Notifications
You must be signed in to change notification settings - Fork 40
Introduced context for OT. Refactored: History, RemoveOperation, OT and other. #977
Conversation
This needs PRs in other repos. ckeditor/ckeditor5-undo#63 |
src/model/range.js
Outdated
* @returns {Boolean} `true` if given {@link ~Range range} boundaries are contained by this range, `false` otherwise. | ||
*/ | ||
containsRange( otherRange ) { | ||
return this.containsPosition( otherRange.start ) && this.containsPosition( otherRange.end ); | ||
containsRange( otherRange, strict = true ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default of a boolean flag should be false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to pass false
as a param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've seen you commented on it previously. I understand your point. My point was that this is creating double negation (nonStrict == false
) which is sometimes confusing to read and understand when the code is longer (which is not the case here, but still I don't like having negation in variable/parameter name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know. So maybe weak
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that loose
is a better term.
f4ba06f
to
fb2bd15
Compare
I've added some more commits but messed up a bit and rebased instead of merge with master, so sorry for this :). |
fb2bd15
to
4e60a99
Compare
I've created all needed PRs in other repos. |
I found a bug in undo during manual testing, fixing it right now. |
… view.Range#containsRange.
…ltas as "undo pairs".
…caused the live range to change.
…oes not set `targetPosition` on its own. Added: `RemoveOperation#isPermanent`. Changed: `Batch#remove` now creates separate delta for each `RemoveOperation` instead of creating one delta with multiple operations. Added: `isPermanent` parameter in `Batch#remove`.
… in `LiveRange` and `RemoveOperation`.
…ations on reverse.
…for deltas transformation (instead of `deltaTransform.transformDeltaSets` which is protected).
…ame and default value from strict to loose.
…rsed()` were incorrect after `RemoveOperation` no longer creates `$graveyardHolder`.
…sformations since `RemoveOperation` no longer creates `graveyardHolder`.
…tion is `NoOperation`.
…eOperation` x `MoveOperation` transformation.
…ds on document.history, better context setting, deltas normalization.
…done to operations and deltas transformations.
Okay, I've rewritten and fixed a lot of stuff in deltas transformations and operations transformations. For now it is okay, however I will create several followups. |
… needed for correct transformation.
I've updated related PRs and checked that all branches together work fine. |
…n `MoveOperation#fromJson`.
I've added follow up issues. |
I pushed |
Please resolve conflicts in ckeditor/ckeditor5-undo#63. |
// Here we do not need to worry that newTargetPosition is inside moved range, because that | ||
// would mean that the MoveOperation targets into itself, and that is incorrect operation. | ||
// Instead, we calculate the new position of that part of original range. | ||
// // If MoveOperations has common range it can be one of two: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it left like this intentionally?
src/model/operation/transform.js
Outdated
@@ -52,12 +53,11 @@ import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays'; | |||
* `a` by `b` and also `b` by `a`. In both transformations the same operation has to be the important one. If we assume | |||
* that first or the second passed operation is always more important we won't be able to solve this case. | |||
* | |||
* @external module:engine/model/model.operation | |||
* @protected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this because it creates a precedence that we have a protected export. We should rather invest in marking internal modules all across the code.
} ); | ||
return makeMoveOperationsFromRanges( a, ranges, newTargetPosition ); | ||
|
||
// // Map transformed range(s) to operations and return them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here again – was it left intentionally?
src/model/range.js
Outdated
} | ||
|
||
/** | ||
* Two ranges are equal if their {@link #start start} and | ||
* {@link #end end} positions are equal. | ||
* Two ranges are equal if their {@link #start start} and {@link #end end} positions are equal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to type #start start
. Just leave the property or class name unless you want to change the wording a bit.
Internal: Undo algorithms were simplified thanks to changes in the model. See ckeditor/ckeditor5-engine#977.
Please close tickets which should be closed now (and please cross-link them for the future reference). Also, please check issues that you assigned to yourself, whether you're still working on them. |
The commented out code was left there by mistake. I already pushed a commit to master fixing it. |
Suggested merge commit message (convention)
Feature: OT uses context information for better conflict resolving.
This includes refactoring of:
History
,RemoveOperation
, operational transformation algorithms, delta transformation algorithms and more.Context will be used instead of removing deltas from history, which caused bugs in more complicated scenarios. This mostly affects undo algorithms.
BREAKING CHANGE:
History
API for deleting undone deltas has been removed.BREAKING CHANGE:
deltaTransform#transformDeltaSets
is nowprotected
. Usemodel.Document#transformDeltas
instead.Additional information:
RemoveOperation
no longer creates$graveyardHolder
elements. We are not using$graveyardHolder
anywhere anymore.RemoveOperation
no longer sets itstargetPosition
on its own in constructor.targetPosition
has to be passed to the constructor instead.Batch#remove
now creates multipleRemoveDelta
s each with oneRemoveOperation
instead of one delta with multiple operations.MoveDelta
has exactly oneMoveOperation
,SplitDelta
has exactlyInsertOperation
andMoveOperation
(orNoOperation
) in this order, etc. After delta transformation using OT algorithms (default case),MoveOperation
may get split into two, creating "not normal" deltas. For exampleSplitDelta
withInsertOperation
and twoMoveOperation
s. This is normalized to oneSplitDelta
(insert + first move) and oneMoveDelta
(second move).RemoveOperation
has been undone, it is not treated as "always more important" than the other operation, duringRemoveOperation
transformation.isStrong
flag (nowcontext.isStrong
). In this new approach it might make too much mess. Deltas priority was supposed to fix some problems in delta transformations. After refactoring and removing this mechanisms no tests fail anyway. Maybe some of problems were fixed along the way, maybe they are more hidden. Anyway there will be a followup to revise all delta transformation special cases, so we will return to that problem later.