-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
number of lines Text Component #94
Comments
Hi, unfortunately this is not supported at the moment. This makes me think it could be a nice idea to add a prop that is spread to all (or only some ?) |
I need this option like the number of lines. Because I want to show some content on my page doesn't want to show whole content. I need this option. ?Is there any solution to do this? |
@MSSPL-PiyaleeMaiti the only way I implemented something similar to the number of lines was
You can do something similar to limit the number of characters using substring function, numberOfLines parameter represents the position where to end the extraction. |
By the way, if you just want to display like half the content, you can simply truncate the HTML string you're rendering before passing it to the module. It's way easier than having to alter the text nodes themselves. It might be useful if you want to lock an article and display only half of it to unregistered users, for example. If that's not what you're looking for, alterData should let you do what you want. |
@Juliocbr and @Exilz thank you for your suggestion. @Juliocbr I am doing using your way, but the problem is if I substring the HTML string it may be cut between any HTML tag and that HTML string will render properly or not! That is the problem of me. @Exilz I am trying to use alterData as per your suggestion, but in alterData I want to return data at limited length, but it's not returned limited data it showing all data means return whole data. Can't cut data using this method. |
@Exilz What is the status of numberOfLines for showing half html content? I need this features urgently. Or can you suggest any alternative solution so that I can show half html content using this package without using any substr() method. substr is not working for html content. |
@MSSPL-PiyaleeMaiti a better way to solve your issue would be to use the prop What you could do is to remove some HTML tags from |
@Exilz I see your example but, I need also html tags when it's show, I want to show half content of a content with html tags. And here in your solution it's remove all html tag then show content without html tags. So what is the solution for my requirement. Can you suggest me? |
Is any solution found for this problem? I need this features urgently. Can anyone give me any solution? |
Hi, any updates regarding this! I have a paragraph |
@yasir-netlinks You can use 'truncate-html', link is below, I solve my problem using this plugin. |
Any plans to fix this in the future? |
Interested in this feature to !!! |
Quick workaround is to wrap html view in a view and set maxHeight to 100 which equivalent to 4 line of text approximately:
|
+1 |
@Asim13se interesting, but I see a problem that |
The maxHeight work around cuts it off on the middle, which is not ideal. |
I was able to fix this with custom renderers:
|
Unfortunately this doesn't work on all cases, especially for android. If your description contains some other html tags this will cause a crash on android, because you can't have nested views inside a text component. On iOS this works just fine. |
This issue will be fixed in 6.x release, where |
With the new foundry pre-release (see #434), you can define a custom renderer as such: const SpanRenderer = ({ TDefaultRenderer, textProps, ...props }) => {
return <TDefaultRenderer {...props} textProps={{...textProps, numberOfLines: 2}} />
}
const renderers = {
span: SpanRenderer
} |
@jsamr Hello Jules,
Although if i provide I am testing it on
I have tested it on both android and iphone. it doesn't work. |
@jaideepYes It doesn't apply to TBlock renderers, which const PRenderer = ({ TDefaultRenderer, textProps, ...props }) => {
const tchildrenAreText = props.tnode.children.every(
(t) => t.type === "text" || t.type === "phrasing"
);
const children = <TNodeChildrenRenderer tnode={props.tnode} />;
return (
<TDefaultRenderer {...props}>
{tchildrenAreText ? <Text numberOfLines={2}>{children}</Text> : children}
</TDefaultRenderer>
);
};
const renderers = {
p: PRenderer,
}; |
@jsamr Thank you for your time to reply. Yes, above method works for me.
and i was supplying I am grateful for your great work. thank you. |
Is there a way to use the number of lines as the Text component?.
Thanks.
The text was updated successfully, but these errors were encountered: