Hi,
In the content tree a JavaScript and jQuery is used for this functionality and it is then invoking appropriate code API to perform the changes. This could be pretty complex - it may be easier to either developer custom web part or integrate some third party one.
Best regards,
Juraj Ondrus