import { decodeEntities } from '@wordpress/html-entities'; import { chevronRightSmall, Icon } from '@wordpress/icons'; // A started label reads as still running, so a finished step drops its dots. const stepText = ({ label, started }) => decodeEntities(label || started.replace(/\s*(\.\.\.|…)$/, '')); const resultText = (result) => typeof result === 'string' ? result : JSON.stringify(result, null, 2); // highlightAll clears every block it painted, so each call covers them all. const SELECTOR = 'pre > code.language-json'; export const highlightToolSteps = (root) => { // Without the Custom Highlight API the JSON stays plain text. if (!window.CSS?.highlights || !root?.querySelector(SELECTOR)) return; import('microlighter') .then(({ highlightAll }) => highlightAll({ root, selector: SELECTOR })) .catch(() => {}); }; export const ToolStep = ({ details }) => { if (details.result === undefined) { return (
{resultText(details.result)}