From 8b67253c0a5866358c537633ba335fc3c2183ce5 Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Mon, 17 Apr 2023 10:47:14 +0700
Subject: [PATCH] merged messageImage preview to image preview
---
src/components/note/comment.tsx | 4 ++--
src/components/note/extend.tsx | 2 +-
src/components/note/preview/image.tsx | 6 ++++--
src/components/note/preview/link.tsx | 2 +-
src/components/note/preview/messageImage.tsx | 18 ------------------
src/components/note/preview/video.tsx | 2 +-
src/utils/parser.tsx | 5 ++---
7 files changed, 11 insertions(+), 28 deletions(-)
delete mode 100644 src/components/note/preview/messageImage.tsx
diff --git a/src/components/note/comment.tsx b/src/components/note/comment.tsx
index ea21b47a..62af7b3f 100644
--- a/src/components/note/comment.tsx
+++ b/src/components/note/comment.tsx
@@ -1,4 +1,4 @@
-import NoteMetadata from '@components/note/metadata';
+import { NoteMetadata } from '@components/note/metadata';
import { ImagePreview } from '@components/note/preview/image';
import { VideoPreview } from '@components/note/preview/video';
import { NoteQuote } from '@components/note/quote';
@@ -18,7 +18,7 @@ export const NoteComment = memo(function NoteComment({ event }: { event: any })
parsedContent = reactStringReplace(parsedContent, /(https?:\/\/\S+)/g, (match, i) => {
if (match.match(/\.(jpg|jpeg|gif|png|webp)$/i)) {
// image url
- return ;
+ return ;
} else if (match.match(/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/i)) {
// youtube
return ;
diff --git a/src/components/note/extend.tsx b/src/components/note/extend.tsx
index 199f54de..92d28508 100644
--- a/src/components/note/extend.tsx
+++ b/src/components/note/extend.tsx
@@ -18,7 +18,7 @@ export const NoteExtend = memo(function NoteExtend({ event }: { event: any }) {
parsedContent = reactStringReplace(parsedContent, /(https?:\/\/\S+)/g, (match, i) => {
if (match.match(/\.(jpg|jpeg|gif|png|webp)$/i)) {
// image url
- return ;
+ return ;
} else if (match.match(/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/i)) {
// youtube
return ;
diff --git a/src/components/note/preview/image.tsx b/src/components/note/preview/image.tsx
index 7f06c4a9..d3cb2756 100644
--- a/src/components/note/preview/image.tsx
+++ b/src/components/note/preview/image.tsx
@@ -1,9 +1,11 @@
import Image from 'next/image';
import { memo } from 'react';
-export const ImagePreview = memo(function ImagePreview({ url }: { url: string }) {
+export const ImagePreview = memo(function ImagePreview({ url, size }: { url: string; size: string }) {
return (
-
+
diff --git a/src/components/note/preview/messageImage.tsx b/src/components/note/preview/messageImage.tsx
deleted file mode 100644
index 1ed79684..00000000
--- a/src/components/note/preview/messageImage.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import Image from 'next/image';
-import { memo } from 'react';
-
-export const MessageImagePreview = memo(function MesssageImagePreview({ url }: { url: string }) {
- return (
-
-
-
- );
-});
diff --git a/src/components/note/preview/video.tsx b/src/components/note/preview/video.tsx
index 6f5b9878..34508fbd 100644
--- a/src/components/note/preview/video.tsx
+++ b/src/components/note/preview/video.tsx
@@ -3,7 +3,7 @@ import ReactPlayer from 'react-player/lazy';
export const VideoPreview = memo(function VideoPreview({ url }: { url: string }) {
return (
-
e.stopPropagation()} className="relative mt-3 flex flex-col overflow-hidden rounded-lg">
+
e.stopPropagation()} className="relative flex flex-col overflow-hidden rounded-lg">
{
parsedContent = reactStringReplace(parsedContent, /(https?:\/\/\S+)/g, (match, i) => {
if (match.match(/\.(jpg|jpeg|gif|png|webp)$/i)) {
// image url
- return ;
+ return ;
} else if (match.match(/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/i)) {
// youtube
return ;
@@ -62,7 +61,7 @@ export const messageParser = (noteContent) => {
parsedContent = reactStringReplace(parsedContent, /(https?:\/\/\S+)/g, (match, i) => {
if (match.match(/\.(jpg|jpeg|gif|png|webp)$/i)) {
// image url
- return ;
+ return ;
} else if (match.match(/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/i)) {
// youtube
return ;