@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
119 lines (118 loc) • 4.28 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/aichat/ui/aichatfeedview
*/
import { type Locale } from 'ckeditor5/src/utils.js';
import { View, type ViewCollection, type BodyCollection } from 'ckeditor5/src/ui.js';
import { type AIChatFeedItemView } from './feed/aichatfeeditemview.js';
import { type AIContentRenderingStrategy } from '../../aicore/ui/suggestioncontainer/aisuggestioncontentpartview.js';
import { type Document } from '../../aicore/utils/htmlparser.js';
import { AIChatFeedSuggestionItemView } from './feed/aichatfeedsuggestionitemview.js';
import { AIChatFeedReplyItemView } from './feed/aichatfeedreplyitemview.js';
import { AIChatFeedUserMessageItemView } from './feed/aichatfeedusermessageitem.js';
import { AIChatFeedErrorItemView } from './feed/aichatfeederroritemview.js';
import { AIChatFeedInteractionHeaderView } from './feed/aichatfeedinteractionheaderview.js';
import { type AISuggestionContentPartDefinition } from '../../aicore/utils/getsuggestionpartsfromreply.js';
import { type AIReplyChangeGroupState, type AIReplySource } from '../../aicore/model/aireply.js';
/**
* A view that displays the chat feed with various items.
*/
export declare class AIChatFeedView extends View {
/**
* A collection of feed items.
*/
readonly children: ViewCollection<AIChatFeedItemView>;
/**
* The pending state of the feed. It indicates whether the feed is currently processing
* a response, meaning there is an active interaction.
*
* @observable
*/
isPending: boolean;
/**
* The loading message displayed when the feed is processing a response.
*
* @observable
*/
loadingMessage: string;
isLoadingSkeletonVisible: boolean;
/**
* @observable
*/
isTrackChangesOn: boolean;
/**
* @inheritDoc
*/
constructor(locale: Locale, bodyCollection: BodyCollection);
render(): void;
destroy(): void;
/**
* Removes all items from the feed.
*/
clear(): void;
/**
* Adds a new item to the feed.
*/
addItem<T extends keyof ChatFeedAddItemTypesInstances>(itemType: T, options: ChatFeedAddItemTypesInstances[T]['options']): void;
/**
* Updates the content of an item in the feed.
*
* **Note**: The content is updated (streamed) asynchronously.
*/
updateReplyItem({ id, parsedContent, renderingStrategy, abortSignal }: {
id: string;
parsedContent: Document;
renderingStrategy: AIContentRenderingStrategy;
abortSignal: AbortSignal;
}): Promise<void>;
updateWebSources(id: string, sources: Array<AIReplySource>): Promise<void>;
updateSuggestionItem({ id, parts, renderingStrategy, abortSignal }: {
id: string;
parts: Array<AISuggestionContentPartDefinition>;
renderingStrategy: AIContentRenderingStrategy;
abortSignal: AbortSignal;
}): Promise<void>;
updateSuggestionPartState({ id, index, state }: {
id: string;
index: number;
state: AIReplyChangeGroupState;
}): void;
/**
* Marks an item as done.
*
* **Note**: Marking the item as done cleans up the streaming animations.
*/
markItemAsDone(id: string): void;
/**
* Returns all item ids.
*/
getItemIds(): Array<string>;
/**
* Removes an item from the feed.
*/
removeItem(id: string): void;
scrollToSuggestion(replyId: string, partIndex: number): void;
setLoadingMessage(message: string): void;
/**
* Toggles the loading skeleton in the feed.
*/
toggleLoadingSkeleton(isLoading: boolean): void;
/**
* Starts the auto-scrolling of the feed.
*/
startAutoScroll(): void;
/**
* Stops the auto-scrolling of the feed.
*/
stopAutoScroll(): void;
}
export interface ChatFeedAddItemTypesInstances {
'interaction-header': AIChatFeedInteractionHeaderView;
'ai-reply': AIChatFeedReplyItemView;
'ai-suggestion-reply': AIChatFeedSuggestionItemView;
'user-message': AIChatFeedUserMessageItemView;
'error-message': AIChatFeedErrorItemView;
}