-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added creation of discussion
- Loading branch information
Showing
20 changed files
with
127 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/shared/components/Chat/ChatMessage/components/DiscussionLink/DiscussionLink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { FC } from "react"; | ||
import classNames from "classnames"; | ||
import styles from "../../ChatMessage.module.scss"; | ||
import { InternalLinkData, parseMessageLink } from "@/shared/utils"; | ||
|
||
interface DiscussionLinkProps { | ||
link: string; | ||
title: string; | ||
mentionTextClassName?: string; | ||
onInternalLinkClick?: (data: InternalLinkData) => void; | ||
} | ||
|
||
export const DiscussionLink: FC<DiscussionLinkProps> = (props) => { | ||
const { title, link, mentionTextClassName, onInternalLinkClick } = | ||
props; | ||
|
||
|
||
const handleInternalLinkClick = () => { | ||
if (onInternalLinkClick && link) { | ||
const data = parseMessageLink(link); | ||
data && onInternalLinkClick(data); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<span | ||
className={classNames(styles.mentionText, mentionTextClassName)} | ||
onClick={handleInternalLinkClick} | ||
> | ||
@{title} | ||
</span> | ||
</> | ||
); | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/shared/components/Chat/ChatMessage/components/DiscussionLink/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./DiscussionLink"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/shared/ui-kit/TextEditor/utils/insertDiscussionLink.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Transforms } from "slate"; | ||
import { ReactEditor } from "slate-react"; | ||
import { ElementType } from "../constants"; | ||
import { DiscussionLinkElement } from "../types"; | ||
|
||
export const insertDiscussionLink = (editor, title, link, onInternalLinkClick) => { | ||
const discussionLink: DiscussionLinkElement = { | ||
type: ElementType.DiscussionLink, | ||
title: `${title} `, | ||
link, | ||
onInternalLinkClick, | ||
children: [{ text: "" }], | ||
}; | ||
Transforms.insertNodes(editor, discussionLink); | ||
Transforms.move(editor); | ||
|
||
ReactEditor.focus(editor); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters