|
@@ -14,6 +14,7 @@ import ModelRange from '../../src/model/range';
|
|
|
import ModelPosition from '../../src/model/position';
|
|
import ModelPosition from '../../src/model/position';
|
|
|
|
|
|
|
|
import ViewElement from '../../src/view/element';
|
|
import ViewElement from '../../src/view/element';
|
|
|
|
|
+import ViewAttributeElement from '../../src/view/attributeelement';
|
|
|
import ViewContainerElement from '../../src/view/containerelement';
|
|
import ViewContainerElement from '../../src/view/containerelement';
|
|
|
import ViewUIElement from '../../src/view/uielement';
|
|
import ViewUIElement from '../../src/view/uielement';
|
|
|
import ViewText from '../../src/view/text';
|
|
import ViewText from '../../src/view/text';
|
|
@@ -59,9 +60,9 @@ describe( 'downcast-helpers', () => {
|
|
|
expectResult( '<p></p>' );
|
|
expectResult( '<p></p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'can be overwritten using priority', () => {
|
|
|
|
|
|
|
+ it( 'can be overwritten using converterPriority', () => {
|
|
|
const helperA = downcastElementToElement( { model: 'paragraph', view: 'p' } );
|
|
const helperA = downcastElementToElement( { model: 'paragraph', view: 'p' } );
|
|
|
- const helperB = downcastElementToElement( { model: 'paragraph', view: 'foo', priority: 'high' } );
|
|
|
|
|
|
|
+ const helperB = downcastElementToElement( { model: 'paragraph', view: 'foo', converterPriority: 'high' } );
|
|
|
|
|
|
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
|
|
|
|
|
@@ -119,9 +120,9 @@ describe( 'downcast-helpers', () => {
|
|
|
expectResult( '<strong>foo</strong>' );
|
|
expectResult( '<strong>foo</strong>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'can be overwritten using priority', () => {
|
|
|
|
|
|
|
+ it( 'can be overwritten using converterPriority', () => {
|
|
|
const helperA = downcastAttributeToElement( { model: 'bold', view: 'strong' } );
|
|
const helperA = downcastAttributeToElement( { model: 'bold', view: 'strong' } );
|
|
|
- const helperB = downcastAttributeToElement( { model: 'bold', view: 'b', priority: 'high' } );
|
|
|
|
|
|
|
+ const helperB = downcastAttributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
|
|
|
|
|
|
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
|
|
|
|
|
@@ -148,6 +149,25 @@ describe( 'downcast-helpers', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
expectResult( '<span class="bg-dark font-light">foo</span>' );
|
|
expectResult( '<span class="bg-dark font-light">foo</span>' );
|
|
|
|
|
+ expect( viewRoot.getChild( 0 ).priority ).to.equal( ViewAttributeElement.DEFAULT_PRIORITY );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'config.view allows specifying the element\'s priority', () => {
|
|
|
|
|
+ const helper = downcastAttributeToElement( {
|
|
|
|
|
+ model: 'invert',
|
|
|
|
|
+ view: {
|
|
|
|
|
+ name: 'span',
|
|
|
|
|
+ priority: 5
|
|
|
|
|
+ }
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ conversion.for( 'downcast' ).add( helper );
|
|
|
|
|
+
|
|
|
|
|
+ model.change( writer => {
|
|
|
|
|
+ writer.insertText( 'foo', { invert: true }, modelRoot, 0 );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ expect( viewRoot.getChild( 0 ).priority ).to.equal( 5 );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'model attribute value is enum', () => {
|
|
it( 'model attribute value is enum', () => {
|
|
@@ -167,7 +187,8 @@ describe( 'downcast-helpers', () => {
|
|
|
name: 'span',
|
|
name: 'span',
|
|
|
styles: {
|
|
styles: {
|
|
|
'font-size': '0.8em'
|
|
'font-size': '0.8em'
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ priority: 5
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} );
|
|
} );
|
|
@@ -178,6 +199,7 @@ describe( 'downcast-helpers', () => {
|
|
|
writer.insertText( 'foo', { fontSize: 'big' }, modelRoot, 0 );
|
|
writer.insertText( 'foo', { fontSize: 'big' }, modelRoot, 0 );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ expect( viewRoot.getChild( 0 ).priority ).to.equal( ViewAttributeElement.DEFAULT_PRIORITY );
|
|
|
expectResult( '<span style="font-size:1.2em">foo</span>' );
|
|
expectResult( '<span style="font-size:1.2em">foo</span>' );
|
|
|
|
|
|
|
|
model.change( writer => {
|
|
model.change( writer => {
|
|
@@ -185,6 +207,7 @@ describe( 'downcast-helpers', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
expectResult( '<span style="font-size:0.8em">foo</span>' );
|
|
expectResult( '<span style="font-size:0.8em">foo</span>' );
|
|
|
|
|
+ expect( viewRoot.getChild( 0 ).priority ).to.equal( 5 );
|
|
|
|
|
|
|
|
model.change( writer => {
|
|
model.change( writer => {
|
|
|
writer.removeAttribute( 'fontSize', modelRoot.getChild( 0 ) );
|
|
writer.removeAttribute( 'fontSize', modelRoot.getChild( 0 ) );
|
|
@@ -265,9 +288,9 @@ describe( 'downcast-helpers', () => {
|
|
|
expectResult( '<img></img>' );
|
|
expectResult( '<img></img>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'can be overwritten using priority', () => {
|
|
|
|
|
|
|
+ it( 'can be overwritten using converterPriority', () => {
|
|
|
const helperA = downcastAttributeToAttribute( { model: 'source', view: 'href' } );
|
|
const helperA = downcastAttributeToAttribute( { model: 'source', view: 'href' } );
|
|
|
- const helperB = downcastAttributeToAttribute( { model: 'source', view: 'src', priority: 'high' } );
|
|
|
|
|
|
|
+ const helperB = downcastAttributeToAttribute( { model: 'source', view: 'src', converterPriority: 'high' } );
|
|
|
|
|
|
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
|
|
|
|
|
@@ -457,9 +480,9 @@ describe( 'downcast-helpers', () => {
|
|
|
expectResult( 'f<marker-search></marker-search>o<marker-search></marker-search>o' );
|
|
expectResult( 'f<marker-search></marker-search>o<marker-search></marker-search>o' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'can be overwritten using priority', () => {
|
|
|
|
|
|
|
+ it( 'can be overwritten using converterPriority', () => {
|
|
|
const helperA = downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
|
|
const helperA = downcastMarkerToElement( { model: 'search', view: 'marker-search' } );
|
|
|
- const helperB = downcastMarkerToElement( { model: 'search', view: 'search', priority: 'high' } );
|
|
|
|
|
|
|
+ const helperB = downcastMarkerToElement( { model: 'search', view: 'search', converterPriority: 'high' } );
|
|
|
|
|
|
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
|
|
|
|
|
@@ -529,9 +552,9 @@ describe( 'downcast-helpers', () => {
|
|
|
expectResult( '<span class="comment">foo</span>' );
|
|
expectResult( '<span class="comment">foo</span>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'can be overwritten using priority', () => {
|
|
|
|
|
|
|
+ it( 'can be overwritten using converterPriority', () => {
|
|
|
const helperA = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
|
|
const helperA = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'comment' } } );
|
|
|
- const helperB = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'new-comment' }, priority: 'high' } );
|
|
|
|
|
|
|
+ const helperB = downcastMarkerToHighlight( { model: 'comment', view: { classes: 'new-comment' }, converterPriority: 'high' } );
|
|
|
|
|
|
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
conversion.for( 'downcast' ).add( helperA ).add( helperB );
|
|
|
|
|
|
|
@@ -655,7 +678,7 @@ describe( 'downcast-converters', () => {
|
|
|
it( 'should be possible to override it', () => {
|
|
it( 'should be possible to override it', () => {
|
|
|
dispatcher.on( 'insert:$text', ( evt, data, conversionApi ) => {
|
|
dispatcher.on( 'insert:$text', ( evt, data, conversionApi ) => {
|
|
|
conversionApi.consumable.consume( data.item, 'insert' );
|
|
conversionApi.consumable.consume( data.item, 'insert' );
|
|
|
- }, { priority: 'high' } );
|
|
|
|
|
|
|
+ }, { converterPriority: 'high' } );
|
|
|
|
|
|
|
|
model.change( writer => {
|
|
model.change( writer => {
|
|
|
writer.insert( new ModelText( 'foobar' ), modelRootStart );
|
|
writer.insert( new ModelText( 'foobar' ), modelRootStart );
|
|
@@ -751,7 +774,7 @@ describe( 'downcast-converters', () => {
|
|
|
|
|
|
|
|
dispatcher.on( 'attribute:class', ( evt, data, conversionApi ) => {
|
|
dispatcher.on( 'attribute:class', ( evt, data, conversionApi ) => {
|
|
|
conversionApi.consumable.consume( data.item, 'attribute:class' );
|
|
conversionApi.consumable.consume( data.item, 'attribute:class' );
|
|
|
- }, { priority: 'high' } );
|
|
|
|
|
|
|
+ }, { converterPriority: 'high' } );
|
|
|
|
|
|
|
|
model.change( writer => {
|
|
model.change( writer => {
|
|
|
writer.insert( modelElement, modelRootStart );
|
|
writer.insert( modelElement, modelRootStart );
|
|
@@ -1602,7 +1625,7 @@ describe( 'downcast-converters', () => {
|
|
|
dispatcher.on( 'removeMarker:marker2', removeHighlight( () => null ) );
|
|
dispatcher.on( 'removeMarker:marker2', removeHighlight( () => null ) );
|
|
|
|
|
|
|
|
viewDiv._setCustomProperty( 'addHighlight', ( element, descriptor ) => {
|
|
viewDiv._setCustomProperty( 'addHighlight', ( element, descriptor ) => {
|
|
|
- expect( descriptor.priority ).to.equal( 10 );
|
|
|
|
|
|
|
+ expect( descriptor.priority ).to.equal( ViewAttributeElement.DEFAULT_PRIORITY );
|
|
|
expect( descriptor.id ).to.equal( 'marker:foo-bar-baz' );
|
|
expect( descriptor.id ).to.equal( 'marker:foo-bar-baz' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -1698,7 +1721,7 @@ describe( 'downcast-converters', () => {
|
|
|
|
|
|
|
|
expect( element.is( 'attributeElement' ) ).to.be.true;
|
|
expect( element.is( 'attributeElement' ) ).to.be.true;
|
|
|
expect( element.name ).to.equal( 'span' );
|
|
expect( element.name ).to.equal( 'span' );
|
|
|
- expect( element.priority ).to.equal( 10 );
|
|
|
|
|
|
|
+ expect( element.priority ).to.equal( ViewAttributeElement.DEFAULT_PRIORITY );
|
|
|
expect( element.hasClass( 'foo-class' ) ).to.be.true;
|
|
expect( element.hasClass( 'foo-class' ) ).to.be.true;
|
|
|
|
|
|
|
|
for ( const key of Object.keys( descriptor.attributes ) ) {
|
|
for ( const key of Object.keys( descriptor.attributes ) ) {
|