All files / roosterjs-content-model-plugins/lib/paste/parsers deprecatedColorParser.ts

100% Statements 10/10
100% Branches 6/6
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221x           1x     60x 240x 240x 240x   3028x   119x 119x        
import { BorderKeys, DeprecatedColors } from 'roosterjs-content-model-dom';
import type { BorderFormat, FormatParser } from 'roosterjs-content-model-types';
 
/**
 * @internal
 */
export const deprecatedBorderColorParser: FormatParser<BorderFormat> = (
    format: BorderFormat
): void => {
    BorderKeys.forEach(key => {
        const value = format[key];
        let color: string = '';
        if (
            value &&
            DeprecatedColors.some(dColor => value.indexOf(dColor) > -1 && (color = dColor))
        ) {
            const newValue = value.replace(color, '').trimRight();
            format[key] = newValue;
        }
    });
};