ink icon indicating copy to clipboard operation
ink copied to clipboard

Truncate without …

Open codemaster138 opened this issue 3 years ago • 3 comments

I'm trying to create an app with ink.js and I need to truncate a string, but without .

I looked through the code of the <Text> component, but it just passes the wrap property on to an underlying <ink-text> component which AFAIK puts altering the way truncation works out of my reach.

I tried limiting the size of the box but leaving wrap set to its default value "wrap", but that resulted in the text wrapping out of its container and overwriting components that came after it – not exactly ideal.

Is there some way to truncate text without adding the character?

codemaster138 avatar Oct 06 '21 14:10 codemaster138

I'd love if we could just have a prop truncateCharacter that we can pass to <Text> to alter the character.

I'll try to write a PR for this right now

codemaster138 avatar Oct 06 '21 14:10 codemaster138

Update: Currently waiting for PR sindresorhus/cli-truncate#19 to be merged, then I'll finish this up

codemaster138 avatar Oct 06 '21 15:10 codemaster138

Sounds like a valid use case, looking forward to the PR!

vadimdemedes avatar Oct 07 '21 17:10 vadimdemedes

Closing until more users want this.

vadimdemedes avatar Mar 17 '23 23:03 vadimdemedes