Skip to content

Commit

Permalink
merge: 게시글 작성 중 이미지 크기 수정
Browse files Browse the repository at this point in the history
게시글 작성 중 이미지 크기 수정
  • Loading branch information
bae-sh authored Dec 13, 2023
2 parents f5a1dd6 + 829d3b9 commit b5ed926
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"react-error-boundary": "^4.0.11",
"react-redux": "^8.0.5",
"socketjs-client": "^1.0.2",
"tiptap-extension-resize-image": "^1.0.2",
"typescript": "5.0.2",
"uuid": "^9.0.0",
"yup": "^1.0.2"
Expand Down
12 changes: 4 additions & 8 deletions client/src/components/board/PostDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//core
import React, { useEffect } from 'react';
import React from 'react';
import Link from 'next/link';

//interface
Expand All @@ -17,10 +17,10 @@ import { BASE_URL } from '@/service/base/api';
import { EditorContent, useEditor } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import Highlight from '@tiptap/extension-highlight';
import Image from '@tiptap/extension-image';
import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';

import { common, createLowlight } from 'lowlight';
import { ImageResize } from 'tiptap-extension-resize-image';

interface PostDetail {
data: Omit<IPostInformation, 'commentsCount'>;
Expand All @@ -32,23 +32,19 @@ export default function PostDetail({ data, IS_AUTHOR }: PostDetail) {
const url = data.postAuthorId
? `${BASE_URL}${data.postAuthorProfileImgPath}`
: '';

const editor = useEditor({
extensions: [
StarterKit,
Highlight,
Image.configure({ inline: true, allowBase64: true }),
CodeBlockLowlight.configure({
lowlight,
}),
ImageResize.configure({ inline: true, allowBase64: true }),
],
editable: false,
content: data.postContent,
});

useEffect(() => {
editor?.commands.setContent(data.postContent);
}, [data, editor]);

return (
<article className="flex flex-col max-w-4xl min-w-full gap-8 px-4 py-6 m-auto bg-white border-2 border-gray-100 sm:p-12">
<h1 className="text-4xl font-extrabold ">{data.postTitle}</h1>
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/Write/useTiptap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
import { useEditor } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import Highlight from '@tiptap/extension-highlight';
import Image from '@tiptap/extension-image';
import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';

import { common, createLowlight } from 'lowlight';
import { ImageResize } from 'tiptap-extension-resize-image';

function useTipTap() {
const lowlight = createLowlight(common);
const editor = useEditor({
extensions: [
StarterKit,
Highlight,
Image.configure({ inline: true, allowBase64: true }),
CodeBlockLowlight.configure({
lowlight,
}),
ImageResize.configure({ inline: true, allowBase64: true }),
],
});
return { editor };
Expand Down
5 changes: 5 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10182,6 +10182,11 @@ tippy.js@^6.3.7:
dependencies:
"@popperjs/core" "^2.9.0"

tiptap-extension-resize-image@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/tiptap-extension-resize-image/-/tiptap-extension-resize-image-1.0.2.tgz#124319eedc04cc344e2af2617f7f20b37456c8fd"
integrity sha512-fdFzodaGlBUYtyXOEyi2NOM47NWASunGdbbw/6LTPL8pEPHdi+b6FpQhbes7oZUtJD4G0PV3wLzHRAjnfwk4cg==

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down

0 comments on commit b5ed926

Please sign in to comment.