How to add a custom toolbar button via external JS?

AI 生成的摘要

godlike is developing a universal JavaScript plugin to add external image hosting support to various forum platforms, including Discourse. While successfully implemented on IPB, Vanilla, and XenForo, they’re facing challenges with Discourse due to its dynamic editor template parsing. They seek guidance on adding a custom toolbar button externally without relying on hacks or event handlers, noting awareness of a workaround but preferring a reliable external solution.

Hi there,

I develop an image hosting script (Chevereto) and I’m building a universal JS plugin that aims to add external image hosting support for a wide range of forum CMS and websites in general. The idea is to achieve this without the need of a custom plugin for each CMS. So far I’ve added it successfully to IPB, Vanilla, XenForo, etc. The plugin is quite straightforward: It detects vendor, editor function and it picks a sibling to append my button element next to it.

For Discourse, I’m having issues since the editor template gets parsed on demand and I’m unable to find a good way to achieve this without the need to add some event handler or hack some object containing that section template.

I will like some guidance here in terms to try to get this to work without breaking something else. Please keep in mind that I’m aware of this workaround but like I said earlier, I’m building it as an external plugin so I will look into that only if the external way is not reliable.

Hope there is way to do this,
Thanks.

1 个赞