@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
136 lines (135 loc) • 4.38 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/aireviewmode/aireviewmode
* @publicApi
*/
import { ContextPlugin } from '@ckeditor/ckeditor5-core';
import { AIReviewModeUI } from './aireviewmodeui.js';
import { AIReviewCoreEditing } from '../aireviewcore/aireviewcoreediting.js';
import { AIReviewModeController } from './aireviewmodecontroller.js';
/**
* The AI Review Mode feature.
*
* The Review feature provides users with AI-powered quality assurance for their content by automatically running checks
* for grammar, style, tone, and more.
*
* Learn more about AI features in CKEditor in the {@glink features/ai/ckeditor-ai-overview AI Overview} documentation.
*/
export declare class AIReviewMode extends ContextPlugin {
/**
* @inheritDoc
*/
static get requires(): readonly [typeof AIReviewModeController, typeof AIReviewModeUI, typeof AIReviewCoreEditing];
/**
* @inheritDoc
*/
static get pluginName(): "AIReviewMode";
/**
* @inheritDoc
*/
static get isOfficialPlugin(): true;
/**
* @inheritDoc
*/
static get isPremiumPlugin(): true;
}
export interface AIReviewModeConfig {
/**
* List of IDs of review commands that will be available in the AI Review feature UI. If not set, all available
* predefined commands will be used. The order of IDs defines the order of commands in the UI.
*
* The list of all predefined commands, used by default:
* - `custom`
* - `correctness`
* - `clarity`
* - `readability`
* - `length`
* - `tone`
*
* The commands can be used selectively and rearranged with this configuration option. For example:
*
* ```ts
* ClassicEditor
* .create( {
* ai: {
* review: {
* availableCommands: [
* 'length', 'tone', 'clarity', 'readability'
* ]
* }
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* @default [ 'custom', 'correctness', 'clarity', 'readability', 'length', 'tone' ]
*/
availableCommands?: Array<string>;
/**
* List of extra review commands that can be added to the AI Review feature.
*
* Keep in mind that each command should have a unique ID that does not collide with predefined commands.
* The `custom` command ID is reserved and cannot be used as an ID for extra command.
*
* To add a command and expose it in the UI, first a command definition needs to be provided:
*
* ```ts
* ClassicEditor
* .create( {
* ai: {
* review: {
* extraCommands: [
* {
* id: 'improve-captions',
* label: 'Improve Captions',
* description: 'Improve image captions in the document.',
* prompt: 'Suggest improvements for the image captions in the document.',
* },
* {
* id: 'expand-abbreviations',
* label: 'Expand Abbreviations',
* description: 'Expand abbreviations in the document.',
* prompt: 'Suggest expansions for abbreviations in the document.',
* model: 'gpt-5-2' // Optional, if not set, default model will be used.
* }
* ]
* }
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* Then if {@link #availableCommands} is not set, the extra commands will be added to the end of the list of available
* commands and visible in the UI by default. Otherwise, the extra commands need to be explicitly added to the list
* of available commands to be exposed in the UI:
*
* ```ts
* ClassicEditor
* .create( {
* ai: {
* review: {
* extraCommands: [ ... ],
* availableCommands: [
* 'custom', 'correctness', 'clarity', 'readability', 'length', 'tone', 'improve-captions', 'expand-abbreviations'
* ]
* }
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*/
extraCommands?: Array<AIReviewCustomCommand>;
}
export type AIReviewCustomCommand = {
id: string;
label: string;
description: string;
prompt: string;
model?: string;
};