Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple characters trigger string #38

Open
terryli0095 opened this issue Feb 28, 2021 · 15 comments
Open

Multiple characters trigger string #38

terryli0095 opened this issue Feb 28, 2021 · 15 comments
Labels
enhancement New feature or request v3 Feature and fixes for the major v3 release

Comments

@terryli0095
Copy link

Would it be possible/are there plans to support multiple character triggers? We have a use case for r/, p/ etc. Or would it be possible to point me to the relevant code?

@andywong418
Copy link

Agreed - this would be a very useful feature!

@dabakovich
Copy link
Owner

Thanks for your feedback!
Can you provide me more examples of phrases that you can use with their triggers?

@terryli0095
Copy link
Author

thanks for the quick response :) The r/ p/ triggers would be similar to subreddits. I think if we allow for the flexibility to enable more than single character triggers, it would make building / commands easier like /zoom, /call, or /calendar

@dabakovich dabakovich added the enhancement New feature or request label Mar 1, 2021
@dabakovich
Copy link
Owner

Got it. I'll think about how to implement it soon.

One more question. There can be cases only with one or two characters (@, /, r/, /p), or there can be even more characters in the trigger?

Will it work for you to add the ability to provide a custom regex and callbacks for extracting the required parts from it (name, id)?

@terryli0095
Copy link
Author

For me personally 2 characters is enough. Regex works for me as well! I can see how regex can be useful for other people but I can say for sure

@terryli0095
Copy link
Author

@dabakovich btw would love to donate or support the library somehow since we are using it pretty heavily, how can we reach you?

dabakovich added a commit that referenced this issue Mar 10, 2021
Add POC for the feature. Just new working 'pattern' and 'parsePattern' props.

If we have 'pattern', we should have also 'parsePattern' to getting 'MentionData' object.

Work for now with 'trigger[name](id)' mention value yet.

#38
@dabakovich
Copy link
Owner

@terryli0095 just published alpha v2.3.0-0 with POC of providing custom regex. For now, working only with regexes like trigger[name](id). But I think it enough for your testing.
Here is an example of part type configuration that supports r/ trigger:

{
  trigger: 'r/',
  allowedSpacesCount: 0,
  renderSuggestions: renderCustomTriggerSuggestions,
  textStyle: {fontWeight: 'bold', color: 'red'},
  pattern: /((r\/)\[([^[]*)]\(([^(^)]*)\))/gi,
  parsePattern: ([, original, trigger, name, id]) => ({original, trigger, name, id}),
},

Also added a "Support Me" category at the bottom of the library's home page :)

@andywong418
Copy link

Cool will test this and support ASAP!! Thank you for this :)

@andywong418
Copy link

Hi @dabakovich I seem to be getting an error trying to pay with paypal and I believe @terryli0095 has the same issue. Is there another way we could contribute?
Screenshot 2021-03-14 at 17 31 57

@dabakovich
Copy link
Owner

Thanks, @andywong418! I see the problem and will try to fix it soon.
Anyway thanks for your attempt! :)

@dabakovich
Copy link
Owner

@andywong418 PayPal payment should work now.

@dabakovich
Copy link
Owner

@terryli0095 Did you test v2.3.0-0 version? Is the update works for you?

@t1amat9409
Copy link

t1amat9409 commented Apr 20, 2021

hey @dabakovich, bumped into this issue, I think it might be a base of what I'm also trying to solve, I'm not sure if I read the comments correctly, but I'm looking to achieve a markdown similar to Hey \uFFFF@[john doe](john-doe-123), kinda got stuck trying to play around the regex

[EDIT]
I just wanna add the prefix \uFFFF to the mention value, so I looked at https://github.com/dabakovich/react-native-controlled-mentions/blob/master/src/utils/utils.ts#L354 I think this is the place to dwell on?

@rgbedin
Copy link

rgbedin commented Apr 22, 2021

@dabakovich @t1amat9409 @andywong418 I have just created a pull request to insert the feature of allowing consumers of the library to specify a custom transformation for the mention value. Please check it here: #52

I am open to suggestions on it.

@dabakovich dabakovich added the v3 Feature and fixes for the major v3 release label May 15, 2022
dabakovich added a commit that referenced this issue May 15, 2022
… pattern

Wrap trigger in regex with {}, so we can now use multiple characters.

Add support for custom trigger pattern.

BREAKING CHANGES
New renames:
`PartType` -> `Config`
`isTriggerPartType` -> `isTriggerConfig`
`getMentionValue` -> `getTriggerValue`
`replaceMentionValues` -> `replaceTriggerValues`

Change default trigger regex and mention value from `@[David Tabaka](123)` to `{@}[David Tabaka](123)`.

Useful for #38, #51, #52, #80.
dabakovich added a commit that referenced this issue May 16, 2022
@dabakovich
Copy link
Owner

Hi all.

I'm glad to say that v3 release is coming with few core improvements. One of the new features is full support of multiple characters trigger and custom regex pattern for mentions.

You can find examples of using new v3 release here: https://github.com/dabakovich/react-native-controlled-mentions/blob/3.0/example/mentions-functional-component.tsx

To test alpha pre-release please, install the library using next command:

yarn add react-native-controlled-mentions@alpha
// or
npm install --save react-native-controlled-mentions@alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v3 Feature and fixes for the major v3 release
Projects
None yet
Development

No branches or pull requests

5 participants