Here are a few screenshots of the original codebase, directly based on a project we did for a customer. The basic functionality was all there, but the internals needed rewrites.
When the user drags a selection, the selection changes color to indicate the legality of tag insertion.

This is illegal, since inserting a tag here would result in improper
nesting of tags.

This, on the other hand, is valid. The user right-clicks and chooses
the tag from the popup menu of legal tags.

The user chose the tag "Commercial", the tag is added, and the display
expands slightly to make space for it.