refactor(entry-content): replace legacy entry content with new preview component
- Removed the legacy EntryContent component and replaced it with EntryContentForPreview in EntryModalPreview. - Updated AIChatContextBar to use a responsive max-width style. - These changes streamline the entry content rendering process and improve the overall code structure. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { usePrefetchEntryDetail } from "@follow/store/entry/hooks"
|
||||
|
||||
import { Paper } from "~/components/ui/paper"
|
||||
import { EntryContent as EntryContentLegacy } from "~/modules/entry-content/EntryContent.legacy"
|
||||
import { EntryContentForPreview } from "~/modules/entry-content/EntryContentForPreview"
|
||||
|
||||
export const EntryModalPreview = ({ entryId }: { entryId: string }) => {
|
||||
const { isPending } = usePrefetchEntryDetail(entryId)
|
||||
@@ -11,7 +11,7 @@ export const EntryModalPreview = ({ entryId }: { entryId: string }) => {
|
||||
{isPending ? (
|
||||
<PeekModalSkeleton />
|
||||
) : (
|
||||
<EntryContentLegacy
|
||||
<EntryContentForPreview
|
||||
className="h-auto [&_#entry-action-header-bar]:!bg-transparent"
|
||||
entryId={entryId}
|
||||
/>
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ export const AIChatContextBar: Component = memo(({ className }) => {
|
||||
? `combined-${item.viewBlock?.id}-${item.feedBlock?.id}-${item.unreadOnlyBlock?.id}`
|
||||
: item.block.id
|
||||
}
|
||||
className="max-w-[240px] shrink-0"
|
||||
className="max-w-[min(240px,100%)] shrink-0"
|
||||
>
|
||||
{renderBlock(item)}
|
||||
</div>
|
||||
|
||||
@@ -1,391 +0,0 @@
|
||||
import { useGlobalFocusableScopeSelector } from "@follow/components/common/Focusable/hooks.js"
|
||||
import { MemoedDangerousHTMLStyle } from "@follow/components/common/MemoedDangerousHTMLStyle.js"
|
||||
import { Spring } from "@follow/components/constants/spring.js"
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useTitle } from "@follow/hooks"
|
||||
import { useEntry } from "@follow/store/entry/hooks"
|
||||
import { useFeedById } from "@follow/store/feed/hooks"
|
||||
import type { FeedModel } from "@follow/store/feed/types"
|
||||
import { useIsInbox } from "@follow/store/inbox/hooks"
|
||||
import { thenable } from "@follow/utils"
|
||||
import { nextFrame, stopPropagation } from "@follow/utils/dom"
|
||||
import { EventBus } from "@follow/utils/event-bus"
|
||||
import { clsx, cn } from "@follow/utils/utils"
|
||||
import { ErrorBoundary } from "@sentry/react"
|
||||
import type { JSAnimation, Variants } from "motion/react"
|
||||
import { AnimatePresence, m, useAnimationControls } from "motion/react"
|
||||
import * as React from "react"
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { useEntryIsInReadability } from "~/atoms/readability"
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { Focusable, FocusablePresets } from "~/components/common/Focusable"
|
||||
import { ShadowDOM } from "~/components/common/ShadowDOM"
|
||||
import type { TocRef } from "~/components/ui/markdown/components/Toc"
|
||||
import { useInPeekModal } from "~/components/ui/modal/inspire/InPeekModal"
|
||||
import { HotkeyScope } from "~/constants"
|
||||
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
|
||||
import { useRenderStyle } from "~/hooks/biz/useRenderStyle"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { useFeedSafeUrl } from "~/hooks/common/useFeedSafeUrl"
|
||||
import { COMMAND_ID } from "~/modules/command/commands/id"
|
||||
import { EntryContentHTMLRenderer } from "~/modules/renderer/html"
|
||||
import { WrappedElementProvider } from "~/providers/wrapped-element-provider"
|
||||
|
||||
import { AISummary } from "./components/AISummary"
|
||||
import { ApplyEntryActions } from "./components/ApplyEntryActions"
|
||||
import { ContainerToc } from "./components/entry-content/accessories/ContainerToc"
|
||||
import { EntryCommandShortcutRegister } from "./components/entry-content/EntryCommandShortcutRegister"
|
||||
import { EntryContentFallback } from "./components/entry-content/EntryContentFallback"
|
||||
import { EntryContentLoading } from "./components/entry-content/EntryContentLoading"
|
||||
import { EntryNoContent } from "./components/entry-content/EntryNoContent"
|
||||
import { EntryRenderError } from "./components/entry-content/EntryRenderError"
|
||||
import { EntryScrollingAndNavigationHandler } from "./components/entry-content/EntryScrollingAndNavigationHandler.js"
|
||||
import { EntryTitleMetaHandler } from "./components/entry-content/EntryTitleMetaHandler"
|
||||
import { ReadabilityNotice } from "./components/entry-content/ReadabilityNotice"
|
||||
import type { EntryContentProps } from "./components/entry-content/types"
|
||||
import { EntryHeader } from "./components/entry-header"
|
||||
import { EntryAttachments } from "./components/EntryAttachments"
|
||||
import { EntryTitle } from "./components/EntryTitle"
|
||||
import { SourceContentPanel } from "./components/SourceContentView"
|
||||
import { NAVIGATION_HINTS_ICONS, NAVIGATION_HINTS_TEXT } from "./constants/navigation-hints"
|
||||
import { useEntryContent, useEntryMediaInfo } from "./hooks"
|
||||
import { useEntryNavigationHints } from "./hooks/useEntryNavigationHints"
|
||||
|
||||
const pageMotionVariants = {
|
||||
initial: { opacity: 0, y: 25 },
|
||||
animate: { opacity: 1, y: 0 },
|
||||
exit: { opacity: 0, y: 25, transition: { duration: 0 } },
|
||||
} satisfies Variants
|
||||
|
||||
const EntryContentImpl: Component<EntryContentProps> = ({
|
||||
entryId,
|
||||
noMedia,
|
||||
className,
|
||||
compact,
|
||||
classNames,
|
||||
}) => {
|
||||
const entry = useEntry(entryId, (state) => {
|
||||
const { feedId, inboxHandle } = state
|
||||
const { title, url } = state
|
||||
|
||||
return { feedId, inboxId: inboxHandle, title, url }
|
||||
})
|
||||
if (!entry) throw thenable
|
||||
|
||||
useTitle(entry?.title)
|
||||
|
||||
const feed = useFeedById(entry?.feedId)
|
||||
|
||||
const isInbox = useIsInbox(entry?.inboxId)
|
||||
const isInReadabilityMode = useEntryIsInReadability(entryId)
|
||||
|
||||
const { error, content, isPending } = useEntryContent(entryId)
|
||||
|
||||
const view = useRouteParamsSelector((route) => route.view)
|
||||
const scrollerRef = useRef<HTMLDivElement | null>(null)
|
||||
const safeUrl = useFeedSafeUrl(entryId)
|
||||
const customCSS = useUISettingKey("customCSS")
|
||||
|
||||
const isInPeekModal = useInPeekModal()
|
||||
|
||||
const [panelPortalElement, setPanelPortalElement] = useState<HTMLDivElement | null>(null)
|
||||
|
||||
const animationController = useAnimationControls()
|
||||
const prevEntryId = useRef<string | undefined>(undefined)
|
||||
const scrollAnimationRef = useRef<JSAnimation<any> | null>(null)
|
||||
useEffect(() => {
|
||||
if (prevEntryId.current !== entryId) {
|
||||
scrollAnimationRef.current?.stop()
|
||||
nextFrame(() => {
|
||||
scrollerRef.current?.scrollTo({ top: 0 })
|
||||
})
|
||||
animationController.start(pageMotionVariants.exit).then(() => {
|
||||
animationController.start(pageMotionVariants.animate)
|
||||
})
|
||||
prevEntryId.current = entryId
|
||||
}
|
||||
}, [animationController, entryId])
|
||||
|
||||
const isInHasTimelineView = ![
|
||||
FeedViewType.Pictures,
|
||||
FeedViewType.SocialMedia,
|
||||
FeedViewType.Videos,
|
||||
].includes(view)
|
||||
|
||||
return (
|
||||
<>
|
||||
<EntryCommandShortcutRegister entryId={entryId} view={view} />
|
||||
{!isInPeekModal && (
|
||||
<EntryHeader
|
||||
entryId={entryId}
|
||||
className={cn("h-[55px] shrink-0 px-3 @container", classNames?.header)}
|
||||
compact={compact}
|
||||
/>
|
||||
)}
|
||||
<div className="w-full" ref={setPanelPortalElement} />
|
||||
|
||||
<Focusable
|
||||
scope={HotkeyScope.EntryRender}
|
||||
className="relative flex size-full flex-col overflow-hidden @container print:size-auto print:overflow-visible"
|
||||
>
|
||||
<RootPortal to={panelPortalElement}>
|
||||
<EntryScrollingAndNavigationHandler
|
||||
scrollAnimationRef={scrollAnimationRef}
|
||||
scrollerRef={scrollerRef}
|
||||
/>
|
||||
</RootPortal>
|
||||
|
||||
<EntryScrollArea className={className} scrollerRef={scrollerRef}>
|
||||
<EntryNavigationHandler entryId={entryId} />
|
||||
{/* Indicator for the entry */}
|
||||
<m.div
|
||||
initial={pageMotionVariants.initial}
|
||||
animate={animationController}
|
||||
transition={Spring.presets.bouncy}
|
||||
className="select-text"
|
||||
>
|
||||
{isInHasTimelineView && !isInPeekModal && (
|
||||
<>
|
||||
<div className="absolute inset-y-0 left-0 flex w-12 items-center justify-center opacity-0 duration-200 hover:opacity-100">
|
||||
<MotionButtonBase
|
||||
// -12: Visual center point
|
||||
className="absolute left-0 shrink-0 !-translate-y-12 cursor-pointer"
|
||||
onClick={() => {
|
||||
EventBus.dispatch(COMMAND_ID.timeline.switchToPrevious)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-left-small-sharp size-16 text-text-secondary" />
|
||||
</MotionButtonBase>
|
||||
</div>
|
||||
|
||||
<div className="absolute inset-y-0 right-0 flex w-12 items-center justify-center opacity-0 duration-200 hover:opacity-100">
|
||||
<MotionButtonBase
|
||||
className="absolute right-0 shrink-0 !-translate-y-12 cursor-pointer"
|
||||
onClick={() => {
|
||||
EventBus.dispatch(COMMAND_ID.timeline.switchToNext)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-right-small-sharp size-16 text-text-secondary" />
|
||||
</MotionButtonBase>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<article
|
||||
data-testid="entry-render"
|
||||
onContextMenu={stopPropagation}
|
||||
className={clsx(
|
||||
"relative m-auto min-w-0",
|
||||
isInPeekModal
|
||||
? "max-w-full"
|
||||
: "max-w-[550px] @7xl:max-w-[80ch] @[950px]:max-w-[70ch]",
|
||||
)}
|
||||
>
|
||||
<EntryTitle entryId={entryId} compact={compact} noRecentReader />
|
||||
|
||||
<WrappedElementProvider boundingDetection>
|
||||
<div className="mx-auto mb-32 mt-8 max-w-full cursor-auto text-[0.94rem]">
|
||||
<EntryTitleMetaHandler entryId={entryId} />
|
||||
<AISummary entryId={entryId} />
|
||||
<ErrorBoundary fallback={EntryRenderError}>
|
||||
<ReadabilityNotice entryId={entryId} />
|
||||
<ShadowDOM injectHostStyles={!isInbox}>
|
||||
{!!customCSS && (
|
||||
<MemoedDangerousHTMLStyle>{customCSS}</MemoedDangerousHTMLStyle>
|
||||
)}
|
||||
|
||||
<Renderer
|
||||
entryId={entryId}
|
||||
view={view}
|
||||
feedId={feed?.id || ""}
|
||||
noMedia={noMedia}
|
||||
content={content}
|
||||
/>
|
||||
</ShadowDOM>
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
</WrappedElementProvider>
|
||||
|
||||
<ApplyEntryActions entryId={entryId} key={entryId} />
|
||||
|
||||
{!content && !isInReadabilityMode && (
|
||||
<div className="center mt-16 min-w-0">
|
||||
{isPending ? (
|
||||
<EntryContentLoading
|
||||
icon={!isInbox ? (feed as FeedModel)?.siteUrl : undefined}
|
||||
/>
|
||||
) : error ? (
|
||||
<div className="center mt-36 flex flex-col items-center gap-3">
|
||||
<i className="i-mgc-warning-cute-re text-4xl text-red" />
|
||||
<span className="text-balance text-center text-sm">Network Error</span>
|
||||
<pre className="mt-6 w-full overflow-auto whitespace-pre-wrap break-all">
|
||||
{error.message}
|
||||
</pre>
|
||||
</div>
|
||||
) : (
|
||||
<EntryNoContent id={entryId} url={entry.url ?? ""} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<EntryAttachments entryId={entryId} />
|
||||
</article>
|
||||
</m.div>
|
||||
</EntryScrollArea>
|
||||
<SourceContentPanel src={safeUrl ?? "#"} />
|
||||
</Focusable>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export const EntryContent: Component<EntryContentProps> = memo((props) => {
|
||||
return (
|
||||
<EntryContentFallback entryId={props.entryId}>
|
||||
<EntryContentImpl {...props} />
|
||||
</EntryContentFallback>
|
||||
)
|
||||
})
|
||||
|
||||
const EntryScrollArea: Component<{
|
||||
scrollerRef: React.RefObject<HTMLDivElement | null>
|
||||
}> = ({ children, className, scrollerRef }) => {
|
||||
const isInPeekModal = useInPeekModal()
|
||||
|
||||
if (isInPeekModal) {
|
||||
return <div className="p-5">{children}</div>
|
||||
}
|
||||
return (
|
||||
<ScrollArea.ScrollArea
|
||||
focusable
|
||||
mask={false}
|
||||
viewportProps={{
|
||||
onWheel: stopPropagation,
|
||||
}}
|
||||
rootClassName={cn(
|
||||
"h-0 min-w-0 grow overflow-y-auto print:h-auto print:overflow-visible",
|
||||
className,
|
||||
)}
|
||||
scrollbarClassName="mr-[1.5px] print:hidden"
|
||||
viewportClassName="p-5"
|
||||
ref={scrollerRef}
|
||||
>
|
||||
{children}
|
||||
</ScrollArea.ScrollArea>
|
||||
)
|
||||
}
|
||||
|
||||
const Renderer: React.FC<{
|
||||
entryId: string
|
||||
view: FeedViewType
|
||||
feedId: string
|
||||
noMedia?: boolean
|
||||
content?: Nullable<string>
|
||||
}> = React.memo(({ entryId, view, feedId, noMedia = false, content = "" }) => {
|
||||
const mediaInfo = useEntryMediaInfo(entryId)
|
||||
|
||||
const readerRenderInlineStyle = useUISettingKey("readerRenderInlineStyle")
|
||||
|
||||
const stableRenderStyle = useRenderStyle()
|
||||
const isInPeekModal = useInPeekModal()
|
||||
|
||||
const tocRef = useRef<TocRef | null>(null)
|
||||
const contentAccessories = useMemo(
|
||||
() => (isInPeekModal ? undefined : <ContainerToc ref={tocRef} />),
|
||||
[isInPeekModal],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (tocRef) {
|
||||
tocRef.current?.refreshItems()
|
||||
}
|
||||
}, [content, tocRef])
|
||||
return (
|
||||
<EntryContentHTMLRenderer
|
||||
view={view}
|
||||
feedId={feedId}
|
||||
entryId={entryId}
|
||||
mediaInfo={mediaInfo}
|
||||
noMedia={noMedia}
|
||||
accessory={contentAccessories}
|
||||
as="article"
|
||||
className="prose !max-w-full hyphens-auto dark:prose-invert prose-h1:text-[1.6em] prose-h1:font-bold"
|
||||
style={stableRenderStyle}
|
||||
renderInlineStyle={readerRenderInlineStyle}
|
||||
>
|
||||
{content}
|
||||
</EntryContentHTMLRenderer>
|
||||
)
|
||||
})
|
||||
|
||||
// EntryNavigationHandler for legacy version (without wheel gesture)
|
||||
const EntryNavigationHandler = ({ entryId }: { entryId: string }) => {
|
||||
const navigate = useNavigateEntry()
|
||||
const when = useGlobalFocusableScopeSelector(FocusablePresets.isEntryRender)
|
||||
|
||||
// Handle close gesture
|
||||
const handleCloseEntry = React.useCallback(() => {
|
||||
navigate({ entryId: null })
|
||||
}, [navigate])
|
||||
|
||||
// Navigation hints for entry content (legacy version without wheel gesture)
|
||||
const { showFirstEntryHint, showScrollHint, showBottomHint } = useEntryNavigationHints({
|
||||
enabled: when && !!entryId,
|
||||
entryId,
|
||||
})
|
||||
|
||||
// Render hint button with different states
|
||||
const renderHintButton = (icon: string, text: string, position: "top" | "bottom" = "top") => (
|
||||
<m.div
|
||||
initial={{ y: position === "top" ? -50 : 50, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
exit={{ y: position === "top" ? -50 : 50, opacity: 0 }}
|
||||
transition={Spring.presets.smooth}
|
||||
className={clsx(
|
||||
"pointer-events-none absolute z-40 flex justify-center",
|
||||
position === "top" ? "inset-x-0 top-4" : "inset-x-0 bottom-4",
|
||||
)}
|
||||
>
|
||||
<button
|
||||
onClick={handleCloseEntry}
|
||||
type="button"
|
||||
className={clsx(
|
||||
"group pointer-events-auto flex items-center gap-2",
|
||||
"rounded-full border px-3.5 py-2",
|
||||
"border-border/40 bg-material-ultra-thin/70 shadow-[0_1px_2px_rgba(0,0,0,0.06),0_8px_24px_rgba(0,0,0,0.08)]",
|
||||
"hover:border-border/60 hover:bg-material-thin/70 active:scale-[0.98]",
|
||||
"backdrop-blur-background",
|
||||
)}
|
||||
>
|
||||
<i className={clsx(icon, "mr-1 size-5 text-text/90")} />
|
||||
<span className="text-left text-[13px] font-medium text-text/90">{text}</span>
|
||||
</button>
|
||||
</m.div>
|
||||
)
|
||||
|
||||
return (
|
||||
<AnimatePresence mode="popLayout">
|
||||
{/* First entry hint */}
|
||||
{showFirstEntryHint &&
|
||||
renderHintButton(
|
||||
NAVIGATION_HINTS_ICONS.ARROW_UP,
|
||||
NAVIGATION_HINTS_TEXT.SCROLL_UP_EXIT,
|
||||
"top",
|
||||
)}
|
||||
|
||||
{/* Scroll threshold hint */}
|
||||
{showScrollHint &&
|
||||
renderHintButton(
|
||||
NAVIGATION_HINTS_ICONS.ARROW_UP,
|
||||
NAVIGATION_HINTS_TEXT.SCROLL_UP_EXIT,
|
||||
"top",
|
||||
)}
|
||||
|
||||
{/* Bottom hint */}
|
||||
{showBottomHint &&
|
||||
renderHintButton(NAVIGATION_HINTS_ICONS.CLOSE, NAVIGATION_HINTS_TEXT.ESC_EXIT, "bottom")}
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useEntry } from "@follow/store/entry/hooks"
|
||||
import { useFeedById } from "@follow/store/feed/hooks"
|
||||
import type { FeedModel } from "@follow/store/feed/types"
|
||||
import { useIsInbox } from "@follow/store/inbox/hooks"
|
||||
import { thenable } from "@follow/utils"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { clsx } from "@follow/utils/utils"
|
||||
import { ErrorBoundary } from "@sentry/react"
|
||||
import * as React from "react"
|
||||
import { memo } from "react"
|
||||
|
||||
import { useEntryIsInReadability } from "~/atoms/readability"
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { ShadowDOM } from "~/components/common/ShadowDOM"
|
||||
import { useRenderStyle } from "~/hooks/biz/useRenderStyle"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { EntryContentHTMLRenderer } from "~/modules/renderer/html"
|
||||
import { WrappedElementProvider } from "~/providers/wrapped-element-provider"
|
||||
|
||||
import { EntryContentFallback } from "./components/entry-content/EntryContentFallback"
|
||||
import { EntryContentLoading } from "./components/entry-content/EntryContentLoading"
|
||||
import { EntryNoContent } from "./components/entry-content/EntryNoContent"
|
||||
import { EntryRenderError } from "./components/entry-content/EntryRenderError"
|
||||
import type { EntryContentProps } from "./components/entry-content/types"
|
||||
import { EntryAttachments } from "./components/EntryAttachments"
|
||||
import { EntryTitle } from "./components/EntryTitle"
|
||||
import { useEntryContent, useEntryMediaInfo } from "./hooks"
|
||||
|
||||
const EntryContentImpl: Component<EntryContentProps> = ({
|
||||
entryId,
|
||||
noMedia,
|
||||
|
||||
compact,
|
||||
}) => {
|
||||
const entry = useEntry(entryId, (state) => {
|
||||
const { feedId, inboxHandle } = state
|
||||
const { title, url } = state
|
||||
|
||||
return { feedId, inboxId: inboxHandle, title, url }
|
||||
})
|
||||
if (!entry) throw thenable
|
||||
|
||||
const feed = useFeedById(entry?.feedId)
|
||||
|
||||
const isInbox = useIsInbox(entry?.inboxId)
|
||||
const isInReadabilityMode = useEntryIsInReadability(entryId)
|
||||
|
||||
const { error, content, isPending } = useEntryContent(entryId)
|
||||
|
||||
const view = useRouteParamsSelector((route) => route.view)
|
||||
|
||||
return (
|
||||
<div className="relative flex size-full flex-col overflow-hidden @container print:size-auto print:overflow-visible">
|
||||
<article
|
||||
onContextMenu={stopPropagation}
|
||||
className={clsx("relative m-auto min-w-0 select-text", "w-full max-w-full")}
|
||||
>
|
||||
<EntryTitle entryId={entryId} compact={compact} noRecentReader />
|
||||
|
||||
<WrappedElementProvider boundingDetection>
|
||||
<div className="mx-auto my-8 max-w-full cursor-auto">
|
||||
<ErrorBoundary fallback={EntryRenderError}>
|
||||
<ShadowDOM injectHostStyles={!isInbox}>
|
||||
<Renderer
|
||||
entryId={entryId}
|
||||
view={view}
|
||||
feedId={feed?.id || ""}
|
||||
noMedia={noMedia}
|
||||
content={content}
|
||||
/>
|
||||
</ShadowDOM>
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
</WrappedElementProvider>
|
||||
|
||||
{!content && !isInReadabilityMode && (
|
||||
<div className="center mt-16 min-w-0">
|
||||
{isPending ? (
|
||||
<EntryContentLoading icon={!isInbox ? (feed as FeedModel)?.siteUrl : undefined} />
|
||||
) : error ? (
|
||||
<div className="center mt-36 flex flex-col items-center gap-3">
|
||||
<i className="i-mgc-warning-cute-re text-4xl text-red" />
|
||||
<span className="text-balance text-center text-sm">Network Error</span>
|
||||
<pre className="mt-6 w-full overflow-auto whitespace-pre-wrap break-all">
|
||||
{error.message}
|
||||
</pre>
|
||||
</div>
|
||||
) : (
|
||||
<EntryNoContent id={entryId} url={entry.url ?? ""} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<EntryAttachments entryId={entryId} />
|
||||
</article>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export const EntryContentForPreview: Component<EntryContentProps> = memo((props) => {
|
||||
return (
|
||||
<EntryContentFallback entryId={props.entryId}>
|
||||
<EntryContentImpl {...props} />
|
||||
</EntryContentFallback>
|
||||
)
|
||||
})
|
||||
|
||||
const Renderer: React.FC<{
|
||||
entryId: string
|
||||
view: FeedViewType
|
||||
feedId: string
|
||||
noMedia?: boolean
|
||||
content?: Nullable<string>
|
||||
}> = React.memo(({ entryId, view, feedId, noMedia = false, content = "" }) => {
|
||||
const mediaInfo = useEntryMediaInfo(entryId)
|
||||
|
||||
const readerRenderInlineStyle = useUISettingKey("readerRenderInlineStyle")
|
||||
|
||||
const stableRenderStyle = useRenderStyle()
|
||||
|
||||
return (
|
||||
<EntryContentHTMLRenderer
|
||||
view={view}
|
||||
feedId={feedId}
|
||||
entryId={entryId}
|
||||
mediaInfo={mediaInfo}
|
||||
noMedia={noMedia}
|
||||
as="article"
|
||||
className="prose !max-w-full hyphens-auto dark:prose-invert prose-h1:text-[1.6em] prose-h1:font-bold"
|
||||
style={stableRenderStyle}
|
||||
renderInlineStyle={readerRenderInlineStyle}
|
||||
>
|
||||
{content}
|
||||
</EntryContentHTMLRenderer>
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user