diff --git a/src/App.js b/src/App.js
index 6bb015d..696ec27 100644
--- a/src/App.js
+++ b/src/App.js
@@ -15,6 +15,7 @@ export default function App() {
const [loadIn, setLoadIn] = useState(null)
const [loadInId, setLoadInId] = useState(-1)
const [shouldUpdate, setShouldUpdate] = useState(false)
+ const [nameCurrent, setNameCurrent] = useState("")
useEffect(() => {
@@ -28,7 +29,7 @@ export default function App() {
setShowDrawing("block")
}
- function onLoadIn(save, id) {
+ function onLoadIn(save, id, name) {
let image = new Image()
image.onload = () => {
setWidthDrawing(image.width)
@@ -37,6 +38,7 @@ export default function App() {
setShowForm("none")
setShowDrawing("block")
setLoadInId(id)
+ setNameCurrent(name)
setShouldUpdate(!shouldUpdate)
}
image.src = save
@@ -49,7 +51,7 @@ export default function App() {
return (
-
{
let file = fileInput.files[0]
@@ -65,6 +67,7 @@ export default function App() {
setShowForm("none")
setShowDrawing("block")
setShouldUpdate(!shouldUpdate)
+ setNameCurrent(file.name)
}
image.src = e.target.result
}
diff --git a/src/Drawing.js b/src/Drawing.js
index 6fa1ffe..8599615 100644
--- a/src/Drawing.js
+++ b/src/Drawing.js
@@ -51,6 +51,10 @@ export default function Drawing(p) {
hintCanvas = document.getElementById("hintCanvas")
hintContext = hintCanvas.getContext("2d")
+ if(p.name !== "") {
+ setNameInput(p.name)
+ }
+
if (p.loadIn !== null) {
console.log("test")
let image = new Image()
@@ -97,6 +101,7 @@ export default function Drawing(p) {
const [textInputX, setTextInputX] = useState(0)
const [textInputY, setTextInputY] = useState(0)
const [showTextInput, setShowTextInput] = useState(false)
+ const [nameInput, setNameInput] = useState("")
class Position {
@@ -272,7 +277,12 @@ export default function Drawing(p) {
let image = new Image()
image.src = "data:image/png;base64," + img
downLink.href = img
- downLink.download = "export.png"
+ if(nameInput !== "") {
+ downLink.download = nameInput + ".png"
+ }
+ else {
+ downLink.download = "export.png"
+ }
downLink.click()
}
@@ -281,13 +291,15 @@ export default function Drawing(p) {
let blob = new Blob([img], {type: "text/plain"})
var url = URL.createObjectURL(blob)
downLink.href = url
- downLink.download = "save.redraw"
+ if(nameInput !== "") {
+ downLink.download = nameInput + ".redraw"
+ }
+ else {
+ downLink.download = "save.redraw"
+ }
downLink.click()
}
- function onOpenButtonClick() {
- fileInput.click()
- }
function handleToolChange(e) {
setShowTextInput(false)
@@ -405,6 +417,18 @@ export default function Drawing(p) {
d="M2 8a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0-3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm3 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0-3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm3 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0-3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm3 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0-3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm3 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm0-3a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
+
+
+ {
+ setNameInput(e.currentTarget.value)
+ }}/>
+
{
if(f.target === f.currentTarget) {
- p.onLoadIn(e.content, e.id)
+ p.onLoadIn(e.content, e.id, e.name)
}
}}>
{e.name}