All files / roosterjs-content-model-dom/lib/modelToDom/utils applyFormat.ts

100% Statements 3/3
100% Branches 4/4
100% Functions 2/2
100% Lines 3/3

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 22 23 24 25                            1x           7474x 40650x      
import type {
    ContentModelFormatBase,
    FormatApplier,
    ModelToDomContext,
} from 'roosterjs-content-model-types';
 
/**
 * @internal
 * Apply formats to the given HTML element using specified appliers
 * @param element The element to apply formats to
 * @param appliers The appliers we are using to apply formats
 * @param format The format object we get format info from
 * @param context Content Model to DOM context
 */
export function applyFormat<T extends ContentModelFormatBase>(
    element: HTMLElement,
    appliers: (FormatApplier<T> | null)[],
    format: T,
    context: ModelToDomContext
) {
    appliers.forEach(applier => {
        applier?.(format, element, context);
    });
}