ianwalter / codemirror-mode-elixir

A CodeMirror mode for the Elixir language
https://codemirror-mode-elixir.optick.io
MIT License
22 stars 5 forks source link

Remove the need to manually register #1

Closed renz45 closed 7 years ago

renz45 commented 7 years ago

Hi there, thanks a bunch for putting this together. I was wondering, would you mind auto instantiating this mode with the CodeMirror instance similar to how the other modes work? Here is an example:

https://github.com/codemirror/CodeMirror/blob/master/mode/css/css.js#L10

The idea is, that all you need to do is include the mode after CodeMirror itself and it auto registers itself with CodeMirror. I'm doing this right now with the following small changes to your code:

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory()(CodeMirror) :
  typeof define === 'function' && define.amd ? define(factory) :
  (global.registerElixirMode = factory()(CodeMirror));
}(this, (function () { 'use strict';
...

I'm guessing this code was originally generated by rollup. I'm thinking it might need a commonjs rollup config alongside the umd to accomplish this?

Thanks again :)

ianwalter commented 7 years ago

Yup, I've been meaning to look into this. Ill do this sometime within the next few days, thanks.

ianwalter commented 7 years ago

Should be fixed in v1.1.0

renz45 commented 7 years ago

Thanks!