Giter Site home page Giter Site logo

react-native-parsed-text's Introduction

React Native Parsed Text

This library allows you to parse a text and extract parts using a RegExp or predefined patterns. Currently there are 3 predefined types: url, phone and email.

All the props are passed down to a new Text Component if there is a matching text. If those are functions they will receive as param the value of the text.

Proptypes

ParsedText can receive Text PropTypes.

parse: Array of parsed text.

  • to use the predefined type: {type: 'url'}.
  • to use your own RegExp: {pattern: /something/}.

renderText: Function called to change the displayed children.

childrenProps : Properties to pass to the children elements generated by react-native-parsed-text.

eg: Your str is 'Mention [@michel:5455345]' where 5455345 is ID of this user and @michel the value to display on interface. Your pattern for ID & username extraction : /\[(@[^:]+):([^\]]+)\]/i Your renderText method :

renderText(matchingString, matches) {
  // matches => ["[@michel:5455345]", "@michel", "5455345"]
  let pattern = /\[(@[^:]+):([^\]]+)\]/i;
  let match = matchingString.match(pattern);
  return `^^${match[1]}^^`;
}

Displayed text will be : Mention ^^@michel^^

Example

import ParsedText from 'react-native-parsed-text';

class Example extends React.Component {
  static displayName = 'Example';

  handleUrlPress(url, matchIndex /*: number*/) {
    LinkingIOS.openURL(url);
  }

  handlePhonePress(phone, matchIndex /*: number*/) {
    AlertIOS.alert(`${phone} has been pressed!`);
  }

  handleNamePress(name, matchIndex /*: number*/) {
    AlertIOS.alert(`Hello ${name}`);
  }

  handleEmailPress(email, matchIndex /*: number*/) {
    AlertIOS.alert(`send email to ${email}`);
  }

  renderText(matchingString, matches) {
    // matches => ["[@michel:5455345]", "@michel", "5455345"]
    let pattern = /\[(@[^:]+):([^\]]+)\]/i;
    let match = matchingString.match(pattern);
    return `^^${match[1]}^^`;
  }

  render() {
    return (
      <View style={styles.container}>
        <ParsedText
          style={styles.text}
          parse={
            [
              {type: 'url',                       style: styles.url, onPress: this.handleUrlPress},
              {type: 'phone',                     style: styles.phone, onPress: this.handlePhonePress},
              {type: 'email',                     style: styles.email, onPress: this.handleEmailPress},
              {pattern: /Bob|David/,              style: styles.name, onPress: this.handleNamePress},
              {pattern: /\[(@[^:]+):([^\]]+)\]/i, style: styles.username, onPress: this.handleNamePress, renderText: this.renderText},
              {pattern: /42/,                     style: styles.magicNumber},
              {pattern: /#(\w+)/,                 style: styles.hashTag},
            ]
          }
          childrenProps={{allowFontScaling: false}}
        >
          Hello this is an example of the ParsedText, links like http://www.google.com or http://www.facebook.com are clickable and phone number 444-555-6666 can call too.
          But you can also do more with this package, for example Bob will change style and David too. [email protected]
          And the magic number is 42!
          #react #react-native
        </ParsedText>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },

  url: {
    color: 'red',
    textDecorationLine: 'underline',
  },

  email: {
    textDecorationLine: 'underline',
  },

  text: {
    color: 'black',
    fontSize: 15,
  },

  phone: {
    color: 'blue',
    textDecorationLine: 'underline',
  },

  name: {
    color: 'red',
  },

  username: {
    color: 'green',
    fontWeight: 'bold'
  },

  magicNumber: {
    fontSize: 42,
    color: 'pink',
  },

  hashTag: {
    fontStyle: 'italic',
  },

});

Install

npm install --save react-native-parsed-text

TODO

  • Add nested text parsing

react-native-parsed-text's People

Contributors

ahanriat avatar bdryanovski avatar bleonard avatar brunocascio avatar brunolemos avatar christophermark avatar conorhastings avatar evanbacon avatar fbartho avatar hartmamt avatar jrichardlai avatar magrinj avatar n-sviridenko avatar peterkottas avatar pietropizzi avatar remstos avatar rodrigopivi avatar uneco avatar ylastapis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-parsed-text's Issues

Support IP & IP:PORT hostnames in URL pattern

Currently the URL pattern doesn't match IP and IP:PORT hostnames.
It supports only FQDN because the regex requires the TLD to be present.

