我在下面添加了一些自定义按钮,但我想知道如何在 TOOLBAR CLASS 中删除已添加的按钮?![]()

另外,我的自定义按钮功能是我用来快速添加骰子的代码片段,我想知道如何让这个按钮在再次单击时像粗体按钮一样使已添加的文本消失?
我搜索了很多主题但仍然找不到解决方案
感谢您的回复!
我在下面添加了一些自定义按钮,但我想知道如何在 TOOLBAR CLASS 中删除已添加的按钮?![]()

另外,我的自定义按钮功能是我用来快速添加骰子的代码片段,我想知道如何让这个按钮在再次单击时像粗体按钮一样使已添加的文本消失?
使用 CSS 隐藏工具栏按钮可能就足够了。
以及由 applySurround 方法实现的 bold 函数。
感谢您的回复!但我注意到,当我单击粗体按钮时,会显示 ** 代码,然后再次单击时会消失。我的自定义按钮没有再次单击时消失代码的功能。
您有什么解决方案吗?我的自定义按钮的代码如下:
<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>
试试 opts 参数。