Comment-rendering events for embedded content
Hi, I'm writing my first Vanilla plugin for embedding some content in discussions/comments. I don't want to save any extra information with the posts (dirty markup), and I want to let the 'front end' do the lifting, so I'm approaching it like this:
- Hook into comment-rendering events and search for content URLs using regex.
- Wrap URL in a tag to mark it for embedded content (a span tag works well here as it's 'safe' HTML)
- Use JS to do the embedding (find the span, get the URL, magicmagicmagic)
This works well using
DiscussionController_AfterCommentFormat_Handler, but of course only works on page render. I'm looking to cover all bases, so that the rendering can happen after a user posts, or after editing a comment. These events appear to be more JS-related, as
DiscussionController_AfterCommentFormat_Handler doesn't seem to hook into these actions, and I can't find any docs on Vanilla's JS.
I guess my main questions are: am I approaching this correctly? Would those of you with more insight approach this differently? If the approach seems sane, what events (PHP or JS) should I be hooking into so that I can do the rendering on posting/editing a comment? The Eventi plugin appears to have fallen behind the times and isn't a lot of help!