-
Notifications
You must be signed in to change notification settings - Fork 11
Missing languages #2
Comments
I recently started using StandardNotes and hit this issue for Scala. Some thoughts are below. Assuming the below works for you, I can put together a PR if you want. The clike languages aren't working since the individual language definitions are based on the mime type, which isn't stored on the note as far as I can tell. One fix would be to store the CodeMirror The fun part would be migrating existing notes. If the existing note has a Some questions:
|
Hey @gshakhn, thanks for looking into this. Is it possible to just create a different mode for each clike language? https://github.com/sn-extensions/code-editor/tree/master/vendor/modes/clike Duplication is fine, if it means not having to tinker with the architecture too much. It looks like we have some if/else to handle the different mime types. Any idea if it would be possible to isolate each one into a separate mode file? |
I was able to hack something together by:
to
In theory it's possible. In practice, I wouldn't recommend this approach since this is fighting against how CodeMirror wants to work and will make upgrades more painful. Plus you'd be changing the mime type from |
Alternatively, you could also have a specific branch for each of the clike languages. e.g. In const actualMode = mode === 'scala' ? 'clike' : mode;
const actualSpec = mode === 'scala' ? 'text/x-scala' : spec;
editor.setOption("mode", actualSpec);
CodeMirror.autoLoadMode(editor, actualMode);
if (clientData) {
clientData.mode = mode;
}
document.getElementById("select").selectedIndex = modes.indexOf(mode); When a new clike language is added, you would have to add an extra branch in addition to adding it to the |
Interesting. I don't have the capacity for this now, so I'll either take a look in the future, or feel free to submit a PR :) |
Submitted #3 |
The text was updated successfully, but these errors were encountered: