@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
107 lines (106 loc) • 3.78 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/aichat/ui/aichatballoonview
*/
import { type Locale } from '@ckeditor/ckeditor5-utils';
import { type AISuggestionActionName } from './feed/aichatfeedsuggestionitemactionsview.js';
import { type AISuggestionContentPartDefinition } from '../../aicore/utils/getsuggestionpartsfromreply.js';
import { type AIContentRenderingStrategy } from '../../aicore/ui/suggestioncontainer/aisuggestionstreamablecontentview.js';
import { AIBalloonView } from '../../aiballoon/ui/aiballoonview.js';
import { ButtonView, FocusCycler, type ViewCollection } from '@ckeditor/ckeditor5-ui';
import { type AIReplyChangeGroupState } from '../../aicore/model/aireply.js';
import '../../../theme/aichat/aichatballoon.css';
export type AIChatBalloonViewConfig = {
showApplyButton: boolean;
showSuggestButton: boolean;
availableActions: Array<AISuggestionActionName>;
};
/**
* A view that displays the AI Chat suggestion preview in the `AIBalloon` dialog.
*
* It also injects previous and next suggestion buttons into the dialog header.
*/
export declare class AIChatBalloonView extends AIBalloonView {
children: ViewCollection;
/**
* View that displays the next rotator button. Injected by `AIChatBalloon` into the dialog header.
*/
nextButtonView: ButtonView;
/**
* View that displays the previous rotator button. Injected by `AIChatBalloon` into the dialog header.
*/
previousButtonView: ButtonView;
/**
* Focus cycler for the balloon view that allows users to navigate through the balloon using the keyboard
* as well as focus the view on demand.
*/
focusCycler: FocusCycler;
/**
* Observable property that indicates whether the suggestion display mode is "show changes".
*/
showDiff: boolean;
/**
* Observable property that indicates whether the track changes are on.
*/
isTrackChangesOn: boolean;
/**
* @inheritDoc
*/
constructor(locale: Locale, config: AIChatBalloonViewConfig);
/**
* @inheritDoc
*/
render(): void;
/**
* @inheritDoc
*/
destroy(): void;
/**
* Focuses the first focusable child view.
*/
focus(): void;
/**
* Focuses the last focusable child view.
*/
focusLast(): void;
/**
* Updates the content of the balloon.
*/
updateContent(options: {
part: AISuggestionContentPartDefinition;
renderingStrategy: AIContentRenderingStrategy;
abortSignal?: AbortSignal;
keepErrors?: boolean;
}): Promise<void>;
/**
* Sets the state of the suggestion part displayed in the balloon.
*/
setState(state: AIReplyChangeGroupState): void;
/**
* Shows an error message in the balloon.
*/
showError(message: string): void;
/**
* Hides the error message in the balloon and re-enables the toolbar buttons.
*/
hideError(): void;
/**
* Displays a blocking error message and disables the toolbar buttons.
*/
showBlockingError(message: string): void;
/**
* Toggles the visibility of the rotator buttons.
*/
toggleRotatorButtonsVisibility(isVisible: boolean): void;
/**
* Toggles the enabled state of the content part toolbar based on the flag.
*
* * Those buttons may become disabled because there's an error in the view.
* * Those buttons may become disabled despite pending state of the suggestion part, for instance, if the suggestion
* was loaded from the history.
*/
togglePartToolbarEnabled(isEnabled: boolean): void;
}