webscopeio / react-textarea-autocomplete

📝 React component implements configurable GitHub's like textarea autocomplete.
MIT License
451 stars 80 forks source link

Allow empty text in output functor #211

Closed anukul closed 3 years ago

anukul commented 3 years ago
output: (item, trigger) => ({
  text: '',
  caretPosition: 'start',
}),

This fails because this throws an error when text is '':

if (!textToReplace.text) {
  throw new Error(
    `Output "text" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "${currentTrigger}"\n`
  );
}

Use case: In my case a custom output is generated outside of the textarea when a selection is made, so I don't want anything to change in the textarea and also remove the trigger character on select.

jukben commented 3 years ago

Released as https://github.com/webscopeio/react-textarea-autocomplete/releases/tag/v4.7.3