I asked this question for JLab 3.x before and need to ask again for JLab 4.x due to API change to @jupyterlab/codemirror. More specifically, I used to get hold of a CodeMirror instance through
import { ICodeMirror } from '@jupyterlab/codemirror';
So everything is CodeMirror 6 now? I have a CM5 style language module that was imported using CodeMirror.defineMode(...) but this does not appear to be supported by the IEditorLanguageRegistry.
I think I need to adapt the mode to CM6 style, publish it separately as a npm package, and import it into the extension, but is there an easier way to do this?
No, the CM5/6 divide is quite absolute. There may be some some applicable patterns in legacy-modes, if the extension happened to be using simple-mode, but for the most part, it’s full-rewrite time.
Here’s a branch which started doing that for a simple-mode one, but the changes are still quite large.
Thanks for the answer. I read more and realized just that. It took me a lot of time to write the language module for CM5 and I have to do it again… but at least now I know what I need to do now.
@edublancas this is super useful, I think we should do that for magic in core ipython mode of JupyterLab. Now, to make it robust is should substitute the language definition in IEditorLanguageRegistry rather than playing with IEditorExtensionRegistry directly, to ensure it is only applied to Python notebooks.