核心 Discourse 现已上线代码块显示“复制”按钮的功能!
import { createWidget } from 'discourse/widgets/widget';
createWidget('my-widget', {
tagName: 'div.hello',
html() {
return "hello world";
}
});
此功能默认关闭,但如果您的社区需要,可以通过启用站点设置 show copy button on codeblocks 来开启。
关于此功能的一些说明:
- 该按钮仅显示在
pre > code代码块上,不适用于行内代码、引用代码或单框代码。 - 由于 Discourse 将于 2020 年 6 月 1 日停止支持 Internet Explorer 11 (IE11),此功能不兼容 Internet Explorer。
- Copy Codeblocks 主题组件 仍可用于旧版 Discourse 实例,但将不再接收任何更新。