Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css not working properly in codemirror editor

Tags:

css

codemirror

I've installed the codemirror editor succesfully.
But there is one issue regarding css of that editor.

You can check here what I mean.

So how can I display the color after 3rd line in the editor.

like image 625
Sanjay Rathod Avatar asked Sep 27 '13 13:09

Sanjay Rathod


People also ask

What is CodeMirror CSS?

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.

How do I set up CodeMirror?

Download CodeMirror files. Download jQuery file. Inside the codemirror project folder create subfolders and name them js, css and plugin. The js folder will hold all the javascript files.

How do I use CodeMirror in textarea?

This could be used to, for example, replace a textarea with a real editor: var myCodeMirror = CodeMirror(function(elt) { myTextArea. parentNode. replaceChild(elt, myTextArea); }, {value: myTextArea.


2 Answers

you should look at

<div class="CodeMirror-gutters" style=" /*height: some_pixel*/; "><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 28px;"></div></div>

instead of some_pixel after press enter or any keyword it will automatically set the height of the line number,
if you have that problem on start you might want to see how to create at first,
there is three common method,
The simplest is to define your Text Area and just use this code:

var YourCodeMirror = CodeMirror.fromTextArea(YourDefinedTextArea);

The best is put values using code:

var yourCodeMirror = CodeMirror(PlaceYouWant, {
  value: /*any code here :*/"function(){return 'anything'}",
  mode:  /*your mode ie.*/"javascript"
});

hope it helps

UPDATE: There is a manual site here : http://codemirror.net/doc/manual.html

like image 55
Sijav Avatar answered Oct 20 '22 06:10

Sijav


CodeMirror parses HTML using the XML mode. To use it, the appropriate script must be included, same as with any other mode.

Add its dependency in your markup:

<script type="text/javascript" 
        src="/site.com/js/libs/codemirror/mode/xml/xml.js"></script>

and set the mode to xml:

config = {
    mode : "xml",
    // ...
};

In addition, you may want to configure the parser to allow for non well-formed XML. You can do so by switching the htmlMode flag on:

config = {
    mode : "xml",
    htmlMode: true,
    // ...
};
like image 41
Walter Jamison Avatar answered Oct 20 '22 04:10

Walter Jamison