@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
65 lines (64 loc) • 2.09 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/aiquickactions/ui/aiquickactionsbuttoncreator
*/
import { type Editor } from 'ckeditor5/src/core.js';
import { ButtonView } from 'ckeditor5/src/ui.js';
import { type AIQuickActionDefinition } from '../aiquickactionsui.js';
/**
* Configuration options for aiQuickActionsButtonCreator.
*/
export interface AIQuickActionsButtonCreatorOptions {
/**
* The CKEditor instance that will contain the button.
*/
editor: Editor;
/**
* The AI quick action definition containing configuration.
*/
action: AIQuickActionDefinition;
/**
* Whether to show the text label on the button.
*
* @default false
*/
withText?: boolean;
/**
* Whether to show the icon on the button.
*
* @default true
*/
withIcon?: boolean;
/**
* Whether the button is in a dropdown.
*
* @default true
*/
isInDropdown?: boolean;
/**
* Optional callback to check if focus should be prevented.
*
* @default false
*/
shouldPreventFocus?: () => boolean;
}
/**
* Creates a button factory function for AI Quick Actions.
*
* This function returns a factory that creates ButtonView instances for individual AI quick actions.
* Each button is configured with the action's properties (label, icon, type) and sets up the
* execution logic that triggers the AI command when clicked.
*
* The button automatically:
* - Uses the action's icon or falls back to parent group icon or default icon
* - Focuses the editor when executed
* - Hides any open balloon toolbar
* - Executes the aiQuickActions command with the action details
*
* @param options Configuration options for the button creator
* @returns Factory function that creates a ButtonView instance
*/
export declare function aiQuickActionsButtonCreator(options: AIQuickActionsButtonCreatorOptions): () => ButtonView;