New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit number of characters in editor #293
Comments
Write a |
I've written a basic demo https://codesandbox.io/s/3204l3on1q PS. Deletion doesn't quite work at the moment (Maybe someone can fix this) |
Thanks @Chrissi2812! Something like that is the way to go so I'll close this here. |
@Chrissi2812 your solution is so buggy. |
Anyone found a reliable way to do this? |
An approximate solution could be like this (it remains to refine the cropping of pasted text) new Editor({
...
editorProps: {
handleTextInput: (view) => {
if (this.maxlength && view.state.doc.textContent.length >= this.maxlength && view.state.selection.empty) {
return true;
}
},
handlePaste: (view, event, slice) => {
if (this.maxlength && view.state.doc.textContent.length + slice.size > this.maxlength) {
slice.content = new DocumentFragment();
}
},
},
...
}); |
Is there any example/solution/feature/extension within this editor to limit number of characters?
For example, textarea has maxlength;
TinyMCE editor has examples how to make it.
The text was updated successfully, but these errors were encountered: