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

truncate only in urls #66

Open
rerererarara opened this issue Sep 1, 2022 · 1 comment
Open

truncate only in urls #66

rerererarara opened this issue Sep 1, 2022 · 1 comment

Comments

@rerererarara
Copy link

rerererarara commented Sep 1, 2022

Hi,

I want to use truncate only in urls. When I use truncate, Custom Matchers are also affected. How can I disable truncate in Custom Matchers?

For example like this;

    <Autolink
        text={text}
        url
        truncate={32}
        matchers={[
            {
                pattern: /@\[([^[]*)]\(([^(^)]*)\)/g,
                truncate:{0},
                style: { color: '#ff00ff' },
                getLinkText: (replacerArgs) => `@${replacerArgs[1]}`,
                onPress: (match) => {
                    navigate('userProfile', { userId: match.getReplacerArgs()[2] });
                },
            },
        ]}
    />

Thanks.

@joshswan
Copy link
Owner

joshswan commented Sep 2, 2022

The best way of achieving this at the moment would be to use a custom renderLink function. It receives the match as an argument, allowing you to perform custom rendering based on the match type.

Unfortunately, the truncate option is a "global" option designed to ensure no links are longer than X so there's no way of enabling/disabling it only for specific types at the moment. This behavior could definitely be improved, though it's not something I've ever run into. I'll leave this open and see if there's demand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants