Baptiste Devessier
2025-04-04 11:20:57 +02:00
committed by GitHub
parent bb40bc9929
commit 9353e777ea
10 changed files with 91 additions and 3 deletions

View File

@ -14,6 +14,7 @@ export const JsonTree = ({
emptyStringLabel,
arrowButtonCollapsedLabel,
arrowButtonExpandedLabel,
onNodeValueClick,
}: {
value: JsonValue;
getNodeHighlighting?: GetJsonNodeHighlighting;
@ -25,6 +26,7 @@ export const JsonTree = ({
emptyStringLabel: string;
arrowButtonCollapsedLabel: string;
arrowButtonExpandedLabel: string;
onNodeValueClick?: (valueAsString: string) => void;
}) => {
return (
<JsonTreeContextProvider
@ -36,6 +38,7 @@ export const JsonTree = ({
emptyStringLabel,
arrowButtonCollapsedLabel,
arrowButtonExpandedLabel,
onNodeValueClick,
}}
>
<JsonList depth={0}>

View File

@ -1,4 +1,5 @@
import styled from '@emotion/styled';
import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTreeContextOrThrow';
import { JsonNodeHighlighting } from '@ui/json-visualizer/types/JsonNodeHighlighting';
const StyledText = styled.span<{
@ -19,5 +20,15 @@ export const JsonNodeValue = ({
valueAsString: string;
highlighting?: JsonNodeHighlighting | undefined;
}) => {
return <StyledText highlighting={highlighting}>{valueAsString}</StyledText>;
const { onNodeValueClick } = useJsonTreeContextOrThrow();
const handleClick = () => {
onNodeValueClick?.(valueAsString);
};
return (
<StyledText highlighting={highlighting} onClick={handleClick}>
{valueAsString}
</StyledText>
);
};