/** * @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/aiediting */ import { type ModelRange, type ModelDocumentFragment } from "@ckeditor/ckeditor5-engine"; import { ContextPlugin, type Context, Editor } from "@ckeditor/ckeditor5-core"; import { type AIEditorConfig } from "./utils/geteditorconfig.js"; export declare const AI_VISUAL_SELECTION_MARKER_NAME = "ai-selection"; export declare class AIEditing extends ContextPlugin { /** * @inheritDoc */ constructor(context: Context | Editor); /** * @inheritDoc */ static get pluginName(): "AIEditing"; /** * @inheritDoc */ static override get isOfficialPlugin(): true; /** * @inheritDoc */ static override get isPremiumPlugin(): true; /** * Returns the session ID for the given editor. If the editor has the * {@link module:real-time-collaboration/realtimecollaborativeediting/realtimecollaborationclient~RealTimeCollaborationClient} * plugin its `sessionId` is reused; otherwise a random id is generated on first call and cached for the editor's lifetime. * * The session id is used to determine whether AI chat changes were created in the same editing session (and therefore * can be safely applied) or in a different one. Each editor in the context has its own session id, so multi-editor and * multi-root setups can route the mismatch check against the editor that actually produced the change. */ getSessionId(editor: Editor): string; /** * Returns the data and version of each document (one entry per editor root, excluding `$graveyard`). * * `rootName` and `channelId` identify the source of each entry so callers can remap AI modifications back to the editor and root * they came from. * * Note, that this method is async and does significant processing if the editor data is big or custom output processor is registered. * If you just want to fetch the session id or document version, use {@link #getSessionId} and {@link #getEditorsVersions}. */ getDocumentData(channelIds?: Set): Promise>; afterInit(): void; /** * Displays a fake visual selection on given ranges. * * Since multiple features may want to show and hide the selection, while at the same time, only one fake selection should be shown, * it is necessary to provide an `id` when showing fake selection. Then, when the fake selection should be hidden, `id` must be * passed as well. This mechanism prevents a feature from mistakenly hiding a fake selection set by another feature. */ showFakeVisualSelection(fakeSelectionData: FakeSelectionData): void; /** * Removes a fake visual selection from the document. * * @param id ID of the fake visual selection to remove. */ hideFakeVisualSelection(id: string): void; modelToDataWithIds(modelFragment: ModelDocumentFragment, editor: Editor, rootName?: string): Promise; } /** * A single document entry returned by {@link module:ai/aicore/aiediting~AIEditing#getDocumentData `AIEditing#getDocumentData()`}. One * entry per editor model root (excluding `$graveyard`); `editor` + `rootName` identify the source root so callers can route AI * modifications back to the correct place. */ export type AIEditingDocumentData = { editor: Editor; rootName: string; content: string; version: number; sessionId: string; channelId: string; selections: Array<{ markerName: string; start: number; end: number; htmlFragment: string; }>; selectionSignature: string; editorConfig: AIEditorConfig; name?: string; description?: string; }; type FakeSelectionData = { /** * Ranges on which fake selection should be shown. */ ranges: Array; /** * Fake selection ID. * * Used when removing fake selection. * * Used as a part of CSS class set on fake selection DOM elements (`ck-fake-ai-selection-${ id }`). */ id: string; /** * Fake selection priority. * * There can be only one fake selection displayed at once. Priority is used to inform which fake selection should be displayed when * multiple features asked to show fake selection on different ranges. */ priority: number; /** * Editor instance in which the fake selection is created. */ editor: Editor; }; export {};