Import Anki decks with their files and history

Files in content: the person's images and sounds as asset rows synced like
all content, their files kept by hash on each device, uploaded after each
sync, downloaded on demand and checked against their hash
(core/asset/AssetRepository). Rich text names them as asset:<id> URLs, in
the editor's image block and an audio block of ours; any other URL is never
fetched. Sounds play through audioplayers, one at a time. Content holding
only an image or a sound isn't blank, and lists show it as such.

The Anki import ("Import from Anki" under Add material): .apkg and .colpkg
packages in all three formats Anki has written, read on an isolate of their
own. Modern packages compress everything with zstd in frames that don't
record their size, which pure_zstd v1.0.0 refuses; our fork decodes them.
Fields become rich text by a converter of our own (lines, lists, formatting,
images, sounds, cloze deletions hidden on the front). One card per note,
the files first, studysets as chosen (flatten, sub-studysets, or tags by
subdeck), the notes' tags, and, if wanted, the review history, which FSRS
replays: the first template's reviews to the card's schedule, a reversed
note type's second to the reverse one.

Imported cards say where they came from in their first revision (card
schema 3); the dashboard doesn't count them as written. The test fixtures
are exported by Anki itself (tool/anki/make_fixtures.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-02 04:52:02 +02:00
commit a6d5769a2e
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -2013,6 +2013,210 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'This no longer exists. It may have been deleted on another device.'**
String get notFoundGone;
/// No description provided for @fileImage.
///
/// In en, this message translates to:
/// **'Image'**
String get fileImage;
/// No description provided for @fileSound.
///
/// In en, this message translates to:
/// **'Sound'**
String get fileSound;
/// No description provided for @fileImageUnavailable.
///
/// In en, this message translates to:
/// **'This image isn\'t on this device yet. It shows once it\'s uploaded and you\'re online.'**
String get fileImageUnavailable;
/// No description provided for @fileFromElsewhere.
///
/// In en, this message translates to:
/// **'Files from the web aren\'t shown.'**
String get fileFromElsewhere;
/// No description provided for @filePlaySound.
///
/// In en, this message translates to:
/// **'Play sound'**
String get filePlaySound;
/// No description provided for @fileStopSound.
///
/// In en, this message translates to:
/// **'Stop sound'**
String get fileStopSound;
/// No description provided for @fileSoundUnavailable.
///
/// In en, this message translates to:
/// **'This sound isn\'t on this device yet. It plays once it\'s uploaded and you\'re online.'**
String get fileSoundUnavailable;
/// No description provided for @ankiImportMenu.
///
/// In en, this message translates to:
/// **'Import from Anki'**
String get ankiImportMenu;
/// No description provided for @ankiImportFileType.
///
/// In en, this message translates to:
/// **'Anki decks'**
String get ankiImportFileType;
/// No description provided for @ankiImportTitle.
///
/// In en, this message translates to:
/// **'Import Anki deck'**
String get ankiImportTitle;
/// No description provided for @ankiImportOptionsTitle.
///
/// In en, this message translates to:
/// **'How should subdecks be imported?'**
String get ankiImportOptionsTitle;
/// No description provided for @ankiImportReading.
///
/// In en, this message translates to:
/// **'Reading the deck…'**
String get ankiImportReading;
/// No description provided for @ankiImportSummary.
///
/// In en, this message translates to:
/// **'{cards, plural, =1{1 card.} other{{cards} cards.}}'**
String ankiImportSummary(int cards);
/// No description provided for @ankiImportSummaryDecks.
///
/// In en, this message translates to:
/// **'{cards, plural, =1{1 card} other{{cards} cards}} across {decks} subdecks.'**
String ankiImportSummaryDecks(int cards, int decks);
/// No description provided for @ankiImportModeFlatten.
///
/// In en, this message translates to:
/// **'Flatten into this studyset'**
String get ankiImportModeFlatten;
/// No description provided for @ankiImportModeFlattenSubtitle.
///
/// In en, this message translates to:
/// **'Import every card here and ignore the subdecks.'**
String get ankiImportModeFlattenSubtitle;
/// No description provided for @ankiImportModeSubStudysets.
///
/// In en, this message translates to:
/// **'Recreate as sub-studysets'**
String get ankiImportModeSubStudysets;
/// No description provided for @ankiImportModeSubStudysetsSubtitle.
///
/// In en, this message translates to:
/// **'Mirror the subdeck tree: each subdeck becomes a nested studyset.'**
String get ankiImportModeSubStudysetsSubtitle;
/// No description provided for @ankiImportModeTag.
///
/// In en, this message translates to:
/// **'Tag cards by subdeck'**
String get ankiImportModeTag;
/// No description provided for @ankiImportModeTagSubtitle.
///
/// In en, this message translates to:
/// **'Keep every card here, tagged with each subdeck it came from.'**
String get ankiImportModeTagSubtitle;
/// No description provided for @ankiImportProgress.
///
/// In en, this message translates to:
/// **'Import study progress'**
String get ankiImportProgress;
/// No description provided for @ankiImportProgressSubtitle.
///
/// In en, this message translates to:
/// **'Bring Anki\'s review history over: cards continue where they left off. New cards stay new.'**
String get ankiImportProgressSubtitle;
/// No description provided for @ankiImportMedia.
///
/// In en, this message translates to:
/// **'{count, plural, =1{Include media (1 file)} other{Include media ({count} files)}}'**
String ankiImportMedia(int count);
/// No description provided for @ankiImportMediaSubtitle.
///
/// In en, this message translates to:
/// **'Keep the deck\'s images and sounds on the cards.'**
String get ankiImportMediaSubtitle;
/// No description provided for @ankiImportRunning.
///
/// In en, this message translates to:
/// **'Importing…'**
String get ankiImportRunning;
/// No description provided for @ankiImportConfirm.
///
/// In en, this message translates to:
/// **'Import'**
String get ankiImportConfirm;
/// No description provided for @ankiImportNotAPackage.
///
/// In en, this message translates to:
/// **'This isn\'t an Anki deck. In Anki, export a deck as an .apkg file and import that.'**
String get ankiImportNotAPackage;
/// No description provided for @ankiImportNewerFormat.
///
/// In en, this message translates to:
/// **'This deck comes from a newer Anki than this app knows. Export it again with “Support older Anki versions”.'**
String get ankiImportNewerFormat;
/// No description provided for @ankiImportUnreadable.
///
/// In en, this message translates to:
/// **'This deck is damaged and can\'t be read.'**
String get ankiImportUnreadable;
/// No description provided for @ankiImportBrokeOff.
///
/// In en, this message translates to:
/// **'The import broke off. The cards it brought in so far stay.'**
String get ankiImportBrokeOff;
/// No description provided for @ankiImported.
///
/// In en, this message translates to:
/// **'{count, plural, =1{Imported 1 flashcard from Anki.} other{Imported {count} flashcards from Anki.}}'**
String ankiImported(int count);
/// No description provided for @ankiImportedSubStudysets.
///
/// In en, this message translates to:
/// **'{count, plural, =1{Imported 1 card into sub-studysets.} other{Imported {count} cards into sub-studysets.}}'**
String ankiImportedSubStudysets(int count);
/// No description provided for @ankiImportedTagged.
///
/// In en, this message translates to:
/// **'{count, plural, =1{Imported 1 card, tagged by subdeck.} other{Imported {count} cards, tagged by subdeck.}}'**
String ankiImportedTagged(int count);
/// No description provided for @ankiImportFilesSkipped.
///
/// In en, this message translates to:
/// **'{count, plural, =1{1 media file couldn\'t be imported.} other{{count} media files couldn\'t be imported.}}'**
String ankiImportFilesSkipped(int count);
}
class _AppLocalizationsDelegate