@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
114 lines (113 loc) • 3.67 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/aiballoon/aiballoon
*/
import { ContextPlugin, type Editor } from '@ckeditor/ckeditor5-core';
import { AIEditing } from '../aicore/aiediting.js';
import '../../theme/aiballoon/aiballoon.css';
import { type ModelRange } from '@ckeditor/ckeditor5-engine';
import { type AIBalloonView } from './ui/aiballoonview.js';
/**
* Event names that can be fired by the AI Balloon plugin.
* Includes all view events plus dialog-specific events.
*/
export declare const AI_BALLOON_EVENT_NAMES: readonly ["applySuggestion", "insertSuggestion", "showNext", "showPrevious", "dialogClosed", "selectionRemoved"];
/**
* Configuration object for opening the AI Balloon.
*/
export interface AIBalloonConfig {
id: string;
index: number;
title: string;
icon?: string;
mainView: AIBalloonView;
ranges: Array<ModelRange>;
class: string;
/**
* The editor the balloon should anchor to. When provided (multi-root / multi-instance setups), it takes precedence over the
* focus-based heuristic used by {@link module:ai/aicore/utils/geteditorfromcontext~getEditorFromContext} — otherwise clicking a
* chat-sidebar suggestion chip routes the balloon to whichever editor happens to be focused, which collapses dialog positioning
* when the chip's target range lives on a different editor or root.
*/
targetEditor?: Editor;
}
/**
* The AI Balloon plugin provides a balloon dialog interface for displaying and interacting with AI suggestions.
*/
export declare class AIBalloon extends ContextPlugin {
/**
* @inheritDoc
*/
static get requires(): readonly [typeof AIEditing];
/**
* @inheritDoc
*/
static get pluginName(): "AIBalloon";
/**
* @inheritDoc
*/
static get isOfficialPlugin(): true;
/**
* @inheritDoc
*/
static get isPremiumPlugin(): true;
/**
* A flag indicating whether the AI Balloon dialog is currently open.
*/
isOpen: boolean;
/**
* Opens the AI Balloon dialog with the provided configuration.
*
* @param config Configuration object containing dialog settings and content data
*/
open(config: AIBalloonConfig): void;
/**
* Closes the currently open AI Balloon dialog.
*/
close(): void;
}
/**
* Event fired when the AI balloon dialog is closed. As opposed to `beforeDialogClosed`, this event is fired
* after the dialog's core view has been destroyed and the dialog is no longer visible.
*/
export type AIBalloonDialogClosedEvent = {
name: 'dialogClosed';
args: [{
id: string;
}];
};
/**
* Event fired when the AI balloon dialog is about to be closed. It gives plugins a chance
* to salvage their views if they were injected into the dialog before they get destroyed along with
* the dialog's core view.
*/
export type AIBalloonBeforeDialogClosedEvent = {
name: 'beforeDialogClosed';
args: [{
id: string;
}];
};
/**
* Event fired when the AI selection related to the balloon is removed.
*/
export type AIBalloonSelectionRemovedEvent = {
name: 'selectionRemoved';
args: [];
};
/**
* Event fired when user clicks the next suggestion button in the rotator.
*/
export type AIBalloonShowNextSuggestionEvent = {
name: 'showNext';
args: [];
};
/**
* Event fired when user clicks the previous suggestion button in the rotator.
*/
export type AIBalloonShowPreviousSuggestionEvent = {
name: 'showPrevious';
args: [];
};