mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-06 06:48:21 +00:00
Fix: Not able to copy value in debugger
This commit is contained in:
parent
679811ad76
commit
cd8e330208
2 changed files with 18 additions and 2 deletions
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue