From 77f5551051e23ef1594aae172c6cdf55e5764628 Mon Sep 17 00:00:00 2001 From: Pavel Meyer Date: Wed, 11 Dec 2024 11:06:46 +0300 Subject: [PATCH] CW-mention-streams Added creation of discussion --- .../ChatComponent/ChatComponent.tsx | 1 + .../components/ChatInput/ChatInput.tsx | 5 ++- .../DiscussionLink/DiscussionLink.tsx | 36 +++++++++++++++++++ .../components/DiscussionLink/index.ts | 1 + .../Chat/ChatMessage/components/index.ts | 1 + .../utils/getTextFromTextEditorString.tsx | 11 +++++- .../ui-kit/TextEditor/BaseTextEditor.tsx | 9 +++-- .../TextEditor/components/Element/Element.tsx | 21 ++++++++++- .../MentionDropdown/MentionDropdown.tsx | 9 ++--- .../TextEditor/constants/elementType.ts | 2 ++ .../ui-kit/TextEditor/hofs/withMentions.ts | 4 +-- src/shared/ui-kit/TextEditor/types.ts | 11 +++++- .../utils/checkIsTextEditorValueEmpty.ts | 2 +- .../utils/countTextEditorEmojiElements.ts | 2 +- src/shared/ui-kit/TextEditor/utils/index.ts | 1 + .../TextEditor/utils/insertDiscussionLink.ts | 18 ++++++++++ .../TextEditor/utils/isRtlWithNoMentions.ts | 2 +- .../removeTextEditorEmptyEndLinesValues.ts | 1 + .../utils/serializeTextEditorValue.ts | 4 +++ src/store/states/common/reducer.ts | 4 +-- 20 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 src/shared/components/Chat/ChatMessage/components/DiscussionLink/DiscussionLink.tsx create mode 100644 src/shared/components/Chat/ChatMessage/components/DiscussionLink/index.ts create mode 100644 src/shared/ui-kit/TextEditor/utils/insertDiscussionLink.ts diff --git a/src/pages/common/components/ChatComponent/ChatComponent.tsx b/src/pages/common/components/ChatComponent/ChatComponent.tsx index 11ae027f83..d48bd19438 100644 --- a/src/pages/common/components/ChatComponent/ChatComponent.tsx +++ b/src/pages/common/components/ChatComponent/ChatComponent.tsx @@ -941,6 +941,7 @@ export default function ChatComponent({ user={user} commonId={commonId} circleVisibility={discussion?.circleVisibility} + onInternalLinkClick={onInternalLinkClick} /> diff --git a/src/pages/common/components/ChatComponent/components/ChatInput/ChatInput.tsx b/src/pages/common/components/ChatComponent/components/ChatInput/ChatInput.tsx index e0311c13eb..69dca3c56f 100644 --- a/src/pages/common/components/ChatComponent/components/ChatInput/ChatInput.tsx +++ b/src/pages/common/components/ChatComponent/components/ChatInput/ChatInput.tsx @@ -18,7 +18,7 @@ import { } from "@/shared/ui-kit"; import { BaseTextEditorHandles } from "@/shared/ui-kit/TextEditor/BaseTextEditor"; import { EmojiCount } from "@/shared/ui-kit/TextEditor/utils"; -import { emptyFunction } from "@/shared/utils"; +import { emptyFunction, InternalLinkData } from "@/shared/utils"; import styles from "./ChatInput.module.scss"; interface ChatInputProps { @@ -44,6 +44,7 @@ interface ChatInputProps { circleVisibility?: string[]; user?: User | null; commonId?: string; + onInternalLinkClick?: (data: InternalLinkData) => void; } export const ChatInput = React.memo( @@ -70,6 +71,7 @@ export const ChatInput = React.memo( circleVisibility, user, commonId, + onInternalLinkClick, } = props; if (shouldHideChatInput) { @@ -131,6 +133,7 @@ export const ChatInput = React.memo( circleVisibility={circleVisibility} user={user} commonId={commonId} + onInternalLinkClick={onInternalLinkClick} />