mirror of
https://github.com/panatgithub/AnkiHeadingSync.git
synced 2026-07-22 06:51:43 +00:00
中文: 新增填空题(全部挖空)变种,支持 #anki-cloze-all 并复用现有填空题模板与主字段。 English: Adds an all-cloze variant using #anki-cloze-all while reusing the existing Cloze note type and main field mapping.
3.5 KiB
3.5 KiB
Cloze All Variant Gap Report
Scope
This report records the real repository state before adding the new cloze-all recognition variant.
Current Cloze recognition flow
- Card type recognition is driven by
cardTypeConfigsinPluginSettings.ts. - Current config ids are
basic,qa-group, andcloze. CardIndexingService.tsresolves headings by:- enabled config
- matching heading level
- matching extra marker suffix when present
- falling back to the empty-marker row only if no marker row matched
- Current Cloze recognition is the
clozeconfig only. - Current default Cloze recognition is
H4 + #anki-cloze. - Indexed normal cards currently only carry
cardType: "basic" | "cloze"; there is no Cloze mode metadata yet.
Current Cloze render and numbering flow
ManualCardRenderer.tsconverts unnumbered highlight or brace cloze segments into Anki native cloze markup.- Current auto-numbering is always sequential because the renderer uses a local
nextClozeIndexcounter. - Explicit numbering is already preserved because the renderer prefers the parsed explicit index when present.
- Current behavior already preserves:
{c2:内容}asc2{{c2::内容}}asc2
- Current render config hashing is handled by
RenderConfigService.ts. - The render config hash does not currently include any Cloze-mode discriminator.
Current settings table behavior
- Visible settings rows are controlled by
VISIBLE_CARD_TYPE_CONFIG_IDSinPluginSettingTab.ts. - Current visible rows are
basic,qa-group, andcloze. getRuntimeCardType(configId)already separates config id from runtime mapping type.clozecurrently shows:- enabled toggle
- heading level
- extra marker
- note type selector
- main field selector
- Field mapping cache hydration and configured-count logic currently assume each visible config resolves its own note type.
Exact model and type changes needed
- Add a new config id:
cloze-all. - Extend default card type configs and normalization so old settings missing
cloze-allare backfilled safely. - Keep runtime
cardTypeasclozefor bothclozeandcloze-all. - Add optional
clozeModemetadata toIndexedCard. - Have indexing emit:
clozeMode: "sequential"forclozeclozeMode: "all"forcloze-all
- Update
ManualCardRendererto useclozeModewhen assigning numbers to unnumbered cloze segments. - Update
RenderConfigServiceso hash payload includesclozeModewith legacy fallback tosequential. - Update settings-page helpers so
cloze-allreuses the existing Cloze note type and mapping instead of introducing a new one.
Tests likely to change
src/application/config/PluginSettings.test.tssrc/presentation/settings/PluginSettingTab.test.tssrc/domain/manual-sync/services/CardIndexingService.test.tssrc/domain/manual-sync/services/ManualCardRenderer.test.ts- tests for render config hash or diff behavior around
RenderConfigService/ diff planning
Risk points
- Adding a new config id affects exhaustive loops over
CARD_TYPE_CONFIG_IDSand visible row lists. cloze-allmust not create or require a second Cloze field mapping entry.- Configured-count and cache hydration logic in the settings page must stay internally consistent when one visible row reuses another row's model and mapping.
- Marker matching must stay unambiguous when both
#anki-clozeand#anki-cloze-allare enabled on the same heading level. - Render hash must change when switching between sequential and all mode, or Anki updates will be skipped.