diff --git a/apps/sim/app/(landing)/components/features/components/features-preview.tsx b/apps/sim/app/(landing)/components/features/components/features-preview.tsx index e485396a7e..ae603009bc 100644 --- a/apps/sim/app/(landing)/components/features/components/features-preview.tsx +++ b/apps/sim/app/(landing)/components/features/components/features-preview.tsx @@ -2,8 +2,8 @@ import { type SVGProps, useEffect, useRef, useState } from 'react' import { AnimatePresence, motion, useInView } from 'framer-motion' -import ReactMarkdown, { type Components } from 'react-markdown' -import remarkGfm from 'remark-gfm' +import { Streamdown } from 'streamdown' +import 'streamdown/styles.css' import { ChevronDown } from '@/components/emcn' import { Database, File, Library, Table } from '@/components/emcn/icons' import { @@ -557,8 +557,8 @@ The team agreed to prioritize the new onboarding flow. Key decisions: Follow up with engineering on the timeline for the API v2 migration. Draft the proposal for the board meeting next week.` -const MD_COMPONENTS: Components = { - h1: ({ children }) => ( +const MD_COMPONENTS = { + h1: ({ children }: { children?: React.ReactNode }) => (
), - h2: ({ children }) => ( + h2: ({ children }: { children?: React.ReactNode }) => (
{children}
, + p: ({ children }: { children?: React.ReactNode }) => ( +{children}
+ ), } function MockFullFiles() { @@ -618,9 +624,9 @@ function MockFullFiles() { transition={{ duration: 0.4, delay: 0.5 }} >
+ inlineCode: ({ children }) => (
+
{children}
),
@@ -212,7 +211,7 @@ export default function ChangelogList({ initialEntries }: Props) {
}}
>
{cleanMarkdown(entry.content)}
-
- {children}
-
- )
- }
- return (
-
- {children}
-
- )
- },
+ inlineCode: ({ children }: { children?: React.ReactNode }) => (
+
+ {children}
+
+ ),
blockquote: ({ children }: React.HTMLAttributes@@ -215,9 +195,9 @@ const MarkdownRenderer = memo(function MarkdownRenderer({ return (), hr: () =>-) }) diff --git a/apps/sim/app/templates/[id]/template.tsx b/apps/sim/app/templates/[id]/template.tsx index 40ad9722a8..b311837cdd 100644 --- a/apps/sim/app/templates/[id]/template.tsx +++ b/apps/sim/app/templates/[id]/template.tsx @@ -14,7 +14,8 @@ import { User, } from 'lucide-react' import { useParams, useRouter, useSearchParams } from 'next/navigation' -import ReactMarkdown from 'react-markdown' +import { Streamdown } from 'streamdown' +import 'streamdown/styles.css' import { Breadcrumb, Button, @@ -875,7 +876,8 @@ export default function TemplateDetails({ isWorkspaceContext = false }: Template About this Workflow+ +{processedContent} - -)} @@ -1056,7 +1058,8 @@ export default function TemplateDetails({ isWorkspaceContext = false }: Template {/* Creator bio */} {template.creator.details?.about && (( +@@ -913,16 +915,16 @@ export default function TemplateDetails({ isWorkspaceContext = false }: Template ), li: ({ children }) =>
{children} , - code: ({ inline, children }: any) => - inline ? ( -- {children} -- ) : ( -- {children} -- ), + inlineCode: ({ children }) => ( ++ {children} ++ ), + code: ({ children }) => ( ++ {children} ++ ), a: ({ href, children }) => ( {template.details.about} --)} diff --git a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx index 2e77eae3eb..0c9867b85b 100644 --- a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx +++ b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx @@ -1,19 +1,22 @@ 'use client' import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef } from 'react' +import { code } from '@streamdown/code' import { useRouter } from 'next/navigation' -import type { Components, ExtraProps } from 'react-markdown' -import ReactMarkdown from 'react-markdown' import rehypeSlug from 'rehype-slug' import remarkBreaks from 'remark-breaks' -import remarkGfm from 'remark-gfm' +import { Streamdown } from 'streamdown' +import 'streamdown/styles.css' import { Checkbox } from '@/components/emcn' import { cn } from '@/lib/core/utils/cn' import { getFileExtension } from '@/lib/uploads/utils/file-utils' import { useAutoScroll } from '@/hooks/use-auto-scroll' -import { useStreamingReveal } from '@/hooks/use-streaming-reveal' import { DataTable } from './data-table' +interface HastNode { + position?: { start?: { offset?: number } } +} + type PreviewType = 'markdown' | 'html' | 'csv' | 'svg' | null const PREVIEWABLE_MIME_TYPES: Record( +@@ -1081,7 +1084,7 @@ export default function TemplateDetails({ isWorkspaceContext = false }: Template }} > {template.creator.details.about} -
= { @@ -72,8 +75,9 @@ export const PreviewPanel = memo(function PreviewPanel({ return null }) -const REMARK_PLUGINS = [remarkGfm, remarkBreaks] +const REMARK_PLUGINS = [remarkBreaks] const REHYPE_PLUGINS = [rehypeSlug] +const STREAMDOWN_PLUGINS = { code } /** * Carries the contentRef and toggle handler from MarkdownPreview down to the @@ -127,34 +131,11 @@ const STATIC_MARKDOWN_COMPONENTS = { {children} ), - code: ({ - className, - children, - node: _node, - ...props - }: React.HTMLAttributes & ExtraProps) => { - const isInline = !className?.includes('language-') - - if (isInline) { - return ( - - {children} -- ) - } - - return ( -- {children} -- ) - }, + inlineCode: ({ children }: { children?: React.ReactNode }) => ( ++ {children} ++ ), pre: ({ children }: { children?: React.ReactNode }) => <>{children}>, strong: ({ children }: { children?: React.ReactNode }) => ( {children} @@ -168,8 +149,13 @@ const STATIC_MARKDOWN_COMPONENTS = {
- {children} -
- ), - h1: ({ children }: any) => ( -
- {children}
-
- )
- }
-
- return (
-
- {children}
-
- )
- },
- a: ({ href, children }: any) => {
- const embedInfo = href ? getEmbedInfo(href) : null
- if (embedInfo) {
- return (
-
-
- {children}
-
-
- {embedInfo.type === 'iframe' && (
-
-
-
- )}
- {embedInfo.type === 'video' && (
-
- )}
- {embedInfo.type === 'audio' && (
-
- )}
-
-
- )
- }
- return (
-
- {children}
-
- )
- },
- strong: ({ children }: any) => (
-
- {children}
-
- ),
- em: ({ children }: any) => (
- {children}
- ),
- blockquote: ({ children }: any) => (
- - {children} -- ), - table: ({ children }: any) => ( -