From f0ea94f7f56806b2e4e5e102582a2e723f3c6f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wr=C3=B3bel?= Date: Fri, 15 Mar 2019 15:24:09 +0100 Subject: [PATCH 1/3] Internal: Allowed $marker element in any parent element. --- src/model/model.js | 15 +++++++++------ tests/model/model.js | 9 +++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/model/model.js b/src/model/model.js index 1213d2fd1..0bfb4fe34 100644 --- a/src/model/model.js +++ b/src/model/model.js @@ -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 marker bound 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 the Schema. + this.schema.register( '$marker' ); + this.schema.addChildCheck( ( context, childDefinition ) => { + if ( childDefinition.name === '$marker' ) { + return true; + } } ); injectSelectionPostFixer( this ); diff --git a/tests/model/model.js b/tests/model/model.js index a0ef069bc..83d8588a8 100644 --- a/tests/model/model.js +++ b/tests/model/model.js @@ -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; } ); } ); From b86729bb60f56cf5557815c998b31f47395323fa Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Fri, 15 Mar 2019 15:54:37 +0100 Subject: [PATCH 2/3] Docs: slight fixes --- src/model/model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/model.js b/src/model/model.js index 0bfb4fe34..75b50b442 100644 --- a/src/model/model.js +++ b/src/model/model.js @@ -106,7 +106,7 @@ export default class Model { // An element needed by the `upcastElementToMarker` converter. // This element temporarily represents marker bound 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 the Schema. + // better place for this registration but both know nothing about `Schema`. this.schema.register( '$marker' ); this.schema.addChildCheck( ( context, childDefinition ) => { if ( childDefinition.name === '$marker' ) { From 314c5315a0e2c474e93962464fb4931eba93ff1c Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Fri, 15 Mar 2019 15:55:25 +0100 Subject: [PATCH 3/3] Docs: slight fix --- src/model/model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/model.js b/src/model/model.js index 75b50b442..e27d35103 100644 --- a/src/model/model.js +++ b/src/model/model.js @@ -104,7 +104,7 @@ export default class Model { this.schema.extend( '$text', { allowIn: '$clipboardHolder' } ); // An element needed by the `upcastElementToMarker` converter. - // This element temporarily represents marker bound during the conversion process and is removed + // 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' );