感谢您的回复!但我注意到,当我单击粗体按钮时,会显示 ** 代码,然后再次单击时会消失。我的自定义按钮没有再次单击时消失代码的功能。
您有什么解决方案吗?我的自定义按钮的代码如下:
<script type="text/discourse-plugin" version="0.8">
const currentLocale = I18n.currentLocale();
if (!I18n.translations[currentLocale].js.composer) {
I18n.translations[currentLocale].js.composer = {};
}
I18n.translations[currentLocale].js.composer.ttl_spoiler_text = "插入隐藏内容";
I18n.translations[currentLocale].js.ttl_dice_title = "ttl-spoiler";
api.onToolbarCreate(function(toolbar) {
toolbar.addButton({
id: "ttl-spoiler",
icon: "ttl-spoiler-icon",
group: "extras",
preventFocus: true,
trimLeading: true,
perform: (e) => e.applySurround("[spoiler]", "[/spoiler]", "ttl_spoiler_text")
});
});
</script>