From 9bbc6c94057641d9da6d753849812dc38eb76b18 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 22 Oct 2023 10:57:50 +1000 Subject: [PATCH] Add image occlusion to stock notetypes --- proto/anki/notetypes.proto | 1 + pylib/anki/stdmodels.py | 1 + rslib/src/import_export/package/apkg/import/notes.rs | 6 +++--- rslib/src/notetype/restore.rs | 1 + rslib/src/notetype/stock.rs | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/proto/anki/notetypes.proto b/proto/anki/notetypes.proto index f1a717752..d6dadc03f 100644 --- a/proto/anki/notetypes.proto +++ b/proto/anki/notetypes.proto @@ -147,6 +147,7 @@ message StockNotetype { KIND_BASIC_OPTIONAL_REVERSED = 2; KIND_BASIC_TYPING = 3; KIND_CLOZE = 4; + KIND_IMAGE_OCCLUSION = 5; } // 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 diff --git a/pylib/anki/stdmodels.py b/pylib/anki/stdmodels.py index ed91e7815..2ce981165 100644 --- a/pylib/anki/stdmodels.py +++ b/pylib/anki/stdmodels.py @@ -38,6 +38,7 @@ def get_stock_notetypes( StockNotetypeKind.KIND_BASIC_OPTIONAL_REVERSED, StockNotetypeKind.KIND_BASIC_TYPING, StockNotetypeKind.KIND_CLOZE, + StockNotetypeKind.KIND_IMAGE_OCCLUSION, ]: note_type = from_json_bytes(col._backend.get_stock_notetype_legacy(kind)) diff --git a/rslib/src/import_export/package/apkg/import/notes.rs b/rslib/src/import_export/package/apkg/import/notes.rs index f4c4dda22..49633fba7 100644 --- a/rslib/src/import_export/package/apkg/import/notes.rs +++ b/rslib/src/import_export/package/apkg/import/notes.rs @@ -979,7 +979,7 @@ mod test { // importing again with merge disabled will fail for the exisitng note, // 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)?; assert_eq!( dst.import_apkg(&path, ImportAnkiPackageOptions::default())? @@ -988,7 +988,7 @@ mod test { .len(), 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 // its note @@ -1006,7 +1006,7 @@ mod test { .len(), 0 ); - assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 6); + assert_eq!(dst.storage.get_all_notetype_names().unwrap().len(), 7); Ok(()) } diff --git a/rslib/src/notetype/restore.rs b/rslib/src/notetype/restore.rs index 92ca2777f..38ce51a06 100644 --- a/rslib/src/notetype/restore.rs +++ b/rslib/src/notetype/restore.rs @@ -28,6 +28,7 @@ impl Collection { Kind::BasicOptionalReversed => OriginalStockKind::BasicOptionalReversed, Kind::BasicTyping => OriginalStockKind::BasicTyping, Kind::Cloze => OriginalStockKind::Cloze, + Kind::ImageOcclusion => OriginalStockKind::ImageOcclusion, }, (stock, _) => stock, }; diff --git a/rslib/src/notetype/stock.rs b/rslib/src/notetype/stock.rs index c06cd8e90..f17f6b949 100644 --- a/rslib/src/notetype/stock.rs +++ b/rslib/src/notetype/stock.rs @@ -45,6 +45,7 @@ pub fn all_stock_notetypes(tr: &I18n) -> Vec { basic_optional_reverse(tr), basic_typing(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::BasicTyping => basic_typing(tr), Kind::Cloze => cloze(tr), + Kind::ImageOcclusion => image_occlusion_notetype(tr), } }