bvaughn / react-highlight-words

React component to highlight words within a larger body of text
https://bvaughn.github.io/react-highlight-words/
MIT License
2.18k stars 171 forks source link

feat: Add unhighlightTag prop #99

Closed kaungmyatlwin closed 2 years ago

kaungmyatlwin commented 2 years ago

Description

This PR adds ability to render custom HTML tags / React Nodes instead of defaulting to <span> element.

Problem

Defaulting to <span> is a good idea and must have, but sometimes we have edge cases where you need to pass custom React nodes in order to provide additional functionalities. Please see the Use Case below.

Use Case

Should be able to render <a> tags whenever necessary or pass React components (such as <Linkify>: https://github.com/tasti/react-linkify) to render the links properly.

kaungmyatlwin commented 2 years ago

Hi @sergei-startsev , thanks for replying. I've added two test cases f8d34a1b4be84b12804933bd01537c20f7e8154f for unhighlightTag to test if they can be functional/class component.

Please have a look.

kaungmyatlwin commented 2 years ago

@sergei-startsev Rebased against master. Can you check?

sergei-startsev commented 2 years ago

@kaungmyatlwin your changes will be included into the next release.

JeffreyATW commented 1 year ago

@sergei-startsev Hi there! Would you mind creating a new release with this change? Thanks!

sergei-startsev commented 1 year ago

@JeffreyATW check out https://www.npmjs.com/package/react-highlight-words/v/0.20.0