@@ -8,6 +8,7 @@ import FitScreenIcon from '@mui/icons-material/FitScreen';
8
8
import HtmlIcon from '@mui/icons-material/Html' ;
9
9
import SchemaIcon from '@mui/icons-material/Schema' ;
10
10
import ShapeLineOutlinedIcon from '@mui/icons-material/ShapeLineOutlined' ;
11
+ import WrapTextIcon from '@mui/icons-material/WrapText' ;
11
12
12
13
import { copyToClipboard } from '~/common/util/clipboardUtils' ;
13
14
import { frontendSideFetch } from '~/common/util/clientFetchers' ;
@@ -106,6 +107,7 @@ function RenderCodeImpl(props: RenderCodeImplProps) {
106
107
const [ showMermaid , setShowMermaid ] = React . useState ( true ) ;
107
108
const [ showPlantUML , setShowPlantUML ] = React . useState ( true ) ;
108
109
const [ showSVG , setShowSVG ] = React . useState ( true ) ;
110
+ const [ softWrap , setSoftWrap ] = React . useState ( false ) ;
109
111
110
112
// derived props
111
113
const {
@@ -171,7 +173,7 @@ function RenderCodeImpl(props: RenderCodeImplProps) {
171
173
component = 'code'
172
174
className = { `language-${ inferredCodeLanguage || 'unknown' } ` }
173
175
sx = { {
174
- whiteSpace : 'pre' , // was 'break-spaces' before we implemented per-block scrolling
176
+ whiteSpace : softWrap ? 'break-spaces' : 'pre' , // was 'break-spaces' before we implemented per-block scrolling
175
177
mx : 0 , p : 1.5 , // this block gets a thicker border
176
178
display : 'flex' ,
177
179
flexDirection : 'column' ,
@@ -265,6 +267,15 @@ function RenderCodeImpl(props: RenderCodeImplProps) {
265
267
</ ButtonGroup >
266
268
) }
267
269
270
+ { /* Soft Wrap toggle */ }
271
+ { ( ! renderHTML && ! renderMermaid && ! renderPlantUML && ! renderSVG ) && (
272
+ < Tooltip title = 'Toggle Soft Wrap' >
273
+ < OverlayButton variant = { softWrap ? 'solid' : 'outlined' } onClick = { ( ) => setSoftWrap ( on => ! on ) } >
274
+ < WrapTextIcon />
275
+ </ OverlayButton >
276
+ </ Tooltip >
277
+ ) }
278
+
268
279
{ /* Copy */ }
269
280
{ props . noCopyButton !== true && (
270
281
< Tooltip title = { optimizeLightweight ? null : 'Copy Code' } >
0 commit comments