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

これを補足するちょっとした追加のお知らせです…

この設定は非常に便利で、広く称賛されているため、現在はデフォルトでオンになっているだけでなく、非表示のサイト設定として隠されています。 :partying_face:

「いいね!」 8

こんにちは :wave:

ちょっとしたメモです…以前は私のサイトで有効になっていましたが、無効にしました。サイト設定の show_copy_button_on_codeblocks を探して再度有効にしようとしましたが、非表示になっていました。そのため、以前この設定を無効にしていた場合、default: false のステータスが維持され、Rails の SiteSetting.show_copy_button_on_codeblocks=true でのみ有効化できるようです。

「いいね!」 5

このトピックは、最後の返信から7日後に自動的に閉じられました。新しい返信は許可されていません。