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

Commit 3706324

Browse files
authored
Merge pull request #1698 from ckeditor/t/1697
Fix: Markers should be now correctly upcasted inside any element. Closes #1697.
2 parents cf56d90 + 314c531 commit 3706324

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/model/model.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ export default class Model {
103103
} );
104104
this.schema.extend( '$text', { allowIn: '$clipboardHolder' } );
105105

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

114117
injectSelectionPostFixer( this );

tests/model/model.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ describe( 'Model', () => {
5151
} );
5252

5353
it( 'registers $marker to the schema', () => {
54+
model.document.createRoot( '$anywhere', 'anywhere' );
55+
schema.register( 'anything' );
56+
5457
expect( schema.isRegistered( '$marker' ) ).to.be.true;
55-
expect( schema.checkChild( [ '$root' ], '$marker' ), 1 ).to.be.true;
56-
expect( schema.checkChild( [ '$block' ], '$marker' ), 1 ).to.be.true;
58+
expect( schema.checkChild( [ '$root' ], '$marker' ) ).to.be.true;
59+
expect( schema.checkChild( [ '$block' ], '$marker' ) ).to.be.true;
60+
expect( schema.checkChild( [ '$anywhere' ], '$marker' ) ).to.be.true;
61+
expect( schema.checkChild( [ 'anything' ], '$marker' ) ).to.be.true;
5762
} );
5863
} );
5964

0 commit comments

Comments
 (0)