mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Merge cloze hint divs into one
This commit is contained in:
parent
5574cb1cfe
commit
0f549d2b82
3 changed files with 9 additions and 20 deletions
|
@ -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(
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
}
|
||||
|
||||
#dupes,
|
||||
#not-a-cloze-notetype,
|
||||
#not-a-cloze-field {
|
||||
#cloze-hint {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue