UNPKG

@promptbook/markdown-utils

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

52 lines (51 loc) 2.19 kB
import { type ChangeEvent, type KeyboardEvent as ReactKeyboardEvent, type MutableRefObject } from 'react'; import type { ChatMessage } from '../types/ChatMessage'; import type { ChatInputUploadedFile } from './ChatInputUploadedFile'; import type { ChatProps, ChatSoundSystem } from './ChatProps'; /** * One programmatic request to replace the composer content with an editable draft. * * A fresh object identity is used for every request so repeated draft insertions * (even with identical text) re-apply to the composer. * * @private function of `<ChatInputArea/>` */ export type ChatComposerDraft = { readonly content: string; }; /** * Props for `useChatInputAreaComposer`. * * @private function of `<ChatInputArea/>` */ type UseChatInputAreaComposerProps = { readonly onMessage?: ChatProps['onMessage']; readonly onChange?: ChatProps['onChange']; readonly defaultMessage?: string; readonly draftMessage?: ChatComposerDraft; readonly enterBehavior?: ChatProps['enterBehavior']; readonly resolveEnterBehavior?: ChatProps['resolveEnterBehavior']; readonly isFocusedOnLoad?: boolean; readonly isMobile: boolean; readonly uploadedFiles: ReadonlyArray<ChatInputUploadedFile>; readonly uploadedFilesRef: MutableRefObject<Array<ChatInputUploadedFile>>; readonly clearUploadedFiles: () => void; readonly replyingToMessage?: ChatMessage | null; readonly onCancelReply?: ChatProps['onCancelReply']; readonly soundSystem?: ChatSoundSystem; }; /** * Manages textarea state, send/newline behavior, and deferred Enter resolution for `<ChatInputArea/>`. * * @private function of `<ChatInputArea/>` */ export declare function useChatInputAreaComposer(props: UseChatInputAreaComposerProps): { textareaRef: import("react").RefObject<HTMLTextAreaElement | null>; messageContent: string; messageContentRef: import("react").RefObject<string>; applyMessageContent: (nextContent: string) => void; handleTextInputChange: (event: ChangeEvent<HTMLTextAreaElement, Element>) => void; handleComposerKeyDown: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void; handleSend: () => Promise<void>; }; export {};