highlight dosen't work
KaneGF opened this issue · 1 comments
KaneGF commented
why my code can't highlight ?
I have no idea to resolve it.
//angular-cli.json
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/codemirror/lib/codemirror.css",
"../node_modules/codemirror/theme/monokai.css",
"../node_modules/codemirror/addon/fold/foldgutter.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/codemirror/lib/codemirror.js",
"../node_modules/codemirror/mode/javascript/javascript.js",
"../node_modules/codemirror/mode/clike/clike.js",
"../node_modules/codemirror/addon/fold/foldcode.js",
"../node_modules/codemirror/addon/fold/foldgutter.js",
"../node_modules/codemirror/addon/fold/brace-fold.js",
"../node_modules/codemirror/addon/fold/indent-fold.js",
"../node_modules/codemirror/addon/fold/comment-fold.js"
],
and an exception : cm.foldCode
//mycomponet
@ViewChild('editor') editor: any;
config = {
lineNumbers: true,
lineWrapping: true,
autofocus: true,
theme: 'monokai',
mode: 'javascript',
matchBrackets: true,
foldGutter: true,
extraKeys: {
"Ctrl-Q": function (cm) {
console.log(cm); //CodeMirror$1 {options: {…}, doc: Doc, display: Display, state: {…}, curOp: {…}, …}
cm.foldCode(cm.getCursor()); //here is an EXCEPTION: cm.foldCode is not a function
}
},
readOnly: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
};
TcQPAD commented
For anyone having the same problem, I encoutered this and solved it by removing the theme
property from the config
object to get the highlighting to work.
Also, I imported the mode in the component declaring the config, doing :
import 'codemirror/mode/go/go'; <--------- Change with your mode