Template Editor - Live Preview and Safe File Sync

AnkiWeb addon 2053098767

Edits card template HTML and shared CSS with live desktop/mobile previews, mirrors files for external tools, detects conflicts via three-way merge, and applies changes only after confirmation.
AI-generated summary; may contain mistakes.

sync-integrationformattingcard-templatesdeveloper-tools

Open on AnkiWeb GitHub Ask about alternatives

AnkiWeb

Rating
0 (πŸ‘ 0 Β· πŸ‘Ž 0)
Updated
2026-08-10
Anki versions
26.08~
Description language
en

Maintenance

active

  • Last update or commit was 52 days before the snapshot (2026-08-10).
  • The repository has 6 test files.
  • The repository has 1 GitHub Actions workflows.

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
25.0726.08+2026-08-10
History across monthly snapshots

Loading…

Similar addons

VS Code For Anki

Upgrades Anki’s Cards template editor with Monaco-powered syntax highlighting, autocompletion, formatting, diagnostics, themes, and preserved live preview and save behavior.

formattingcard-templates

Rating 0 πŸ‘ 0 Β· πŸ‘Ž 0 ⭐ 0 Anki 26.08.1~ Updated 2026-08-06
External Code Editor

Enables copying notetype code to an HTML file in collection.media for external editing, then updating it back during review or preview, with menu and shortcut integration.

card-templatesdeveloper-tools

Rating 7 πŸ‘ 6 Β· πŸ‘Ž 1 ⭐ 5 Anki 23.09~ Updated 2024-01-18

README

Anki Template Editor

Native Anki add-on for editing card template HTML and shared CSS with live mobile/desktop previews. Every selected note type is mirrored to readable files, so ChatGPT, editors, and other tools can modify templates without touching Anki's database.

Anki Template Editor showing template source beside mobile question and answer previews

What it does

  • Adds Tools β†’ Template Editor
  • Opens React + CodeMirror inside Anki
  • Mirrors front.html, back.html, styles.css, and preview-only fields.json
  • Detects external file changes while editor is open
  • Saves editor changes to disk after five seconds, on blur, and on tab switch
  • Applies to Anki only after explicit confirmation
  • Detects independent disk/Anki edits with three-way merge
  • Saves ten pre-apply source snapshots per card type
  • Resolves card media directly from active Anki collection
  • Searches notes from first character and previews selected note without modifying mirror or collection
  • Uses standard editing controls by default; Vim mode remains optional

AnkiConnect and Node are not runtime dependencies. Node is needed only to build package.

Requirements

  • Anki 25.07 or newer, Qt 6 build
  • Node.js 22.13+ and npm for development/package creation

Mirror layout

Default root: ~/.AnkiTemplateEditor. Configure different absolute path through Tools β†’ Add-ons β†’ Anki Template Editor β†’ Config. Open or copy selected mirror path from controls above editor.

~/.AnkiTemplateEditor/<profile>/
└── model-<id>--<name>/
    β”œβ”€β”€ styles.css
    β”œβ”€β”€ fields.json
    β”œβ”€β”€ cards/
    β”‚   └── card-<ordinal>--<name>/
    β”‚       β”œβ”€β”€ front.html
    β”‚       └── back.html
    β”œβ”€β”€ .anki-template-editor.json
    └── .state/
        β”œβ”€β”€ base/
        └── history/

styles.css belongs to whole note type. Changing it affects every card type. fields.json changes preview only; it never modifies notes or field schema.

Build and install

AnkiWeb add-on code: 2053098767. In Anki, open Tools β†’ Add-ons β†’ Get Add-ons, enter code, install, then restart Anki.

npm ci
npm test
npm run test:python
npm run lint
npm run package

Generated package: release/anki-template-editor-<version>.ankiaddon.

npm run package builds a flat, reproducible archive, syncs human_version from package.json, and rejects missing runtime files, invalid JSON/Python, source maps, bytecode, cache folders, symlinks, and unsafe archive paths.

Install through Tools β†’ Add-ons β†’ Install from file, select package, restart Anki, then use Tools β†’ Template Editor.

Editing with ChatGPT or another tool

  1. Open card type in Template Editor once. Mirror files are created.
  2. Choose Open folder or Copy dir path above source editor.
  3. Let external tool edit files.
  4. Keep Template Editor open. Preview refreshes after stable disk change is detected.
  5. Review output and choose Apply to Anki.

Invalid UTF-8, missing files, malformed fields.json, and files over size limit never apply to Anki. Template JavaScript runs inside sandboxed preview iframe.

Development

npm run dev

Browser development shows bridge-unavailable message because collection operations exist only inside Anki. Pure merge/storage/service behavior is covered by Python tests; renderer and bridge behavior by Vitest.

See release checklist and AnkiWeb listing copy before upload.

License

0BSD. Use, copy, modify, distribute, or relicense for any purpose, with or without fee. No attribution required.