Copy codeblock contents to clipboard

:mega: Now live in core Discourse is the ability to show a copy button for codeblocks!

import { createWidget } from 'discourse/widgets/widget';

createWidget('my-widget', {
  tagName: 'div.hello',

  html() {
    return "hello world";
  }
});

This feature is off by default, but if your community could benefit from it, you can turn it on by enabling the show copy button on codeblocks site setting.

Some notes about the feature:

44 Likes

Just a little extra announcement to append to this…

The setting has proved to be so useful and universally lauded that it is now not only default on but also tucked away as a hidden site setting: :partying_face:

8 Likes

Hello :wave:

Just a little note… Previously it was enabled on my site but than I disabled it. Now I looked for the site setting show_copy_button_on_codeblocks to turn it on again. But it has been hidden. So the reason I write it is it seems if previously had disabled this setting it keeps the default: false status and can only be activate with rails SiteSetting.show_copy_button_on_codeblocks=true.

5 Likes

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