be994f4102
Allows add-on authors to define their own label for a group of undoable operations. For example: def mark_and_bury( *, parent: QWidget, card_id: CardId, ) -> CollectionOp[OpChanges]: def op(col: Collection) -> OpChanges: target = col.add_custom_undo_entry("Mark and Bury") col.sched.bury_cards([card_id]) card = col.get_card(card_id) col.tags.bulk_add(note_ids=[card.nid], tags="marked") return col.merge_undo_entries(target) return CollectionOp(parent, op) The .add_custom_undo_entry() is for adding your own custom actions. When extending a standard Anki action, instead store `target = col.undo_status().last_step` after executing the standard operation. This started out as a bigger refactor that required a separate .commit_undoable() call to be run after each operation, instead of having each operation return changes directly. But that proved to be somewhat cumbersome in unit tests, and ran the risk of unexpected behaviour if the caller invoked an operation without remembering to finalize it. |
||
---|---|---|
.. | ||
anki | ||
rsbridge | ||
tests | ||
tools | ||
.gitignore | ||
.isort.cfg | ||
.pylintrc | ||
BUILD.bazel | ||
mypy.ini | ||
orjson.bzl | ||
protobuf.bzl | ||
README.md |
Anki's Python library code is in anki/.
The Rust/Python extension module is in rsbridge/; it references the library defined in ../rslib.