Skip to content

Commit f2e315e

Browse files
committed
feat: display linewraps for multi-line strings
1 parent 2ecef6d commit f2e315e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/pages/full/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ map.set({}, 'world')
6969
const set = new Set([1, 2, 3])
7070

7171
const superLongString = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'
72+
const shortMultiLineString = `Line 1
73+
Line 2
74+
Line 3`
75+
const multiLineString = `Lorem ipsum dolor sit amet,
76+
consectetur adipiscing elit.
77+
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
78+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.`
7279

7380
const example = {
7481
avatar,
@@ -101,6 +108,8 @@ const example = {
101108
[3, 4]
102109
],
103110
superLongString,
111+
shortMultiLineString,
112+
multiLineString,
104113
function: aPlusB,
105114
constFunction: aPlusBConst,
106115
anonymousFunction: function (a: number, b: number) {

src/components/DataTypes/String.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ export const stringType = defineEasyType<string>({
1616
const value = showRest
1717
? props.value
1818
: props.value.slice(0, collapseStringsAfterLength)
19-
const hasRest = props.value.length > collapseStringsAfterLength
19+
const hasRest = (props.value.length > collapseStringsAfterLength) || props.value.includes('\n')
2020
return (
2121
<Box
2222
component='span'
2323
sx={{
2424
overflowWrap: 'anywhere',
25-
cursor: hasRest ? 'pointer' : 'inherit'
25+
cursor: hasRest ? 'pointer' : 'inherit',
26+
whiteSpace: showRest ? 'pre-wrap' : 'normal'
2627
}}
2728
onClick={() => {
2829
if (window.getSelection()?.type === 'Range') {

src/components/mui/DataBox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const DataBox: FC<DataBoxProps> = props => (
1111
{...props}
1212
sx={{
1313
display: 'inline-block',
14+
verticalAlign: 'top',
1415
...props.sx
1516
}}
1617
/>

0 commit comments

Comments
 (0)