Current regex
/(https?://|www.)[-a-zA-Z0-9@:%.+~#=]{2,256}.[a-z]{2,6}\b([-a-zA-Z0-9@:%+.~#?&//=]*)/i

Proposed regex
/(https?://|www.)[-a-zA-Z0-9@:%.+~#=]{2,256}(.[a-z]{2,6})?\b([-a-zA-Z0-9@:%+.~#?&//=]*)/i
if not very clear by bolding, .[a-z]{2,6} became (.[a-z]{2,6})?

Ideally the URL pattern should be according to RFC 3986 or the newer version RFC 7595

Inline images in messages?

Has anyone got inline images in messages working? Trying to add a pattern for it but I cant make them split the lines. Seems like it should be an easy fix.

renderImage = (matchingString, matches) => (
    <View
      style={{
        paddingVertical: 10,
      }}
    >
      <MessageImage currentMessage={{ image: matches[1] }} />
    </View>
  );
{
  pattern: /\[IMG:(.+?)\]/gi,
  style: {},
  onPress: () => {},
  renderText: this.renderImage,
},

How to use variable in Regex?

This is my code and i wanted to parsed a dynamic string from an array unfortunately it gave an error saying Type Error: pattern.pattern.exec is not a function. I believe im doing it wrong becaue i dont know how to use a variable on regex string

                  {this.state.data.map(names => (
                    <ParsedText
                      parse={[
                        { pattern: names, style: { color: '#ff0000' } }
                      ]}
                    >
                      some long texts here........
                    </ParsedText>
                  ))}

No Touchevents within a ListView

I´m new to react native, I cant get it to work inside a ListView as a row. Somehow touchevents don´t go through.

# inside my render method
<ListView
          dataSource={this.state.dataSource}
          renderRow={this.renderPost}
          style={styles.listView}
        />

# my render a single row method
renderPost(post) {
    return (
      <View style={styles.container}>
        <ParsedText
          style={styles.text}
          parse={
            [
              {pattern: /#(\w+)/, style: styles.hashtag, onPress: this.handleHashtagPress},
            ]
          }
        >
          {post.text}
        </ParsedText>
      </View>
    );
  }

Everything works fine outside the listview

Add an open source license?

Thanks for sharing this project! We'd love to use it as part of the Mattermost open source project in our React Native mobile app (which users an Apache 2.0 license).

Would you consider adding either an MIT or an Apache 2.0 license?

To do so, in GitHub you can hit "Create new file" and name a file LICENSE.txt

image

This will prompt GitHub to offer a license template:

image

If you use either an MIT license or an Apache 2.0 license it would make it easy to add your work to other open source projects, and we'd love to include your work in ours.

Thanks kindly for your consideration.

Usage on web: Unexpected token import

Can you use Babel to compile the source code into ES5 before publishing to NPM? I am trying to use this library on a website using react-native-web, but browsers can't interpret ES6+

[Android] Incorrect bold font processing

Preconditions:

Platform: Android

"react-native": "0.63.3", 
"react-native-parsed-text": "^0.0.22",

Issue:

Could someone explain this behavior? And how could we fix it?

code:

 <ParsedText style={{fontSize: 50, fontFamily: Nobblee.Bold}}>
    {'HELLO'}
 </ParsedText>

result (as expected)
Screenshot 2020-10-20 at 23 27 33


code:

 <ParsedText style={{fontSize: 50, fontFamily: Nobblee.Bold}} parse={[]}>
    {'HELLO'}
 </ParsedText>

result (as NOT expected)
Screenshot 2020-10-20 at 23 26 51

And this happens for any array of parse param. BUT SHOULD NOT!
I configured some banch of parse templates, but usual text is affected because of this.
Any clues?


I've put this font here as well
EENobblee-Bold.ttf.zip

parse the state

How can I parse the variable from this.state.xx? the code below give no help

<ParsedText
style={styles.text}
parse={
[
{pattern: /{this.state.search}/,style: styles.found},
]
}
childrenProps={{allowFontScaling: false}}

blahblah

Global flag not respected on regex pattern

If I utilise a regex with the global flag enabled, like this:

<ParsedText parse={[{pattern: /a/g, renderText: () => 'z'}]}> aaaa </ParsedText>

I would expect the output to be: zzzz

Whereas, I would expect this:

<ParsedText parse={[{pattern: /a/, renderText: () => 'z'}]}> aaaa </ParsedText>

to output: zaaa as the global flag is removed and is only matching the first instance.

At the moment the second example will output zzzz as the parser will continue matching the pattern against any remaining text.

While I understand there may be people depending on this behaviour is there any workaround to ensure only the first match is rendered?

How to search this

I need to change the styling of a given string unfortunately it contains ( ) + % these symbols

example:
Jumping causes damage of 550 (+50% Total Physical Atk)

how can i style the (+50% Total Physical Atk) without having an error of invalid regular expression: nothing to repeat

My code

         <ParsedText
            style={styles.heroSkillDescText}
            parse={[
               { pattern: /+Total Physical ATK/, style: { color: 'red' } },
            ]}
          >
              Jumping causes damage of 550 (+50% Total Physical Atk)
          </ParsedText>

Not parsing with numberOfLines

The following snipped does not change the styling of "bar" unless I remove the /numberofLines/.

Any idea why or is it a bug?

<ParsedText
    style={{fontSize: 15}}
    parse={[{
        pattern: /bar/, style: {fontWeight: 'bold'}}
    ]}
    numberOfLines={3}
>
    Foo bar yada
</ParsedText>

[feature request] Replace matched text by a component

Hello,

Great module! I'd like to propose a feature request, and see if other people would be interested in this:
I have a use case where I need to match text fragments and replace them with some other texts which need to be wrapped in <TouchableOpacity /> components, to make them easily clickable/tapable. Currently, as renderText only accepts strings as output values, this is not possible. But this also implies that the root component returned by <ParsedText /> needs to be a <View> component rather than a <Text> component, since React Native only does not allow <View> components to be nested in <Text> components.

What do you think?

onPress not fired for email custom pattern

Hello, thank you for this very useful component.

I tried to implement an email parsing using the following option:
{pattern: /^\S+@\S+$/, style: {textDecorationLine: 'underline'}, onPress: () => { console.log('email pressed'); }},

The text is underlined properly but nothing happens when I press the word.
Do you experiment the same issue?

react-native 0.14.2
npm 2.14.7
nodejs 4.2.2

onPress feedback

it would be great to be able to provide some sort of onPress feedback for the user.

one option could be having a renderComponent method, similar to a renderText method, to overwrite the default. Usage could be as follows:


  private renderComponent = (text, onPress) => {
    return <TouchableOpacity onPress={onPress}>{text}x</TouchableOpacity>; // or whatever other touchable response component user wants to use, e.g., react-native-material-ripple
  };

  public render() {
    const { children } = this.props;
    return (
      <ParsedText
        selectable={this.props.selectable}
        style={{
          color: Colors.text.primary,
          fontSize: 16,
        }}
        parse={[
          { type: 'url', style: clickableStyle, onPress: this.handleUrlPress, renderComponent: this.renderComponent },
          { type: 'phone', style: clickableStyle, onPress: this.handlePhonePress, renderComponent: this.renderComponent },
          { type: 'email', style: clickableStyle, onPress: this.handleEmailPress, renderComponent: this.renderComponent },
        ]}
        childrenProps={{ allowFontScaling: false }}
      >
        {children}
      </ParsedText>

Not parsing when 2 variables

Strange thing:
<ParsedText ...>{a} {b}</ParsedText>
does not get parsed but
<ParsedText ...>{a + ' ' + b}</ParsedText>
does.
I don't know if it's a bug or if I'm doing something wrong.

Many thanks!

Style prop does not works with parse

style props is not working if I add parse.

<ParsedText
  parse={[
    { type: "url", style: styles.url, onPress: this.handleUrlPress }
  ]}
  style={styles.text}
>
  {children}
</ParsedText>

Can this work with TextInput?

Can this be made to work live with a TextInput? My current thought would be to have a <ParsedText /> component that is controlled by a hidden <TextInput /> but that doesn't feel right... Any thoughts?

Some props style cant work

i use the version
"react-native-parsed-text": "0.0.21",
It cant work with style

{
    paddingVertical: 4,
    paddingHorizontal: 10,
    marginHorizontal: 10,
    borderRadius: 10,
    marginRight: 5,
    fontSize: 12,
    textAlign: 'center',
    textAlignVertical: 'center',
    alignContent: 'center',
    justifyContent: 'center',
    fontWeight: 'bold',
  }

Could anyone find solution for this?
Thank you!

How to use I18n to make pattern

I want to match a constant, which is return from I18n.t('test').

But the pattern don't know how to handle it. I try pattern: /I18n.t('test')/ but it not work

Feature: Nested Matchers

The current Architecture doesn't really support nested matchers. It says if you match a thing, then the hunk of text that was matched is no longer eligible to be matched by something else.

And unfortunately this is order dependent so you should put your important patterns as early as possible in the pattern list.

Example:

[b]Bold[/b] [i]italic [b]italic and bold[/b][/i]

  1. If you have your matchers set to (Pseudocode) [ { …bold }, { …italic } ] then with this example, you'll get the bold stuff set right, but you won't get any italic code.

Bold [i]italic italic and bold [/i]

  1. If you have your matchers set to [ { …italic }, { …bold } ] then with this example text, you'll get the first bold section, and you'll get the rest in italics

Bold italic [b]italic and bold[/b]

Workaround

There could be a workaround for some, but not all use-cases, but this only works if you delete the tokens you're matching against -- so you can't keep the tokens in the original stream.

The workaround is recursive and a bit hard to describe:

[ { …boldStartPattern, tag: "boldStart" }, [ { …boldEndPattern, tag: "boldEnd", }, { …italicStartPattern, tag: "italicStart" }, { …italicEndPattern, tag: "italicEnd" } ]

Then you use TextExtraction directly, and recursively from within the "renderText" methods. Each unique renderText method deletes the Tag/Tokens they're matching against, and repeats the extraction recursively while mutating a global array of matched chunks / unmatched chunks.

Your result will be a deeply nested array of arrays, something like this:

[
  { children: "", tag: "boldStart" },
  { children: "Bold" },
  { children: "", tag: "boldEnd" },
  { children: " " },
  { children: "", tag: "italicStart" },
  { children: "italic" },
  [
    { children: "", tag: "boldStart" },
    { children: "italic and bold" },
    { children: "", tag: "boldEnd" },
  ],
  { children: "", tag: "italicEnd" },
]

While this isn't pretty, and wouldn't help for mismatched tags, it would probably be functional for rendering into a real UI.


Discussion

If people are interested in this feature, please mark your interests on this ticket or in comments, and let's discuss it.

Invariant Violation: StaticRenderer

I am getting this error

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `StaticRenderer

from

let parse = [
{type: 'url', style: [styles.link, (rowData.position === 'left' ? styles.linkLeft : styles.linkRight)], onPress: this.handleUrlPress},
{type: 'phone', style: [styles.link, (rowData.position === 'left' ? styles.linkLeft : styles.linkRight)], onPress: this.handlePhonePress},
{type: 'email', style: [styles.link, (rowData.position === 'left' ? styles.linkLeft : styles.linkRight)], onPress: this.handleEmailPress}
];

  return (
    <ParsedText
      style={[styles.text, (rowData.position === 'left' ? styles.textLeft : styles.textRight)]}
      parse={parse}          
    >
    </ParsedText>
  );

Any idea.

Android error

Hello, i just try to use this module on an Android device and i get the folowing error :

error

there is my code (realy simple) :

'use strict';

var React = require('react-native');
var ParsedText = require('react-native-parsed-text');
var {
  Component,
  Text,
  View
} = React;

class Home extends Component {
  constructor (props) {
    super(props);
  }
  render() {
    return (
      <View style={{flex: 1}}>
        <Text style={{marginVertical: 20, marginHorizontal: 10}}>Welcome</Text>
        <ParsedText style={{color: 'black', fontSize: 15}} parse={  [ {type: 'url', style: {color: '#456'}, onPress: () => {}} ] } >hello</ParsedText>
      </View>
    );
  }
}

module.exports = Home;

My api version : API 18

So is this module supposed to work on Android or did i miss something ?

Does not consider Test.com to be a URL

Hi, great module. I was trying out Test.com or Test.org and these would not be discovered as URL. Any chance this is expected or it's a bug? Thanks in advance.

Child Text components do not respect `allowFontScaling={false}`

Child Text components do not inherit any properties from their parent -- rightfully so, we wouldn't want onLayout being passed to all the child Text components, and React Native does a good job of automatically passing down style and display related rules with text nesting.

However, allowFontScaling does not make its way down here automatically.

Example

<Text allowFontScaling={false} style={{fontSize: 14}}>A normal text node</Text>
<ParsedText allowFontScaling={false} style={{fontSize: 14}} parse={rules}>
  Hello world.
  https://www.google.com.
  End of example.
</ParsedText>

Which yields

fontFamily error on ReactNative v60

This package is now failing unless explicitly given a fontFamily style for both the parent & child render methods in ParsedText. For now I have simply added fontFamily to my use-cases. Any ideas why this issue is arising as of v60?
Screen Shot 2019-11-18 at 4 10 06 PM
Screen Shot 2019-11-18 at 4 30 07 PM

URl preview

Possibility to add url preview on parsed text
image

Text returned from method is not getting parsed

Hi,

In my case the text is returned from a function.

<ParsedText
parse={
[
{type: 'url', style: {color:"red"}, onPress: this.handleUrlPress},
]
}
>
{format(answers)}

in this case the parse is not happening

Help me on this

Thanks

Is this maintained?

I see some open issues and last update from nov 2018. I am wondering if the repo is updated or shall we search for alternatives? Or help to maintain it?

Presets for Markdown

I've been experimenting with this very excellent library to try and implement a basic Markdown functionality. So far, I have bold, italics and strikethrough working. I wondering if there's any interest out there in a PR to add such functionality, or maybe setting it up as an add-on to it.

I've gone for the asterisks to denote bold text, underscores for italics and dashes for strikethrough. This follows what I'm used from using JIRA, although I don't how standard an implementation their's is!

The difficulty I had was ignoring whitespace and line breaks in the regex statements. The markdown character (asterisk, underscore or dash) has to be directly against the start and ending words, like so:

This should be bold bold text
This should not be bold * not bold text *
This should not be bold either * not bold text

This should be italic italic text
This should not be italic _ not italic text _
This should not be italic either _ not italic text

This should be strikethrough -strikethrough text-
This should not be strikethrough - not strikethrough text -
This should not be strikethrough either - not strikethrough text

Okay, so Github itself is actually rendering the italics and bold examples above! But it's not doing it for strikethrough, so you can see what I mean on that one.

Using https://regexr.com/, these are the regex patterns that I came up with:

const boldPattern = /(\s\*|^\*)(?=\S)([\s\S]*?\S)\*(?![*\S])/gm;
const italicPattern = /(\s_|^_)(?=\S)([\s\S]*?\S)_(?![_\S])/gm;
const strikethroughPattern = /(\s-|^-)(?=\S)([\s\S]*?\S)-(?![-\S])/gm;

Plugging in that in the configs for react-native-parsed-text, I came up with this:

export const markdownStyles = StyleSheet.create({
  bold: {
    fontWeight: "bold"
  },
  italic: {
    fontStyle: "italic"
  },
  strikethrough: {
    textDecorationLine: "line-through"
  }
});
const boldPattern = /(\s\*|^\*)(?=\S)([\s\S]*?\S)\*(?![*\S])/gm;
const italicPattern = /(\s_|^_)(?=\S)([\s\S]*?\S)_(?![_\S])/gm;
const strikethroughPattern = /(\s-|^-)(?=\S)([\s\S]*?\S)-(?![-\S])/gm;

const renderBoldText = (matchingString, matches) => {
  const match = matchingString.match(boldPattern);
  return `${match[0].replace(/\*(.*)\*/, "$1")}`;
};

const renderItalicText = (matchingString, matches) => {
  const match = matchingString.match(italicPattern);
  return `${match[0].replace(/_(.*)_/, "$1")}`;
};

const renderStrikethroughText = (matchingString, matches) => {
  const match = matchingString.match(strikethroughPattern);
  return `${match[0].replace(/-(.*)-/, "$1")}`;
};

export const parsedTextArray = [
  {
    // Bold (matching asterisks)
    pattern: boldPattern,
    style: markdownStyles.bold,
    renderText: renderBoldText
  },
  {
    // Italic (matching underscores)
    pattern: italicPattern,
    style: markdownStyles.italic,
    renderText: renderItalicText
  },
  {
    // strikethrough (matching dashes)
    pattern: strikethroughPattern,
    style: markdownStyles.strikethrough,
    renderText: renderStrikethroughText
  }
];

Anybody interested in my taking this any further?

Replace the phone and email into the chat with *******

Issue Description

Hi, I am using react-native-gifted-chat and I wanted to know, how to restrict the user to input any phone number or email address in chat ??

In My second scenario, I want to replace my chated phone number or email with ********* so that the end user cant see the shared number or email for the privacy reason.

PLEASE HELP I AM NEW WITH THIS LIBRARY

React version: "16.3.1"
React Native version: 0.55.1
react-native-gifted-chat version: ^0.4.3
Platform(s) (iOS, Android, or both?): both

Feature: numberOfLines control

I'm using this library, and when passing the numberOfLines prop it works on IOS but it doesn't on Android. This is my code:

export const MessageTextParsed = ({
  children,
  messageTextColor,
  messageTextFontSize,
  messageTextOpacity,
  parseSettings,
  numberOfLines
}) => {
  return (
    <MessageText
      messageTextColor={messageTextColor}
      messageTextFontSize={messageTextFontSize}
      messageTextOpacity={messageTextOpacity}
      parse={parseSettings}
      childrenProps={{ allowFontScaling: false }}
      selectable
      numberOfLines={numberOfLines}
    >
      {children}
    </MessageText>
  );
};

const MessageText = styled(ParsedText)`
  color: ${({ messageTextColor }) => messageTextColor};
  font-family: OpenSans;
  font-size: ${({ messageTextFontSize }) => messageTextFontSize || 16};
  opacity: ${({ messageTextOpacity }) => messageTextOpacity || 1};
`;

and I'm implementing my component like this:

<MessageTextParsed
                  mentions={mentions}
                  messageTextColor={colors.primaryFontColor}
                  messageTextFontSize={14}
                  numberOfLines={2}
                >
                  {message.content}
</MessageTextParsed>

How can I get the url parsed?

Let say,
I use parsed-text within <Textinput />, like https://github.com.
How can I get the https://github.com url string?

Or another use case which is more general, when input something like Hey, I want to see you guys on https://facebook.com !!! Come on, that would be fun!!!, facebook link would be parsed and changed the color, but how can I get the facebook link string from this text?

PropTypes has been moved to a separate package

React 15.5 and later have moved PropTypes to a separate package

Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.

https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes

Does this library require the outdated version of react native or has an update never been required?

If so can we update it?

renderText prop not updated using HMR

Hi, Thanks for this great module, it's really help me getting my work done. However there is small issue with renderText prop and HMR. I can't see it updated when there is a changes in my code.

I need to manually reload the app to get the result. Is it normal behaviour?

renderText's style does not work after I adding any character inside TextInput tag

Preconditions:
Platform: Android

  "react-native": "^0.61.5"
  "react-native-parsed-text": "^0.0.22",

issue:

code:

       <TextInput>
        <ParsedText
            style={{}}
            parse={
              [
                { 
                   pattern: /((@)\[([^[]*)\]\((([\d\w-]*))\))/giu, 
                   style: themedStyle.txtMention, 
                   renderText: (str, matches) => matches[3],
                 },
              ]
            }
            childrenProps={{ allowFontScaling: false }}
          >
            {commentTextFormatted}
          </ParsedText>
        </TextInput>

matches's result example:
image

Actual result:

renderText's style does not work after adding any character

Expected result:

Keep renderText's style after adding any character

Help me, please!

5771505214108783026.mp4

this.state cannot be parsed

In the issue #76 , the way suggested is not working, please help

this.state.search cannot be parsed, please help. Thanks

<ParsedText
style={styles.text}
parse={
[
{pattern: /{this.state.search}/,style: styles.found},
]
}
childrenProps={{allowFontScaling: false}}

pattern : RegExp(/{this.state.search}/) is not working also.

Add Typescript definition

Hi,
Thanks for this project.
I'm using TypeScript.
It will be great to add a definition file.
Thanks.

Pass matches result to renderText

hi!
It would be great to pass pattern matches as second param to renderText. That is easy and allows to avoid duoble regex parsing of already matched str.
I mean if I want to replace aa{text}bb with bold I just write

pattern: /\{(.+)\}/,
style: fontWeight: 'bold',
renderText: (str, matches) => matches[1]

Doesn't work with react-native 0.16.0 due to babel

TransformError: /.../node_modules/react-native-parsed-test/lib/libTextExtraction.js: [BABEL] /.../node_modules/react-native-parsed-text/lib/lib/TextExtraction.js: Unknown option: /.../node_modules/react-native-parsed-text/package.json.stage

I think you should rely on Babel 6 (as RN0.16.0) to translate code but I wasn't able to find a configuration that work. :)

Above this, what's the interest of distributing build code (lib/*) in npm? You module should be used only in RN context and a build process is already done by react-native during packaging.

React Native v .17 throwing error.

Unknown plugin "syntax-async-functions" specified in [appfolder]/node_modules/react-native-parsed-text/

Removing the .babelrc file fixes the issue. I don't think it should be published to NPM.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.