Avoiding overlapping comments

Hi,

I’m working on an annotation prototype, similar to Google Docs annotations.

When you click on the canvas, it creates an inline comment. However, I want to ensure that existing comments never overlap, and if they move, they don’t end up on top of each other.

I’m new to this—do you have any advice on how to prevent the comment boxes from overlapping?

Thank you