-
Notifications
You must be signed in to change notification settings - Fork 129
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
Support for text without spaces #85
base: master
Are you sure you want to change the base?
Conversation
Not sure how maintained this library is anymore but this fix would be really awesome! |
In case it helps anyone, react-text-truncate supports this feature out of the box. |
@@ -188,7 +191,8 @@ export default class Truncate extends Component { | |||
|
|||
const lines = []; | |||
const text = innerText(elements.text); | |||
const textLines = text.split('\n').map(line => line.split(' ')); | |||
const wordSeparator = breakAll ? '' : ' '; | |||
const textLines = text.split('\n').map(line => line.split(wordSeparator)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a breakAll
property, we could introduce a separator
property, that defaults to ' '
and use it here. What do you think?
This should enable multiline truncating of non-typical text that does not contain spaces (eg URLs) and hopefully also resolve #82.
New property
breakAll
added (default:false
).When set to
true
, truncated text will behave as if css ruleword-break: break-all
was applied to the parent block.Result looks like this: