Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for emoji inside messages markdown #5384

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"rehype-highlight": "^6.0.0",
"rehype-katex": "^6.0.3",
"remark-directive": "^3.0.0",
"remark-emoji": "^5.0.1",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"remark-supersub": "^1.0.0",
Expand Down
18 changes: 10 additions & 8 deletions client/src/components/Chat/Messages/Content/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import supersub from 'remark-supersub';
import rehypeKatex from 'rehype-katex';
import remarkEmoji from 'remark-emoji';
import { useRecoilValue } from 'recoil';
import ReactMarkdown from 'react-markdown';
import rehypeHighlight from 'rehype-highlight';
import remarkDirective from 'remark-directive';
import type { Pluggable } from 'unified';
import { useToastContext, CodeBlockProvider, useCodeBlockContext } from '~/Providers';
import { Artifact, artifactPlugin } from '~/components/Artifacts/Artifact';
import { langSubset, preprocessLaTeX, handleDoubleClick } from '~/utils';
import { useToastContext, CodeBlockProvider, useCodeBlockContext } from '~/Providers';
import CodeBlock from '~/components/Messages/Content/CodeBlock';
import { useFileDownload } from '~/data-provider';
import useLocalize from '~/hooks/useLocalize';
Expand Down Expand Up @@ -185,13 +186,14 @@ const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentPr

const remarkPlugins: Pluggable[] = codeArtifacts
? [
supersub,
remarkGfm,
[remarkMath, { singleDollarTextMath: true }],
remarkDirective,
artifactPlugin,
]
: [supersub, remarkGfm, [remarkMath, { singleDollarTextMath: true }]];
supersub,
remarkEmoji,
remarkGfm,
[remarkMath, { singleDollarTextMath: true }],
remarkDirective,
artifactPlugin,
]
: [supersub, remarkEmoji, remarkGfm, [remarkMath, { singleDollarTextMath: true }]];

return (
<CodeBlockProvider>
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Chat/Messages/Content/MarkdownLite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import supersub from 'remark-supersub';
import remarkEmoji from 'remark-emoji';
import ReactMarkdown from 'react-markdown';
import rehypeHighlight from 'rehype-highlight';
import type { PluggableList } from 'unified';
Expand Down Expand Up @@ -30,6 +31,7 @@ const MarkdownLite = memo(
remarkPlugins={[
/** @ts-ignore */
supersub,
remarkEmoji,
remarkGfm,
[remarkMath, { singleDollarTextMath: true }],
]}
Expand Down
160 changes: 159 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading