@mui/docs 6.0.0-alpha.8 → 6.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +407 -3
- package/HighlightedCode/HighlightedCode.d.ts +1 -1
- package/HighlightedCode/HighlightedCode.js +5 -2
- package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.d.ts +29 -0
- package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +353 -0
- package/HighlightedCodeWithTabs/index.d.ts +2 -0
- package/HighlightedCodeWithTabs/index.js +2 -0
- package/HighlightedCodeWithTabs/package.json +6 -0
- package/Link/Link.js +0 -2
- package/MarkdownElement/MarkdownElement.js +129 -104
- package/branding/BrandingProvider.d.ts +1 -1
- package/branding/brandingTheme.js +184 -50
- package/i18n/i18n.js +9 -6
- package/node/HighlightedCode/HighlightedCode.js +5 -2
- package/node/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +363 -0
- package/node/HighlightedCodeWithTabs/index.js +24 -0
- package/node/Link/Link.js +0 -2
- package/node/MarkdownElement/MarkdownElement.js +129 -104
- package/node/branding/brandingTheme.js +184 -50
- package/node/i18n/i18n.js +9 -6
- package/node/translations/translations.json +3 -2
- package/package.json +4 -3
- package/translations/translations.json +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { alpha, darken, styled } from '@mui/material/styles';
|
|
4
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
4
5
|
import { brandingDarkTheme as darkTheme, brandingLightTheme as lightTheme } from '../branding';
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
const Root = styled('div')(({
|
|
7
8
|
theme
|
|
8
9
|
}) => ({
|
|
9
10
|
...lightTheme.typography.body1,
|
|
10
|
-
lineHeight: 1.
|
|
11
|
-
//
|
|
11
|
+
lineHeight: 1.625,
|
|
12
|
+
// Rounds up to 26px-increased compared to the 1.5 default to make the docs easier to read.
|
|
12
13
|
color: `var(--muidocs-palette-text-primary, ${lightTheme.palette.text.primary})`,
|
|
13
14
|
'& :focus-visible': {
|
|
14
15
|
outline: `3px solid ${alpha(lightTheme.palette.primary[500], 0.5)}`,
|
|
@@ -23,7 +24,7 @@ const Root = styled('div')(({
|
|
|
23
24
|
// Developers like when the code is dense.
|
|
24
25
|
margin: theme.spacing(2, 'auto'),
|
|
25
26
|
padding: theme.spacing(2),
|
|
26
|
-
backgroundColor: 'hsl(210,
|
|
27
|
+
backgroundColor: 'hsl(210, 25%, 9%)',
|
|
27
28
|
// a special, one-off, color tailored for the code blocks using MUI's branding theme blue palette as the starting point. It has a less saturaded color but still maintaining a bit of the blue tint.
|
|
28
29
|
color: 'hsl(60, 30%, 96%)',
|
|
29
30
|
colorScheme: 'dark',
|
|
@@ -122,6 +123,44 @@ const Root = styled('div')(({
|
|
|
122
123
|
marginBottom: 6
|
|
123
124
|
}
|
|
124
125
|
},
|
|
126
|
+
'& a[target="_blank"]::after': {
|
|
127
|
+
content: '""',
|
|
128
|
+
maskImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' focusable='false' aria-hidden='true' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z'%3E%3C/path%3E%3C/svg%3E")`,
|
|
129
|
+
display: 'inline-flex',
|
|
130
|
+
width: '1em',
|
|
131
|
+
height: '1em',
|
|
132
|
+
color: 'inherit',
|
|
133
|
+
backgroundColor: 'currentColor',
|
|
134
|
+
transform: 'translate(0, 2px)',
|
|
135
|
+
transition: 'transform 0.3s cubic-bezier(0.1, 0.8, 0.3, 1)',
|
|
136
|
+
// bounce effect
|
|
137
|
+
opacity: 0.8
|
|
138
|
+
},
|
|
139
|
+
'& a[target="_blank"]:hover::after': {
|
|
140
|
+
opacity: 1,
|
|
141
|
+
transform: 'translate(1px, 0)'
|
|
142
|
+
},
|
|
143
|
+
'& a.remove-link-arrow::after': {
|
|
144
|
+
// Allows to remove link arrows for images
|
|
145
|
+
display: 'none'
|
|
146
|
+
},
|
|
147
|
+
'& .Ad-root a::after': {
|
|
148
|
+
// Remove link arrow for ads
|
|
149
|
+
display: 'none'
|
|
150
|
+
},
|
|
151
|
+
'& a': {
|
|
152
|
+
// Style taken from the Link component
|
|
153
|
+
color: `var(--muidocs-palette-primary-600, ${lightTheme.palette.primary[600]})`,
|
|
154
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
155
|
+
textDecoration: 'underline',
|
|
156
|
+
textDecorationColor: alpha(lightTheme.palette.primary.main, 0.4),
|
|
157
|
+
'&:hover': {
|
|
158
|
+
textDecorationColor: 'inherit'
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
'& a code': {
|
|
162
|
+
color: darken(lightTheme.palette.primary.main, 0.2)
|
|
163
|
+
},
|
|
125
164
|
'& h1, & h2, & h3, & h4': {
|
|
126
165
|
display: 'flex',
|
|
127
166
|
alignItems: 'center',
|
|
@@ -135,9 +174,12 @@ const Root = styled('div')(({
|
|
|
135
174
|
'& .title-link-to-anchor': {
|
|
136
175
|
color: 'inherit',
|
|
137
176
|
textDecoration: 'none',
|
|
177
|
+
boxShadow: 'none',
|
|
178
|
+
fontWeight: 'inherit',
|
|
138
179
|
position: 'relative',
|
|
139
180
|
display: 'flex',
|
|
140
|
-
alignItems: 'center'
|
|
181
|
+
alignItems: 'center',
|
|
182
|
+
userSelect: 'text'
|
|
141
183
|
},
|
|
142
184
|
'& .anchor-icon': {
|
|
143
185
|
// To prevent the link to get the focus.
|
|
@@ -145,12 +187,6 @@ const Root = styled('div')(({
|
|
|
145
187
|
alignItems: 'center',
|
|
146
188
|
visibility: 'hidden'
|
|
147
189
|
},
|
|
148
|
-
'& a:not(.title-link-to-anchor):hover': {
|
|
149
|
-
color: 'currentColor',
|
|
150
|
-
border: 'none',
|
|
151
|
-
boxShadow: '0 1px 0 0 currentColor',
|
|
152
|
-
textDecoration: 'none'
|
|
153
|
-
},
|
|
154
190
|
'& .anchor-icon, & .comment-link': {
|
|
155
191
|
padding: 0,
|
|
156
192
|
cursor: 'pointer',
|
|
@@ -161,11 +197,13 @@ const Root = styled('div')(({
|
|
|
161
197
|
marginLeft: 8,
|
|
162
198
|
height: 26,
|
|
163
199
|
width: 26,
|
|
164
|
-
backgroundColor: `var(--muidocs-palette-primary-50, ${lightTheme.palette.grey[50]})`,
|
|
165
200
|
color: `var(--muidocs-palette-grey-600, ${lightTheme.palette.grey[600]})`,
|
|
166
|
-
|
|
167
|
-
|
|
201
|
+
backgroundColor: 'transparent',
|
|
202
|
+
border: '1px solid transparent',
|
|
168
203
|
borderRadius: 8,
|
|
204
|
+
transition: theme.transitions.create(['visibility', 'background-color', 'color', 'border-color'], {
|
|
205
|
+
duration: theme.transitions.duration.shortest
|
|
206
|
+
}),
|
|
169
207
|
'&:hover': {
|
|
170
208
|
backgroundColor: alpha(lightTheme.palette.primary[100], 0.4),
|
|
171
209
|
borderColor: `var(--muidocs-palette-primary-100, ${lightTheme.palette.primary[100]})`,
|
|
@@ -186,7 +224,7 @@ const Root = styled('div')(({
|
|
|
186
224
|
display: 'none',
|
|
187
225
|
// So we can have the comment button opt-in.
|
|
188
226
|
marginLeft: 'auto',
|
|
189
|
-
transition: theme.transitions.create('
|
|
227
|
+
transition: theme.transitions.create(['background-color', 'color', 'border-color'], {
|
|
190
228
|
duration: theme.transitions.duration.shortest
|
|
191
229
|
}),
|
|
192
230
|
'& svg': {
|
|
@@ -284,44 +322,58 @@ const Root = styled('div')(({
|
|
|
284
322
|
},
|
|
285
323
|
'& .MuiCallout-root': {
|
|
286
324
|
display: 'flex',
|
|
287
|
-
gap:
|
|
288
|
-
padding: '
|
|
325
|
+
gap: '8px',
|
|
326
|
+
padding: '12px',
|
|
289
327
|
margin: '16px 0',
|
|
290
328
|
border: '1px solid',
|
|
291
329
|
color: `var(--muidocs-palette-text-secondary, ${lightTheme.palette.text.secondary})`,
|
|
292
330
|
borderColor: `var(--muidocs-palette-grey-100, ${lightTheme.palette.grey[100]})`,
|
|
293
331
|
borderRadius: `var(--muidocs-shape-borderRadius, ${theme.shape?.borderRadius ?? lightTheme.shape.borderRadius}px)`,
|
|
294
|
-
'&
|
|
332
|
+
'& .MuiCallout-content': {
|
|
333
|
+
minWidth: 0,
|
|
334
|
+
// Allows content to shrink. Useful when callout contains code block
|
|
335
|
+
flexGrow: 1
|
|
336
|
+
},
|
|
337
|
+
'& code': {
|
|
295
338
|
height: 'fit-content',
|
|
296
339
|
backgroundColor: `var(--muidocs-palette-grey-100, ${lightTheme.palette.grey[100]})`,
|
|
297
340
|
borderColor: `var(--muidocs-palette-grey-300, ${lightTheme.palette.grey[300]})`
|
|
298
341
|
},
|
|
299
|
-
'&
|
|
300
|
-
|
|
301
|
-
// Allows content to shrink. Useful when callout contains code block
|
|
302
|
-
flexGrow: 1,
|
|
342
|
+
'& p': {
|
|
343
|
+
marginBottom: '8px',
|
|
303
344
|
'& > p:last-child, & > ul:last-child': {
|
|
304
345
|
// Avoid margin on last child
|
|
305
346
|
marginBottom: 0
|
|
306
347
|
},
|
|
307
|
-
'& .MuiCode-root': {
|
|
308
|
-
'& > pre': {
|
|
309
|
-
margin: 0,
|
|
310
|
-
marginTop: 4
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
348
|
'& > ul': {
|
|
314
349
|
// Because of the gap left by the icon, we visually need less padding
|
|
315
350
|
paddingLeft: 22
|
|
316
351
|
}
|
|
317
352
|
},
|
|
318
|
-
'&
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
353
|
+
'& .MuiCode-root': {
|
|
354
|
+
'& pre': {
|
|
355
|
+
margin: '4px 0 0 0',
|
|
356
|
+
borderRadius: '12px 12px 6px 12px',
|
|
357
|
+
borderColor: alpha(lightTheme.palette.primaryDark[600], 0.6),
|
|
358
|
+
'& code': {
|
|
359
|
+
backgroundColor: 'transparent'
|
|
360
|
+
}
|
|
361
|
+
}
|
|
323
362
|
},
|
|
324
|
-
'&
|
|
363
|
+
'& .MuiCallout-icon-container': {
|
|
364
|
+
width: 26,
|
|
365
|
+
// to match text's line-height
|
|
366
|
+
height: 26,
|
|
367
|
+
display: 'flex',
|
|
368
|
+
alignItems: 'center',
|
|
369
|
+
justifyContent: 'center',
|
|
370
|
+
flexShrink: 0,
|
|
371
|
+
'& svg': {
|
|
372
|
+
width: 18,
|
|
373
|
+
height: 18
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
'& ul, & p': {
|
|
325
377
|
'&:last-child': {
|
|
326
378
|
margin: 0
|
|
327
379
|
}
|
|
@@ -336,7 +388,7 @@ const Root = styled('div')(({
|
|
|
336
388
|
'& strong': {
|
|
337
389
|
color: `var(--muidocs-palette-error-800, ${lightTheme.palette.error[800]})`
|
|
338
390
|
},
|
|
339
|
-
'&
|
|
391
|
+
'& svg': {
|
|
340
392
|
fill: `var(--muidocs-palette-error-500, ${lightTheme.palette.error[600]})`
|
|
341
393
|
},
|
|
342
394
|
'& a': {
|
|
@@ -354,7 +406,7 @@ const Root = styled('div')(({
|
|
|
354
406
|
'& strong': {
|
|
355
407
|
color: `var(--muidocs-palette-primary-800, ${lightTheme.palette.primary[800]})`
|
|
356
408
|
},
|
|
357
|
-
'&
|
|
409
|
+
'& svg': {
|
|
358
410
|
fill: `var(--muidocs-palette-grey-600, ${lightTheme.palette.grey[600]})`
|
|
359
411
|
}
|
|
360
412
|
},
|
|
@@ -365,7 +417,7 @@ const Root = styled('div')(({
|
|
|
365
417
|
'& strong': {
|
|
366
418
|
color: `var(--muidocs-palette-success-900, ${lightTheme.palette.success[900]})`
|
|
367
419
|
},
|
|
368
|
-
'&
|
|
420
|
+
'& svg': {
|
|
369
421
|
fill: `var(--muidocs-palette-success-600, ${lightTheme.palette.success[600]})`
|
|
370
422
|
},
|
|
371
423
|
'& a': {
|
|
@@ -383,7 +435,7 @@ const Root = styled('div')(({
|
|
|
383
435
|
'& strong': {
|
|
384
436
|
color: `var(--muidocs-palette-warning-800, ${lightTheme.palette.warning[800]})`
|
|
385
437
|
},
|
|
386
|
-
'&
|
|
438
|
+
'& svg': {
|
|
387
439
|
fill: `var(--muidocs-palette-warning-600, ${lightTheme.palette.warning[600]})`
|
|
388
440
|
},
|
|
389
441
|
'& a': {
|
|
@@ -395,47 +447,6 @@ const Root = styled('div')(({
|
|
|
395
447
|
}
|
|
396
448
|
}
|
|
397
449
|
},
|
|
398
|
-
'& a[target="_blank"]::after': {
|
|
399
|
-
content: '""',
|
|
400
|
-
maskImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' focusable='false' aria-hidden='true' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z'%3E%3C/path%3E%3C/svg%3E")`,
|
|
401
|
-
display: 'inline-flex',
|
|
402
|
-
width: '1em',
|
|
403
|
-
height: '1em',
|
|
404
|
-
color: 'inherit',
|
|
405
|
-
backgroundColor: 'currentColor',
|
|
406
|
-
transform: 'translate(0, 2px)',
|
|
407
|
-
transition: 'transform 0.3s cubic-bezier(0.1, 0.8, 0.3, 1)',
|
|
408
|
-
// bounce effect
|
|
409
|
-
opacity: 0.8
|
|
410
|
-
},
|
|
411
|
-
'& a[target="_blank"]:hover::after': {
|
|
412
|
-
opacity: 1,
|
|
413
|
-
transform: 'translate(1px, 0)'
|
|
414
|
-
},
|
|
415
|
-
'& a.remove-link-arrow::after': {
|
|
416
|
-
// Allows to remove link arrows for images
|
|
417
|
-
display: 'none'
|
|
418
|
-
},
|
|
419
|
-
'& .Ad-root a::after': {
|
|
420
|
-
// Remove link arrow for ads
|
|
421
|
-
display: 'none'
|
|
422
|
-
},
|
|
423
|
-
'& a:not(.title-link-to-anchor), & a:not(.title-link-to-anchor) code': {
|
|
424
|
-
// Style taken from the Link component
|
|
425
|
-
color: `var(--muidocs-palette-primary-600, ${lightTheme.palette.primary[600]})`,
|
|
426
|
-
fontWeight: theme.typography.fontWeightMedium,
|
|
427
|
-
textDecoration: 'underline',
|
|
428
|
-
textDecorationColor: alpha(lightTheme.palette.primary.main, 0.4),
|
|
429
|
-
'&:hover': {
|
|
430
|
-
textDecorationColor: 'inherit'
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
'& a code': {
|
|
434
|
-
color: darken(lightTheme.palette.primary.main, 0.04)
|
|
435
|
-
},
|
|
436
|
-
'& a:not(.title-link-to-anchor) code': {
|
|
437
|
-
color: darken(lightTheme.palette.primary.main, 0.2)
|
|
438
|
-
},
|
|
439
450
|
'& img, & video': {
|
|
440
451
|
// Use !important so that inline style on <img> or <video> can't win.
|
|
441
452
|
// This avoid horizontal overflows on mobile.
|
|
@@ -539,7 +550,6 @@ const Root = styled('div')(({
|
|
|
539
550
|
display: 'inline-flex',
|
|
540
551
|
flexDirection: 'row-reverse',
|
|
541
552
|
alignItems: 'center',
|
|
542
|
-
height: 24,
|
|
543
553
|
padding: theme.spacing(0.5),
|
|
544
554
|
paddingBottom: '5px',
|
|
545
555
|
// optical alignment
|
|
@@ -550,7 +560,7 @@ const Root = styled('div')(({
|
|
|
550
560
|
border: '1px solid',
|
|
551
561
|
borderColor: alpha(lightTheme.palette.primaryDark[600], 0.5),
|
|
552
562
|
backgroundColor: alpha(lightTheme.palette.primaryDark[800], 0.5),
|
|
553
|
-
color: `var(--muidocs-palette-grey-
|
|
563
|
+
color: `var(--muidocs-palette-grey-300, ${lightTheme.palette.grey[300]})`,
|
|
554
564
|
transition: theme.transitions.create(['background', 'borderColor', 'display'], {
|
|
555
565
|
duration: theme.transitions.duration.shortest
|
|
556
566
|
}),
|
|
@@ -663,24 +673,26 @@ const Root = styled('div')(({
|
|
|
663
673
|
'& hr': {
|
|
664
674
|
backgroundColor: `var(--muidocs-palette-divider, ${darkTheme.palette.divider})`
|
|
665
675
|
},
|
|
666
|
-
'&
|
|
667
|
-
color: `var(--muidocs-palette-
|
|
676
|
+
'& a': {
|
|
677
|
+
color: `var(--muidocs-palette-primary-300, ${darkTheme.palette.primary[300]})`
|
|
668
678
|
},
|
|
669
|
-
'&
|
|
670
|
-
color: `var(--muidocs-palette-
|
|
679
|
+
'& a code': {
|
|
680
|
+
color: `var(--muidocs-palette-primary-light, ${darkTheme.palette.primary.light})`
|
|
671
681
|
},
|
|
672
|
-
'& h1, & h2, & h3, & h4': {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
backgroundColor: alpha(darkTheme.palette.primaryDark[700], 0.5),
|
|
682
|
+
'& h1, & h2, & h3, & h4, & h5': {
|
|
683
|
+
color: `var(--muidocs-palette-grey-50, ${darkTheme.palette.grey[50]})`,
|
|
684
|
+
'& .anchor-icon, & .comment-link': {
|
|
685
|
+
color: `var(--muidocs-palette-primary-300, ${darkTheme.palette.primaryDark[400]})`,
|
|
677
686
|
'&:hover': {
|
|
687
|
+
color: `var(--muidocs-palette-primary-100, ${darkTheme.palette.primary[100]})`,
|
|
678
688
|
borderColor: `var(--muidocs-palette-primary-900, ${darkTheme.palette.primary[900]})`,
|
|
679
|
-
backgroundColor: alpha(darkTheme.palette.primary[900], 0.6)
|
|
680
|
-
color: `var(--muidocs-palette-primary-100, ${darkTheme.palette.primary[100]})`
|
|
689
|
+
backgroundColor: alpha(darkTheme.palette.primary[900], 0.6)
|
|
681
690
|
}
|
|
682
691
|
}
|
|
683
692
|
},
|
|
693
|
+
'& p, & ul, & ol': {
|
|
694
|
+
color: `var(--muidocs-palette-grey-400, ${darkTheme.palette.grey[400]})`
|
|
695
|
+
},
|
|
684
696
|
'& h1 code, & h2 code, & h3 code': {
|
|
685
697
|
color: `var(--muidocs-palette-grey-100, ${darkTheme.palette.grey[100]})`
|
|
686
698
|
},
|
|
@@ -714,8 +726,7 @@ const Root = styled('div')(({
|
|
|
714
726
|
},
|
|
715
727
|
'& .MuiCallout-root': {
|
|
716
728
|
borderColor: `var(--muidocs-palette-primaryDark-700, ${darkTheme.palette.primaryDark[700]})`,
|
|
717
|
-
'&
|
|
718
|
-
height: 'fit-content',
|
|
729
|
+
'& code': {
|
|
719
730
|
backgroundColor: `var(--muidocs-palette-primaryDark-600, ${darkTheme.palette.primaryDark[600]})`,
|
|
720
731
|
borderColor: `var(--muidocs-palette-primaryDark-500, ${darkTheme.palette.primaryDark[500]})`
|
|
721
732
|
},
|
|
@@ -726,7 +737,7 @@ const Root = styled('div')(({
|
|
|
726
737
|
'& strong': {
|
|
727
738
|
color: `var(--muidocs-palette-error-300, ${darkTheme.palette.error[300]})`
|
|
728
739
|
},
|
|
729
|
-
'&
|
|
740
|
+
'& svg': {
|
|
730
741
|
fill: `var(--muidocs-palette-error-500, ${darkTheme.palette.error[500]})`
|
|
731
742
|
},
|
|
732
743
|
'& a': {
|
|
@@ -740,7 +751,7 @@ const Root = styled('div')(({
|
|
|
740
751
|
'& strong': {
|
|
741
752
|
color: `var(--muidocs-palette-primary-200, ${darkTheme.palette.primary[200]})`
|
|
742
753
|
},
|
|
743
|
-
'&
|
|
754
|
+
'& svg': {
|
|
744
755
|
fill: `var(--muidocs-palette-grey-400, ${darkTheme.palette.grey[400]})`
|
|
745
756
|
}
|
|
746
757
|
},
|
|
@@ -751,7 +762,7 @@ const Root = styled('div')(({
|
|
|
751
762
|
'& strong': {
|
|
752
763
|
color: `var(--muidocs-palette-success-200, ${darkTheme.palette.success[200]})`
|
|
753
764
|
},
|
|
754
|
-
'&
|
|
765
|
+
'& svg': {
|
|
755
766
|
fill: `var(--muidocs-palette-success-500, ${darkTheme.palette.success[500]})`
|
|
756
767
|
},
|
|
757
768
|
'& a': {
|
|
@@ -765,7 +776,7 @@ const Root = styled('div')(({
|
|
|
765
776
|
'& strong': {
|
|
766
777
|
color: `var(--muidocs-palette-warning-200, ${darkTheme.palette.warning[200]})`
|
|
767
778
|
},
|
|
768
|
-
'&
|
|
779
|
+
'& svg': {
|
|
769
780
|
fill: `var(--muidocs-palette-warning-400, ${darkTheme.palette.warning[400]})`
|
|
770
781
|
},
|
|
771
782
|
'& a': {
|
|
@@ -773,12 +784,6 @@ const Root = styled('div')(({
|
|
|
773
784
|
}
|
|
774
785
|
}
|
|
775
786
|
},
|
|
776
|
-
'& a:not(.title-link-to-anchor), & a:not(.title-link-to-anchor) code': {
|
|
777
|
-
color: `var(--muidocs-palette-primary-300, ${darkTheme.palette.primary[300]})`
|
|
778
|
-
},
|
|
779
|
-
'& a:not(.title-link-to-anchor) code': {
|
|
780
|
-
color: `var(--muidocs-palette-primary-light, ${darkTheme.palette.primary.light})`
|
|
781
|
-
},
|
|
782
787
|
'& kbd.key': {
|
|
783
788
|
color: `var(--muidocs-palette-text-primary, ${darkTheme.palette.text.primary})`,
|
|
784
789
|
backgroundColor: `var(--muidocs-palette-primaryDark-800, ${darkTheme.palette.primaryDark[800]})`,
|
|
@@ -802,12 +807,32 @@ const Root = styled('div')(({
|
|
|
802
807
|
}
|
|
803
808
|
}
|
|
804
809
|
}));
|
|
810
|
+
function handleHeaderClick(event) {
|
|
811
|
+
const selection = document.getSelection();
|
|
812
|
+
if (selection === null) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (selection.type === 'Range') {
|
|
816
|
+
// Disable the <a> behavior to be able to select text.
|
|
817
|
+
event.preventDefault();
|
|
818
|
+
}
|
|
819
|
+
}
|
|
805
820
|
export const MarkdownElement = /*#__PURE__*/React.forwardRef(function MarkdownElement(props, ref) {
|
|
806
821
|
const {
|
|
807
822
|
className,
|
|
808
823
|
renderedMarkdown,
|
|
809
824
|
...other
|
|
810
825
|
} = props;
|
|
826
|
+
const rootRef = React.useRef(null);
|
|
827
|
+
const handleRef = useForkRef(rootRef, ref);
|
|
828
|
+
React.useEffect(() => {
|
|
829
|
+
const elements = rootRef.current.getElementsByClassName('title-link-to-anchor');
|
|
830
|
+
for (let i = 0; i < elements.length; i += 1) {
|
|
831
|
+
// More reliable than `-webkit-user-drag` (https://caniuse.com/webkit-user-drag)
|
|
832
|
+
elements[i].setAttribute('draggable', 'false');
|
|
833
|
+
elements[i].addEventListener('click', handleHeaderClick);
|
|
834
|
+
}
|
|
835
|
+
}, []);
|
|
811
836
|
const more = {};
|
|
812
837
|
if (typeof renderedMarkdown === 'string') {
|
|
813
838
|
// workaround for https://github.com/facebook/react/issues/17170
|
|
@@ -820,6 +845,6 @@ export const MarkdownElement = /*#__PURE__*/React.forwardRef(function MarkdownEl
|
|
|
820
845
|
className: clsx('markdown-body', className),
|
|
821
846
|
...more,
|
|
822
847
|
...other,
|
|
823
|
-
ref:
|
|
848
|
+
ref: handleRef
|
|
824
849
|
});
|
|
825
850
|
});
|
|
@@ -4,6 +4,6 @@ export interface BrandingProviderProps {
|
|
|
4
4
|
/**
|
|
5
5
|
* If not `undefined`, the provider is considered nesting and does not render NextNProgressBar & CssBaseline
|
|
6
6
|
*/
|
|
7
|
-
mode
|
|
7
|
+
mode?: 'light' | 'dark';
|
|
8
8
|
}
|
|
9
9
|
export declare function BrandingProvider(props: BrandingProviderProps): React.JSX.Element;
|