mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add the Extra field back to cloze deletions as "Back Extra"
Originally removed because some users were adding cloze deletions to it, but removing it just replaced that problem with a new problem where users add the field but don't add it to their card templates.
This commit is contained in:
parent
7bab99d873
commit
389b8a0536
3 changed files with 13 additions and 4 deletions
|
@ -4,6 +4,7 @@ notetypes-front-field = Front
|
||||||
notetypes-back-field = Back
|
notetypes-back-field = Back
|
||||||
notetypes-add-reverse-field = Add Reverse
|
notetypes-add-reverse-field = Add Reverse
|
||||||
notetypes-text-field = Text
|
notetypes-text-field = Text
|
||||||
|
notetypes-back-extra-field = Back Extra
|
||||||
|
|
||||||
## Default note type names
|
## Default note type names
|
||||||
|
|
||||||
|
|
|
@ -142,11 +142,16 @@ mod test {
|
||||||
assert_eq!(¬e.fields, &["one BBB", "two BBB"]);
|
assert_eq!(¬e.fields, &["one BBB", "two BBB"]);
|
||||||
|
|
||||||
let note2 = col.storage.get_note(note2.id)?.unwrap();
|
let note2 = col.storage.get_note(note2.id)?.unwrap();
|
||||||
assert_eq!(¬e2.fields, &["three BBB"]);
|
assert_eq!(¬e2.fields, &["three BBB", ""]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
col.storage.field_names_for_notes(&nids)?,
|
col.storage.field_names_for_notes(&nids)?,
|
||||||
vec!["Back".to_string(), "Front".into(), "Text".into()]
|
vec![
|
||||||
|
"Back".to_string(),
|
||||||
|
"Back Extra".into(),
|
||||||
|
"Front".into(),
|
||||||
|
"Text".into()
|
||||||
|
]
|
||||||
);
|
);
|
||||||
let cnt = col.find_and_replace(nids.clone(), "BBB", "ccc", Some("Front".into()))?;
|
let cnt = col.find_and_replace(nids.clone(), "BBB", "ccc", Some("Front".into()))?;
|
||||||
// still 2, as the caller is expected to provide only note ids that have
|
// still 2, as the caller is expected to provide only note ids that have
|
||||||
|
|
|
@ -112,8 +112,11 @@ pub(crate) fn cloze(i18n: &I18n) -> NoteType {
|
||||||
nt.name = i18n.tr(TR::NotetypesClozeName).into();
|
nt.name = i18n.tr(TR::NotetypesClozeName).into();
|
||||||
let text = i18n.tr(TR::NotetypesTextField);
|
let text = i18n.tr(TR::NotetypesTextField);
|
||||||
nt.add_field(text.as_ref());
|
nt.add_field(text.as_ref());
|
||||||
let fmt = format!("{{{{cloze:{}}}}}", text);
|
let back_extra = i18n.tr(TR::NotetypesBackExtraField);
|
||||||
nt.add_template(nt.name.clone(), fmt.clone(), fmt);
|
nt.add_field(back_extra.as_ref());
|
||||||
|
let qfmt = format!("{{{{cloze:{}}}}}", text);
|
||||||
|
let afmt = format!("{}<br>\n{{{{{}}}}}", qfmt, back_extra);
|
||||||
|
nt.add_template(nt.name.clone(), qfmt, afmt);
|
||||||
nt.config.kind = NoteTypeKind::Cloze as i32;
|
nt.config.kind = NoteTypeKind::Cloze as i32;
|
||||||
nt.config.css += "
|
nt.config.css += "
|
||||||
.cloze {
|
.cloze {
|
||||||
|
|
Loading…
Reference in a new issue