import { FormatType } from "../../utils/RichTextFormatting"; import { CometChatTextFormatter } from "../../formatters/CometChatFormatters/CometChatTextFormatter"; /** * Configuration for the useRichTextComposer hook */ export interface RichTextComposerConfig { enableRichTextEditor: boolean; hideRichTextFormattingOptions: boolean; showToolbarOnSelection: boolean; getCurrentDocument: () => Document; getCurrentWindow: () => Window; getCurrentInput: () => Element | null | undefined; composerContainerClass: string; errorHandler: (error: unknown, context: string) => void; setTextFormatters: React.Dispatch>; } export interface LinkPopoverData { linkText: string; linkUrl: string; linkElement: HTMLAnchorElement | null; position: { top: number; left: number; }; } export interface LinkEditData { url: string; text: string; } /** * State for undoing markdown conversions */ export interface MarkdownUndoState { originalHtml: string; cursorPosition: number; timestamp: number; } /** * Shared hook that encapsulates all rich text formatting logic * used by both CometChatMessageComposer and CometChatCompactMessageComposer. */ export declare function useRichTextComposer(config: RichTextComposerConfig): { isFixedToolbarVisible: boolean; setIsFixedToolbarVisible: import("react").Dispatch>; isFloatingToolbarVisible: boolean; setIsFloatingToolbarVisible: import("react").Dispatch>; floatingToolbarPosition: { top: number; left: number; } | null; activeFormats: FormatType[]; setActiveFormats: import("react").Dispatch>; showLinkInput: boolean; showLinkPopover: boolean; linkPopoverData: LinkPopoverData | null; isLinkEditMode: boolean; linkEditData: LinkEditData | null; linkDialogSelectedText: string; linkDialogSelectedTextRef: import("react").MutableRefObject; richTextFormatter: { getSelection: () => Selection | null; saveSelection: () => Range | null; restoreSelection: (range: Range | null) => void; hasSelection: () => boolean; getSelectedText: (savedRange?: Range | null) => string; isFormatted: (formatType: FormatType, containerElement: HTMLElement) => boolean; isFormattingModeActive: () => boolean; getActiveFormats: (containerElement: HTMLElement) => FormatType[]; getActiveFormattingModes: () => FormatType[]; findFormattingAncestor: () => HTMLElement | null; applyFormat: () => void; removeFormat: () => void; toggleFormat: (formatType: FormatType, containerElement: HTMLElement) => void; toggleFormattingMode: () => void; toggleBold: (containerElement: HTMLElement) => void; toggleItalic: (containerElement: HTMLElement) => void; toggleUnderline: (containerElement: HTMLElement) => void; toggleStrikethrough: (containerElement: HTMLElement) => void; insertLink: (url: string, displayText: string | undefined, containerElement: HTMLElement) => void; updateLink: (url: string, displayText: string | undefined, containerElement: HTMLElement) => void; removeLink: (containerElement: HTMLElement) => void; isInsideLink: (containerElement: HTMLElement) => boolean; toggleOrderedList: (containerElement: HTMLElement) => void; toggleUnorderedList: (containerElement: HTMLElement) => void; fixOrderedListContinuation: (containerElement: HTMLElement) => void; isInsideList: (listType: "orderedList" | "unorderedList", containerElement: HTMLElement) => HTMLElement | null; isInsideAnyList: (containerElement: HTMLElement) => HTMLElement | null; getCurrentListItem: (containerElement: HTMLElement) => HTMLLIElement | null; isCurrentListItemEmpty: (containerElement: HTMLElement) => boolean; isCursorAtListItemStart: (containerElement: HTMLElement) => boolean; handleListBackspace: (containerElement: HTMLElement) => boolean; handleListEnter: (containerElement: HTMLElement) => boolean; handleListTab: (containerElement: HTMLElement, shiftKey: boolean) => boolean; handleCodeBlockEnter: (containerElement: HTMLElement) => boolean; handleCodeBlockBackspace: (containerElement: HTMLElement) => boolean; handleAutoListTrigger: (containerElement: HTMLElement) => "orderedList" | "unorderedList" | null; applyListInlineStyles: (containerElement: HTMLElement) => void; toggleBlockquote: (containerElement: HTMLElement) => void; isInsideBlockquote: (containerElement: HTMLElement) => HTMLElement | null; toggleCodeInline: (containerElement: HTMLElement) => void; toggleCodeBlock: (containerElement: HTMLElement) => void; isInsideCodeInline: (containerElement: HTMLElement) => HTMLElement | null; isInsideCodeBlock: (containerElement: HTMLElement) => HTMLElement | null; handleInlineCodePreservation: (containerElement: HTMLElement, wasInsideInlineCode: boolean) => void; clearFormattingModes: () => void; resetFontContext: (containerElement?: HTMLElement) => void; handleKeyboardShortcut: (event: KeyboardEvent, containerElement: HTMLElement) => boolean; handleArrowKeyInCode: (event: KeyboardEvent, containerElement: HTMLElement) => boolean; getPlainText: (htmlContent: string) => string; normalizeHtml: (htmlContent: string) => string; trimRichTextWhitespace: (html: string | null | undefined) => string; handleMarkdownShortcuts: (containerElement: HTMLElement, onBeforeConversion?: () => void) => boolean; clearPendingFormats: () => void; getPendingFormats: () => FormatType[]; getTextOffsetAtCursor: (containerElement: HTMLElement) => number; setCursorByTextOffset: (containerElement: HTMLElement, offset: number) => void; convertMarkdownToFormat: (containerElement: HTMLElement, startOffset: number, endOffset: number, contentStart: number, contentEnd: number, formatType: FormatType, linkUrl?: string) => void; positionCursorAfterFormat: (containerElement: HTMLElement, formattedNode: Node) => void; applyMarkdownConversion: (containerElement: HTMLElement, match: { startOffset: number; endOffset: number; contentStart: number; contentEnd: number; linkUrl?: string; }, formatType: FormatType) => void; } | null; handleLinkClick: () => void; handleLinkSubmit: (url: string, displayText?: string) => void; handleLinkCancel: () => void; handleInputClick: (event: React.MouseEvent) => void; handleLinkPopoverEdit: () => void; handleLinkPopoverRemove: () => void; handleLinkPopoverClose: () => void; handleFormatApplied: () => void; handleFormattingKeyDown: (event: KeyboardEvent, contenteditable: Element) => boolean; saveMarkdownUndoState: () => void; handleMarkdownUndo: () => boolean; };