Add image occlusion to stock notetypes

This commit is contained in:
Damien Elmes 2023-10-22 10:57:50 +10:00
parent 26b2ac4ee3
commit 9bbc6c9405
5 changed files with 8 additions and 3 deletions

View file

@ -147,6 +147,7 @@ message StockNotetype {
KIND_BASIC_OPTIONAL_REVERSED = 2; KIND_BASIC_OPTIONAL_REVERSED = 2;
KIND_BASIC_TYPING = 3; KIND_BASIC_TYPING = 3;
KIND_CLOZE = 4; KIND_CLOZE = 4;
KIND_IMAGE_OCCLUSION = 5;
} }
// This is decoupled from Kind to allow us to evolve notetypes over time // This is decoupled from Kind to allow us to evolve notetypes over time
// (eg an older notetype might require different JS), and allow us to store // (eg an older notetype might require different JS), and allow us to store

View file

@ -38,6 +38,7 @@ def get_stock_notetypes(
StockNotetypeKind.KIND_BASIC_OPTIONAL_REVERSED, StockNotetypeKind.KIND_BASIC_OPTIONAL_REVERSED,
StockNotetypeKind.KIND_BASIC_TYPING, StockNotetypeKind.KIND_BASIC_TYPING,
StockNotetypeKind.KIND_CLOZE, StockNotetypeKind.KIND_CLOZE,
StockNotetypeKind.KIND_IMAGE_OCCLUSION,
]: ]:
note_type = from_json_bytes(col._backend.get_stock_notetype_legacy(kind)) note_type = from_json_bytes(col._backend.get_stock_notetype_legacy(kind))

View file

@ -979,7 +979,7 @@ mod test {
// importing again with merge disabled will fail for the exisitng note, // importing again with merge disabled will fail for the exisitng note,
// but the new one will be added with an extra notetype // but the new one will be added with an extra notetype
assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 6); assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 7);
src.export_apkg(&path, "", false, false, false, None)?; src.export_apkg(&path, "", false, false, false, None)?;
assert_eq!( assert_eq!(
dst.import_apkg(&path, ImportAnkiPackageOptions::default())? dst.import_apkg(&path, ImportAnkiPackageOptions::default())?
@ -988,7 +988,7 @@ mod test {
.len(), .len(),
1 1
); );
assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 7); assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 8);
// if enabling merge, it should succeed and remove the empty notetype, remapping // if enabling merge, it should succeed and remove the empty notetype, remapping
// its note // its note
@ -1006,7 +1006,7 @@ mod test {
.len(), .len(),
0 0
); );
assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 6); assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 7);
Ok(()) Ok(())
} }

View file

@ -28,6 +28,7 @@ impl Collection {
Kind::BasicOptionalReversed => OriginalStockKind::BasicOptionalReversed, Kind::BasicOptionalReversed => OriginalStockKind::BasicOptionalReversed,
Kind::BasicTyping => OriginalStockKind::BasicTyping, Kind::BasicTyping => OriginalStockKind::BasicTyping,
Kind::Cloze => OriginalStockKind::Cloze, Kind::Cloze => OriginalStockKind::Cloze,
Kind::ImageOcclusion => OriginalStockKind::ImageOcclusion,
}, },
(stock, _) => stock, (stock, _) => stock,
}; };

View file

@ -45,6 +45,7 @@ pub fn all_stock_notetypes(tr: &I18n) -> Vec<Notetype> {
basic_optional_reverse(tr), basic_optional_reverse(tr),
basic_typing(tr), basic_typing(tr),
cloze(tr), cloze(tr),
image_occlusion_notetype(tr),
] ]
} }
@ -81,6 +82,7 @@ pub(crate) fn get_stock_notetype(kind: StockKind, tr: &I18n) -> Notetype {
Kind::BasicOptionalReversed => basic_optional_reverse(tr), Kind::BasicOptionalReversed => basic_optional_reverse(tr),
Kind::BasicTyping => basic_typing(tr), Kind::BasicTyping => basic_typing(tr),
Kind::Cloze => cloze(tr), Kind::Cloze => cloze(tr),
Kind::ImageOcclusion => image_occlusion_notetype(tr),
} }
} }