RequireJS/CodeMirror (sql mode) - how to make it work -


i'm starting out codemirror (4.1) , using requirejs. (i'm using reactjs i'm pretty sure not problem)

i have not got configured correctly. grateful if point out error.

my config looks this

require.config({  deps: ["main"],  paths: {   ...   codemirror:          "../../external/codemirror/codemirror-4.1/lib/codemirror",   cmsql:               "../../external/codemirror/codemirror-4.1/mode/sql/sql" },  shim: {   ...   codemirror:          { exports: "codemirror" },   cmsql:               { deps: ["codemirror"],  exports: "cmsql" }     }    

});

and module instantiating follows :

define(['jquery', 'react', 'codemirror', 'cmsql'], function ($, react, codemirror) {  return react.createclass({    render: function () {     console.log("render-editarea");     return (       <textarea id="editarea">       -- comment here       select id        [patient demographics]       </textarea>     )   },    componentdidmount: function () {                       var editornode = document.getelementbyid("editarea");      var editor = codemirror.fromtextarea(editornode, {               linenumbers: true,       matchbrackets: true,       indentunit: 4,       mode: "text/x-sql"     });             },    }); }); 

the codemirror manual appears show configuration when using module loaders.

i can see effects of codemirror in terms of line numbers etc not in terms of syntax colouring

enter image description here

so gratefully received.

s

why post ...

the answer (once i'd digested manual bit more)

require.config({    deps: ["main"],    paths: {     cm:                  "../../external/codemirror/codemirror-4.1"   },    shim: {     ...   }  }); 

and

define(['jquery', 'react', 'cm/lib/codemirror', 'cm/mode/sql/sql'],   function ($, react, codemirror) {    ... 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -