@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
155 lines (154 loc) • 4.72 kB
TypeScript
/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
import { Plugin } from 'ckeditor5/src/core.js';
import { type Locale } from 'ckeditor5/src/utils.js';
import { BalloonToolbar } from 'ckeditor5/src/ui.js';
import '../../theme/aiquickactions/aiquickactions.css';
/**
* Defines the different types of AI quick actions available in the editor.
* Each type determines how the action will be presented and executed.
*/
export declare enum AIQuickActionType {
/**
* Actions that open the AI Chat interface for interactive conversations.
*/
CHAT = "CHAT",
/**
* Actions that display results in a balloon popup for quick inline operations.
*/
ACTION = "ACTION",
/**
* Actions that open the AI Review interface for detailed content analysis.
*/
REVIEW = "REVIEW"
}
/**
* Maps AI quick action types to their corresponding CKEditor plugin names.
* Used for checking plugin availability and determining which actions to display.
*/
export declare enum AIQuickActionTypeToPluginName {
CHAT = "AIChat",
ACTION = "AIActions",
REVIEW = "AIReviewMode"
}
/**
* UI plugin for AI Quick Actions that provides a set of predefined AI-powered tools.
*
* This plugin manages the creation and configuration of AI quick action buttons and dropdowns
* in the editor's toolbar. It handles both individual actions and grouped actions, automatically
* filtering based on available plugins and creating the appropriate UI components.
*
* The plugin supports three types of AI actions:
* - AICHAT: Opens interactive AI chat interface
* - AIACTIONS: Shows results in inline balloon popups
* - REVIEW: Opens detailed AI review interface
*/
export declare class AIQuickActionsUI extends Plugin {
/**
* @inheritDoc
*/
static get requires(): readonly [typeof BalloonToolbar];
/**
* @inheritDoc
*/
static get pluginName(): "AIQuickActionsUI";
/**
* @inheritDoc
*/
static get isOfficialPlugin(): true;
/**
* @inheritDoc
*/
static get isPremiumPlugin(): true;
/**
* Initializes the AI Quick Actions UI plugin.
*
* Sets up the default quick actions configuration and creates all necessary
* UI components and commands for the quick actions functionality.
*
* @inheritDoc
*/
init(): Promise<void>;
/**
* Returns the default quick actions configuration.
*
* @param locale The editor's locale for text translation
* @returns Array of quick action definitions and groups
*/
static getDefaultQuickActions(locale: Locale): Array<AIQuickActionsGroupDefinition | AIQuickActionDefinition>;
}
/**
* Defines a group of related AI quick actions that appear together in a dropdown.
*
* Groups allow organizing multiple related actions under a single menu item,
* such as "Change Tone" containing "More Casual", "More Professional", etc.
*/
export type AIQuickActionsGroupDefinition = {
/**
* Unique identifier for the action group.
*/
id: string;
/**
* Display label for the group.
*/
label: string;
/**
* Array of actions contained within this group.
*/
actions: Array<AIQuickActionDefinition>;
/**
* Optional icon to display for the group.
*/
icon?: string;
};
/**
* Defines an individual AI quick action that can be executed by the user.
*
* Actions can exist independently or as part of a group. Each action specifies
* its type to determine the execution interface (chat, balloon, or review).
*/
export type AIQuickActionDefinition = {
/**
* Whether the action is enabled.
*/
isEnabled?: boolean;
/**
* Unique identifier for the action.
*/
id: string;
/**
* Display label for the action.
*/
displayedPrompt: string;
/**
* Type determining how the action will be executed.
*/
type: AIQuickActionType;
/**
* Optional icon to display for the action.
*/
icon?: string;
/**
* Optional action name to be used for actions with args.
*/
actionName?: string;
/**
* Optional parameters for the call.
*/
args?: Record<string, string>;
/**
* Optional predefined prompt text for the action.
*/
prompt?: string;
/**
* Optional model to be used.
*/
model?: string;
/**
* Reference to parent group (if action is part of a group).
* Excludes the actions array to prevent circular references.
*/
parent?: Omit<AIQuickActionsGroupDefinition, 'actions'>;
};