mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12: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">
|
<div id="dupes" class="is-inactive">
|
||||||
<a href="#" onclick="pycmd('dupes');return false;">{}</a>
|
<a href="#" onclick="pycmd('dupes');return false;">{}</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="not-a-cloze-notetype" class="is-inactive">{}</div>
|
<div id="cloze-hint"></div>
|
||||||
<div id="not-a-cloze-field" class="is-inactive">{}</div>
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,11 +130,7 @@ class Editor:
|
||||||
|
|
||||||
# then load page
|
# then load page
|
||||||
self.web.stdHtml(
|
self.web.stdHtml(
|
||||||
_html.format(
|
_html.format(tr.editing_show_duplicates()),
|
||||||
tr.editing_show_duplicates(),
|
|
||||||
tr.adding_cloze_outside_cloze_notetype(),
|
|
||||||
tr.adding_cloze_outside_cloze_field(),
|
|
||||||
),
|
|
||||||
css=[
|
css=[
|
||||||
"css/editor.css",
|
"css/editor.css",
|
||||||
],
|
],
|
||||||
|
@ -515,16 +510,16 @@ $editorToolbar.then(({{ toolbar }}) => toolbar.appendGroup({{
|
||||||
|
|
||||||
def _update_duplicate_display(self, result: NoteFieldsCheckResult.V) -> None:
|
def _update_duplicate_display(self, result: NoteFieldsCheckResult.V) -> None:
|
||||||
cols = [""] * len(self.note.fields)
|
cols = [""] * len(self.note.fields)
|
||||||
wrong_notetype = wrong_field = "false"
|
cloze_hint = ""
|
||||||
if result == NoteFieldsCheckResult.DUPLICATE:
|
if result == NoteFieldsCheckResult.DUPLICATE:
|
||||||
cols[0] = "dupe"
|
cols[0] = "dupe"
|
||||||
elif result == NoteFieldsCheckResult.NOTETYPE_NOT_CLOZE:
|
elif result == NoteFieldsCheckResult.NOTETYPE_NOT_CLOZE:
|
||||||
wrong_notetype = "true"
|
cloze_hint = tr.adding_cloze_outside_cloze_notetype()
|
||||||
elif result == NoteFieldsCheckResult.FIELD_NOT_CLOZE:
|
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"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:
|
def showDupes(self) -> None:
|
||||||
aqt.dialogs.open(
|
aqt.dialogs.open(
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#dupes,
|
#dupes,
|
||||||
#not-a-cloze-notetype,
|
#cloze-hint {
|
||||||
#not-a-cloze-field {
|
|
||||||
position: sticky;
|
position: sticky;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|
||||||
|
|
|
@ -144,13 +144,8 @@ export function setBackgrounds(cols: ("dupe" | "")[]): void {
|
||||||
.classList.toggle("is-inactive", !cols.includes("dupe"));
|
.classList.toggle("is-inactive", !cols.includes("dupe"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setClozeHints(wrong_notetype: boolean, wrong_field: boolean): void {
|
export function setClozeHint(cloze_hint: string): void {
|
||||||
document
|
document.getElementById("cloze-hint")!.innerHTML = cloze_hint;
|
||||||
.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 setFonts(fonts: [string, number, boolean][]): void {
|
export function setFonts(fonts: [string, number, boolean][]): void {
|
||||||
|
|
Loading…
Reference in a new issue