npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@brbtcoficial/react-native-hyperlinked-text

v0.0.1

Published

Text component for React Native with regex defined hyperlinks forked from https://github.com/Kimaia/react-native-hyperlinked-text

Downloads

28

Readme

HyperlinkedText

Text component for React Native with regex defined hyperlinks.

Heavily inspired from react-native-hyperlink.

The difference is that with react-native-hyperlink you use linkify which I couldn't configure to detect arbitrary regex without prefix (e.g. '1:00'). If you only need to detect regexs with prefixes (e.g. mentions with '@' or links with 'schema://') then use hyperlink. react-native-hyperlink also supports nesting <Text> components. Important - put only strings inside a <HyperlinkedText> component. There is no way to nest components right now.

Installation

npm install --save @erickcrus/react-native-hyperlinked-text

Usage Examples

The default behavior is to identify URLs and open web browser when they are clicked:

<HyperlinkedText>You get regular URLs handling by default - https://www.brasilbitcoin.com.br</HyperlinkedText>

Configure the default link style and on press behavior:

<HyperlinkedText
  linkStyle={{color: 'red'}}
  onLinkPress=text=>window.alert(`Pressed ${text}`)
>You get regular URLs handling by default - https://www.brasilbitcoin.com.br</HyperlinkedText>

Pass in linkDefs array to configure custom regex and behavior:

<HyperlinkedText
  style={styles.entry}
  linkDefs={[
    {
      regex: /\[(.*?)\]\((.*?)\)/mgi,
      style: {color: 'red'},
      replaceText: (orig, text, url) => text,
      onPress: (orig, text, url) => HyperlinkedText._openWebUrl(url)
    }
  ]}>
  Use markdown style links [Kimaia](https://www.brasilbitcoin.com.br)
</HyperlinkedText>

Props

| Prop | Description | Example | Default | | --- | --- | --- | --- | | style | The style of the entire component | style={{backgroundColor:'blue'}} | None | | linkStyle | Default style for links. Can be overriden in linkDef.style | linkStyle={{color: 'purple'}} | {{color:'#0000EE'}} | | onLinkPress | Default handler for link presses | onLinkPress={text=>window.alert(text)} | Open browser | | linkDefs | Array of linkDef definitions. See below. | linkDefs=[{regex:/\d+/mgi}] | [] |

LinkDef

Each link definition is an object with the following properties:

{
  regex: /regex/mgi, /* The regex to match. You can capturing groups and you probably want to add the 'm' and 'g' flags to search in entire text. If you use capturing groups they will be passed to your handlers*/
  onPress: (wholeMatch, ...capturingGroups) => {}, /* optional - handler for presses. Receives the whole match and the capturing groups. If you don't specify a handler, the default handler will be used */
  noPress: false, /* optional - set to false to disable presses. Default is false */
  style: {}, /* optional - style for link. If undefined then default link style will be used */
  replaceText: (wholeMatch, ...capturingGroups) => newText /* optional - the match will be replaced with whatever you return here */  
}