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

Commit

Permalink
Merge pull request #1698 from ckeditor/t/1697
Browse files Browse the repository at this point in the history
Fix: Markers should be now correctly upcasted inside any element. Closes #1697.
  • Loading branch information
scofalik committed Mar 15, 2019
2 parents cf56d90 + 314c531 commit 3706324
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ export default class Model {
} );
this.schema.extend( '$text', { allowIn: '$clipboardHolder' } );

// Element needed by `upcastElementToMarker` converter.
// This element temporarily represents marker bound during conversion process and is removed
// at the end of conversion. `UpcastDispatcher` or at least `Conversion` class looks like a better for this
// registration but both know nothing about Schema.
this.schema.register( '$marker', {
allowIn: [ '$root', '$block' ]
// An element needed by the `upcastElementToMarker` converter.
// This element temporarily represents a marker boundary during the conversion process and is removed
// at the end of the conversion. `UpcastDispatcher` or at least `Conversion` class looks like a
// better place for this registration but both know nothing about `Schema`.
this.schema.register( '$marker' );
this.schema.addChildCheck( ( context, childDefinition ) => {
if ( childDefinition.name === '$marker' ) {
return true;
}
} );

injectSelectionPostFixer( this );
Expand Down
9 changes: 7 additions & 2 deletions tests/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ describe( 'Model', () => {
} );

it( 'registers $marker to the schema', () => {
model.document.createRoot( '$anywhere', 'anywhere' );
schema.register( 'anything' );

expect( schema.isRegistered( '$marker' ) ).to.be.true;
expect( schema.checkChild( [ '$root' ], '$marker' ), 1 ).to.be.true;
expect( schema.checkChild( [ '$block' ], '$marker' ), 1 ).to.be.true;
expect( schema.checkChild( [ '$root' ], '$marker' ) ).to.be.true;
expect( schema.checkChild( [ '$block' ], '$marker' ) ).to.be.true;
expect( schema.checkChild( [ '$anywhere' ], '$marker' ) ).to.be.true;
expect( schema.checkChild( [ 'anything' ], '$marker' ) ).to.be.true;
} );
} );

Expand Down

0 comments on commit 3706324

Please sign in to comment.