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 3232 flex : 1 ;
3333}
3434
35+ .Link {
36+ color : var (--color-link );
37+ white-space : pre;
38+ overflow : hidden;
39+ text-overflow : ellipsis;
40+ flex : 1 ;
41+ }
42+
3543.None {
3644 color : var (--color-dimmer );
3745 font-style : italic;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import styles from './KeyValue.css';
2424import Button from 'react-devtools-shared/src/devtools/views/Button' ;
2525import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon' ;
2626import { InspectedElementContext } from './InspectedElementContext' ;
27+ import { PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE } from './constants' ;
2728
2829import type { InspectedElement } from './types' ;
2930import type { Element } from 'react-devtools-shared/src/devtools/views/Components/types' ;
@@ -243,6 +244,16 @@ export default function KeyValue({
243244 displayValue = 'undefined' ;
244245 }
245246
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+
246257 children = (
247258 < div
248259 key = "root"
@@ -259,6 +270,14 @@ export default function KeyValue({
259270 path = { path }
260271 value = { value }
261272 />
273+ ) : shouldDisplayValueAsLink ? (
274+ < a
275+ className = { styles . Link }
276+ href = { value }
277+ target = "_blank"
278+ rel = "noopener noreferrer" >
279+ { displayValue }
280+ </ a >
262281 ) : (
263282 < span className = { styles . Value } > { displayValue } </ span >
264283 ) }
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