Allow copy/paste of formatting and mentions

This commit is contained in:
Scott Nonnenberg 2023-05-09 17:40:19 -07:00 committed by GitHub
parent 320ac044a8
commit b4caf67bf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 1003 additions and 446 deletions

View file

@ -24,6 +24,7 @@ import { SendStoryModal } from './SendStoryModal';
import { MediaEditor } from './MediaEditor';
import { TextStoryCreator } from './TextStoryCreator';
import type { SmartCompositionTextAreaProps } from '../state/smart/CompositionTextArea';
import type { DraftBodyRanges } from '../types/BodyRange';
export type PropsType = {
debouncedMaybeGrabLinkPreview: (
@ -38,7 +39,8 @@ export type PropsType = {
onSend: (
listIds: Array<UUIDStringType>,
conversationIds: Array<string>,
attachment: AttachmentType
attachment: AttachmentType,
bodyRanges: DraftBodyRanges | undefined
) => unknown;
imageToBlurHash: typeof imageToBlurHash;
processAttachment: (
@ -123,6 +125,7 @@ export function StoryCreator({
>();
const [isReadyToSend, setIsReadyToSend] = useState(false);
const [attachmentUrl, setAttachmentUrl] = useState<string | undefined>();
const [bodyRanges, setBodyRanges] = useState<DraftBodyRanges | undefined>();
useEffect(() => {
let url: string | undefined;
@ -192,7 +195,7 @@ export function StoryCreator({
onRepliesNReactionsChanged={onRepliesNReactionsChanged}
onSelectedStoryList={onSelectedStoryList}
onSend={(listIds, groupIds) => {
onSend(listIds, groupIds, draftAttachment);
onSend(listIds, groupIds, draftAttachment, bodyRanges);
setDraftAttachment(undefined);
}}
onViewersUpdated={onViewersUpdated}
@ -219,7 +222,13 @@ export function StoryCreator({
supportsCaption
renderCompositionTextArea={renderCompositionTextArea}
imageToBlurHash={imageToBlurHash}
onDone={({ contentType, data, blurHash, caption }) => {
onDone={({
contentType,
data,
blurHash,
caption,
captionBodyRanges,
}) => {
setDraftAttachment({
...draftAttachment,
contentType,
@ -228,6 +237,7 @@ export function StoryCreator({
blurHash,
caption,
});
setBodyRanges(captionBodyRanges);
setIsReadyToSend(true);
}}
recentStickers={recentStickers}