Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codemirror-textarea resizable like a standard textarea

Does anybody know how to make a codemirror textarea resizable like text-area ?

So that the codemirror textarea can be resized by dragging their bottom down grabber corner.

I know it's possible for html divs (see div resizable like text-area) but I have not managed to achieve the same thing on code mirror.

like image 612
Zo72 Avatar asked Dec 20 '12 17:12

Zo72


People also ask

What is the use of CodeMirror?

CodeMirror is a code editor component for the web. It can be used in websites to implement a text input field with support for many editing features, and has a rich programming interface to allow further extension.

How do I reset CodeMirror editor?

If you don't want to kill the CodeMirror instance, just change the entire document holding the text, data on markers etc. This can be done by calling cm. swapDoc(doc: CodeMirror. Doc) .


2 Answers

WITHOUT JQUERY , CSS only

.CodeMirror {       resize: vertical;       overflow: auto !important;     } 

After some struggle, this simple code actually worked for me. I got a resizable Codemirror Instance vertically with scroll working properly.

like image 166
Tadeu Marques Avatar answered Oct 05 '22 01:10

Tadeu Marques


Some Googling suggests that it is not supported in CodeMirror but you can achieve it with jQuery UI:

var editor = CodeMirror.fromTextArea(document.getElementById("code"), {   lineNumbers: true, }); $('.CodeMirror').resizable({   resize: function() {     editor.setSize($(this).width(), $(this).height());   } }); 
like image 33
brianpeiris Avatar answered Oct 05 '22 01:10

brianpeiris