t and its context.
    const canvas = document.querySelector("canvas");
    canvas.height = FONT_SIZE + VERTICAL_MARGIN * 3;
    const canvasCtx = canvas.getContext("2d");
    canvasCtx.font = FONT;
    const CHAR_HEIGHT = canvasCtx.measureText("M").emHeightAscent;

    // Create the EditContext instance.
    const editContext = new EditContext();
    canvas.editContext = editContext;

    let selectionStart = 0;
    let selectionEnd = 0;
    let textFormats = [];
    let firstRenderTime = undefined;

    f