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

Refactored view->model conversion to use position. #1256

Merged
merged 44 commits into from
Jan 31, 2018
Merged

Refactored view->model conversion to use position. #1256

merged 44 commits into from
Jan 31, 2018

Conversation

oskarwrobel
Copy link
Contributor

@oskarwrobel oskarwrobel commented Jan 29, 2018

Suggested merge commit message (convention)

Feature: Convert view to model using position. Closes ckeditor/ckeditor5#4225. Closes https://github.com/ckeditor/ckeditor5-engine/issues/1250.

BREAKING CHANGE: DataController#parse, DataController#toModel, ViewConversionDispatcher#convert gets SchemaContextDefinition as a contex instead of String.
BREAKING CHANGE: ViewConversionApi#splitToAllowedParent has been introduced.
BREAKING CHANGE: ViewConversionApi#storage has been introduced.
BREAKING CHANGE: ViewConsumable has been merged to ViewConversionApi.
BREAKING CHANGE: Format od data object passed across conversion callback has been changed.
BREAKING CHANGE: Schema#findAllowedParent has been introduced.
BREAKING CHANGE: SchemaContext#concat has been introduced.


Constelation: https://github.com/ckeditor/ckeditor5/tree/t/ckeditor5-engine/1213

Related PR's:

Related branches (small changes):

@coveralls
Copy link

coveralls commented Jan 29, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 3b55b0e on t/1213 into d1838a4 on master.

this.fire( 'viewCleanup', viewItem );
// Create set for split elements. We need to remember this elements, because at the end of conversion
// we want to remove all empty elements that was created as a result of the split.
this.conversionApi.splitElements = new Set();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to move splitElements from conversionApi to private ViewConversiondispatcher property.

// element, so we need to move range after parent of the last converted child.
//
// after: <allowed>[]</allowed>
// before: <allowed>[<converted><child></child></converted><child></child><converted>]</converted></allowed>
Copy link

Choose a reason for hiding this comment

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

after, before? Shouldn't it be: before, after?

// after element.
//
// after: <allowed>[]</allowed>
// before: <allowed>[<converted></converted>]</allowed>
Copy link

Choose a reason for hiding this comment

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

As above.

Copy link

Choose a reason for hiding this comment

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

Also, as far as I understand, this is a case when there are no children. Otherwise, the previous one will do the job.

Copy link
Contributor Author

@oskarwrobel oskarwrobel Jan 30, 2018

Choose a reason for hiding this comment

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

Hm... I changed it yesterday.


// Remember all elements that are created as a result of split.
// This is important because at the end of conversion we want to remove all empty split elements.
for ( const pos of data.range.getPositions() ) {
Copy link

Choose a reason for hiding this comment

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

A sample in the comment would be useful to explain what this loop does.

args[ 0 ] = new SchemaContext( args[ 0 ] );
if ( !( args[ 0 ] instanceof SchemaContext ) ) {
args[ 0 ] = new SchemaContext( args[ 0 ] );
}
Copy link

Choose a reason for hiding this comment

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

As above.

@oskarwrobel
Copy link
Contributor Author

oskarwrobel commented Jan 31, 2018

Everything is fixed (I hope).


// When allowed parent is in context tree.
if ( this._modelCursor.parent.getAncestors().includes( allowedParent ) ) {
return null;
Copy link

@pjasiun pjasiun Jan 31, 2018

Choose a reason for hiding this comment

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

Are you sure that null should be returned here? Shouldn't we break it as much as possible in such case, and let insertContent do the rest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When insertContent is inserting conversion result it means that it is a pasting. Pasting is converted in $clipboardHolder context.

We do not allow anywhere to create invalid (from schema perspective) model tree. The idea of splitting was introduced to avoid creating invalid tree.

@pjasiun pjasiun merged commit 1961395 into master Jan 31, 2018
@pjasiun pjasiun deleted the t/1213 branch January 31, 2018 15:19
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.

Convert view to model using positions
4 participants