Handling input events
Since the input is uncontrolled, events are how you observe it. You change content by calling ref methods; you react to changes by listening to the callbacks below.
Full payload shapes of the available callbacks can be found in the EnrichedTextInput reference.
This page covers EnrichedTextInput events. The read-only
EnrichedText component only
exposes onLinkPress and onMentionPress callbacks.
Content
onChangeText- plain-text content changed.onChangeHtml- the HTML changed.
The onChangeHtml callback has to parse the content into HTML on every keystroke.
This is a heavy computational operation that might slow down your app's performance. Consider using the getHTML() ref method instead if it meets your requirements.
Selection and style state
onChangeSelection- the cursor moved or the selection changed. Gives youstart,end, and the selectedtext. Useful for range-based methods likesetLink.onChangeState- the active styles at the cursor changed. This is the event that drives a toolbar by using reportedisActive,isBlocking, andisConflicting, plus the currentalignment. See the style state model.
Focus
onFocus/onBlur- the input gained or lost focus.
Mentions
onStartMention- a mention started being edited.onChangeMention- the query after the indicator changed.onEndMention- editing a mention stopped.onMentionDetected- the cursor entered or left a mention.
Links
onLinkDetected- the cursor entered or left a link.
Images
onPasteImages- the user pasted one or more images; hands you each image's data so you can upload and insert them withsetImage.
Keyboard and submission
onKeyPress- a key was pressed.onSubmitEditing- the user pressed return/enter key. Fired whensubmitBehavioris set to eithersubmitorblurAndSubmit.