I think CSS Injector will change the default field style for all fields in any deck, right? Will it change the display of the text in the fields for all decks, and what effect will these changes have on the styling of cards? I’m looking for a way to avoid manually (using the editor style options) changing the style of fields, from the default. I have notes with over 20 fields and I want to set them all at once but just for certain notes, I don’t want to unilaterally change the default styles for all fields in Anki. Is that possible with this add on?
I rooted around with the inspector and found that the no part of the html of the editor tells us which note template the editor is currently displaying, so i’m guessing that the generation of the html part is fully handled within editor.py or something?
Would it be troublesome to change the addon to grab the name of the note template currently in view, and add it as a classname to an element somewhere in the DOM of the editor, so that we could apply css specific to certain notetypes?
I noticed there’s some code like that in your Exon catalyst addon which (i think) only injects certain css if the notetype’s mid matches with a certain mid, but I lack the (or any) python knowledge to adapt it to what I want it to.
@kleinerpirat : Thanks for keeping this functionality alive for newer anki versions.
at the moment user changes to web/fields.css and web/editor.css should be deleted (as far as i remember) when you install an update of this add-on. To preserve user files they should be in a subfolder user_files, see the add-on writing guide and the source code.
@kleinerpirat : I another idea for the location of the user files. Maybe put them in the media folder the same way glutanimate’s original does i? This way user settings should be synced between different devices and better survive and accidental deletion of add-ons (e.g. when trying to resolve an add-on problem). Though on second thought you probably have put some thought into the current file layout so you should probably just ignore this idea …
That’s probably the best location. I originally tried to do it with user_files, but for some reason the import didn’t work from that folder.
I haven’t, actually ^^ Your idea is great!
This addon is very simplistic - and I think I’ll keep it that way. That’s why I love @shallash’s idea as well: it saves me from having to deal with Qt and users will benefit from a pure CSS solution too
I think it should just be the file name - e.g. “field.css” (though I’d add a leading underscore so that it’s not deleted when the unused media is cleaned).
My thinking goes like this: The editor is basically a webpage and the images you add and see in the editor that are stored in the media folder have as the src in their html source code just their filename (and no additional path etc) - so this should be the base path for all relative locations.
You could also check the source code of the editor webview - i think the code inspector add-on doesn’t work for this view so I’d view it from chrome after setting QTWEBENGINE_REMOTE_DEBUGGING and then starting Anki, Porting 2.0 Add-ons - Writing Anki Add-ons
I was exploring, whether is it possible to make the edit field view and review card view the same.
With this addon, I was able to change the background colour of all fields, in the editor window, using this code.
My question is, is it possible to decorate the field text in the editor, same as the card text, as shown here. I just want to change the Bold, Underlined, Italic and hyperlinked text only.
In the same folder as editor.css, there’s a file called field.css. This file will be injected into the shadow-root* of each field and therefore affect its contents.
If you copy your template CSS into that file, you can style the content of your editor fields the same way as it’s shown in the reviewer.
*a mini-DOM which isn’t affected by outside styles
Also, keep an eye out for this PR:
Once that makes it into Anki, your template styles will affect the editor styles automatically and my add-on will be redundant ^^
I still use this add-on and I love it. However I need help, with the last Anki’s version I want to reduce the line-height but I don’t know the tag for paragraphs in fields (it’s not “p” ?). Could you tell me please ?