easy-markdown-editor icon indicating copy to clipboard operation
easy-markdown-editor copied to clipboard

Allow `imageUploadFunction` to return a data-URI

Open pabzm opened this issue 3 months ago • 1 comments

This allows to include images without uploading them onto a server first. Instead their content is specified inline in a data-URI https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data.

Example of an imageUploadFunction that takes advantage of this:

(file, onSuccess, onError) => {
    const reader = new FileReader();
    reader.addEventListener('load', () => onSuccess(reader.result));
    reader.addEventListener('error', (event) => onError(event));
    reader.addEventListener('abort', (event) => onError(event));
    reader.readAsDataURL(file);
}

pabzm avatar Aug 26 '25 16:08 pabzm

~~This appears to break cypress/e2e/4.image-rendering/image-rendering.cy.js:12 ("must render an image inside the editor").~~

~~I'm at a loss about the reason, though, since the inserted syntax is the same as before, as far as I can see. Do you maybe have a hint why the test fails?~~

Nevermind, subsequent test runs are green. Seems to have been a glitch.

pabzm avatar Aug 26 '25 16:08 pabzm