我使用 Jodit 作为所见即所得编辑器,并且有一个初学者问题。 在编辑器初始化时,我想隐藏工具栏。 这很完美:
var editor = new Jodit('#freitext_oben', {
fullsize: false,
toolbar: false,
editorCssClass: 'editor_freitext'
});
现在我想要一个自定义按钮,它调用一个切换工具栏的函数,但我不知道如何设置此选项。
我需要类似的东西
function toggle_toolbar() {
editor.toggleToolbar();
}
但我不知道确切的语法...
请帮忙;-(
所以这是我发现的一种方法:
public ToggleToolbarVisibility()
{
if(!editor.editor.toolbar.container.style.display != "none")
{
editor.toolbar.container.style.display = "none";
}
else
{
editor.toolbar.container.style.display = "";
}
}
Jodit 有
show
和 hide
工具栏方法,所以你可以尝试以下方法:
let isToolbarVisible = false;
function toggle_toolbar() {
if (isToolbarVisible) editor.toolbar.hide()
else editor.toolbar.show();
isToolbarVisible = !isToolbarVisible;
}