Merge cloze hint divs into one

This commit is contained in:
RumovZ 2021-06-14 10:21:42 +02:00
parent 5574cb1cfe
commit 0f549d2b82
3 changed files with 9 additions and 20 deletions

View file

@ -81,8 +81,7 @@ _html = """
<div id="dupes" class="is-inactive">
<a href="#" onclick="pycmd('dupes');return false;">{}</a>
</div>
<div id="not-a-cloze-notetype" class="is-inactive">{}</div>
<div id="not-a-cloze-field" class="is-inactive">{}</div>
<div id="cloze-hint"></div>
"""
@ -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(

View file

@ -29,8 +29,7 @@
}
#dupes,
#not-a-cloze-notetype,
#not-a-cloze-field {
#cloze-hint {
position: sticky;
bottom: 0;

View file

@ -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 {