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

Computes lines with one very long word #2

Open
arnaud-zg opened this issue Dec 1, 2017 · 4 comments
Open

Computes lines with one very long word #2

arnaud-zg opened this issue Dec 1, 2017 · 4 comments
Assignees

Comments

@arnaud-zg
Copy link

arnaud-zg commented Dec 1, 2017

I think it could be cool to split a word by length when it's too long. The idea will be to split a long word each part should have given maximum number of characters.

For example if we use lines method on a string like this Craspharetrapharetragravida.Vivamusconsequatlacusvelposuerecongue.Duisaloremvitaeexauctorscelerisquenoneuturpis.Utimperdietmagnasitametjustobibendumvehicula..

Actually it returns the same string, with the option wordwrap it should return something like the example just below.

[
        'Craspharetraphar-',
        'retragravida.Vivam-',
        'musconsequatlac-',
        'cusvelposuerecon-',
        'ngue.Duisaloremv-',
        'vitaeexauctorscel-',
        'lerisquenoneutur-',
        'rpis.Utimperdietma-',
        'agnasitametjustob-',
        'bibendumvehicul-',
        'la.'
]
@bezoerb
Copy link
Owner

bezoerb commented Dec 10, 2017

When the css rule word-break: break-all; is defined for the element you'll get

[ 'Craspharetraph',
  'aretragravida.Vi',
  'vamusconsequ',
  'atlacusvelposu',
  'erecongue.Duis',
  'aloremvitaeexa',
  'uctorscelerisqu',
  'enoneuturpis.Ut',
  'imperdietmagn',
  'asitametjustobi',
  'bendumvehicul',
  'a.' ]

This rule can also be enforced by adding style overwrites to the method call like this:

textMetrics(el).lines(text, {}, {'word-break': 'break-all'});

@iakovoszournatzis
Copy link

I have tried a similar situation with overflow-wrap: break-word; but without any luck. My "VeryVeryVeryVeryVeryLongText" doesn't break. Any ideas?

@bezoerb bezoerb reopened this Jun 7, 2020
@bezoerb
Copy link
Owner

bezoerb commented Jun 7, 2020

Sorry for the late reply. I totally missed this issue.
overflow-wrap is currently not supported.
Thanks for reporting. I‘ll try to add support in the next days.

@bezoerb bezoerb self-assigned this Jun 7, 2020
@bezoerb
Copy link
Owner

bezoerb commented Jun 15, 2020

seems a bit more complicated than i thought ;)

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

3 participants