Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

게시글 작성 시 이미지 복사 붙혀넣기로 이미지 첨부 가능하도록 구현 #624

Merged
merged 3 commits into from
Sep 18, 2023

Conversation

Gilpop8663
Copy link
Collaborator

🔥 연관 이슈

close: #602

📝 작업 요약

  • 본문 이미지 복사 붙혀넣기로 동작되도록 구현
  • 중복되는 코드 분리 후 useContentImage, useWritingOption에서 import하여 사용

⏰ 소요 시간

40분

🔎 작업 상세 설명

  • onPaste 이벤트에서 file의 타입이 image라면 이미지 파일을 붙혀넣기한 것으로 판단하고 업로드 input에 파일을 넣어주도록 구현
  • 선택지와 본문에서 이미지 업로드 하는 코드가 중복된다고 생각하여 분리하였음
  • 붙혀넣기 기능은 선택지는 미적용, 본문만 적용하였습니다. 그 이유는 useWritingOption에서 업로드 버튼의 ref가 필요한데 수아의 PR이 머지된 후 진행하는 것이 깔끔하다고 생각했습니다

적용된 동영상

2023-09-15.1.46.35.mov

🌟 논의 사항

크루들과 이야기 해보고 싶은 부분을 적어주세요.

@github-actions
Copy link

⚡️ Lighthouse report!

Category Score
🟠 Performance 56
🟠 Accessibilty 88
🟠 SEO 85
🟠 PWA 89
Category Score
🟢 First Contentful Paint 0.6 s
🔴 Largest Contentful Paint 4.9 s
🔴 Total Blocking Time 1,140 ms
🟢 Cumulative Layout Shift 0
🟠 Speed Index 4.3 s

Copy link
Collaborator

@chsua chsua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통된 파일 추출하는 부분을 분리하니 가독성이 훨씬 좋아졌어요!
붙여넣기 이벤트를 통해서 웹에서 사용할때 사용성이 훨씬 좋아질 것 같아요bb 너무 좋습니다

클립보드 이벤트도 이미지 등록 이벤트와 유사한 부분이 있네요
궁금한 점이 하나 있어서 남겼습니다.

다른 수정 부분은 없어서 approve하겠습니다.
제꺼 머지되면 선택지도 넣으면 좋겠네요ㅎㅎㅎ

fe-리뷰완

const handlePasteImage = (event: ClipboardEvent<HTMLTextAreaElement>) => {
const file = event.clipboardData.files[0];

if (file.type.slice(0, 5) === 'image') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 해당 file.type이 뭐라고 나오나요??
찾아도 관련없는 것들이 많이 나오네요
참고하신 자료가 있다면 공유 부탁들려요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'image/png' , 'image/webp'와 같이 나와요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

참고한 자료는 따로 없고 console.log를 통해 파일의 정보를 확인하고 코드를 작성했었습니다 😃

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bb 대단합니다

Copy link
Member

@inyeong-kang inyeong-kang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와 붙여넣기 정말 편리하겠는걸요??
uploadImage 함수 리팩터링도 깔끔해서 좋네요👍👍


import { convertImageToWebP } from '@utils/resizeImage';

export const uploadImage = async ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

}) => {
if (!inputElement) return;

const webpFileList = await convertImageToWebP(imageFile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 혹시 정말 사소하게 궁금한 부분인데, 변환하는데 몇초가 걸리는지 궁금해요! 만약 시간이 걸리는 작업이거나, slow 3g 환경이라면 변환 중.. 같은 문구나 로딩 스피너를 보여줘도 좋겠네요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 짧은 시간이라서 따로 설정을 안해줘도 될 것 같아요. 그리고 미리보기는 webP로 변환된 이미지가 아닌 처음 입력받은 이미지로 미리보기 URL을 만들어서 변환 시간은 포함이 안되도록 했습니당

메모리 6배 부하, slow3G일 때

걸린 시간 : 19ms , 0.019초

image

메모리 부하 X, slow3G일 때

걸린 시간 : 8ms , 0.008초

image

메모리 부하 X, 노 쓰로틀링일 때

걸린 시간 : 6ms , 0.006초

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제로의 제안으로 webp로 이미지 변환 속도를 측정해보았습니다 ~

fe-리뷰요청

@inyeong-kang
Copy link
Member

fe-리뷰완

@Gilpop8663 Gilpop8663 merged commit 5887ccd into dev Sep 18, 2023
2 checks passed
@woo-chang woo-chang deleted the feat/#602 branch September 19, 2023 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

게시글 작성 시 이미지 복사 붙혀넣기로 이미지 첨부 가능하도록 구현
3 participants