editor-js / editor-js/image

Prevent user from selecting the image in certain situations

Open
#178 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
285
Forks
307
PR merge metrics
No merged PRs in 30d

Description

How can we prevent the user from selecting an image in certain situations?

My problem is that I succeed on preventing the upload of the image to the server but the UI is still loaded with the image selected. I don't know how to clear or avoid showing it.

[**See JSFiddle example**](https://jsfiddle.net/oqgzLurv/2/)

The plugin says we should return a Promise when using the function `uploadByFile`. What have I tried:

```
uploadByFile(file)
{
alert('Error, you cannot proceed');

// Does not work
return Promise.reject(new Error(''));

// Does not work
return new Promise((resolve, reject) => {});

// Does not work
return false;
},
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.