Editor: apply font color, background color, custom class, custom style [Official thread]

I’ve noticed that styles from css classes defined in a file are no longer displayed in the editor, but they work when reviewing or in preview window.

Do you have some more information on that?

I hope there is no intention to remove support for css (classes) loaded from a file. It’s a powerful feature e.g. allowing me to change the highlight colour on all my existing notes with one simple edit, if I ever want to do so.

When Anki started using ShadowRoots for the editor fields, it got a bit more complicated to apply CSS to field contents - which is actually intentional. There’s value in protecting field content from editor stylesheets. The new way to do it is to link the stylesheet separately inside each ShadowRoot (=field).

Probably not. Henrik just needs to find the time to update the add-on and everything will work like before :slight_smile:

I think “contributor” is the right term here, I’d even accept “a main contributor”, but co-author goes a bit far :sweat_smile:

The change was important to be able to separate editor CSS from field CSS. Field CSS can now be dynamically loaded via JS, you can see an example in this PR:

1 Like

When I chose that wording, I thought about the way people working on academic papers are credited. In my head it sounded right, as you contributed a significant chunk to Anki’s codebase (same goes for Rumo) :smile:

Didn’t mean to take anything away from Damien’s massive effort, which dwarfs everyone else’s contributions ofc ^^

Is this possible somewhere in Anki or does it require an add-on?

This is currently only possible with an add-on (e.g. CSS Injector - Change default editor styles - AnkiWeb or the one this thread is about).

However, applying user stylesheets defined in the template CSS section to the editor fields is (or has been) somewhere on the roadmap: Include user styles in note editor by hgiesel · Pull Request #1049 · ankitects/anki · GitHub.

1 Like

Hi Hengiesel,

Thanks for creating this add on, it seems really useful. However when I installed it and followed your instructions closely, like making sure the One liner is above my styling, it doesn’t seem to work with the latest version of Anki. Not quite sure what I am doing wrongly.

Hope you can help out, because I think many others will have this issue too. Thanks!