UNPKG

@dotcms/uve

Version:

Official JavaScript library for interacting with Universal Visual Editor (UVE)

63 lines (62 loc) 2.53 kB
import { DotCMSPageResponse } from '@dotcms/types'; /** * Sets up scroll event handlers for the window to notify the editor about scroll events. * Adds listeners for both 'scroll' and 'scrollend' events, sending appropriate messages * to the editor when these events occur. */ export declare function scrollHandler(): { destroyScrollHandler: () => void; }; /** * Adds 'empty-contentlet' class to contentlet elements that have no height. * This helps identify and style empty contentlets in the editor view. * * @remarks * The function queries all elements with data-dot-object="contentlet" attribute * and checks their clientHeight. If an element has no height (clientHeight = 0), * it adds the 'empty-contentlet' class to that element. */ export declare function addClassToEmptyContentlets(): void; /** * Registers event handlers for various UVE (Universal Visual Editor) events. * * This function sets up subscriptions for: * - Page reload events that refresh the window * - Bounds request events to update editor boundaries * - Iframe scroll events to handle smooth scrolling within bounds * - Contentlet hover events to notify the editor * * @remarks * For scroll events, the function includes logic to prevent scrolling beyond * the top or bottom boundaries of the iframe, which helps maintain proper * scroll event handling. */ export declare function registerUVEEvents(): { subscriptions: import("@dotcms/types").UVEEventSubscription[]; }; /** * Notifies the editor that the UVE client is ready to receive messages. * * This function sends a message to the editor indicating that the client-side * initialization is complete and it's ready to handle editor interactions. * * @remarks * This is typically called after all UVE event handlers and DOM listeners * have been set up successfully. */ export declare function setClientIsReady(config?: DotCMSPageResponse): void; /** * Listen for block editor inline event. */ export declare function listenBlockEditorInlineEvent(): { destroyListenBlockEditorInlineEvent: () => void; }; /** * Injects UVE editor styles for empty containers and contentlets into the page. * Provides visual placeholders so editors can identify and interact with empty areas. * * The empty-container label is read from the dotCMS i18n cache in localStorage * (`dotMessagesKeys`). Falls back to 'Empty container' if the cache is unavailable * (e.g. headless pages on a different origin). */ export declare function injectEmptyStateStyles(): void;