我剛開始使用CodeMirror(4.1)並使用RequireJs。 (我也使用ReactJs,但我很確定這不是問題)RequireJS/CodeMirror(sql模式) - 如何使它工作
我明顯沒有正確配置它。如果有人能指出我的錯誤,我將不勝感激。
我的配置是這樣的
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" }
}
});
,我實例化模塊是如下:
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
FROM [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"
});
},
});
});
的CodeMirror手冊出現使用模塊裝載機何時顯示此配置。
我可以看到CodeMirror的影響中說行號等方面而不是在語法方面的着色
因此,任何幫助將受到歡迎。
小號