codemirror-textarea resizable like a standard textarea

Zo72 picture Zo72 · Dec 20, 2012 · Viewed 13.6k times · Source

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.

Answer

brianpeiris picture brianpeiris · Dec 20, 2012

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());
  }
});