signavio / react-mentions

@mention people in a textarea
https://react-mentions.vercel.app
Other
2.4k stars 560 forks source link

How can i allow filtering data but also choose how I want the data to be stored as #720

Closed philmetzger closed 8 months ago

philmetzger commented 8 months ago

I have this Mention:

<Mention
          style=''
          className='mentions__mention'
          appendSpaceOnAdd={true}
          trigger='#'
          data={tags ? tags?.map((tag) => ({ id: tag, display: tag })) : []}
          displayTransform={(tag) => `#${tag}`}
          renderSuggestion={(suggestion, search, highlightedDisplay) => (
            <div className='py-2 px-4'>
              <Text>#{highlightedDisplay}</Text>
            </div>
          )}
          // markup='#__id__'
        />

Now in my textarea, if i type "hello #cool", its actually seen as: "hello @[cool](cool) " But I want it to be "hello #cool" If I include the line for markup above, then it works, except it does not filter the data as I type.

Any ideas?

philmetzger commented 8 months ago

nevermind, figured it out, there is newPlainTextValue in the onChange handler :)