Ionaru / Ionaru/easy-markdown-editor
Is there any working example on how to use the imageUploadFunction
- Dominant language
- JavaScript
- Stars
- 3.1k
- Forks
- 363
- PR merge metrics
- No merged PRs in 30d
Description
There was a similar question #334, but the answer to that is not working that well.
The image is displayed kinda weird.
**In Markdown, it looks like this:**

**When Im using the preview it looks like this:**

**But as soon as I click on the "Z", it looks like this:**

And there is no other way to go out of the preview, than reloading the website.
The answer to question #334 was this code:
```javascript
(file, onSuccess, onError) => {
const reader = new FileReader();
reader.onload = () => onSuccess(reader.result);
reader.onerror = () => onError("Error loading"+file.name);
reader.readAsDataURL(file)
```
In total my Editor looks like this:
```javascript
const easyMDE = new EasyMDE({
element: document.getElementById("example"),
placeholder: "Nach dem schreiben bitte speichern",
toolbar: [
"bold","italic","heading","|","code","quote","|","unordered-list","ordered-list","table","|","link","upload-image","|","preview","side-by-side","fullscreen","|","guide"
],
uploadImage: true,
imageUploadFunction:
(file, onSuccess, onError) => {
const reader = new FileReader();
reader.onload = () => onSuccess(reader.result);
reader.onerror = () => onError("Error loading"+file.name);
reader.readAsDataURL(file)
// EasyMDE.drawUploadedImage(easyMDE)
}
})
```
It would be nice to have a working example of the imageUploadFunction.
Contributor guide
Assessment
This issue has not been assessed yet.