@@ -405,7 +405,7 @@ function upcastElementToElement( config ) {
405
405
406
406
const converter = prepareToElementConverter ( config ) ;
407
407
408
- const elementName = getViewElementNameFromConfig ( config ) ;
408
+ const elementName = getViewElementNameFromConfig ( config . view ) ;
409
409
const eventName = elementName ? 'element:' + elementName : 'element' ;
410
410
411
411
return dispatcher => {
@@ -431,7 +431,7 @@ function upcastElementToAttribute( config ) {
431
431
432
432
const converter = prepareToAttributeConverter ( config , false ) ;
433
433
434
- const elementName = getViewElementNameFromConfig ( config ) ;
434
+ const elementName = getViewElementNameFromConfig ( config . view ) ;
435
435
const eventName = elementName ? 'element:' + elementName : 'element' ;
436
436
437
437
return dispatcher => {
@@ -493,15 +493,15 @@ function upcastElementToMarker( config ) {
493
493
// Helper function for from-view-element conversion. Checks if `config.view` directly specifies converted view element's name
494
494
// and if so, returns it.
495
495
//
496
- // @param {Object } config Conversion config.
496
+ // @param {Object } config Conversion view config.
497
497
// @returns {String|null } View element name or `null` if name is not directly set.
498
- function getViewElementNameFromConfig ( config ) {
499
- if ( typeof config . view == 'string' ) {
500
- return config . view ;
498
+ function getViewElementNameFromConfig ( viewConfig ) {
499
+ if ( typeof viewConfig == 'string' ) {
500
+ return viewConfig ;
501
501
}
502
502
503
- if ( typeof config . view == 'object' && typeof config . view . name == 'string' ) {
504
- return config . view . name ;
503
+ if ( typeof viewConfig == 'object' && typeof viewConfig . name == 'string' ) {
504
+ return viewConfig . name ;
505
505
}
506
506
507
507
return null ;
@@ -684,7 +684,7 @@ function prepareToAttributeConverter( config, shallow ) {
684
684
return ;
685
685
}
686
686
687
- if ( onlyViewNameIsDefined ( config ) ) {
687
+ if ( onlyViewNameIsDefined ( config . view , data . viewItem ) ) {
688
688
match . match . name = true ;
689
689
} else {
690
690
// Do not test or consume `name` consumable.
@@ -714,14 +714,17 @@ function prepareToAttributeConverter( config, shallow ) {
714
714
715
715
// Helper function that checks if element name should be consumed in attribute converters.
716
716
//
717
- // @param {Object } config Conversion config.
717
+ // @param {Object } config Conversion view config.
718
718
// @returns {Boolean }
719
- function onlyViewNameIsDefined ( config ) {
720
- if ( typeof config . view == 'object' && ! getViewElementNameFromConfig ( config ) ) {
719
+ function onlyViewNameIsDefined ( viewConfig , viewItem ) {
720
+ // https://github.com/ckeditor/ckeditor5-engine/issues/1786
721
+ const configToTest = typeof viewConfig == 'function' ? viewConfig ( viewItem ) : viewConfig ;
722
+
723
+ if ( typeof configToTest == 'object' && ! getViewElementNameFromConfig ( configToTest ) ) {
721
724
return false ;
722
725
}
723
726
724
- return ! config . view . classes && ! config . view . attributes && ! config . view . styles ;
727
+ return ! configToTest . classes && ! configToTest . attributes && ! configToTest . styles ;
725
728
}
726
729
727
730
// Helper function for to-model-attribute converter. Sets model attribute on given range. Checks {@link module:engine/model/schema~Schema}
0 commit comments