/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { useContext } from '@wordpress/element'; import { RangeControl } from '@wordpress/components'; import { Stack } from '@wordpress/ui'; /** * Internal dependencies */ import { AdminContext } from '../../index'; import { useSearchVisibility } from '../index'; import ItemHelp from '../components/item-help'; import { toNumber } from '../../../lib/helper'; export default function Rulers() { const { editorOptions, setEditorOptions } = useContext( AdminContext ); const title = __( 'Vertical line position', 'custom-html-block-extension' ); const isVisible = useSearchVisibility( title ); if ( ! isVisible ) { return null; } const onChange = ( value: number | undefined ) => { const nextValue = value ?? 0; setEditorOptions( { ...editorOptions, rulers: 0 < nextValue ? [ toNumber( nextValue, 1, 80 ) ] : [], } ); }; return ( ); }