Hooks/ways to change CodeMirror config/extensions

I haven’t yet moved to 2.50 (upcoming exam on Friday, don’t want to break anything) but just looking in the source I see you’ve integrated a plain-text editor using CodeMirror (5.something from what i understand). I didn’t see any hooks to change CM config/behavior/extensions (granted, I may just have missed them). Are there any plans to add hooks or other options to allow addon modification/manipulation of the CM setup?

The reason I am asking is that I have an unpublished addon that opens a field in a CM6 window (with cloze shortcut keys added) after converting the input to Markdown (using a modified Showdown) and then vice-versa on close. I was looking at the source specifically to get an estimate on how much work it would be to insert CM instead of the “regular” Anki editor rather than have an external window - now it seems all the leg work has already been done :smile: All that remains is to config the Anki CM for that purpose and then inject HTML→MD conversion on note load and MD→HTML on save for an initial functioning version!

As a side note, in the long run I would also like to:

  • Create a CM extension to make a block widget displaying images (assuming it can be done in CM5, seems doable in CM6 at least)
  • Create a CM extension to intercept paste to convert HTML to MD or add images to Anki media
2 Likes

For anyone interested: Markdown input.