I think it’s worth studying how other plugins work, for example: Visual Composer.
The logic that came into my head, is to pick the element selector clicked with jQuery, and work on it. Read this that may help you:
https://stackoverflow.com/questions/5706837/get-unique-selector-of-element-in-jquery
Following this logic, if each page element has the same class, it will be easier to work with