Как ограничить ограничение текста в редакторе quill максимум 5000 символами в angularJS? - PullRequest
0 голосов
/ 27 апреля 2018

Это мой HTML-код. Как ограничить пользователя вводом максимум 5000 символов.

<div class="ql-container ql-bubble" id="richTextQuel">
  <ng-quill-editor theme="bubble" id="richTextEditor" placeholder="Inclusions" ng-model="title" modules="richTextEditorModules" class="ng-pristine ng-untouched ng-valid ng-isolate-scope 
                             ng-not-empty">
  </ng-quill-editor>
</div>

1 Ответ

0 голосов
/ 27 апреля 2018

см. Документ изменение текста

Код разметки: -

<div class="ql-container ql-bubble" id="richTextQuel">
   <ng-quill-editor theme="bubble" id="richTextEditor" placeholder="Inclusions" ng-model="title" modules="richTextEditorModules" class="ng-pristine ng-untouched ng-valid ng-isolate-scope ng-change="textChanged($event)"
   ng-not-empty">
   </ng-quill-editor>
</div>

Код Js: -

var limit = 5000;
quill.on('text-change', function(delta, old, source) {
    if (quill.getLength() > limit) {
        quill.deleteText(limit, quill.getLength());
    }
});
...