@dotcms/uve
Version:
Official JavaScript library for interacting with Universal Visual Editor (UVE)
109 lines (108 loc) • 4.43 kB
TypeScript
import { UVEEventHandler, UVEEventType } from '@dotcms/types';
/**
* Subscribes to content changes in the UVE editor
*
* @param {UVEEventHandler} callback - Function to be called when content changes are detected
* @returns {Object} Object containing unsubscribe function and event type
* @returns {Function} .unsubscribe - Function to remove the event listener
* @returns {UVEEventType} .event - The event type being subscribed to
* @internal
*/
export declare function onContentChanges(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};
/**
* Subscribes to page reload events in the UVE editor
*
* @param {UVEEventHandler} callback - Function to be called when page reload is triggered
* @returns {Object} Object containing unsubscribe function and event type
* @returns {Function} .unsubscribe - Function to remove the event listener
* @returns {UVEEventType} .event - The event type being subscribed to
* @internal
*/
export declare function onPageReload(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};
/**
* The single bounds-sync channel. Observes the iframe document and
* every `[data-dot-object="container"]` with a single ResizeObserver,
* debounces the trailing edge by {@link AUTO_BOUNDS_DEBOUNCE_MS}ms, and
* emits the full `getDotCMSPageBounds(...)` payload whenever the layout
* settles. Also listens on `scroll` (since scrolling moves contentlets
* without changing layout) and on `UVE_FLUSH_BOUNDS` (the editor's
* "give me bounds NOW, skip the debounce" message used during drag).
*
* Re-runs `querySelectorAll` and the observer wiring whenever a
* MutationObserver detects child changes that touch container nodes,
* so containers that mount/unmount after page-load are picked up
* automatically.
*
* @internal
*/
export declare function onAutoBounds(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};
/**
* Subscribes to iframe scroll events in the UVE editor
*
* @param {UVEEventHandler} callback - Function to be called when iframe scroll occurs
* @returns {Object} Object containing unsubscribe function and event type
* @returns {Function} .unsubscribe - Function to remove the event listener
* @returns {UVEEventType} .event - The event type being subscribed to
* @internal
*/
export declare function onIframeScroll(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};
/**
* Listens for scroll-to-section requests from the UVE editor.
*
* Queries `#dot-section-{n}` first, then falls back to `#section-{n}`.
* If the element is found, calls the callback with `{ sectionIndex, offsetTop }`.
* If not found, the callback is not invoked.
*
* @param {UVEEventHandler} callback - Receives `{ sectionIndex: number; offsetTop: number }`.
* @internal
*/
export declare function onScrollToSection(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};
/**
* Subscribes to contentlet hover events in the UVE editor.
*
* The callback is invoked with a payload while the pointer is over a
* DotCMS element, and once with `null` when the pointer leaves the last
* reported element (transitions onto dead space). The editor uses the
* `null` signal to clear the hover overlay so it doesn't linger over
* areas that no longer have a contentlet under the pointer.
*
* @param {UVEEventHandler} callback - Function to be called when hover state changes
* @returns {Object} Object containing unsubscribe function and event type
* @returns {Function} .unsubscribe - Function to remove the event listener
* @returns {UVEEventType} .event - The event type being subscribed to
* @internal
*/
export declare function onContentletHovered(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};
/**
* Subscribes to contentlet click events in the UVE editor.
*
* The editor's hover overlay is `pointer-events: none` so wheel events pass
* through to the iframe. We detect the user's selection click here instead and
* post it back to the editor.
*
* @param {UVEEventHandler} callback - Function to be called when a contentlet is clicked
* @returns {Object} Object containing unsubscribe function and event type
* @internal
*/
export declare function onContentletClicked(callback: UVEEventHandler): {
unsubscribe: () => void;
event: UVEEventType;
};