Conversation
…to 'window manager'
sergiodxa
left a comment
There was a problem hiding this comment.
You also created a branch from the branch you used to your other PR so you send the whole code of that PR here.
renderer/pages/index.js
Outdated
| } | ||
|
|
||
| handleDrop = event => event.preventDefault() | ||
| handleDrop = e => imageDrop(e, this) |
There was a problem hiding this comment.
Don't do this, be explicit, e could be event or error or whatever.
renderer/components/image-drop.js
Outdated
| @@ -0,0 +1,57 @@ | |||
| // validate file format with a list of format supports imgur | |||
| let validateFile = (file) => { | |||
There was a problem hiding this comment.
Use const, only use let if you realize you need to change this variable later (tip: never do it, use immutable code)
renderer/components/image-drop.js
Outdated
| @@ -0,0 +1,57 @@ | |||
| // validate file format with a list of format supports imgur | |||
| let validateFile = (file) => { | |||
| let imageFormat = ['jpeg', 'png', 'gif', 'peg', 'apng', 'tiff', 'pdf', 'xcf'] | |||
There was a problem hiding this comment.
Use const, only use let if you realize you need to change this variable later (tip: never do it, use immutable code)
renderer/components/image-drop.js
Outdated
| let validateFile = (file) => { | ||
| let imageFormat = ['jpeg', 'png', 'gif', 'peg', 'apng', 'tiff', 'pdf', 'xcf'] | ||
| return imageFormat.filter((kind) => { | ||
| let res = new RegExp("\\b(" + kind + ")\\b") |
There was a problem hiding this comment.
Use const, only use let if you realize you need to change this variable later (tip: never do it, use immutable code)
renderer/components/image-drop.js
Outdated
|
|
||
| // send file via XMLHTTP | ||
| let sendData = (_this, file) => { | ||
| let fd = new FormData() |
There was a problem hiding this comment.
Use const, only use let if you realize you need to change this variable later (tip: never do it, use immutable code)
Be explicit, use formData not fd, fd doesn't say anything about what's inside
renderer/components/image-drop.js
Outdated
| // without 'preventDefault', when you drop the image, change the whole editor view | ||
| e.preventDefault() | ||
| let event = {} | ||
| let file = e.dataTransfer.files[0] |
There was a problem hiding this comment.
Use const, only use let if you realize you need to change this variable later (tip: never do it, use immutable code)
renderer/components/image-drop.js
Outdated
| let valido = validateFile(file) | ||
| if (!!valido && valido.length !== 0) { | ||
| sendData(_this, file) | ||
| } else { |
There was a problem hiding this comment.
Don't use else, just return inside the if
renderer/components/image-drop.js
Outdated
| if (!!valido && valido.length !== 0) { | ||
| sendData(_this, file) | ||
| } else { | ||
| event.target = { |
renderer/components/image-drop.js
Outdated
| @@ -0,0 +1,57 @@ | |||
| // validate file format with a list of format supports imgur | |||
There was a problem hiding this comment.
This whole file is not a component, is a lib, move it to another directory.
renderer/pages/index.js
Outdated
| import New from '../components/new-button' | ||
| import Export from '../components/export-button' | ||
| import Create from '../components/window-button' | ||
| import imageDrop from '../components/image-drop' |
There was a problem hiding this comment.
Aside of that file not being a component it's only used inside this page so it doesn't need to be externalized
|
Sergio, I have a doubt. |
renderer/pages/index.js
Outdated
| 'Authorization': `Client-ID e3f6a51d5c12580` | ||
| }, | ||
| body: imageData}) | ||
| .then(response => response.json()) |
|
@demian-arenas each feature should be a PR |
Now, Pulse can upload an image with only Drop a local image onto the editor, this image upload to Imgur and automatically sets the image in the Markdown file.
If the file who drops onto editor isn't supported by Imgur, it inserts schema of an image but with message 'Problem with the format file'. like this
