Dynamically assign Code Mirror Language Type at frontend

I am using Jupyterlite along with Pyodide, a Python kernel. You may try at JupyterLite.

Pyodide supports both Python and Javascript. For Javascript, you have to use “%%Javascript” as cell magic.

When Javascript is using, a Javascript Language for Code Mirror is expected. So that the syntax highlight is available. But now, the cell has always the same Language type (“Python”). This is not convenient.

Sorry, the topic cannot be categorized into any existing ones. Basically, this is a frontend one.

Any ideas?