Search code examples
javascriptcodemirror

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.


Solution

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