2022-10-04 23:17:15 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
2022-10-04 23:17:15 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import type { CompositionTextAreaProps } from '../../components/CompositionTextArea';
|
|
|
|
import { CompositionTextArea } from '../../components/CompositionTextArea';
|
2023-05-10 00:40:19 +00:00
|
|
|
import { getIntl, getPlatform } from '../selectors/user';
|
2024-03-12 16:29:31 +00:00
|
|
|
import { useEmojisActions as useEmojiActions } from '../ducks/emojis';
|
2023-08-09 00:53:06 +00:00
|
|
|
import { useItemsActions } from '../ducks/items';
|
2022-10-04 23:17:15 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
2022-12-21 03:25:10 +00:00
|
|
|
import { useComposerActions } from '../ducks/composer';
|
2023-04-18 01:16:41 +00:00
|
|
|
import { getTextFormattingEnabled } from '../selectors/items';
|
2022-10-04 23:17:15 +00:00
|
|
|
|
|
|
|
export type SmartCompositionTextAreaProps = Pick<
|
|
|
|
CompositionTextAreaProps,
|
2023-04-14 18:16:28 +00:00
|
|
|
| 'bodyRanges'
|
2022-10-04 23:17:15 +00:00
|
|
|
| 'draftText'
|
|
|
|
| 'placeholder'
|
|
|
|
| 'onChange'
|
|
|
|
| 'onScroll'
|
|
|
|
| 'onSubmit'
|
|
|
|
| 'theme'
|
|
|
|
| 'maxLength'
|
|
|
|
| 'whenToShowRemainingCount'
|
|
|
|
| 'scrollerRef'
|
|
|
|
>;
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartCompositionTextArea = memo(function SmartCompositionTextArea(
|
2022-10-04 23:17:15 +00:00
|
|
|
props: SmartCompositionTextAreaProps
|
2024-03-13 20:44:13 +00:00
|
|
|
) {
|
2023-05-10 00:40:19 +00:00
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const platform = useSelector(getPlatform);
|
2022-10-04 23:17:15 +00:00
|
|
|
|
|
|
|
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);
|
2023-05-10 00:40:19 +00:00
|
|
|
const isFormattingEnabled = useSelector(getTextFormattingEnabled);
|
2022-10-04 23:17:15 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CompositionTextArea
|
|
|
|
{...props}
|
2023-05-10 00:40:19 +00:00
|
|
|
getPreferredBadge={getPreferredBadge}
|
2022-10-04 23:17:15 +00:00
|
|
|
i18n={i18n}
|
2023-04-14 18:16:28 +00:00
|
|
|
isFormattingEnabled={isFormattingEnabled}
|
2022-10-04 23:17:15 +00:00
|
|
|
onPickEmoji={onPickEmoji}
|
|
|
|
onSetSkinTone={onSetSkinTone}
|
2022-12-21 03:25:10 +00:00
|
|
|
onTextTooLong={onTextTooLong}
|
2023-05-10 00:40:19 +00:00
|
|
|
platform={platform}
|
2022-10-04 23:17:15 +00:00
|
|
|
/>
|
|
|
|
);
|
2024-03-13 20:44:13 +00:00
|
|
|
});
|