How to set a maximum character limit to editor ?
See original GitHub issueHow to restrict characters from being entered after the maximum limit exceeds ? and to show the character length 234/5000 likewise. I couldn’t find an exact documentation explaining this for the react integration. I’m using react functional component.
<TinyMCE
key={field.NAME}
config={{
menubar: false,
plugins: 'autolink link lists',
toolbar: 'fontselect fontsizeselect formatselect| bold italic underline strikethrough |
bullist numlist outdent indent | alignleft aligncenter alignright| insertfile
image media pageembed template link anchor codesample'
}}
onChange={handleDescriptionEdito}
onKeyup={handleDescriptionEditor}
/>
EDIT :
I found out this doc
i tried
const wordcount = window.tinymce.activeEditor.plugins; wordcount.body.getCharacterCount();
in my handler function handleDescriptionEditor
but it is giving out an error
Cannot read property 'getCharacterCount' of undefined
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to set character limit and maxlength - TinyMCE
One solution is to keep the character limit in a textarea set to a specific length with warnings about size. Another is to...
Read more >Limit Max Characters for Editor? - Google Groups
I am developing my own component and i can't seem to figure out how to set the maximum number of characters a person...
Read more >Specify the character limit for a text box - Microsoft Support
Click the Display tab. Under Options, select the Limit text box to check box, and then specify the number of characters that you...
Read more >How to specify minimum & maximum number of characters ...
To set the maximum character limit in input field, we use <input> maxlength attribute. This attribute is used to specify the maximum number ......
Read more >Character limit | Lokalise Docs
Setting character limit for a single key ... To limit the maximum character length of your translations for a specific key, open the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, i tryed also to get the number of character in react. it works fine with this code
handleEditorChange(content, Editor) { const wordcount = Editor.plugins.wordcount; this.setState({ content, numberOfCharacter: wordcount.body.getCharacterCountWithoutSpaces(), }); } it set my state with the value
Hello, some updates about this?
I have a controlled component with
onEditorChange
andvalue
and I can get the size of the content but even I won’t updating my state, my view is updating and showing more characters that my value.