Olddevs UI4.14.0
Recipes

Image upload

onUploadImage — paste, drag and drop and “Upload from device”, a placeholder while uploading, and failure.

An image in the Document is always an http or https URL. The app uploads the file: the Editor hands it to onUploadImage and waits for the URL.

Try it

Paste a screenshot or drop an image file into the field. Tick “Make uploads fail” to see a failure.

How it works

While the upload is in progress

While the promise is pending, a placeholder takes the image's place, and the image is not in the Document: not in getHTML(), not in onChange, not in the form.

Success and failure

Success inserts the image as one edit — one undo removes it. Failure (a rejected promise or a non-http/https URL) removes the placeholder and shows a role="alert" line under the field; the Document does not change.

Without onUploadImage

Without an uploader the Editor refuses files from paste and drop, and a hint under the field suggests inserting the image by URL.

Removed images

The Editor does not track images removed from the Document: undo and cut would give false alarms. Files the Document no longer points to are found by the server comparing src on save — sample code is in the extension API.

On this page