@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
82 lines (81 loc) • 3.28 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
*/
/**
* @module ai/aiactions/aiactions
* @publicApi
*/
import { type Editor, Plugin } from '@ckeditor/ckeditor5-core';
import { AIConnector } from '../aicore/aiconnector.js';
import { Dialog } from '@ckeditor/ckeditor5-ui';
import { AIEditing } from '../aicore/aiediting.js';
import { AIBalloon } from '../aiballoon/aiballoon.js';
import { DocumentCompare } from '@ckeditor/ckeditor5-collaboration-core';
/**
* @experimental **Experimental:** Some methods of this class are production-ready but experimental and may change
* in minor releases without the standard deprecation policy. Check the changelog for migration guidance.
*/
export declare class AIActions extends Plugin {
/**
* @inheritDoc
*/
static get requires(): readonly [typeof AIConnector, typeof Dialog, typeof AIEditing, typeof AIBalloon, typeof DocumentCompare];
/**
* @inheritDoc
*/
static get pluginName(): "AIActions";
/**
* @inheritDoc
*/
static get isOfficialPlugin(): true;
/**
* @inheritDoc
*/
static get isPremiumPlugin(): true;
/**
* The busy state of the AI actions.
*
* It is set to `true` when there are AI response being streamed or rendered.
*
* @observable
*/
isBusy: boolean;
constructor(editor: Editor);
/**
* Stops the currently running AI action interaction, aborting any in-progress streaming and resetting the busy state.
*
* @experimental **Experimental:** This is a production-ready API but may change in minor releases
* without the standard deprecation policy. Check the changelog for migration guidance.
*/
stopInteraction(): void;
/**
* Executes an AI action on the current editor selection. The action processes the selected content
* using the AI model and displays the result in an inline balloon.
*
* @experimental **Experimental:** This is a production-ready API but may change in minor releases
* without the standard deprecation policy. Check the changelog for migration guidance.
* @param action The action definition specifying which AI action to execute.
* @param label The display label shown in the balloon UI while the action is being processed.
* @param icon Optional icon to display alongside the label in the balloon UI.
*/
executeAction(action: AIActionDefinition, label: string, icon?: string): Promise<void>;
/**
* @inheritDoc
*/
destroy(): Promise<void>;
private _createInteraction;
}
export type AIActionsNames = 'continue' | 'fix-grammar' | 'improve-writing' | 'make-longer' | 'make-shorter' | 'make-tone-casual' | 'make-tone-formal' | 'translate';
/**
* Defines the parameters for an AI action executed via
* {@link module:ai/aiactions/aiactions~AIActions#executeAction `executeAction()`}.
*
* For system actions, provide `actionName`. For custom actions, provide `userMessage` and `model`.
*/
export type AIActionDefinition = {
actionName?: AIActionsNames;
args?: Record<string, string>;
userMessage?: string;
model?: string;
};