Skip to content

Commit 470c8d1

Browse files
committed
feat: markdown editor 적용
1 parent b3bf487 commit 470c8d1

6 files changed

Lines changed: 2379 additions & 182 deletions

File tree

app/(with-sidebar)/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import Sidebar from '@/components/common/Sidebar';
22

3+
import '@uiw/react-md-editor/markdown-editor.css';
4+
import '@uiw/react-markdown-preview/markdown.css';
5+
36
export default function SidebarLayout({
47
children,
58
}: {

app/(with-sidebar)/write/page.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Editor from '@/components/write/Editor';
2+
3+
const Page = () => {
4+
return (
5+
<div className="bg-background flex min-h-screen flex-col">
6+
<Editor />
7+
</div>
8+
);
9+
};
10+
11+
export default Page;

components/common/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const navItems = [
1616
{ label: '홈', href: '/', icon: Home },
1717
{ label: '개발 일지', href: '/logs', icon: ClipboardList },
1818
{ label: '새 계획 만들기', href: '/plans/new', icon: CalendarPlus },
19-
{ label: '새 페이지 만들기', href: '/pages/new', icon: CopyPlus },
19+
{ label: '새 페이지 만들기', href: '/write', icon: CopyPlus },
2020
];
2121

2222
const Sidebar = () => {

components/write/Editor.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use client';
2+
3+
import dynamic from 'next/dynamic';
4+
import { useState } from 'react';
5+
import type { MDEditorProps } from '@uiw/react-md-editor';
6+
7+
const MDEditor = dynamic<MDEditorProps>(() => import('@uiw/react-md-editor'), {
8+
ssr: false,
9+
});
10+
11+
const Editor = () => {
12+
const [value, setValue] = useState<string>('');
13+
14+
return (
15+
<div
16+
data-color-mode="light"
17+
className="mx-auto mt-8 w-full max-w-5xl rounded-2xl px-4 [&_.w-md-editor]:border-0! [&_.w-md-editor]:bg-transparent! [&_.w-md-editor]:shadow-none [&_.w-md-editor-text]:bg-transparent! [&_.w-md-editor-toolbar]:bg-transparent! [&_.wmde-markdown]:bg-transparent!"
18+
>
19+
<MDEditor
20+
value={value}
21+
onChange={(v) => setValue(v ?? '')}
22+
height={850}
23+
preview="live"
24+
textareaProps={{
25+
placeholder: '내용을 입력하세요',
26+
maxLength: 2000,
27+
}}
28+
commandsFilter={(cmd) => {
29+
if (cmd?.name === 'fullscreen') return false;
30+
return cmd;
31+
}}
32+
/>
33+
</div>
34+
);
35+
};
36+
37+
export default Editor;

0 commit comments

Comments
 (0)