diff --git a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.css b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.css index bca22c8786c6f..0f6bee239d3d8 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.css +++ b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.css @@ -32,6 +32,14 @@ flex: 1; } +.Link { + color: var(--color-link); + white-space: pre; + overflow: hidden; + text-overflow: ellipsis; + flex: 1; +} + .None { color: var(--color-dimmer); font-style: italic; diff --git a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js index 39ba220efbc1f..be45bab429dda 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js @@ -24,6 +24,7 @@ import styles from './KeyValue.css'; import Button from 'react-devtools-shared/src/devtools/views/Button'; import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon'; import {InspectedElementContext} from './InspectedElementContext'; +import {PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE} from './constants'; import type {InspectedElement} from './types'; import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types'; @@ -243,6 +244,16 @@ export default function KeyValue({ displayValue = 'undefined'; } + let shouldDisplayValueAsLink = false; + if ( + dataType === 'string' && + PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE.some(protocolPrefix => + value.startsWith(protocolPrefix), + ) + ) { + shouldDisplayValueAsLink = true; + } + children = (
+ ) : shouldDisplayValueAsLink ? ( + + {displayValue} + ) : ( {displayValue} )} diff --git a/packages/react-devtools-shared/src/devtools/views/Components/constants.js b/packages/react-devtools-shared/src/devtools/views/Components/constants.js new file mode 100644 index 0000000000000..f1fa5e9dd5bbb --- /dev/null +++ b/packages/react-devtools-shared/src/devtools/views/Components/constants.js @@ -0,0 +1,6 @@ +export const PROTOCOLS_SUPPORTED_AS_LINKS_IN_KEY_VALUE = [ + 'file:///', + 'http://', + 'https://', + 'vscode://', +];