import { BaseControl, CheckboxControl, TextControl, } from '@wordpress/components'; import { useEffect, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import type { AttributesPropsAndSetter } from '../../types'; import { parseStringArrayWithSingleNestedArray } from '../../util/arrayHelpers'; export const HighlightingControl = ({ attributes, setAttributes, }: AttributesPropsAndSetter) => { const inputRef = useRef(null); useEffect(() => { try { parseStringArrayWithSingleNestedArray(attributes.lineHighlights); inputRef.current ?.querySelector('input') ?.classList.remove('cbp-input-error'); } catch (e) { console.error(e); inputRef.current ?.querySelector('input') ?.classList.add('cbp-input-error'); } }, [attributes.lineHighlights]); return ( { setAttributes({ enableHighlighting }); }} /> {attributes.enableHighlighting && (
{ setAttributes({ lineHighlights }); }} value={attributes?.lineHighlights ?? ''} />
)} { setAttributes({ highlightingHover }); }} />
); };