이정민

tui image editor 추가

...@@ -3,16 +3,18 @@ ...@@ -3,16 +3,18 @@
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 + "@next/bundle-analyzer": "^10.0.7",
6 "@testing-library/jest-dom": "^5.11.4", 7 "@testing-library/jest-dom": "^5.11.4",
7 "@testing-library/react": "^11.1.0", 8 "@testing-library/react": "^11.1.0",
8 "@testing-library/user-event": "^12.1.10", 9 "@testing-library/user-event": "^12.1.10",
9 - "@next/bundle-analyzer": "^10.0.7", 10 + "next": "^10.0.5",
10 "react": "^17.0.2", 11 "react": "^17.0.2",
11 "react-dom": "^17.0.2", 12 "react-dom": "^17.0.2",
12 "styled-components": "^5.2.3", 13 "styled-components": "^5.2.3",
13 - "web-vitals": "^1.0.1", 14 + "styled-reset": "^4.3.4",
14 - "next": "^10.0.5", 15 + "tui-image-editor": "3.14.2",
15 - "styled-reset": "^4.3.4" 16 + "@toast-ui/react-image-editor": "3.14.2",
17 + "web-vitals": "^1.0.1"
16 }, 18 },
17 "devDependencies": { 19 "devDependencies": {
18 "@babel/core": "^7.13.10", 20 "@babel/core": "^7.13.10",
......
...@@ -3,7 +3,7 @@ import styled from "styled-components"; ...@@ -3,7 +3,7 @@ import styled from "styled-components";
3 3
4 const Image = () => { 4 const Image = () => {
5 const [file, setFile] = useState(undefined); 5 const [file, setFile] = useState(undefined);
6 - const [previewURL, setPreviewURL] = useState(""); 6 + const [previewURL, setPreviewURL] = useState<string | ArrayBuffer>("");
7 7
8 // const uploadImage = (file) => { 8 // const uploadImage = (file) => {
9 // if (!file) { 9 // if (!file) {
...@@ -29,13 +29,15 @@ const Image = () => { ...@@ -29,13 +29,15 @@ const Image = () => {
29 <ImgBox> 29 <ImgBox>
30 {file === undefined ? ( 30 {file === undefined ? (
31 <> 31 <>
32 + <div className="sub-flex">
32 <BlankBox /> 33 <BlankBox />
33 <div>Click to add a photo</div> 34 <div>Click to add a photo</div>
34 <input 35 <input
35 type="file" 36 type="file"
36 style={{ 37 style={{
37 - marginTop: "5px",
38 position: "absolute", 38 position: "absolute",
39 + top: 0,
40 + paddingLeft: 0,
39 zIndex: 0, 41 zIndex: 0,
40 width: "90%", 42 width: "90%",
41 height: "100%", 43 height: "100%",
...@@ -45,16 +47,23 @@ const Image = () => { ...@@ -45,16 +47,23 @@ const Image = () => {
45 }} 47 }}
46 onChange={selectImg} 48 onChange={selectImg}
47 /> 49 />
50 + </div>
51 + <div className="sub-flex">Open Image Editor</div>
48 </> 52 </>
49 ) : ( 53 ) : (
50 <img 54 <img
51 alt={""} 55 alt={""}
52 - style={{ objectFit: "cover", display: "flex", margin: "0 auto" }} 56 + style={{
53 - src={previewURL} 57 + objectFit: "cover",
58 + display: "flex",
59 + margin: "0 auto",
60 + width: "50rem",
61 + }}
62 + src={previewURL as string}
54 /> 63 />
55 )} 64 )}
56 </ImgBox> 65 </ImgBox>
57 - <Menu /> 66 + {/* <Menu /> */}
58 </Container> 67 </Container>
59 ); 68 );
60 }; 69 };
...@@ -77,7 +86,6 @@ const Container = styled.div` ...@@ -77,7 +86,6 @@ const Container = styled.div`
77 `; 86 `;
78 const ImgBox = styled.div` 87 const ImgBox = styled.div`
79 position: relative; 88 position: relative;
80 - width: 40rem;
81 height: 30rem; 89 height: 30rem;
82 background-color: white; 90 background-color: white;
83 box-shadow: ${({ theme }) => theme.boxShadow.normal}; 91 box-shadow: ${({ theme }) => theme.boxShadow.normal};
...@@ -87,6 +95,20 @@ const ImgBox = styled.div` ...@@ -87,6 +95,20 @@ const ImgBox = styled.div`
87 align-items: center; 95 align-items: center;
88 justify-content: center; 96 justify-content: center;
89 font-size: 1rem; 97 font-size: 1rem;
98 + display: flex;
99 + flex: 0.6;
100 + padding: 1rem 0;
101 + .sub-flex {
102 + position: relative;
103 + width: 100%;
104 + height: 100%;
105 + display: flex;
106 + align-items: center;
107 + justify-content: center;
108 + :first-child {
109 + border-right: 1px solid ${({ theme }) => theme.color.gray};
110 + }
111 + }
90 `; 112 `;
91 113
92 const Box = styled.div` 114 const Box = styled.div`
......
1 +/// <reference path="react-image-editor.d.ts" />
2 +import ImageEditor from "@toast-ui/react-image-editor";
3 +import "tui-image-editor/dist/tui-image-editor.css";
4 +
5 +const ToastEditor = () => {
6 + return (
7 + <ImageEditor
8 + includeUI={{
9 + loadImage: {
10 + // path: 'img/sampleImage.jpg',
11 + name: "SampleImage",
12 + },
13 + // theme: myTheme,
14 + menu: ["shape", "filter"],
15 + initMenu: "filter",
16 + uiSize: {
17 + width: "1000px",
18 + height: "700px",
19 + },
20 + menuBarPosition: "bottom",
21 + }}
22 + cssMaxHeight={500}
23 + cssMaxWidth={700}
24 + selectionStyle={{
25 + cornerSize: 20,
26 + rotatingPointOffset: 70,
27 + }}
28 + usageStatistics={true}
29 + />
30 + );
31 +};
32 +
33 +export default ToastEditor;
1 +declare module "@toast-ui/react-image-editor";
...@@ -58,6 +58,13 @@ class MyDocument extends Document { ...@@ -58,6 +58,13 @@ class MyDocument extends Document {
58 <body> 58 <body>
59 <Main /> 59 <Main />
60 <NextScript /> 60 <NextScript />
61 + <script src="libs/code-snippet.min.js"></script>
62 + <script src="libs/jquery.min.js"></script>
63 + <script src="libs/fabric.min.js"></script>
64 + <script src="js/image-editor.js"></script>
65 + <div id="my-image-editor">
66 + <canvas></canvas>
67 + </div>
61 </body> 68 </body>
62 </Html> 69 </Html>
63 ); 70 );
......
1 import Header from "components/Header"; 1 import Header from "components/Header";
2 import Image from "components/Image"; 2 import Image from "components/Image";
3 import styled from "styled-components"; 3 import styled from "styled-components";
4 +import dynamic from "next/dynamic";
5 +
6 +const ToastEditor = dynamic(() => import("components/ToastEditor"), {
7 + ssr: false,
8 +});
4 9
5 const Index = () => ( 10 const Index = () => (
6 <Container> 11 <Container>
7 <Header /> 12 <Header />
8 <Image /> 13 <Image />
14 + <ToastEditor />
9 </Container> 15 </Container>
10 ); 16 );
11 17
......
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.