File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
packages/react-devtools-shared/src/devtools/views/Components Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 32
32
flex : 1 ;
33
33
}
34
34
35
+ .Link {
36
+ color : var (--color-link );
37
+ white-space : pre;
38
+ overflow : hidden;
39
+ text-overflow : ellipsis;
40
+ flex : 1 ;
41
+ }
42
+
35
43
.None {
36
44
color : var (--color-dimmer );
37
45
font-style : italic;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import styles from './KeyValue.css';
24
24
import Button from 'react-devtools-shared/src/devtools/views/Button' ;
25
25
import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon' ;
26
26
import { InspectedElementContext } from './InspectedElementContext' ;
27
+ import { PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE } from './constants' ;
27
28
28
29
import type { InspectedElement } from './types' ;
29
30
import type { Element } from 'react-devtools-shared/src/devtools/views/Components/types' ;
@@ -243,6 +244,16 @@ export default function KeyValue({
243
244
displayValue = 'undefined' ;
244
245
}
245
246
247
+ let shouldDisplayValueAsLink = false ;
248
+ if (
249
+ dataType === 'string' &&
250
+ PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE . some ( protocolPrefix =>
251
+ value . startsWith ( protocolPrefix ) ,
252
+ )
253
+ ) {
254
+ shouldDisplayValueAsLink = true ;
255
+ }
256
+
246
257
children = (
247
258
< div
248
259
key = "root"
@@ -259,6 +270,14 @@ export default function KeyValue({
259
270
path = { path }
260
271
value = { value }
261
272
/>
273
+ ) : shouldDisplayValueAsLink ? (
274
+ < a
275
+ className = { styles . Link }
276
+ href = { value }
277
+ target = "_blank"
278
+ rel = "noopener noreferrer" >
279
+ { displayValue }
280
+ </ a >
262
281
) : (
263
282
< span className = { styles . Value } > { displayValue } </ span >
264
283
) }
Original file line number Diff line number Diff line change
1
+ export const PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE = [
2
+ 'file:///' ,
3
+ 'http://' ,
4
+ 'https://' ,
5
+ 'vscode://' ,
6
+ ] ;
You can’t perform that action at this time.
0 commit comments