This repository was archived by the owner on Feb 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
studio/src/app/utils/editor Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import {extractRgb, extractRgba} from '@deckdeckgo/utils';
33export class ContrastUtils {
44 static async calculateContrastRatio ( bgColor : string | undefined , color : string | undefined ) : Promise < number > {
55 const bgColorWithDefault : string = bgColor === undefined || bgColor === '' ? `rgb(255, 255, 255)` : bgColor ;
6- const colorWithDefault : string = color === undefined || color === '' ? `rgb(0, 0, 0)` : color ;
6+ const colorWithDefault : string = color === undefined || color === '' || color === 'initial' ? `rgb(0, 0, 0)` : color ;
77
88 // The text color may or may not be semi-transparent, but that doesn't matter
99 const bgRgba : number [ ] | undefined = extractRgba ( bgColorWithDefault ) ;
Original file line number Diff line number Diff line change @@ -20,8 +20,12 @@ export class NodeUtils {
2020 return Array . from ( elements ) . reduce ( ( acc : HTMLElement [ ] , slot : HTMLElement ) => {
2121 const children : NodeListOf < HTMLElement > = slot . querySelectorAll ( '*' ) ;
2222
23- if ( children && children . length > 0 ) {
24- acc . push ( ...Array . from ( children ) ) ;
23+ const filteredChildren : HTMLElement [ ] | undefined = Array . from ( children ) . filter ( ( child ) =>
24+ Array . from ( child . childNodes ) . some ( ( element ) => element . nodeType === Node . TEXT_NODE )
25+ ) ;
26+
27+ if ( filteredChildren && filteredChildren . length > 0 ) {
28+ acc . push ( ...Array . from ( filteredChildren ) ) ;
2529 }
2630
2731 return acc ;
@@ -48,7 +52,8 @@ export class NodeUtils {
4852
4953 const styleAttr : string = color === 'background' ? 'background-color' : 'color' ;
5054
51- if ( node . style [ styleAttr ] !== '' && node . style [ styleAttr ] !== 'initial' ) {
55+ // initial act for background as inherit
56+ if ( node . style [ styleAttr ] !== '' && ( ( color === 'background' && node . style [ styleAttr ] !== 'initial' ) || color === 'color' ) ) {
5257 return node . style [ styleAttr ] ;
5358 }
5459
You can’t perform that action at this time.
0 commit comments