/** * @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/aiquickactions/ui/balloon/aiactionsballoonview */ import { type ViewWithFocusCycler } from "@ckeditor/ckeditor5-ui"; import { type Locale } from "@ckeditor/ckeditor5-utils"; import { type AISuggestionActionName } from "../../../aichat/ui/feed/aichatfeedsuggestionitemactionsview.js"; import { type AIMiniToolbarConfig } from "../../../aicore/ui/suggestioncontainer/aiminitoolbarview.js"; import { type AIContentRenderingStrategy } from "../../../aicore/ui/suggestioncontainer/aisuggestionstreamablecontentview.js"; import { type AISuggestionContentPartDefinition } from "../../../aicore/utils/getsuggestionpartsfromreply.js"; import { AIBalloonView } from "../../../aiballoon/ui/aiballoonview.js"; /** * Event names that can be fired by the AI Balloon view. */ export declare const AI_ACTIONS_BALLOON_VIEW_EVENT_NAMES: readonly ["applySuggestion", "insertSuggestion"]; /** * Configuration object for creating AI Balloon content. */ export interface AIActionsBalloonViewConfig { showApplyButton: boolean; showSuggestButton: boolean; miniToolbarConfig: AIMiniToolbarConfig; availableActions: Array; } /** * The AI Actions Balloon view class responsible for creating and managing the balloon dialog UI. * * This view handles: * - Focus management and keyboard navigation * - Event firing for suggestion interactions * - Toolbar and disclaimer management */ export declare class AIActionsBalloonView extends AIBalloonView implements ViewWithFocusCycler { /** * Observable property that indicates whether the view is busy. * * It is set to `true` when there are AI response being streamed or rendered. */ isBusy: boolean; /** * Whether the target editor is read-only. When `true`, the apply/suggest buttons are disabled (running is still allowed). * * @observable */ isTargetReadOnly: boolean; constructor(locale: Locale, config: AIActionsBalloonViewConfig); /** * @inheritDoc */ override render(): void; /** * @inheritDoc */ override destroy(): void; /** * Focuses the balloon view. */ focus(direction?: 1 | -1): void; /** * Sets the view loading state, enabling or disabling all interactive elements. */ setIsLoading(isLoading: boolean): void; /** * Disables specific buttons (show changes) for error state. */ setErrorState(): void; /** * Re-enables specific buttons (show changes) after clearing error state. */ clearErrorState(): void; /** * Shows an error message in the balloon. */ override showError(message: string): void; /** * Clears the error state, re-enabling the previously disabled buttons (apply, suggest, etc.). */ override hideError(): void; /** * Displays a blocking error message and disables the toolbar buttons. */ override showBlockingError(message: string): void; /** * Shows the loader if it exists. */ showLoader(): void; /** * Hides the loader if it exists. */ hideLoader(): void; /** * Updates the main content view of the balloon. * This method replaces the current main view with a new one without recreating the entire balloon. * * @param options The content update options. */ updateContent(options: { part: AISuggestionContentPartDefinition; renderingStrategy: AIContentRenderingStrategy; abortSignal?: AbortSignal; }): Promise; /** * Removes streaming artifacts after all chunks have been received. */ finalizeContent(): void; /** * Clears the main content of the view. */ clearContent(): void; /** * Starts auto-scrolling to the bottom during streaming. */ startAutoScroll(): void; /** * Stops auto-scrolling. */ stopAutoScroll(): void; toggleIsLoading(isLoading: boolean): void; /** * Resets the show changes button to default state (off). */ resetShowChangesButton(): void; } /** * Event fired when user clicks the apply button to apply a suggestion. */ export type AIActionsBalloonApplySuggestionEvent = { name: "applySuggestion"; args: []; }; /** * Event fired when user clicks the insert/suggest button to insert a suggestion. */ export type AIActionsBalloonInsertSuggestionEvent = { name: "insertSuggestion"; args: []; }; /** * Event fired when user clicks the try again button. */ export type AIActionsBalloonTryAgainEvent = { name: "tryAgain"; args: []; }; /** * Event fired when user toggles the suggestion display mode. */ export type AIActionsBalloonToggleSuggestionDisplayModeEvent = { name: "toggleSuggestionDisplayMode"; args: [{ showDiff: boolean; }]; };