or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

commands.mdcore-functionality.mdimage-captions.mdimage-insertion.mdimage-resizing.mdimage-styling.mdimage-text-alternative.mdimage-upload.mdindex.mdutility-functions.md
tile.json

image-upload.mddocs/

Image Upload

Comprehensive upload functionality supporting file selection, drag-and-drop, progress tracking, and integration with various upload adapters.

Capabilities

ImageUpload Plugin

Main upload plugin that combines editing, UI, and progress functionality.

/**
 * Main upload plugin that combines editing, UI, and progress functionality
 */
class ImageUpload {
  static pluginName: 'ImageUpload';
  static requires: [ImageUploadEditing, ImageUploadUI, ImageUploadProgress];
  static isOfficialPlugin: true;
}

Usage:

import { ImageUpload } from '@ckeditor/ckeditor5-image';
import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic';

ClassicEditor
  .create(document.querySelector('#editor'), {
    plugins: [ImageUpload],
    toolbar: ['imageUpload'],
    image: {
      upload: {
        types: ['jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff']
      }
    }
  });

ImageUploadEditing Plugin

Core upload editing functionality with file handling and progress tracking.

/**
 * Core upload editing functionality with file handling and progress tracking
 */
class ImageUploadEditing {
  static pluginName: 'ImageUploadEditing';
  static requires: [FileRepository, Notification, Clipboard, ImageUtils];
  static isOfficialPlugin: true;
}

Events:

The plugin fires the following events during upload process:

interface ImageUploadCompleteEvent {
  name: 'uploadComplete';
}

interface ImageUploadCompleteData {
  imageElement: ModelElement;
}

ImageUploadUI Plugin

User interface for image upload functionality with button and integration support.

/**
 * User interface for image upload functionality with button and integration support
 */
class ImageUploadUI {
  static pluginName: 'ImageUploadUI';
  static requires: [FileDialogButtonView, ImageInsertUI];
  static isOfficialPlugin: true;
}

ImageUploadProgress Plugin

Visual progress indication during image upload with placeholder and progress bar.

/**
 * Visual progress indication during image upload with placeholder and progress bar
 */
class ImageUploadProgress {
  static pluginName: 'ImageUploadProgress';
  static requires: [FileRepository, Notification];
  static isOfficialPlugin: true;
}

UploadImageCommand

Command for programmatic image file uploads.

/**
 * Command for programmatic image file uploads
 * @param options - Upload options including files and image type
 */
class UploadImageCommand {
  constructor(editor: Editor);
  
  execute(options: {
    file: Array<File>;
    imageType?: 'imageBlock' | 'imageInline';
  }): void;
  
  readonly value: null;
}

Usage:

// Upload files programmatically
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', (event) => {
  const files = Array.from(event.target.files);
  editor.execute('uploadImage', { file: files });
});

Configuration

interface ImageUploadConfig {
  /** 
   * Supported image file types 
   * Default: ['jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff']
   */
  types: Array<string>;
}

Example Configuration:

ClassicEditor
  .create(document.querySelector('#editor'), {
    image: {
      upload: {
        types: ['jpeg', 'png', 'webp'] // Restrict to specific formats
      }
    }
  });

Utility Functions

/**
 * Creates RegExp for image MIME type validation
 * @param types - Array of image type extensions
 * @returns RegExp for validating image MIME types
 */
function createImageTypeRegExp(types: Array<string>): RegExp;

/**
 * Checks if clipboard contains HTML content
 * @param dataTransfer - DataTransfer object from clipboard
 * @returns True if HTML content is detected
 */
function isHtmlInDataTransfer(dataTransfer: DataTransfer): boolean;