Showing
6 changed files
with
86 additions
and
5 deletions
... | @@ -7,13 +7,15 @@ | ... | @@ -7,13 +7,15 @@ |
7 | "@testing-library/jest-dom": "^5.11.4", | 7 | "@testing-library/jest-dom": "^5.11.4", |
8 | "@testing-library/react": "^11.1.0", | 8 | "@testing-library/react": "^11.1.0", |
9 | "@testing-library/user-event": "^12.1.10", | 9 | "@testing-library/user-event": "^12.1.10", |
10 | + "@toast-ui/react-image-editor": "3.14.2", | ||
11 | + "@types/fabric": "^4.2.5", | ||
12 | + "fabric": "^4.4.0", | ||
10 | "next": "^10.0.5", | 13 | "next": "^10.0.5", |
11 | "react": "^17.0.2", | 14 | "react": "^17.0.2", |
12 | "react-dom": "^17.0.2", | 15 | "react-dom": "^17.0.2", |
13 | "styled-components": "^5.2.3", | 16 | "styled-components": "^5.2.3", |
14 | "styled-reset": "^4.3.4", | 17 | "styled-reset": "^4.3.4", |
15 | "tui-image-editor": "3.14.2", | 18 | "tui-image-editor": "3.14.2", |
16 | - "@toast-ui/react-image-editor": "3.14.2", | ||
17 | "web-vitals": "^1.0.1" | 19 | "web-vitals": "^1.0.1" |
18 | }, | 20 | }, |
19 | "devDependencies": { | 21 | "devDependencies": { | ... | ... |
src/components/GifEditor.tsx
0 → 100644
1 | +import { useEffect, useState } from "react"; | ||
2 | +import styled from "styled-components"; | ||
3 | + | ||
4 | +const GifEditor = ({ previewURL }) => { | ||
5 | + const [canvas, setCanvas] = useState<HTMLCanvasElement>(); | ||
6 | + | ||
7 | + useEffect(() => { | ||
8 | + if (window) { | ||
9 | + setCanvas(document.getElementById("gif-canvas") as HTMLCanvasElement); | ||
10 | + } | ||
11 | + }, []); | ||
12 | + | ||
13 | + useEffect(() => { | ||
14 | + // const img = lowerCanvas?.toDataURL("image/png"); | ||
15 | + // const uploaded = document.getElementById("image"); | ||
16 | + // console.log(uploaded); | ||
17 | + // let w = window.open(); | ||
18 | + // if (w?.window) w.document.body.innerHTML = "<img src='" + img + "'>"; | ||
19 | + const image = new Image(); | ||
20 | + // image.onload = function () { | ||
21 | + // lowerCanvas.width = uploaded.clientWidth; | ||
22 | + // lowerCanvas.height = uploaded.clientHeight; | ||
23 | + // lowerCanvas?.getContext("2d").drawImage(image, 0, 0); | ||
24 | + // }; | ||
25 | + console.log("fdasdafs", previewURL); | ||
26 | + image.src = previewURL; | ||
27 | + console.log("canvas", canvas); | ||
28 | + if (canvas?.getContext) { | ||
29 | + image.onload = function () { | ||
30 | + canvas.width = 1000; | ||
31 | + canvas.height = 572; | ||
32 | + canvas?.getContext("2d").drawImage(image, 0, 0); | ||
33 | + }; | ||
34 | + console.log(canvas.getContext("2d")); | ||
35 | + } | ||
36 | + }, [canvas]); | ||
37 | + | ||
38 | + return ( | ||
39 | + <Container> | ||
40 | + <ImgBox> | ||
41 | + <canvas id="gif-canvas" /> | ||
42 | + </ImgBox> | ||
43 | + </Container> | ||
44 | + ); | ||
45 | +}; | ||
46 | + | ||
47 | +const Container = styled.div` | ||
48 | + width: 100%; | ||
49 | + display: flex; | ||
50 | + justify-content: center; | ||
51 | + margin-top: 10rem; | ||
52 | +`; | ||
53 | +const ImgBox = styled.div` | ||
54 | + position: relative; | ||
55 | + width: 90%; | ||
56 | + background-color: white; | ||
57 | + box-shadow: ${({ theme }) => theme.boxShadow.normal}; | ||
58 | + border-radius: 2rem; | ||
59 | + margin-top: 2rem; | ||
60 | + display: flex; | ||
61 | + align-items: center; | ||
62 | + justify-content: center; | ||
63 | + font-size: 1rem; | ||
64 | + display: flex; | ||
65 | + padding: 1rem 0; | ||
66 | +`; | ||
67 | + | ||
68 | +export default GifEditor; |
... | @@ -7,7 +7,7 @@ const ToastEditor = dynamic(() => import("components/ToastEditor"), { | ... | @@ -7,7 +7,7 @@ const ToastEditor = dynamic(() => import("components/ToastEditor"), { |
7 | }); | 7 | }); |
8 | const Image = ({ previewURL, setPreviewURL }) => { | 8 | const Image = ({ previewURL, setPreviewURL }) => { |
9 | const [file, setFile] = useState(undefined); | 9 | const [file, setFile] = useState(undefined); |
10 | - console.log("previewURL", previewURL); | 10 | + // console.log("previewURL", previewURL); |
11 | 11 | ||
12 | // const uploadImage = (file) => { | 12 | // const uploadImage = (file) => { |
13 | // if (!file) { | 13 | // if (!file) { | ... | ... |
... | @@ -59,7 +59,7 @@ const ToastEditor = ({ setPreviewURL, setIsImgAdded, setIsEditorOpened }) => { | ... | @@ -59,7 +59,7 @@ const ToastEditor = ({ setPreviewURL, setIsImgAdded, setIsEditorOpened }) => { |
59 | "lower-canvas" | 59 | "lower-canvas" |
60 | )[0] as HTMLCanvasElement; | 60 | )[0] as HTMLCanvasElement; |
61 | setPreviewURL(lowerCanvas.toDataURL("image/png")); | 61 | setPreviewURL(lowerCanvas.toDataURL("image/png")); |
62 | - console.log("asdf"); | 62 | + // console.log("asdf"); |
63 | setIsImgAdded(true); | 63 | setIsImgAdded(true); |
64 | setIsEditorOpened(false); | 64 | setIsEditorOpened(false); |
65 | }; | 65 | }; |
... | @@ -126,7 +126,11 @@ const Container = styled.div` | ... | @@ -126,7 +126,11 @@ const Container = styled.div` |
126 | border-radius: 1.5rem; | 126 | border-radius: 1.5rem; |
127 | } | 127 | } |
128 | .tui-image-editor-container .tui-image-editor-help-menu.top { | 128 | .tui-image-editor-container .tui-image-editor-help-menu.top { |
129 | - top: 2rem; | 129 | + left: 19rem; |
130 | + top: 1rem; | ||
131 | + } | ||
132 | + .tui-image-editor-header-logo { | ||
133 | + display: none; | ||
130 | } | 134 | } |
131 | `; | 135 | `; |
132 | 136 | ... | ... |
... | @@ -3,6 +3,7 @@ import Image from "components/Image"; | ... | @@ -3,6 +3,7 @@ import Image from "components/Image"; |
3 | import styled from "styled-components"; | 3 | import styled from "styled-components"; |
4 | import dynamic from "next/dynamic"; | 4 | import dynamic from "next/dynamic"; |
5 | import { useState } from "react"; | 5 | import { useState } from "react"; |
6 | +import GifEditor from "components/GifEditor"; | ||
6 | 7 | ||
7 | const ToastEditor = dynamic(() => import("components/ToastEditor"), { | 8 | const ToastEditor = dynamic(() => import("components/ToastEditor"), { |
8 | ssr: false, | 9 | ssr: false, |
... | @@ -46,6 +47,7 @@ const Index = () => { | ... | @@ -46,6 +47,7 @@ const Index = () => { |
46 | </button> | 47 | </button> |
47 | </div> | 48 | </div> |
48 | <Image {...{ previewURL, setPreviewURL }} /> | 49 | <Image {...{ previewURL, setPreviewURL }} /> |
50 | + <GifEditor {...{ previewURL }} /> | ||
49 | </> | 51 | </> |
50 | ) | 52 | ) |
51 | )} | 53 | )} | ... | ... |
... | @@ -1367,6 +1367,11 @@ | ... | @@ -1367,6 +1367,11 @@ |
1367 | resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.1.tgz#78b5433344e2f92e8b306c06a5622c50c245bf6b" | 1367 | resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.1.tgz#78b5433344e2f92e8b306c06a5622c50c245bf6b" |
1368 | integrity sha512-S6oPal772qJZHoRZLFc/XoZW2gFvwXusYUmXPXkgxJLuEk2vOt7jc4Yo6z/vtI0EBkbPBVrJJ0B+prLIKiWqHg== | 1368 | integrity sha512-S6oPal772qJZHoRZLFc/XoZW2gFvwXusYUmXPXkgxJLuEk2vOt7jc4Yo6z/vtI0EBkbPBVrJJ0B+prLIKiWqHg== |
1369 | 1369 | ||
1370 | +"@types/fabric@^4.2.5": | ||
1371 | + version "4.2.5" | ||
1372 | + resolved "https://registry.yarnpkg.com/@types/fabric/-/fabric-4.2.5.tgz#095e412b49c896e2fa0d441bd2fceb6690074c4d" | ||
1373 | + integrity sha512-nifrrxvgsYRoxNJB+xZUBe6pLWoqGbZdfwJ0y9zzdt3uU89SzP+8L9Whwrxbvu7eIXjPArSZOyuQmbD4zewdZA== | ||
1374 | + | ||
1370 | "@types/hoist-non-react-statics@*": | 1375 | "@types/hoist-non-react-statics@*": |
1371 | version "3.3.1" | 1376 | version "3.3.1" |
1372 | resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" | 1377 | resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" |
... | @@ -3086,7 +3091,7 @@ extsprintf@^1.2.0: | ... | @@ -3086,7 +3091,7 @@ extsprintf@^1.2.0: |
3086 | resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" | 3091 | resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" |
3087 | integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= | 3092 | integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= |
3088 | 3093 | ||
3089 | -fabric@^4.2.0: | 3094 | +fabric@^4.2.0, fabric@^4.4.0: |
3090 | version "4.4.0" | 3095 | version "4.4.0" |
3091 | resolved "https://registry.yarnpkg.com/fabric/-/fabric-4.4.0.tgz#2b73454008b8082f2d234c4637bdf645876c490c" | 3096 | resolved "https://registry.yarnpkg.com/fabric/-/fabric-4.4.0.tgz#2b73454008b8082f2d234c4637bdf645876c490c" |
3092 | integrity sha512-mX6BZqssJjrT6LN1B4Wcmgm93NIlmKfPN5qTqon9wdDJgRAxPfrhfz2iT+QmDso9P8+s0qyLXFhuVpxOBBMHEw== | 3097 | integrity sha512-mX6BZqssJjrT6LN1B4Wcmgm93NIlmKfPN5qTqon9wdDJgRAxPfrhfz2iT+QmDso9P8+s0qyLXFhuVpxOBBMHEw== | ... | ... |
-
Please register or login to post a comment