/** * Shared utilities for scrolling to block elements with expand node support. * Used by both Confluence's useScrollOnUrlChange and platform renderer's useScrollToBlock. */ import type { DocNode } from '@atlaskit/adf-schema'; export type NodeWithExpandParents = { /** Array of expand parent localIds (empty if no expand parents, ordered from outermost to innermost). */ expandParentLocalIds: string[]; }; /** * Find a node by its localId in an ADF document and determine if it has expand or nestedExpand parents. * This is used to identify nodes that may be hidden inside collapsed expands. * * @param adfDoc - The ADF document to search * @param targetLocalId - The localId to search for * @returns NodeWithExpandParents if found, undefined otherwise */ export declare function findNodeWithExpandParents(adfDoc: DocNode, targetLocalId: string): NodeWithExpandParents | undefined; /** * Find all parent expand elements that contain the target element. * Searches up the DOM tree to find expand or nestedExpand containers. * * This function limits the search depth to prevent infinite loops and performance issues. * The default maxDepth of 2 is chosen because: * - Most use cases have 0-2 levels of nesting * - Searching deeper can impact performance * - Users rarely nest expands more than 2 levels deep * * @param element - The target element to find parents for. * @param maxDepth - Maximum depth to search (default: 2). This is the maximum number of * expand ancestors to find, starting from the target element. * @returns Array of expand containers ordered from outermost to innermost. * For example, if element is inside expand B which is inside expand A, * this returns [expandA, expandB]. */ export declare const findParentExpands: (element: HTMLElement, maxDepth?: number) => HTMLElement[]; /** * Expand all parent expands then scroll to the element. * * This is the main entry point for scrolling to elements that may be hidden inside collapsed expands. * It handles nested expands by expanding them one at a time from outermost to innermost, * waiting for DOM updates between each expansion. * * The function uses a recursive approach with retry logic to handle: * - Nested expands that need sequential expansion * - DOM updates that may take time to reflect * - Failed expand operations (e.g., if toggle button is temporarily unavailable) * - Disconnected elements (removed from DOM) * * After all parent expands are open (or max attempts reached), scrolls the element into view * with smooth behavior and centered in the viewport. * * @param element - The target element to scroll to. * @param attempt - Current attempt number (used internally for retry logic, starts at 0). * @returns A cleanup function that cancels any pending timeouts. Call this when the operation * should be aborted (e.g., component unmount, navigation, or new scroll request). */ export declare const expandAllParentsThenScroll: (element: HTMLElement, attempt?: number, scrollFn?: (element: HTMLElement) => void) => (() => void); export { SCROLL_TO_BLOCK_TIMING } from './SCROLL_TO_BLOCK_TIMING'; export { isExpandCollapsed } from './isExpandCollapsed'; export { expandElement } from './expandElement'; export { getLocalIdSelector } from './getLocalIdSelector';