@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
100 lines (99 loc) • 3.33 kB
TypeScript
/**
* @license Copyright (c) 2003-2025, 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/ui/aisuggestioncontainer/aisuggestioncontainerview
*/
import { type Locale } from 'ckeditor5/src/utils.js';
import { View, type ViewCollection, ButtonView } from 'ckeditor5/src/ui.js';
import { type AIMiniToolbarConfig } from './aiminitoolbarview.js';
import { type AISuggestionContentPartDefinition } from '../../utils/getsuggestionpartsfromreply.js';
import { type AIContentRenderingStrategy } from './aisuggestioncontentpartview.js';
import { type AIReplySource } from '../../model/aireply.js';
import { type AISuggestionActionName } from '../../../aichat/ui/feed/aichatfeedsuggestionitemactionsview.js';
/**
* This view displays a suggestion from the AI.
*
* It comes with a header with a switch button to show/hide the changes.
*
* It also has a body view and a changes views that are toggled by the toggle button.
*
* It comes with a mini toolbar with copy, like and dislike buttons.
*/
export declare class AISuggestionContainerView extends View<HTMLDivElement> {
/**
* Observable property that indicates whether the view is in loading state.
* When true, all interactive elements should be disabled.
*/
isLoading: boolean;
/**
* @inheritDoc
*/
constructor(locale: Locale, options: AISuggestionContainerViewOptions);
updateContent(options: {
parts: Array<AISuggestionContentPartDefinition>;
renderingStrategy: AIContentRenderingStrategy;
abortSignal?: AbortSignal;
}): Promise<void>;
updateSources(sources: Array<AIReplySource>): void;
/**
* Shows the loader if it exists.
*/
showLoader(): void;
/**
* Hides the loader if it exists.
*/
hideLoader(): void;
/**
* Shows an error message in the suggestion container.
*/
showError(message: string): void;
/**
* Hides the error message.
*/
hideError(): void;
/**
* Marks the suggestion container as done.
*/
markAsDone(): void;
/**
* Sets the view to loading state, disabling all interactive elements.
*/
setLoading(): void;
/**
* Clears the loading state, enabling all interactive elements.
*/
clearLoading(): void;
/**
* Disables specific buttons (show changes) for error state.
*/
setErrorState(): void;
/**
* Re-enables specific buttons (show changes) after clearing error state.
*/
clearErrorState(): void;
}
export type AISuggestionContainerToggleSuggestionDisplayModeEvent = {
name: 'toggleSuggestionDisplayMode';
args: [{
showDiff: boolean;
}];
};
export type AISuggestionContainerViewOptions = {
showDiff: boolean;
areActionsDisabled: boolean;
availableActions: Array<AISuggestionActionName>;
miniToolbarConfig?: AIMiniToolbarConfig;
hideHeader?: boolean;
showLoader?: boolean;
showUnchangedParts?: boolean;
};
export declare class AIWebSourcesView extends View {
children: ViewCollection;
isVisible: boolean;
constructor(locale: Locale);
}
export declare class AIWebSourceView extends ButtonView {
constructor(locale: Locale, source: AIReplySource);
}