@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
58 lines (57 loc) • 2.44 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/controls/resources/aichatcontextresourcesview
*/
import { View } from '@ckeditor/ckeditor5-ui';
import { type Locale } from '@ckeditor/ckeditor5-utils';
import { type AIContextResourceState, type AIContextProvider } from '../../../model/aichatcontext.js';
/**
* Main view component for AI context resources management.
*
* This view combines a search input and resources list, managing the complete
* user experience for browsing and selecting resources from an AI context provider.
* It handles loading states, search functionality, and resource state updates.
*/
export declare class AIChatContextResourcesView extends View {
/**
* Creates a new AI context resources view.
*
* @param locale The locale instance for internationalization
* @param options.source The AI context provider source for this resources view.
*/
constructor(locale: Locale, options: {
source: AIContextProvider;
searchInputVisibleFrom?: number;
});
/**
* Renders the view and initiates initial resource loading.
*/
render(): void;
/**
* Loads resources for the current source with the given search query.
* Generates a unique identifier to prevent race conditions between requests.
*
* @param query The search query string to filter resources
*/
loadResources(query: string): void;
/**
* Sets the resources to display, with race condition protection.
* Only processes the response if it matches the latest request UID.
* Respects the source's highlighting configuration when setting resources.
*
* @param resources Array of resource states to display
* @param uid Optional unique identifier for the request (for race condition protection)
*/
setResources(resources: Array<AIContextResourceState>, uid?: string): void;
/**
* Updates the state of a specific resource in the list.
* Delegates to the resources list view to handle the actual update.
*
* @param resourceId The unique identifier of the resource to update
* @param isInContext Whether the resource is currently in the context
*/
updateResourceState(resourceId: string, isInContext: boolean): void;
}