title: MaxLength in Codemirror
body: <p>Hi is there any way to set a maxlength of characters in codemirror v5.5.0. I have tried to do the following:</p>
  
  <p><strong><em>Code:</em></strong></p>
  
  <pre><code>CMUtils.enforceMaxLength = function(cm, change) {
      var maxLength = cm.getOption("maxLength");
      if (maxLength &amp;&amp; change.update) {
          var str = change.text.join("\n");
          var delta = str.length-(cm.indexFromPos(change.to) - cm.indexFromPos(change.from));
          if (delta &lt;= 0) { return true; }
          delta = cm.getValue().length+delta-maxLength;
          if (delta &gt; 0) {
              str = str.substr(0, str.length-delta);
              change.update(change.from, change.to, str.split("\n"));
          }
      }
      return true;
  }
  
  html_editor.on("beforeChange", CMUtils.enforceMaxLength);
  css_editor.on("beforeChange", CMUtils.enforceMaxLength);
  js_editor.on("beforeChange", CMUtils.enforceMaxLength);
  </code></pre>
  
  <p>But it doesn't work</p>
  
  <p>P.S I have written maxLength in my code</p>
  
  <pre><code>var html_editor = CodeMirror.fromTextArea(document.getElementById("html"), {
      lineNumbers: true,
      indentWithTabs: false,
      indentUnit: 2,
      autoCloseTags: true,
      theme: 'dracula',
      maxLenght: 25,
      mode: {
          htmlMode: true,
          name: "xml"
      }
  });
  </code></pre>
  
  <p><strong><em>UPDATE 1</em></strong>
  My console says that CMUtils isn't defined. How do I define it?</p>