@@ -227,7 +227,7 @@ export const toRedactor = (jsonValue: any,options?:IJsonToHtmlOptions) : string
227
227
Object . keys ( options . allowedEmptyAttributes ) . forEach ( key => {
228
228
if ( key === 'img' || key === 'reference' ) {
229
229
ALLOWED_EMPTY_ATTRIBUTES [ key ] = [
230
- 'alt' ,
230
+ ... ALLOWED_EMPTY_ATTRIBUTES [ key ] ,
231
231
...( options . allowedEmptyAttributes ?. [ key ] || [ ] )
232
232
] ;
233
233
} else {
@@ -523,24 +523,21 @@ export const toRedactor = (jsonValue: any,options?:IJsonToHtmlOptions) : string
523
523
delete attrsJson [ 'url' ]
524
524
}
525
525
delete attrsJson [ 'redactor-attributes' ]
526
+
526
527
Object . entries ( attrsJson ) . forEach ( ( item ) => {
527
528
if ( forbiddenAttrChars . some ( char => item [ 0 ] . includes ( char ) ) ) {
528
529
return ;
529
530
}
530
- if ( ALLOWED_EMPTY_ATTRIBUTES . hasOwnProperty ( jsonValue [ 'type' ] ) ) {
531
- if ( ALLOWED_EMPTY_ATTRIBUTES [ jsonValue [ 'type' ] ] . includes ( item [ 0 ] ) ) {
532
- // Check for 'display-type' attribute for reference type, as refernce is used for entries and assets
533
- if ( jsonValue [ 'type' ] === 'reference' && jsonValue . attrs [ 'display-type' ] === 'display' ) {
531
+
532
+ if ( ALLOWED_EMPTY_ATTRIBUTES . hasOwnProperty ( jsonValue [ 'type' ] ) && ALLOWED_EMPTY_ATTRIBUTES [ jsonValue [ 'type' ] ] . includes ( item [ 0 ] ) ) {
533
+ if ( jsonValue [ 'type' ] !== 'reference' || ( jsonValue [ 'type' ] === 'reference' && jsonValue . attrs [ 'display-type' ] === 'display' ) ) {
534
534
attrs += `${ item [ 0 ] } ="${ replaceHtmlEntities ( item [ 1 ] ) } " ` ;
535
535
return ;
536
- }
537
- attrs += `${ item [ 0 ] } ="${ replaceHtmlEntities ( item [ 1 ] ) } " ` ;
538
- return ;
539
- }
536
+ }
540
537
}
541
538
return item [ 1 ] ? ( item [ 1 ] !== '' ? ( attrs += `${ item [ 0 ] } ="${ replaceHtmlEntities ( item [ 1 ] ) } " ` ) : '' ) : ''
542
539
} )
543
-
540
+
544
541
attrs = ( attrs . trim ( ) ? ' ' : '' ) + attrs . trim ( )
545
542
}
546
543
if ( jsonValue [ 'type' ] === 'table' ) {
0 commit comments