I need to set setCurrentActivity to cloud-image-edit with a url. But I couldn’t able to find a way to do this. When I use the following code, it opens a empty image editor and getting a console error “Failed to construct ‘URL’: Invalid URL”. Is there a way to load a file to the editor programatically? Thank you
The current API of the uploader doesn’t have a method that would allow you to open a file in image editor directly. {cdnUrl:url} won’t have any effect here because this activity doesn’t support additional parameters. Here’s how you can work around this:
You need to preload an image via addFileFromUrl and get its internal ID first
const file = api.addFileFromUrl(url);
const id = file.internalId;
When the file is loaded, you change set the focus on it and change the activity to cloud-image-edit
ctxProvider.addEventListener("file-upload-success", e => {
if (e.detail.internalId = id) {
// (!) undocumented API method, subject to change
const internalEntry = api._uploadCollection.read(e.detail.internalId);
// (!) undocumented API method, subject to change
api._ctx.$['*focusedEntry'] = internalEntry;
api.setCurrentActivity("cloud-image-edit");
api.setModalState(true);
}
});
In the next update, we’ll make it possible to pass an internal ID to the setCurrentActivity method like this: