-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changed character limit to be calculated from character width #41455
Conversation
@@ -2,6 +2,8 @@ | |||
* External dependencies | |||
*/ | |||
import { isNil } from 'lodash'; | |||
// eslint-disable-next-line import/no-extraneous-dependencies | |||
import stringWidth from 'string-width'; |
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.
Thanks for persisting with this one.
Things work as described in the browser, and functionality-wise, a good addition to the Truncate component I think.
My only question would be to ask whether the library is appropriate.
This package and its dependencies aren't actively maintained, and I'm wondering the utility is worth the bump in package size:
| `build/components/index.min.js` | 233 kB | +5.01 kB (+2%) |
(from the CI reports)
Plus jest doesn't seem to be able to compile the library via Babel.
Even so, do we care about possible ANSI or emoji characters?
Taking those away, it seems as if string-width
relies mainly on eastasianwidth
Maybe we could get away with just using https://github.com/komagata/eastasianwidth?
I'm not sure. What do you think?
May I suggest we stick with the standard CSS truncation here (the // Assuming `ellipsizeMode='auto'` and `limit=0`, which are the default values
<Truncate numberOfLines={ 1 }>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</Truncate> My impression is that the character-based I would probably discourage people from using cc @ciampo |
100% aligned with the above, let's move forward with what suggested by @mirka ! |
Text → Truncate
This reverts commit 2bafe7c.
48fc825
to
58c70c5
Compare
Resolves #40463
Related #40807
What?
Changed character limit to be calculated from character width.
Why?
How?
This comment is used to calculate the width of the character count using the string-width package.
#40463 (comment)
Before
After
Testing Instructions
Go to the block editor and place the image block.
Open the side panel and look at the style preview.
Screenshots or screencast