Insert by address
Use the image tool or insertImage with ImageAttributes. Addresses, dimensions and attributes are validated; unsupported/dangerous URLs are not accepted. Images entered by URL can request that external server. The editor does not provide a media backend.
Upload a file
In the builder preview, the image dialog lets you choose a file. It is read locally and embedded in HTML as a data URL; the website does not receive the file. To upload and store images separately in your own application, provide an uploadImage callback returning a persistent URL. Without this callback, the dialog only offers an image address.
Supply uploadImage in the constructor. Your application uploads a PNG/JPEG/GIF/WebP file and resolves with supported image attributes. The callback receives an AbortSignal. Keep authorization and storage policy in the application; do not embed service keys in the browser.
Cancellation and revisions
Uploading captures the insertion range. A changed document revision can reject a stale result. Abort, failure and stale-document errors must be handled without silently overwriting later edits. Upload is not available simply because the image URL tool exists.
Presets
Images are disabled in Simple, available in Base/Pro and selectable in the builder. Image metadata dialogs and drag-based resizing are not implemented. Security, errors.
editor.insertImage({ src: '/uploads/picture.png', alt: 'Описание', width: 640, height: 480 });
const editor = new ViText('#editor', {
preset: 'base',
uploadImage: async (file, { signal }) => {
const body = new FormData(); body.append('image', file);
const response = await fetch('/api/images', { method: 'POST', body, signal });
if (!response.ok) throw new Error('Загрузка не выполнена');
const result = await response.json();
return { src: result.url, alt: file.name };
}
});