I have a max length that I need editor.getData().length to be before I send it to my server. I have the word Count plugin working I just need to add some code to achieve this in the on update method. I want the editor to behave as an html input tag would behave with the "maxlength" attribute set, so it would disable any further typing when the dataCount reaches the specified limit(5000).
ClassicEditor
.create( document.querySelector( '#editor' ),{
})
.then( editor => {
editor.plugins.get( 'WordCount' ).on( 'update', ( evt, stats ) => {
const limit = 5000;
const dataCount = editor.getData().length;
//disable typing when dataCount >= limit
//what code do I put here?
} );
} )
.catch( error => {
console.error( 'Oops, something went wrong!' );
console.error( error );
} );