refactor: remove Markdown and MarkdownWeb components

- Deleted Markdown and MarkdownWeb components to streamline the codebase.
- This change eliminates unused components related to markdown rendering, improving maintainability.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2025-05-29 22:29:30 +08:00
parent f7faf78eb5
commit 4e4e09919c
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
2 changed files with 0 additions and 108 deletions

View File

@ -1,41 +0,0 @@
import type { FC } from "react"
import { useRef } from "react"
import { Linking } from "react-native"
import type { WebView } from "react-native-webview"
import MarkdownWeb from "./MarkdownWeb"
export const Markdown: FC<{
value: string
style?: React.CSSProperties
className?: string
webViewProps?: import("expo/dom").DOMProps
}> = ({ value, style, className, webViewProps }) => {
const ref = useRef<WebView>(null)
return (
<MarkdownWeb
value={value}
ref={ref}
style={style}
className={className}
dom={{
...webViewProps,
onMessage: (event) => {
const { type, url } = JSON.parse(event.nativeEvent.data)
if (type === "openLinkInModal") {
Linking.openURL(url)
}
},
injectedJavaScriptBeforeContentLoaded: `window.openLinkInModal = (url) => {
window.ReactNativeWebView.postMessage(JSON.stringify({
type: "openLinkInModal",
url,
}))
}`,
}}
/>
)
}

View File

@ -1,67 +0,0 @@
"use dom"
import "@/src/global.css"
import { parseMarkdown } from "@follow/components/utils/parse-markdown.tsx"
import { cn } from "@follow/utils"
import { useMemo } from "react"
import { useDarkMode } from "usehooks-ts"
import { useCSSInjection } from "@/src/theme/web"
declare const window: {
openLinkInModal: (url: string) => void
}
/**
* @internal
*/
const MarkdownWeb: WebComponent<{
value: string
style?: React.CSSProperties
className?: string
}> = ({ value, style, className }) => {
useCSSInjection()
const { isDarkMode } = useDarkMode()
return (
<div
className={cn("text-text prose min-w-0", isDarkMode ? "prose-invert" : "prose", className)}
style={style}
>
<style
dangerouslySetInnerHTML={{
__html: `
:root {
overscroll-behavior: none;
}
body, html {
overflow-y: hidden;
}
`,
}}
/>
{useMemo(
() =>
parseMarkdown(value, {
components: {
a: ({ children, ref, ...props }) => (
<a
onClick={(e) => {
if (!props.href) return
e.preventDefault()
window.openLinkInModal(props.href)
}}
{...props}
>
{children}
</a>
),
},
}).content,
[value],
)}
</div>
)
}
export default MarkdownWeb