diff --git a/README.md b/README.md index 70409a7..14f7bb5 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ theme via Tailwind. - Code Highlighting - Tables - JSON + - Embeds - File Uploads - Animations - Conversation Pagination diff --git a/package-lock.json b/package-lock.json index b1fa9cc..3e0f408 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ "reablocks": "^8.4.3", "react-markdown": "^9.0.1", "reakeys": "^2.0.3", - "remark-gfm": "^4.0.0" + "remark-gfm": "^4.0.0", + "remark-youtube": "^1.3.2" }, "devDependencies": { "@storybook/addon-docs": "^8.2.6", @@ -14714,6 +14715,20 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark-youtube": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/remark-youtube/-/remark-youtube-1.3.2.tgz", + "integrity": "sha512-Rtre0gfwzdfcjBbjkFQlQKJs5J7e6xEFBrto/amYWX70Jjzh2EH4lUQnRGKkGAWuReo7XZMqJalv67ygRIN/wg==", + "dependencies": { + "unist-util-visit": "^5.0.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "remark-rehype": "^11.1.0" + } + }, "node_modules/requireindex": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", diff --git a/package.json b/package.json index 3efb775..cb48734 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "reablocks": "^8.4.3", "react-markdown": "^9.0.1", "reakeys": "^2.0.3", - "remark-gfm": "^4.0.0" + "remark-gfm": "^4.0.0", + "remark-youtube": "^1.3.2" }, "devDependencies": { "@storybook/addon-docs": "^8.2.6", diff --git a/src/SessionMessages/SessionMessage.tsx b/src/SessionMessages/SessionMessage.tsx index b8a6124..edfc9ed 100644 --- a/src/SessionMessages/SessionMessage.tsx +++ b/src/SessionMessages/SessionMessage.tsx @@ -8,6 +8,7 @@ import ThumbUpIcon from '@/assets/thumbs-up.svg?react'; import RefreshIcon from '@/assets/refresh.svg?react'; import { PluggableList } from 'react-markdown/lib'; import { Markdown } from '@/Markdown'; +import remarkYoutube from 'remark-youtube'; export interface SessionMessageProps { /** @@ -67,7 +68,7 @@ export const SessionMessage: FC = ({ onDownvote, onRefresh }) => { - const { theme, remarkPlugins = [remarkGfm] } = useContext(SessionsContext); + const { theme, remarkPlugins = [remarkGfm, remarkYoutube] } = useContext(SessionsContext); const handleCopy = (text: string) => { navigator.clipboard diff --git a/stories/Demos.stories.tsx b/stories/Demos.stories.tsx index 2156e7e..edd1cb5 100644 --- a/stories/Demos.stories.tsx +++ b/stories/Demos.stories.tsx @@ -165,6 +165,86 @@ export const CustomComponents = () => { ); }; +export const Embeds = () => { + const fakeSessionsWithEmbeds: Session[] = [ + { + id: '1', + title: 'Session with Embeds', + createdAt: new Date(), + updatedAt: new Date(), + conversations: [ + { + id: '1', + question: 'Can you show me a video about React?', + response: ` + ## Watch this video + + https://youtu.be/enTFE2c68FQ + + https://www.youtube.com/watch?v=enTFE2c68FQ + + These links showcase a video about React basics. You can click on either link to watch the video.`, + createdAt: new Date(), + updatedAt: new Date() + }, + { + id: '2', + question: 'Do you have another video recommendation?', + response: ` + Certainly! Here's another great video about web development: + + ## Check out this tutorial + + https://www.youtube.com/watch?v=dQw4w9WgXcQ + + This video covers some interesting web development concepts.`, + createdAt: new Date(), + updatedAt: new Date() + } + ] + } + ]; + + return ( +
+ alert('delete!')} + > + + + + {groups => + groups.map(({ heading, sessions }) => ( + + {sessions.map(s => )} + + )) + } + + +
+ + +
+
+
+ ); +}; + // export const NewSessionContent = () => { // return ( //