Limit the number of character in tinyMCE

后端 未结 16 1163
心在旅途
心在旅途 2020-11-29 07:44

Im using tinyMCe for my project.Everything is working fine but now i want to restrict the number of character that will be insert into tinyMce text

16条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 08:12

    There is no tinymce configuration setting max_chars, except you implement it yourself:

    tinyMCE.init({
       ...
       max_chars : "10",
       setup : function(ed) {
          ed.onKeyDown.add(function(ed, evt) {
    
            if ( $(ed.getBody()).text().length > ed.getParam('max_char')){
              e.preventDefault();
              e.stopPropagation();
              return false;
            } 
    
          });
       }
    });
    

提交回复
热议问题