Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
MAC_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이정민
2021-04-21 23:43:07 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dd48d3c9ee1314d75872c8af06e941f35cb285e6
dd48d3c9
1 parent
f630893e
canvas 가져오기
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
src/components/ToastEditor/index.tsx
src/components/ToastEditor/index.tsx
View file @
dd48d3c
/// <reference path="react-image-editor.d.ts" />
import ImageEditor from "@toast-ui/react-image-editor";
import { useEffect, useState } from "react";
import "tui-image-editor/dist/tui-image-editor.css";
const ToastEditor = () => {
const [lowerCanvas, setLowerCanvas] = useState<HTMLCanvasElement>();
// console.log(
// document.getElementsByClassName("lower-canvas")[0]?.toDataURL("image/png")
// );
console.log("c");
// const [upperCanvas, setUpperCanvas] = useState(
// document.getElementsByClassName("upper-canvas ")[0]
// );
useEffect(() => {
window?.addEventListener("click", () => {
setLowerCanvas(
document.getElementsByClassName("lower-canvas")[0] as HTMLCanvasElement
);
});
}, []);
useEffect(() => {
const img = lowerCanvas?.toDataURL("image/png");
let w = window.open();
if (w?.window) w.document.body.innerHTML = "<img src='" + img + "'>";
console.log("b");
if (lowerCanvas?.getContext) {
console.log(lowerCanvas.getContext("2d"));
}
}, [lowerCanvas?.toDataURL("image/png")]);
return (
<ImageEditor
includeUI={{
...
...
Please
register
or
login
to post a comment