如果带有拖拽文本的编辑器文本的长度超过最大长度,有没有一种方法可以防止从外部编辑器拖放文本?我曾尝试使用handleDrop事件,但它接受参数(SelectionState、dataTransfer、isInternal)我试图从SelectionState对象获取文本,但无法成功
发布于 2021-10-11 05:57:56
我不确定handlePastedText是否支持拖放,但handleBeforeInput应该可以。
发布于 2021-10-14 12:21:16
我已经通过使用event onEditorStateChange解决了上述问题
const onEditorStateChange = (editorState) => {
const text = editorState.getCurrentContent().getPlainText('')
const lines = text ? text.split('\n') : 0
if (lines.length <= 15 && text.length <= charLimit) {
setEditorState(editorState)
} else {
return 'handled'
}
}https://stackoverflow.com/questions/69497755
复制相似问题