lear the canvas.
      canvasCtx.clearRect(0, 0, canvas.width, canvas.height);

      // Render the text.
      canvasCtx.fillText(editContext.text, TEXT_ANCHOR_X, TEXT_ANCHOR_Y);

      if (selectionStart == selectionEnd) {
        // Render the caret.
        const caretIndex = selectionStart;
        const caretX = TEXT_ANCHOR_X + canvasCtx.measureText(editContext.text.substring(0, caretIndex)).width;

        if (elapsedTime % BLINK_SPEED < BLINK_SPEED / 2) {
          renderCaret(caretX);
        }

  