/** * @fileoverview Media Preview Plugin for CKEditor 5 * * This module provides CKEditor 5 plugins for handling media preview components * and upload failed components. It includes: * - MediaPreview: Plugin for media preview widgets * - UploadFailedTag: Plugin for failed upload widgets * - Commands for inserting components * - Utility functions for element creation and validation * * @author Arbo Collaboration * @version 2.0.0 */ import { Command, Plugin, Widget, type ViewDowncastWriter as DowncastWriter } from "../ckeditor-plugins"; /** * Interface for component properties */ interface ComponentProps { id: string; path: string; [key: string]: unknown; } /** * Interface for component attributes */ interface ComponentAttributes extends Record { id?: string; path?: string; name?: string; fileid?: string; mimetype?: string; thumbnail?: string; } /** * Base command class for media components */ declare abstract class BaseMediaCommand extends Command { /** * Executes the command to insert a media component * @param elementName - The name of the element to create * @param props - The properties for the component */ protected executeCommand(elementName: string, props: ComponentProps): void; } /** * Command for inserting preview components */ export declare class PreviewComponentCommand extends BaseMediaCommand { execute(props: ComponentProps): void; } /** * Command for inserting failed upload components */ export declare class FailedUploadComponentCommand extends BaseMediaCommand { execute(props: ComponentProps): void; } declare module "@ckeditor/ckeditor5-core" { interface CommandsMap { Preview: MediaPreview; UploadFailed: UploadFailedTag; } } /** * Base class for media plugins to reduce code duplication */ declare abstract class BaseMediaPlugin extends Plugin { protected abstract getElementName(): string; protected abstract getPluginName(): string; protected abstract getWidgetLabel(): string; protected abstract getSchemaConfig(): any; protected abstract getCommandClass(): new (editor: any) => Command; static get requires(): (typeof Widget)[]; /** * Initialize the plugin */ init(): void; /** * Define the schema for the component * @private */ private _defineSchema; /** * Add commands to the editor * @private */ private _addCommands; /** * Create upcast converter * @private */ private _createUpcaster; /** * Create editing downcast converter * @private */ private _createEditingDowncaster; /** * Create data downcast converter * @private */ private _createDataDowncaster; /** * Define converters for the component * @private */ private _defineConverters; } /** * MediaPreview Plugin for CKEditor 5 * Handles preview components in the editor */ export declare class MediaPreview extends BaseMediaPlugin { static get pluginName(): string; protected getElementName(): string; protected getPluginName(): string; protected getWidgetLabel(): string; protected getSchemaConfig(): any; protected getCommandClass(): new (editor: any) => Command; } /** * UploadFailedTag Plugin for CKEditor 5 * Handles failed upload components in the editor */ export declare class UploadFailedTag extends BaseMediaPlugin { static get pluginName(): string; protected getElementName(): string; protected getPluginName(): string; protected getWidgetLabel(): string; protected getSchemaConfig(): any; protected getCommandClass(): new (editor: any) => Command; } /** * Utility functions for creating media elements */ /** * Creates a preview element with proper error handling * @param writer - The downcast writer * @param attributes - The attributes for the element * @returns The created preview element */ export declare const createPreviewElement: (writer: DowncastWriter, attributes: ComponentAttributes) => import("@ckeditor/ckeditor5-engine").ViewEmptyElement; /** * Creates an upload failed element with proper error handling * @param writer - The downcast writer * @param attributes - The attributes for the element * @returns The created upload failed element */ export declare const createUploadFailedElement: (writer: DowncastWriter, attributes: ComponentAttributes) => import("@ckeditor/ckeditor5-engine").ViewEmptyElement; /** * Validates component properties * @param props - The properties to validate * @param requiredFields - Array of required field names * @returns True if valid, false otherwise */ export declare const validateComponentProps: (props: ComponentProps, requiredFields?: string[]) => boolean; export {};