-
Notifications
You must be signed in to change notification settings - Fork 40
T/1211 Operations that do not operate on document should have baseVersion set to null #1220
Conversation
I will wait with the review to close #1216. |
…before an operation affecting marker is applied.
src/controller/datacontroller.js
Outdated
const modelRange = ModelRange.createIn( modelElementOrFragment ); | ||
|
||
const viewDocumentFragment = new ViewDocumentFragment(); | ||
this.mapper.bindElements( modelElementOrFragment, viewDocumentFragment ); | ||
|
||
this.modelToView.convertInsert( modelRange ); | ||
|
||
if ( !modelElementOrFragment.is( 'documentFragment' ) ) { | ||
// Then, if document element is converted, convert markers. | ||
// Get only those markers that contain or are contained by the element. |
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.
What other elements do we have?
src/controller/editingcontroller.js
Outdated
// it would be impossible to map some markers to view (if, for example, marker boundary parent got removed). | ||
// | ||
// `removedMarkers` keeps information which markers already has been removed to prevent removing them twice. | ||
// (The second remove would not be at "the soonest moment" and it could crash.) |
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 second remove would not be at "the soonest moment" and it could crash.)
I don't get it.
removedMarkers.add( marker.name ); | ||
this.modelToView.convertMarkerRemove( marker.name, markerRange ); | ||
|
||
// TODO: This stinks but this is the safest place to have this code. |
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 mean all of these listeners? ;)
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.
src/controller/editingcontroller.js
Outdated
}, { priority: 'high' } ); | ||
|
||
// If a marker with given name was added again, remove it from `removedMarkers`. This is to prevent a bug in | ||
// a situation when marker is removed, then added, then removed again (would not got removed if it is saved in `removedMarkers`). |
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.
Are you sure we need this? If a marker is added, we add it on "changes done", so it should not be removed immediately, only removed from differ.
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.
Wow, good catch! I've added a test and it is true that it is not only unnecessary but it's even harmful.
src/model/writer.js
Outdated
@@ -574,7 +564,9 @@ export default class Writer { | |||
const delta = new RenameDelta(); | |||
this.batch.addDelta( delta ); | |||
|
|||
const renameOperation = new RenameOperation( Position.createBefore( element ), element.name, newName, this.model.document.version ); | |||
const version = element.root.document ? this.model.document.version : null; |
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.
More natural is: element.root.document ? element.root.document.version : null;
src/model/writer.js
Outdated
@@ -605,21 +597,24 @@ export default class Writer { | |||
} | |||
|
|||
const copy = new Element( splitElement.name, splitElement.getAttributes() ); | |||
const insertVersion = splitElement.root.document ? this.model.document.version : null; |
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.
splitElement.root.document ? splitElement.root.document.version : null;
src/model/writer.js
Outdated
@@ -670,16 +665,20 @@ export default class Writer { | |||
const delta = new WrapDelta(); | |||
this.batch.addDelta( delta ); | |||
|
|||
const insert = new InsertOperation( range.end, element, this.model.document.version ); | |||
const insertVersion = range.root.document ? this.model.document.version : null; |
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.
range.root.document ? range.root.document.version : null;
src/model/writer.js
Outdated
@@ -707,26 +706,20 @@ export default class Writer { | |||
this.batch.addDelta( delta ); | |||
|
|||
const sourcePosition = Position.createFromParentAndOffset( element, 0 ); | |||
const moveVersion = sourcePosition.root.document ? this.model.document.version : null; |
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.
sourcePosition.root.document ? sourcePosition.root.document : null;
src/model/writer.js
Outdated
|
||
if ( position.root.document ) { | ||
const doc = model.document; | ||
const gyPosition = new Position( doc.graveyard, [ 0 ] ); |
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.
graveyardPosition
Changed: Minor refactor tweaks and doc tweaks.
Suggested merge commit message (convention)
Other: Operations that do not operate on a document should have
baseVersion
set tonull
. Closes ckeditor/ckeditor5#4223.Fixed: Markers again are properly converted in
engine.controller.DataController
.Fixed: Markers are cleared now before an operation is applied to
model.Document
tree to fix scenarios where marker range could not be converted to the view after the model changed.Additional information
This PR bases on #1216. Please close that PR first.