@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
135 lines (134 loc) • 4.22 kB
TypeScript
/**
* @license Copyright (c) 2003-2026, 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 '@ckeditor/ckeditor5-core';
import { type Locale } from '@ckeditor/ckeditor5-utils';
import { BalloonToolbar } from '@ckeditor/ckeditor5-ui';
import { AIConnector } from '../aicore/aiconnector.js';
import '../../theme/common/aibutton.css';
import '../../theme/common/aicolor.css';
import '../../theme/aiquickactions/aiquickactions.css';
import { type AIQuickActionType } from './aiquickactions.js';
/**
* 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 2 types of AI actions:
* - chat: opens interactive AI chat interface,
* - action: shows results in inline balloon popups.
*/
export declare class AIQuickActionsUI extends Plugin {
/**
* @inheritDoc
*/
static get requires(): readonly [typeof BalloonToolbar, typeof AIConnector];
/**
* @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.
*
* See {@link module:core/plugin~PluginInterface#init}.
*/
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 or balloon).
*/
export type AIQuickActionDefinition = {
/**
* Whether the action is enabled.
*/
isEnabled?: boolean;
/**
* Unique identifier for the action.
*/
id: string;
/**
* Display label for the action.
*/
label: string;
/**
* Type determining how the action will be executed.
*/
type: AIQuickActionType;
/**
* Displayed prompt for the action. Used in the UI to show shorter prompt version in some cases.
*/
displayedPrompt?: string;
/**
* 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'>;
};