import React, { useState, useEffect } from 'react'; import styles from './CustomFormatter.module.css'; interface CustomFormatterProps { formatter: string; setFormatter: (formatter: string) => void; } const CustomFormatter: React.FC = ({ formatter, setFormatter, }) => { const [isExpanded, setIsExpanded] = useState(false); let initialName = ''; let initialDesc = ''; if (formatter.startsWith('custom:') && formatter.length > 7) { const formatterData = JSON.parse(formatter.substring(7)); initialName = formatterData.name || ''; initialDesc = formatterData.description || ''; } const [customNameSyntax, setCustomNameSyntax] = useState(initialName); const [customDescSyntax, setCustomDescSyntax] = useState(initialDesc); // Load the existing formatter on component mount useEffect(() => { const formatterData = { name: customNameSyntax, description: customDescSyntax, }; setFormatter(`custom:${JSON.stringify(formatterData)}`); }, [customNameSyntax, customDescSyntax, setFormatter]); return (

setIsExpanded(!isExpanded)} > Custom Formatter {isExpanded ? '▼' : '►'}

{isExpanded && (

Define a custom formatter syntax. Write {'{debug.jsonf}'} to see the available variables.
For a more detailed explanation, check the{' '} wiki