All files / roosterjs-content-model-dom/lib/modelApi/editing runEditSteps.ts

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

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 26                        1x 344x 225x 217x               225x    
import type {
    DeleteSelectionContext,
    DeleteSelectionResult,
    DeleteSelectionStep,
    ValidDeleteSelectionContext,
} from 'roosterjs-content-model-types';
 
/**
 * Run editing steps on top of a given context object which includes current insert point and previous editing result
 * @param steps The editing steps to run
 * @param context Context for the editing steps.
 */
export function runEditSteps(steps: DeleteSelectionStep[], context: DeleteSelectionResult) {
    steps.forEach(step => {
        if (step && isValidDeleteSelectionContext(context)) {
            step(context);
        }
    });
}
 
function isValidDeleteSelectionContext(
    context: DeleteSelectionContext
): context is ValidDeleteSelectionContext {
    return !!context.insertPoint;
}