From 0f549d2b82f3916f853cec3a89d4f1fe9ba60601 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Mon, 14 Jun 2021 10:21:42 +0200 Subject: [PATCH] Merge cloze hint divs into one --- qt/aqt/editor.py | 17 ++++++----------- ts/editor/fields.scss | 3 +-- ts/editor/index.ts | 9 ++------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index f9f60a7af..b07137d69 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -81,8 +81,7 @@ _html = """
{}
-
{}
-
{}
+
""" @@ -131,11 +130,7 @@ class Editor: # then load page self.web.stdHtml( - _html.format( - tr.editing_show_duplicates(), - tr.adding_cloze_outside_cloze_notetype(), - tr.adding_cloze_outside_cloze_field(), - ), + _html.format(tr.editing_show_duplicates()), css=[ "css/editor.css", ], @@ -515,16 +510,16 @@ $editorToolbar.then(({{ toolbar }}) => toolbar.appendGroup({{ def _update_duplicate_display(self, result: NoteFieldsCheckResult.V) -> None: cols = [""] * len(self.note.fields) - wrong_notetype = wrong_field = "false" + cloze_hint = "" if result == NoteFieldsCheckResult.DUPLICATE: cols[0] = "dupe" elif result == NoteFieldsCheckResult.NOTETYPE_NOT_CLOZE: - wrong_notetype = "true" + cloze_hint = tr.adding_cloze_outside_cloze_notetype() elif result == NoteFieldsCheckResult.FIELD_NOT_CLOZE: - wrong_field = "true" + cloze_hint = tr.adding_cloze_outside_cloze_field() self.web.eval(f"setBackgrounds({json.dumps(cols)});") - self.web.eval(f"setClozeHints({wrong_notetype}, {wrong_field});") + self.web.eval(f"setClozeHint({json.dumps(cloze_hint)});") def showDupes(self) -> None: aqt.dialogs.open( diff --git a/ts/editor/fields.scss b/ts/editor/fields.scss index f5533bf65..857a16ac1 100644 --- a/ts/editor/fields.scss +++ b/ts/editor/fields.scss @@ -29,8 +29,7 @@ } #dupes, -#not-a-cloze-notetype, -#not-a-cloze-field { +#cloze-hint { position: sticky; bottom: 0; diff --git a/ts/editor/index.ts b/ts/editor/index.ts index a118203f6..6056047cc 100644 --- a/ts/editor/index.ts +++ b/ts/editor/index.ts @@ -144,13 +144,8 @@ export function setBackgrounds(cols: ("dupe" | "")[]): void { .classList.toggle("is-inactive", !cols.includes("dupe")); } -export function setClozeHints(wrong_notetype: boolean, wrong_field: boolean): void { - document - .getElementById("not-a-cloze-notetype")! - .classList.toggle("is-inactive", !wrong_notetype); - document - .getElementById("not-a-cloze-field")! - .classList.toggle("is-inactive", !wrong_field); +export function setClozeHint(cloze_hint: string): void { + document.getElementById("cloze-hint")!.innerHTML = cloze_hint; } export function setFonts(fonts: [string, number, boolean][]): void {