From c7c17c2e760d9e6c6e03f94f4cdbb2f1b1db8bf8 Mon Sep 17 00:00:00 2001 From: codytseng Date: Mon, 20 Jan 2025 09:37:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Content/index.tsx | 5 +- src/components/ImageGallery/index.tsx | 17 +++- src/components/NoteStats/RepostButton.tsx | 20 +--- .../PostEditor/PicturePostContent.tsx | 92 ++++++------------- src/components/PostEditor/Preview.tsx | 1 + src/components/PostEditor/index.tsx | 6 +- src/components/ui/dialog.tsx | 3 +- 7 files changed, 55 insertions(+), 89 deletions(-) diff --git a/src/components/Content/index.tsx b/src/components/Content/index.tsx index 2ae76003..97661053 100644 --- a/src/components/Content/index.tsx +++ b/src/components/Content/index.tsx @@ -23,11 +23,13 @@ const Content = memo( ({ event, className, - size = 'normal' + size = 'normal', + disableLightbox = false }: { event: Event className?: string size?: 'normal' | 'small' + disableLightbox?: boolean }) => { const { content, images, videos, embeddedNotes, lastNonMediaUrl } = preprocess(event) const isNsfw = isNsfwEvent(event) @@ -48,6 +50,7 @@ const Content = memo( images={images} isNsfw={isNsfw} size={size} + disableLightbox={disableLightbox} /> ) } diff --git a/src/components/ImageGallery/index.tsx b/src/components/ImageGallery/index.tsx index d84b4ba4..7d66174b 100644 --- a/src/components/ImageGallery/index.tsx +++ b/src/components/ImageGallery/index.tsx @@ -12,12 +12,14 @@ export default function ImageGallery({ className, images, isNsfw = false, - size = 'normal' + size = 'normal', + disableLightbox = false }: { className?: string images: TImageInfo[] isNsfw?: boolean size?: 'normal' | 'small' + disableLightbox?: boolean }) { const { isSmallScreen } = useScreenSize() const [index, setIndex] = useState(-1) @@ -33,7 +35,11 @@ export default function ImageGallery({ imageContent = ( handlePhotoClick(e, 0)} /> @@ -44,7 +50,7 @@ export default function ImageGallery({ {images.map((image, i) => ( handlePhotoClick(e, i)} /> @@ -57,7 +63,7 @@ export default function ImageGallery({ {images.map((image, i) => ( handlePhotoClick(e, i)} /> @@ -70,7 +76,7 @@ export default function ImageGallery({ {images.map((image, i) => ( handlePhotoClick(e, i)} /> @@ -83,6 +89,7 @@ export default function ImageGallery({
{imageContent} {index >= 0 && + !disableLightbox && createPortal(
e.stopPropagation()}> e.stopPropagation()} - disabled={!canRepost} title={t('Repost')} > {reposting ? : } {!!repostCount &&
{formatCount(repostCount)}
} - { - e.stopPropagation() - e.preventDefault() - }} - > - + + {t('Repost')} - { - e.stopPropagation() - setIsPostDialogOpen(true) - }} - > + setIsPostDialogOpen(true)}> {t('Quote')} diff --git a/src/components/PostEditor/PicturePostContent.tsx b/src/components/PostEditor/PicturePostContent.tsx index 6a8463c1..9dff1a5c 100644 --- a/src/components/PostEditor/PicturePostContent.tsx +++ b/src/components/PostEditor/PicturePostContent.tsx @@ -9,10 +9,7 @@ import { cn } from '@/lib/utils' import { useNostr } from '@/providers/NostrProvider' import { ChevronDown, Loader, LoaderCircle, Plus, X } from 'lucide-react' import { Dispatch, SetStateAction, useEffect, useState } from 'react' -import { createPortal } from 'react-dom' import { useTranslation } from 'react-i18next' -import Lightbox from 'yet-another-react-lightbox' -import Zoom from 'yet-another-react-lightbox/plugins/zoom' import Image from '../Image' import Mentions from './Mentions' import Uploader from './Uploader' @@ -177,68 +174,39 @@ function PictureUploader({ > > }) { - const [index, setIndex] = useState(-1) const [uploading, setUploading] = useState(false) return ( - <> -
- {pictureInfos.map(({ url }, index) => ( -
- { - e.stopPropagation() - setIndex(index) - }} - /> - -
- ))} - { - setPictureInfos((prev) => [...prev, { url, tags }]) - }} - onUploadingChange={setUploading} - > -
+ {pictureInfos.map(({ url }, index) => ( +
+ +
- -
- {index >= 0 && - createPortal( -
e.stopPropagation()}> - ({ src: url }))} - plugins={[Zoom]} - open={index >= 0} - close={() => setIndex(-1)} - controller={{ - closeOnBackdropClick: true, - closeOnPullUp: true, - closeOnPullDown: true - }} - styles={{ toolbar: { paddingTop: '2.25rem' } }} - /> -
, - document.body - )} - + + +
+ ))} + { + setPictureInfos((prev) => [...prev, { url, tags }]) + }} + onUploadingChange={setUploading} + > +
+ {uploading ? : } +
+
+
) } diff --git a/src/components/PostEditor/Preview.tsx b/src/components/PostEditor/Preview.tsx index b421ff2e..4cb0e2e9 100644 --- a/src/components/PostEditor/Preview.tsx +++ b/src/components/PostEditor/Preview.tsx @@ -15,6 +15,7 @@ export default function Preview({ content }: { content: string }) { pubkey: '', sig: '' }} + disableLightbox /> ) diff --git a/src/components/PostEditor/index.tsx b/src/components/PostEditor/index.tsx index 888767aa..49c66c5f 100644 --- a/src/components/PostEditor/index.tsx +++ b/src/components/PostEditor/index.tsx @@ -31,7 +31,7 @@ export default function PostEditor({ const { isSmallScreen } = useScreenSize() const content = useMemo(() => { - return parentEvent ? ( + return parentEvent || defaultContent ? ( +
@@ -78,7 +78,7 @@ export default function PostEditor({ } return ( - +
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index db188d71..353b5463 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -32,8 +32,7 @@ const DialogContent = React.forwardRef< React.ComponentPropsWithoutRef & { withoutClose?: boolean } >(({ className, children, withoutClose, ...props }, ref) => ( - {/* */} -
+