|
|
@@ -35,21 +35,14 @@ describe( 'upcast-helpers', () => {
|
|
|
schema = model.schema;
|
|
|
|
|
|
schema.extend( '$text', {
|
|
|
- allowIn: '$root'
|
|
|
- } );
|
|
|
-
|
|
|
- schema.register( '$marker', {
|
|
|
- inheritAllFrom: '$block'
|
|
|
+ allowIn: '$root',
|
|
|
+ allowAttributes: [ 'bold' ]
|
|
|
} );
|
|
|
|
|
|
schema.register( 'paragraph', {
|
|
|
inheritAllFrom: '$block'
|
|
|
} );
|
|
|
|
|
|
- schema.extend( '$text', {
|
|
|
- allowAttributes: [ 'bold' ]
|
|
|
- } );
|
|
|
-
|
|
|
upcastDispatcher = new UpcastDispatcher( { schema } );
|
|
|
upcastDispatcher.on( 'text', convertText() );
|
|
|
upcastDispatcher.on( 'element', convertToModelFragment(), { priority: 'lowest' } );
|
|
|
@@ -580,6 +573,26 @@ describe( 'upcast-helpers', () => {
|
|
|
|
|
|
expectResult( frag, 'foobar', marker );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'marker is in a block element', () => {
|
|
|
+ conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'paragraph', view: 'p' } ) );
|
|
|
+
|
|
|
+ const helper = upcastElementToMarker( { view: 'marker-search', model: 'search' } );
|
|
|
+
|
|
|
+ conversion.for( 'upcast' ).add( helper );
|
|
|
+
|
|
|
+ const element = new ViewContainerElement( 'p', null, [
|
|
|
+ new ViewText( 'fo' ),
|
|
|
+ new ViewUIElement( 'marker-search' ),
|
|
|
+ new ViewText( 'oba' ),
|
|
|
+ new ViewUIElement( 'marker-search' ),
|
|
|
+ new ViewText( 'r' )
|
|
|
+ ] );
|
|
|
+
|
|
|
+ const marker = { name: 'search', start: [ 0, 2 ], end: [ 0, 5 ] };
|
|
|
+
|
|
|
+ expectResult( element, '<paragraph>foobar</paragraph>', marker );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
function expectResult( viewToConvert, modelString, marker ) {
|