Show/Hide Cloze button depending on whether cloze type

This commit is contained in:
Henrik Giesel 2021-04-08 23:17:11 +02:00
parent fe4ba87490
commit eceb98f8e6
2 changed files with 12 additions and 2 deletions

View File

@ -1351,3 +1351,13 @@ gui_hooks.editor_will_use_font_for_field.append(fontMungeHack)
gui_hooks.editor_will_munge_html.append(munge_html)
gui_hooks.editor_will_munge_html.append(remove_null_bytes)
gui_hooks.editor_will_munge_html.append(reverse_url_quoting)
def set_cloze_button(editor: Editor) -> None:
if editor.note.model()["type"] == MODEL_CLOZE:
editor.web.eval('document.getElementById("editorToolbar").showButton("template", "cloze"); ')
else:
editor.web.eval('document.getElementById("editorToolbar").hideButton("template", "cloze"); ')
gui_hooks.editor_did_load_note.append(set_cloze_button)

View File

@ -36,11 +36,11 @@ function searchByIdOrIndex<T extends { id?: string }>(
: values[idOrIndex];
}
function hideComponent(component: Hideable) {
function showComponent(component: Hideable) {
component.hidden = false;
}
function showComponent(component: Hideable) {
function hideComponent(component: Hideable) {
component.hidden = true;
}