2022-10-04 23:17:15 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import type { CompositionTextAreaProps } from '../../components/CompositionTextArea';
|
|
|
|
import { CompositionTextArea } from '../../components/CompositionTextArea';
|
|
|
|
import type { LocalizerType } from '../../types/I18N';
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { useActions as useEmojiActions } from '../ducks/emojis';
|
|
|
|
import { useActions as useItemsActions } from '../ducks/items';
|
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
2022-12-21 03:25:10 +00:00
|
|
|
import { useComposerActions } from '../ducks/composer';
|
2022-10-04 23:17:15 +00:00
|
|
|
|
|
|
|
export type SmartCompositionTextAreaProps = Pick<
|
|
|
|
CompositionTextAreaProps,
|
|
|
|
| 'draftText'
|
|
|
|
| 'placeholder'
|
|
|
|
| 'onChange'
|
|
|
|
| 'onScroll'
|
|
|
|
| 'onSubmit'
|
|
|
|
| 'theme'
|
|
|
|
| 'maxLength'
|
|
|
|
| 'whenToShowRemainingCount'
|
|
|
|
| 'scrollerRef'
|
|
|
|
>;
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function SmartCompositionTextArea(
|
2022-10-04 23:17:15 +00:00
|
|
|
props: SmartCompositionTextAreaProps
|
2022-11-18 00:45:19 +00:00
|
|
|
): JSX.Element {
|
2022-10-04 23:17:15 +00:00
|
|
|
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
|
|
|
|
|
|
|
const { onUseEmoji: onPickEmoji } = useEmojiActions();
|
|
|
|
const { onSetSkinTone } = useItemsActions();
|
2022-12-21 03:25:10 +00:00
|
|
|
const { onTextTooLong } = useComposerActions();
|
2022-10-04 23:17:15 +00:00
|
|
|
|
|
|
|
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CompositionTextArea
|
|
|
|
{...props}
|
|
|
|
i18n={i18n}
|
|
|
|
onPickEmoji={onPickEmoji}
|
|
|
|
onSetSkinTone={onSetSkinTone}
|
|
|
|
getPreferredBadge={getPreferredBadge}
|
2022-12-21 03:25:10 +00:00
|
|
|
onTextTooLong={onTextTooLong}
|
2022-10-04 23:17:15 +00:00
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|