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개의 좋아요

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:

https://github.com/discourse/discourse/commit/81f3f56deb9d9f363e8b3bdcf81306fc34751d7d

8개의 좋아요

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개의 좋아요

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