/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { useContext } from '@wordpress/element'; import { RangeControl } from '@wordpress/components'; /** * Internal dependencies */ import { AdminContext } from '../../index'; import { useSearchVisibility } from '../index'; import { toNumber } from '../../../lib/helper'; export default function FastScrollSensitivity() { const { editorOptions, setEditorOptions } = useContext( AdminContext ); const title = __( 'Mouse wheel scroll speed (when pressing Alt key)', 'custom-html-block-extension' ); const isVisible = useSearchVisibility( title ); if ( ! isVisible ) { return null; } const onChange = ( value: number | undefined ) => { setEditorOptions( { ...editorOptions, fastScrollSensitivity: value ? toNumber( value, 1, 10 ) : 5, } ); }; return (