UNPKG

@kontent-ai/smart-link

Version:

Kontent.ai Smart Link SDK allowing to automatically inject [smart links](https://docs.kontent.ai/tutorials/develop-apps/build-strong-foundation/set-up-editing-from-preview#a-using-smart-links) to Kontent.ai according to manually specified [HTML data attri

38 lines (37 loc) 2.08 kB
/** * Groups HTML elements by their rendering root element. * The rendering root is determined by traversing up the DOM tree to find an element that is either: * - Positioned (position is not static) * - Has clipped content (overflow is auto, scroll, clip, or hidden) * For table elements (td, th, table), they must be positioned to be considered a rendering root. */ export declare function groupElementsByRenderingRoot(elements: ReadonlySet<HTMLElement>): Map<HTMLElement | null, ReadonlySet<HTMLElement>>; /** * Iterate through node ancestors and find an element which will be used as a parent for * the ksl-container. This element should either be positioned (position is anything except static) or should * have its content clipped. In case of table element (td, th, table) it should be positioned or it will be ignored * (even if its content is clipped). */ export declare function getRenderingRootForElement(element: HTMLElement): HTMLElement | null; export type RenderingRootMetadata = { /** * Indicates if the element is positioned (computed position is anything except static). * Offset top and offset left values of child elements are relative to the first positioned ancestor, * which is used to correctly position the highlight. */ readonly isPositioned: boolean; /** * Content is clipped when overflow of the element is hidden (overflow is auto, scroll, clip, or hidden). * Highlights should be placed inside such elements to prevent overflow of their parent. */ readonly isContentClipped: boolean; }; /** * Gets metadata about an element's rendering properties that determine how it should be used as a container. */ export declare function getRenderingRootMetadata(root: HTMLElement): RenderingRootMetadata; /** * Iterate through node ancestors until HTMLElement.offsetParent is reached and sum scroll offsets. */ export declare function getTotalScrollOffset(node: HTMLElement | null): [number, number]; export declare function createTemplateForCustomElement(html: string): HTMLTemplateElement;