Skip to content

Commit 48c102c

Browse files
authored
Merge pull request #48 from gummmmmy0v0/feature/#47
[#47] 텍스트 에디터 외부 모듈 적용
2 parents 523c6ae + 49c3c0a commit 48c102c

File tree

9 files changed

+373
-97
lines changed

9 files changed

+373
-97
lines changed

index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@
1111
crossorigin
1212
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/variable/pretendardvariable-dynamic-subset.min.css"
1313
/>
14+
<link
15+
rel="stylesheet"
16+
href="https://unpkg.com/[email protected]/dist/quill.snow.css"
17+
/>
18+
<link rel="preconnect" href="https://fonts.googleapis.com" />
19+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
20+
<link
21+
href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"
22+
rel="stylesheet"
23+
/>
24+
<link rel="preconnect" href="https://fonts.googleapis.com" />
25+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
26+
<link
27+
href="https://fonts.googleapis.com/css2?family=Nanum+Gothic&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"
28+
rel="stylesheet"
29+
/>
30+
<link rel="preconnect" href="https://fonts.googleapis.com" />
31+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32+
<link
33+
href="https://fonts.googleapis.com/css2?family=Edu+SA+Hand:[email protected]&family=Nanum+Gothic&family=Nanum+Pen+Script&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"
34+
rel="stylesheet"
35+
/>
1436
<title>Rolling</title>
1537
</head>
1638
<body>

package-lock.json

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"axios": "^1.11.0",
1414
"react": "^19.1.1",
1515
"react-dom": "^19.1.1",
16+
"react-quill-new": "^3.6.0",
1617
"react-router": "^7.8.0",
1718
"react-router-dom": "^7.8.0",
1819
"styled-components": "^6.1.19"

src/app.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import MainPage from "./pages/main-page";
77
import MessagePage from "./pages/message-list";
88
import MessagesPage from "./pages/messages-page";
99
import SendMessagePage from "./pages/send-message-page";
10-
import SendPage from "./pages/send-page";
1110
import TestPage from "./pages/test-page";
1211

1312
function Provider({ children }) {
@@ -56,7 +55,6 @@ function App() {
5655
</Route>
5756
<Route path="/test-components" element={<TestPage />} />
5857
<Route path="/list" element={<MessagePage />} />
59-
<Route path="/post/{id}/message" element={<SendPage />} />
6058
</Routes>
6159
</BrowserRouter>
6260
</Provider>

src/components/option/background-select.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const OptionItem = styled.div`
2525
background-position: center;
2626
background-size: cover;
2727
background-repeat: no-repeat;
28+
opacity: ${({ selected }) => (selected ? 0.3 : 1)};
2829
`;
2930

3031
const CircleButtonWrapper = styled.div`
@@ -94,6 +95,7 @@ function BackgroundSelect({ type, selected, onSelect }) {
9495
color={option.color}
9596
url={option.url}
9697
onClick={() => onSelect(index)}
98+
selected={selected === index}
9799
>
98100
{selected === index && (
99101
<CircleButtonWrapper>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { useEffect, useRef, useState } from "react";
2+
import ReactQuill, { Quill } from "react-quill-new";
3+
import "react-quill-new/dist/quill.snow.css";
4+
5+
interface TextEditorProps {
6+
style?: any;
7+
value?: string;
8+
onChange: (value: string) => void;
9+
font?: string;
10+
}
11+
12+
const Font: any = Quill.import("formats/font");
13+
Font.whitelist = [
14+
"Noto Sans",
15+
"Pretendard",
16+
"Nanum Gothic",
17+
"Nanum Pen Script",
18+
];
19+
Quill.register(Font, true);
20+
21+
function TextEditor({ style, value, onChange, font }: TextEditorProps) {
22+
const editorRef = useRef<any>(null);
23+
24+
useEffect(() => {
25+
if (editorRef.current) {
26+
const editor = editorRef.current.getEditor();
27+
editor.root.style.fontFamily = font || "Noto Sans";
28+
editor.root.style.fontSize = "20px";
29+
}
30+
}, [font]);
31+
32+
const modules = {
33+
toolbar: {
34+
container: [
35+
["bold", "italic", "underline"],
36+
[{ align: "center" }, { align: "right" }, { align: "justify" }],
37+
[{ list: "bullet" }, { list: "ordered" }],
38+
[{ background: [] }, { color: [] }],
39+
[{ size: [] }],
40+
],
41+
},
42+
};
43+
44+
return (
45+
<ReactQuill
46+
ref={editorRef}
47+
style={style}
48+
modules={modules}
49+
value={value}
50+
onChange={onChange}
51+
/>
52+
);
53+
}
54+
55+
export default TextEditor;

src/pages/create-post-page.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
import InputTextField from "../components/text-field/text-field";
2+
import TextField from "../components/text-field/text-field";
33
import TEXT_FIELD_TYPE from "../components/text-field/text-field-type";
44
import Colors from "../components/color/colors";
55
import ToggleButton from "../components/button/toggle-button";
@@ -39,6 +39,7 @@ const ToggleButtonWrapper = styled.div`
3939

4040
const ButtonWrapper = styled.div`
4141
padding-top: 50px;
42+
padding-bottom: 150px;
4243
width: 720px;
4344
`;
4445

@@ -82,13 +83,13 @@ function CreatePostPage() {
8283
navigate(`/post/${randomID}`);
8384
};
8485

85-
const canCreate = name !== "" || name !== name.trim();
86+
const canCreate = name.trim() !== "";
8687

8788
return (
8889
<PostContainer>
8990
<Wrapper>
9091
<PostTitle>To.</PostTitle>
91-
<InputTextField // TextField로 변경
92+
<TextField
9293
type={TEXT_FIELD_TYPE.input}
9394
value={name}
9495
onChange={handleChange}

0 commit comments

Comments
 (0)