Copy JSON values on click (#11382)
https://github.com/user-attachments/assets/1638c196-fb9c-4f2b-910c-6d8b0693a37a Closes https://github.com/twentyhq/core-team-issues/issues/568
This commit is contained in:
committed by
GitHub
parent
bb40bc9929
commit
9353e777ea
@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user