Browse Source

reverted fix

imwald
Silberengel 5 months ago
parent
commit
af06fa79d8
  1. 10
      src/components/Image/index.tsx
  2. 4
      src/components/ImageWithLightbox/index.tsx
  3. 15
      src/components/Note/LongFormArticle/index.tsx
  4. 2
      src/components/ui/scroll-area.tsx
  5. 2
      src/layouts/SecondaryPageLayout/index.tsx

10
src/components/Image/index.tsx

@ -102,7 +102,7 @@ export default function Image({
} }
return ( return (
<span className={cn('relative overflow-hidden inline-block', classNames.wrapper)} {...props}> <div className={cn('relative overflow-hidden', classNames.wrapper)} {...props}>
{displaySkeleton && ( {displaySkeleton && (
<span className="absolute inset-0 z-10 inline-block"> <span className="absolute inset-0 z-10 inline-block">
{blurHash ? ( {blurHash ? (
@ -141,17 +141,17 @@ export default function Image({
/> />
)} )}
{hasError && ( {hasError && (
<span <div
className={cn( className={cn(
'object-cover flex flex-col items-center justify-center w-full h-full bg-muted inline-block', 'object-cover flex flex-col items-center justify-center w-full h-full bg-muted',
className, className,
classNames.errorPlaceholder classNames.errorPlaceholder
)} )}
> >
{errorPlaceholder} {errorPlaceholder}
</span> </div>
)} )}
</span> </div>
) )
} }

4
src/components/ImageWithLightbox/index.tsx

@ -57,7 +57,7 @@ export default function ImageWithLightbox({
} }
return ( return (
<span className="inline-block"> <div>
<Image <Image
key={0} key={0}
className={className} className={className}
@ -92,6 +92,6 @@ export default function ImageWithLightbox({
</div>, </div>,
document.body document.body
)} )}
</span> </div>
) )
} }

15
src/components/Note/LongFormArticle/index.tsx

@ -4,7 +4,7 @@ import { getLongFormArticleMetadataFromEvent } from '@/lib/event-metadata'
import { toNote, toNoteList, toProfile } from '@/lib/link' import { toNote, toNoteList, toProfile } from '@/lib/link'
import { ExternalLink } from 'lucide-react' import { ExternalLink } from 'lucide-react'
import { Event, kinds } from 'nostr-tools' import { Event, kinds } from 'nostr-tools'
import { useMemo } from 'react' import React, { useMemo } from 'react'
import Markdown from 'react-markdown' import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm' import remarkGfm from 'remark-gfm'
import NostrNode from './NostrNode' import NostrNode from './NostrNode'
@ -61,7 +61,18 @@ export default function LongFormArticle({
</a> </a>
) )
}, },
p: (props) => <p {...props} className="break-words" />, p: (props) => {
// Check if the paragraph contains only an image
const children = props.children
if (React.Children.count(children) === 1 && React.isValidElement(children)) {
const child = children as React.ReactElement
if (child.type === ImageWithLightbox) {
// Render image outside paragraph context
return <div {...props} className="break-words" />
}
}
return <p {...props} className="break-words" />
},
div: (props) => <div {...props} className="break-words" />, div: (props) => <div {...props} className="break-words" />,
code: (props) => <code {...props} className="break-words whitespace-pre-wrap" />, code: (props) => <code {...props} className="break-words whitespace-pre-wrap" />,
img: (props) => ( img: (props) => (

2
src/components/ui/scroll-area.tsx

@ -8,7 +8,7 @@ const ScrollArea = React.forwardRef<
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & { scrollBarClassName?: string } React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & { scrollBarClassName?: string }
>(({ className, scrollBarClassName, children, ...props }, ref) => ( >(({ className, scrollBarClassName, children, ...props }, ref) => (
<ScrollAreaPrimitive.Root className={cn('relative overflow-hidden', className)} {...props}> <ScrollAreaPrimitive.Root className={cn('relative overflow-hidden', className)} {...props}>
<ScrollAreaPrimitive.Viewport ref={ref} className="h-full w-full rounded-[inherit] *:!block"> <ScrollAreaPrimitive.Viewport ref={ref} className="h-full w-full rounded-[inherit]">
{children} {children}
</ScrollAreaPrimitive.Viewport> </ScrollAreaPrimitive.Viewport>
<ScrollBar className={scrollBarClassName} /> <ScrollBar className={scrollBarClassName} />

2
src/layouts/SecondaryPageLayout/index.tsx

@ -83,7 +83,7 @@ const SecondaryPageLayout = forwardRef(
return ( return (
<DeepBrowsingProvider active={currentIndex === index} scrollAreaRef={scrollAreaRef}> <DeepBrowsingProvider active={currentIndex === index} scrollAreaRef={scrollAreaRef}>
<ScrollArea <ScrollArea
className="h-full overflow-auto" className="h-[calc(100vh-2rem)] overflow-auto"
scrollBarClassName="z-50 pt-12" scrollBarClassName="z-50 pt-12"
ref={scrollAreaRef} ref={scrollAreaRef}
> >

Loading…
Cancel
Save