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

T/940 #941

Merged
merged 5 commits into from
May 9, 2017
Merged

T/940 #941

merged 5 commits into from
May 9, 2017

Conversation

scofalik
Copy link
Contributor

@scofalik scofalik commented May 8, 2017

Suggested merge commit message (convention)

Feature: When engine debugging is on, deltas that are results of transformation will keep their history of changes in #history property. Closes ckeditor/ckeditor5#4061.


Additional information

This PR needs a change in ckeditor5-undo. Related PR ckeditor/ckeditor5-undo#61

Delta#history is created and filled automatically when engine/model/delta/transform~deltaTransform#transform is used, if engine debugging is on (engine/dev-utils/enableenginedebug~enableEngineDebug was called).

Delta#history is an array. Each item is an object containing properties:

  • {String} before - JSON string containing delta state before transformation,
  • {String} transformedBy - JSON string containing delta which before was transformed by,
  • {Boolean} wasImportant - whether before was more important than transformedBy when it was transformed,
  • {Number} resultsTotal - how many deltas were returned as the transformation result,
  • {Number} resultIndex - what was the index of that delta in the transformation result.

This info will let us recreate all steps which led to current delta state, even if it was transformed multiple times. First item's before property is the original delta. Then it has to be transformed by transformBy deltas of following items (using wasImportant). After each transformation, resultIndex delta has to be chosen from among returned deltas.

Non-first before values and resultsTotal values can be used for additional checking or when there is no need to perform transformation back from the original delta. Those could be omitted/removed if we don't want them.

Note: before and transformedBy JSON strings do not contain their own history properties. That would lead to enormous data duplication.

@@ -317,27 +320,57 @@ function enableLoggingTools() {
}
};

Delta.prototype.saveHistory = function( before, transformedBy, wasImportant, resultIndex, resultsTotal ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't saveHistory be protected?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also before, transformedBy, wasImportant, resultIndex, resultsTotal should be replaced by an object.

@pjasiun
Copy link

pjasiun commented May 8, 2017

After fixing saveHistory method, feel free to merge this PR and the one in the undo repository.

@scofalik scofalik merged commit 7d8db49 into master May 9, 2017
@scofalik scofalik deleted the t/940 branch May 9, 2017 11:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delta: enable history log when delta becomes transformed
2 participants