Keep model of add cards

AnkiWeb addon 424778276

Keeps the note type in the Add window fixed unless changed there, preventing unintended model switches from the browser, importer, or other windows that can cause data loss.
AI-generated summary; may contain mistakes.

card-creationnote-managementbugfix-workaround

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
13 (👍 11 · 👎 2)
Updated
2021-10-16
Anki versions
2.1.48~
License
GPL-3.0 (from the license file in the package)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python, Batchfile
Description language
en

Maintenance

abandoned

  • Last update or commit: 2021-10-16 (1842 days before the snapshot).
  • Commits in the last year: 0.
  • Issues: 3 open, 7 closed.
  • Pull requests: 1 open, 0 merged.
  • Median first response: 1 hour (7 answered issues and pull requests).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.02.1.232019-03-22
2.1.242.1.472020-05-16
2.1.48+2021-10-16
History across monthly snapshots

Loading…

Similar addons

Auto Markdown has 2 forks →

Converts fields between Markdown and HTML automatically on focus change or manually via a configurable shortcut, while preventing editing of the generated HTML.

formatting

42 votes 56% approval 👍 30 · 👎 12 ⭐ 36 Updated 2019-06-18

Description

Ensure that the «add» window keep the same model. This correct a bug which, sometime, change the model in the add window, because you changed it in import or while changing a note's type.

README

Keep model of add cards

Rationale

For some reason, the note type in anki «add» window may suddenly change. In the worst case, it may lead to losing data, if the new note type has less fields than the old note type. It may also means you'll submit the note in the wrong type if you didn't pay attention.

More precisely, this may occur in the following cases:

  • In the browser, if you change the note type of a note already existing.
  • If you use the importing window and change the note type.
  • Using addon Open multiple instances of the same window, when you change the note type of a «add» window.

Usage

This add-on ensure that the note type of a «add» window only change when you choose a note type from the same window.

Internal

  • In module aqt.addcards, AddCards is replaced by a class. The new class inherits from the older one. It redefines __init__ and _reject, by calling the previous method, and changing its hooks. It redefines setupChoosers, onReset, _addCards, by copy-pasting the previous code and doing some modification. Thus, it may be incompatible with other add-ons also editing those notes. Finally it creates a method onResetSameModel.
  • Hooks currentModelChanged does not change anything in the "add" window. "reset" still call the method "onReset", but a version which does not change the model.
  • The ModelChooser of the "add" window is a new class, inheriting from aqt.modelchooser.ModelChooser. It redefines __init__, calling the previous method and removing some hook. It redefine onModelChange by copy-paste the old code, removing everything affecting the environment, and affecting directly the current "add" window.

Links, licence and credits

Key Value
Copyright Arthur Milchior arthur@milchior.fr
Based on Anki code by Damien Elmes anki@ichi2.net
License GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
Source in https://github.com/Arthur-Milchior/anki-keep-model-in-add-cards
Addon number 424778276