Open dalboris opened 4 years ago
I agree this would be good to have.
I know it's been a few months but if anyone is looking to do this, you can find it in this line: https://github.com/Ionaru/easy-markdown-editor/blob/3b6402b3e86edb1c5bdaf66689bf60ee0981a685/src/js/easymde.js#L2341
Just change it to:
onSuccess(response.data.filePath);
If you're using the min version you'll want to search for:
(window.location.origin+"/"+e.data.filePath)
and change it to:
(e.data.filePath)
Hope this is helpful to someone searching for an answer to this.
Describe the problem
If I run easyMDE on a webpage hosted at
https://www.example.com
, and my imageUploadEndpoint returns something like:Then easyMDE will add the following markdown:
which is obviously incorrect. This is a bit frustrating, I think it's quite a typical situation for images to be hosted on a different subdomain than the main application, so support for absolute URLs is very important.
Another concrete example I encountered is that while developing and testing my API, I temporarily returned
http://placekitten.com/200/300
(some generic image placeholder showing cute kitten) when I hadn't yet implemented the methods to store the image and return the real URL. This didn't correctly work since easyMDE doesn't support absolute URLs.Describe the solution you'd like
A solution is to simply detect whether the provided
filePath
is an absolute URL, in which case the current domain shouldn't be prepended.