import classNames from 'clsx'; import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { changeComposeSpoilerness, changeComposeSpoilerText } from 'soapbox/actions/compose'; import AutosuggestInput, { IAutosuggestInput } from 'soapbox/components/autosuggest_input'; import { Divider, Stack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useCompose } from 'soapbox/hooks'; const messages = defineMessages({ title: { id: 'compose_form.spoiler_title', defaultMessage: 'Sensitive content' }, placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here (optional)' }, remove: { id: 'compose_form.spoiler_remove', defaultMessage: 'Remove sensitive' }, }); interface ISpoilerInput extends Pick { composeId: string extends 'default' ? never : string, } /** Text input for content warning in composer. */ const SpoilerInput = React.forwardRef(({ composeId, onSuggestionsFetchRequested, onSuggestionsClearRequested, onSuggestionSelected, }, ref) => { const intl = useIntl(); const dispatch = useAppDispatch(); const compose = useCompose(composeId); const handleChangeSpoilerText: React.ChangeEventHandler = (e) => { dispatch(changeComposeSpoilerText(composeId, e.target.value)); }; const handleRemove = () => { dispatch(changeComposeSpoilerness(composeId)); }; return ( {intl.formatMessage(messages.title)}
); }); export default SpoilerInput;