/** * useRichTextState - Centralized state management for RichText editing lifecycle. * * Replaces scattered isTextEditing / isTextEditingRef / wasTextEditingRef / activateTextEditing * with a single hook that co-locates state, refs, and transition functions. * * Stores preEditSelection so Escape-from-config-panel can restore the caret reliably. */ import { Range } from 'slate'; export interface RichTextStateResult { /** Whether the user is actively editing text (caret visible). */ isTextEditing: boolean; /** Imperative ref always in sync with isTextEditing (for event handlers that read mid-render). */ isTextEditingRef: React.MutableRefObject; /** Whether the user was text-editing before entering the skip-link/config-panel flow. * Exposed as a ref so document-level event listeners (stale closures) read the latest value. */ wasTextEditingRef: React.MutableRefObject; /** Activate text editing (Enter-to-edit, click-to-edit). */ activateTextEditing: () => void; /** Deactivate text editing (Escape, blur, etc.). Clears preEditSelection. */ deactivateTextEditing: () => void; /** Transition from text-editing to skip-link/config-panel flow. * Stores the current selection so it can be restored on Escape-from-panel. * Sets wasTextEditing = true and isTextEditing = false. */ enterSkipLinkFlow: (selection: Range | null) => void; /** Re-enter text editing from config panel (Escape-from-panel). * Sets isTextEditing = true. preEditSelection is preserved for the caller to read. */ returnFromConfigPanel: () => void; /** Save the pre-edit selection without changing isTextEditing or wasTextEditing. * Used when focus moves to the panel via mouse click (caret should stay visible). */ savePreEditSelection: (selection: Range | null) => void; /** Read the selection that was saved when entering the skip-link flow. */ getPreEditSelection: () => Range | null; /** Reset wasTextEditing to false (after skip-link Enter handler consumes it). */ clearWasTextEditing: () => void; } export declare function useRichTextState(): RichTextStateResult; //# sourceMappingURL=useRichTextState.d.ts.map