/** * @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/aicore/aieditorconfig * @publicApi */ import { ContextPlugin, type Editor } from "@ckeditor/ckeditor5-core"; import { type AlignmentConfig } from "@ckeditor/ckeditor5-alignment"; import { type CodeBlockConfig } from "@ckeditor/ckeditor5-code-block"; import { type FontSizeConfig, type FontFamilyConfig, type FontColorConfig } from "@ckeditor/ckeditor5-font"; import { type FootnotesConfig } from "@ckeditor/ckeditor5-footnotes"; import { type HeadingConfig } from "@ckeditor/ckeditor5-heading"; import { type HighlightConfig } from "@ckeditor/ckeditor5-highlight"; import { type ImageConfig } from "@ckeditor/ckeditor5-image"; import { type IndentBlockConfig } from "@ckeditor/ckeditor5-indent"; import { type TextPartLanguageOption } from "@ckeditor/ckeditor5-language"; import { type LineHeightConfig } from "@ckeditor/ckeditor5-line-height"; import { type LinkConfig } from "@ckeditor/ckeditor5-link"; import { type ListConfig } from "@ckeditor/ckeditor5-list"; import { type MentionConfig } from "@ckeditor/ckeditor5-mention"; import { type MergeFieldsConfig } from "@ckeditor/ckeditor5-merge-fields"; import { type MultiLevelListConfig } from "@ckeditor/ckeditor5-list-multi-level"; import { type StyleConfig } from "@ckeditor/ckeditor5-style"; import { type TableConfig } from "@ckeditor/ckeditor5-table"; import { type MediaEmbedConfig } from "@ckeditor/ckeditor5-media-embed"; import { type GeneralHtmlSupportConfig } from "@ckeditor/ckeditor5-html-support"; import { type RestrictedEditingConfig } from "@ckeditor/ckeditor5-restricted-editing"; /** * The plugin that describes the editor's feature capabilities to the AI agent. * * It builds a {@link ~AIEditorConfig#get compact, serializable snapshot} of the features loaded in an editor and * lets custom plugins {@link ~AIEditorConfig#add register their own features} so that the AI agent can produce and * preserve their content. */ export declare class AIEditorConfig extends ContextPlugin { /** * @inheritDoc */ static get pluginName(): "AIEditorConfig"; /** * @inheritDoc */ static override get isOfficialPlugin(): true; /** * @inheritDoc */ static override get isPremiumPlugin(): true; /** * Registers a custom editor feature (plugin) with the AI agent. It allows the AI agent to match the existing * [custom skill](https://ckeditor.com/docs/cs/latest/guides/ckeditor-ai/extensions/skills.html) with a specific custom editor feature. * * This is a mandatory step for any custom plugin that introduces content the AI agent should be able to produce or preserve. * * Example of using this API in a custom plugin's `init()` method: * * ```ts * if ( this.editor.plugins.has( 'AIEditorConfig' ) ) { * // The name must correspond to the "configKey" property of the custom skill to be used by the AI agent. * // Use empty object as the configuration when the feature has no practical configuration. * this.editor.plugins.get( 'AIEditorConfig' ).add( this.editor, 'myCustomFeature', { * // Configuration that may be relevant to the AI agent for producing or preserving the feature's content. * someKey: 'someValue' * } ); * } * ``` * * Learn more about registering custom editor features with the AI agent in the * {@glink features/ai/ckeditor-ai-feature-understanding#registering-custom-features dedicated guide}. * * **Note**: Editor comes with a set built-in features and corresponding skills. It is not possible to override configuration of * a core editor feature with a custom feature using this API. The used name must be unique. * * @param editor The editor the feature is registered for. * @param name The key under which the feature is reported. It must correspond to the `configKey` property of the custom * skill to be used by the AI agent. * @param config The configuration of the feature. It should pass information relevant to the AI agent for producing or * preserving the feature's content. Use empty object when the feature has no practical configuration. */ add(editor: Editor, name: string, config: Record): void; /** * Builds a compact, serializable snapshot of the editor's feature capabilities for the AI agent. * * The returned object is keyed by feature. A key is present only when the feature's plugin is loaded, so the agent * can tell at a glance what content the editor is able to produce: * * * For configurable features, the value is that feature's configuration with UI-only options stripped out * (toolbars, color pickers, icons, labels, keystrokes, dropdown limits, preview machinery, …), leaving only the * options that actually shape the document data. * * For features that expose no data-relevant configuration, the value is an empty object acting purely as a * presence flag. * * Knowing both which features are available and how they are configured (e.g. the allowed heading levels, font * sizes or table properties) lets the agent keep its edits within what the editor can represent. * * On top of the features, the snapshot describes the root it was gathered for in * the {@link ~AIEditorConfigSnapshot `rootType`} property — what that root can hold and what surrounds it. A snapshot is * therefore specific to one root, which matters for editors with more than one. * * Features registered by custom plugins through {@link #add `add()`} are added on top of the built-in ones. * Their names are checked against the built-in keys when they are registered, so they never overwrite a built-in feature. * * @param editor The editor whose feature configuration is gathered. * @param rootName The name of the root the snapshot is gathered for. * @returns The editor's feature capabilities snapshot. */ get(editor: Editor, rootName: string): AIEditorConfigSnapshot; } /** * A compact, serializable snapshot of the editor's feature capabilities, returned by * {@link module:ai/aicore/aieditorconfig~AIEditorConfig#get `AIEditorConfig#get()`}. * * It consists of: * * * {@link module:ai/aicore/aieditorconfig~AIEditorConfigFeatureConfigs Configurations of the built-in configurable features}, * * {@link module:ai/aicore/aieditorconfig~AIEditorConfigPresenceFlags presence flags of the built-in features} * that expose no data-relevant configuration, * * {@link module:ai/aicore/aieditorconfig~AIEditorConfigCustomFeatures features registered by custom plugins}, * * information about the root and the editor version (see below). */ export type AIEditorConfigSnapshot = AIEditorConfigFeatureConfigs & AIEditorConfigPresenceFlags & AIEditorConfigCustomFeatures & { /** * A snapshot of the root the document relates to: whether it is an inline root and which element hosts it. */ rootType: AIRootInfo; /** * The version of CKEditor 5 the snapshot was taken from. Tells the agent which editor release its capabilities describe. */ editorVersion: string; }; /** * A snapshot of a single editor root, reported in the {@link ~AIEditorConfigSnapshot `rootType`} property of * the {@link ~AIEditorConfig#get editor configuration snapshot}. * * It tells the AI agent what the root can hold and what surrounds it, so it can keep its edits within the shape of that * root: an inline root cannot take block content at all, and a root hosted by a semantic element (a `

` title, * a `` label) implies a different tone and length than a full-page `
`. */ export interface AIRootInfo { /** * Whether the root is an inline root, that is, whether it rejects block content and behaves like a single * paragraph. Content of such a root must stay inline-only. */ isInline: boolean; /** * The tag name of the element hosting the root, for example `div` for a regular rich-text area or `h1` for a * title mounted on a heading. * * This element surrounds the root - it is not part of the root's content and cannot be edited. It must not be * reproduced in content produced for this root. */ hostElement: string; } /** * The configurable features reported in the {@link ~AIEditorConfig#get editor configuration snapshot}. * * A key is present only when the feature's plugin is loaded. Its value is the feature's configuration with * UI-only options stripped out, leaving only the options that shape the document data. */ export type AIEditorConfigFeatureConfigs = { alignment?: AlignmentConfig; codeBlock?: CodeBlockConfig; fontBackgroundColor?: FontColorConfig; fontColor?: FontColorConfig; fontFamily?: FontFamilyConfig; fontSize?: FontSizeConfig; footnotes?: FootnotesConfig; htmlSupport?: GeneralHtmlSupportConfig; heading?: HeadingConfig; highlight?: HighlightConfig; image?: ImageConfig; indentBlock?: IndentBlockConfig; lineHeight?: LineHeightConfig; link?: LinkConfig; list?: ListConfig; listMultiLevel?: MultiLevelListConfig; mediaEmbed?: MediaEmbedConfig; mention?: MentionConfig; mergeFields?: MergeFieldsConfig; restrictedEditingMode?: Omit; style?: StyleConfig; table?: TableConfig; textPartLanguage?: Array; }; /** * The features reported in the {@link ~AIEditorConfig#get editor configuration snapshot} that expose no * data-relevant configuration. * * A key is set to an empty object only when the feature's plugin is loaded, acting purely as a presence flag. * It is absent otherwise. */ export type AIEditorConfigPresenceFlags = { blockQuote?: object; bold?: object; bookmark?: object; code?: object; horizontalLine?: object; htmlEmbed?: object; italic?: object; math?: object; pageBreak?: object; paragraph?: object; restrictedEditing?: object; shiftEnter?: object; strikethrough?: object; subscript?: object; superscript?: object; tableOfContents?: object; title?: object; todoList?: object; underline?: object; }; /** * Features registered by custom plugins through * {@link module:ai/aicore/aieditorconfig~AIEditorConfig#add `AIEditorConfig#add()`}, reported in the * {@link ~AIEditorConfig#get editor configuration snapshot}. * * Each key is the name of a registered feature and its value is the configuration passed during registration * (with regular expressions converted to strings). Custom feature names never collide with the built-in keys * of the snapshot. */ export type AIEditorConfigCustomFeatures = { [customFeatureName: string]: unknown; };