Embed Runkit widget in Discourse

Hey there! I’m running a Discourse-hosted Discourse instance (business plan, not enterprise), and wanted to embed a Runkit widget in a post. Do you know whether this is possible? Thanks!

3 Likes

Technically this is possible with a theme component that decorates posts, you would then define a [wrap] section for the embed and on post decoration load up the library and do the embedding stuff.

I would recommend quite a bit of caution here:

  1. You don’t want to invalidate your CSP, so you would have to consider this
  2. You do not want to slow down Discourse due to loading some big dynamic JS payload
  3. You are placing a lot of trust with runkit by allowing them to run JavaScript on your Discourse.

I would estimate building something here would take 1-2 days of work. If you have budget perhaps open a topic on #marketplace ? Theme components can be installed fine on our business plan setups.

5 Likes

Thanks to the oEmbed standard, you can add https://runkit.com/ to the setting allowed iframes and call it a day.

Just paste a runkit URL in a line by itself and Discourse will work it’s magic:

https://runkit.com/falco/5e13a3b7f5d2e2001a5741d2

becomes

It does becomes weird when the embed is too long, so a theme-component to help decorate (and scroll) embeds may be needed indeed.

7 Likes

Thanks a lot for your replies! @sam Runkit runs code server-side on their end, not client-side, so it’s rather safe (it may slow down loading due to the loading of the widget itself, but that’s it).

@Falco I had totally missed the allowed iframes setting. As soon as I set it, it started working like a charm! I’ll see what I can do regarding the team component :slight_smile:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.