Fix: Not able to copy value in debugger

This commit is contained in:
devanshu052000 2025-01-17 15:06:47 +05:30
parent 679811ad76
commit cd8e330208
2 changed files with 18 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import JSONTreeViewer from '@/_ui/JSONTreeViewer';
import cx from 'classnames';
import SolidIcon from '@/_ui/Icon/SolidIcons';
import useStore from '@/AppBuilder/_stores/store';
import { toast } from 'react-hot-toast';
function Logs({ logProps, idx }) {
const [open, setOpen] = React.useState(false);
@ -52,10 +53,19 @@ function Logs({ logProps, idx }) {
}
};
const copyToClipboard = (data) => {
const stringified = JSON.stringify(data, null, 2).replace(/\\/g, '');
navigator.clipboard.writeText(stringified);
return toast.success('Value copied to clipboard', { position: 'top-center' });
};
const callbackActions = [
{
for: 'all',
actions: [{ name: 'Select Widget', dispatchAction: handleSelectComponentOnEditor, icon: false, onSelect: true }],
actions: [
{ name: 'Copy value', dispatchAction: copyToClipboard, icon: false },
{ name: 'Select Widget', dispatchAction: handleSelectComponentOnEditor, icon: false, onSelect: true },
],
enableForAllChildren: true,
enableFor1stLevelChildren: true,
},

View file

@ -269,7 +269,7 @@ export const JSONNode = ({ data, ...restProps }) => {
return (
<div style={{ fontSize: '9px', marginTop: '0px', right: '10px' }} className="d-flex position-absolute">
{enableCopyToClipboard && (
{enableCopyToClipboard ? (
<ToolTip message={'Copy to clipboard'}>
<span
onClick={() => {
@ -281,6 +281,12 @@ export const JSONNode = ({ data, ...restProps }) => {
<DefaultCopyIcon />
</span>
</ToolTip>
) : (
// Temporary fix for hover issue for copy value button. Need to remove this once inspector gets revamped.
<span
style={{ height: '13px', width: '13px', marginBottom: '4px' }}
className="mx-1 copy-to-clipboard"
></span>
)}
<ToolTip message={'Copy value'}>
<span