truncate only in urls
Opened this issue · 1 comments
rerererarara commented
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 commented
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.