Skip to content

Line break for long strings #94

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

Closed
baartch opened this issue Sep 30, 2022 · 2 comments · Fixed by #99
Closed

Line break for long strings #94

baartch opened this issue Sep 30, 2022 · 2 comments · Fixed by #99
Labels
bug Something isn't working

Comments

@baartch
Copy link
Contributor

baartch commented Sep 30, 2022

I would like to ask, what you think about to add the CSS style overflow-wrap: anywhere; to string values.

If I have very long strings without spaces, the JSON viewer will stretch accordingly. And the part that is larger than the parent is hidden. I am not very happy about this behaviour.

withoutOverflowWrap

If I add overflow-wrap: anywhere; it looks like this:
withOverflowWrap

I added the CSS property directly in the Developer Tools of the browser. I wasn't able to find the right place in the source code.

What do you think about this?

@himself65 himself65 added the bug Something isn't working label Sep 30, 2022
@himself65
Copy link
Contributor

You re correct. I will fix it later

@himself65
Copy link
Contributor

The source code is here

registerType<string>(
{
is: (value) => typeof value === 'string',
...createEasyType(
'string',
(props) => {
const [showRest, setShowRest] = useState(false)
const collapseStringsAfterLength = useJsonViewerStore(
store => store.collapseStringsAfterLength)
const value = showRest
? props.value
: props.value.slice(0,
collapseStringsAfterLength)
const hasRest = props.value.length > collapseStringsAfterLength
return (
<Box
component='span'
sx={{
overflowWrap: 'break-word',
cursor: hasRest ? 'pointer' : 'inherit'
}}
onClick={() => {
setShowRest(value => !value)
}}
>
&quot;
{value}
{hasRest && <span>...</span>}
&quot;
</Box>
)
},
{
colorKey: 'base09',
fromString: value => value
}
)
}
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants