UNPKG

@dotcms/client

Version:

Official JavaScript library for interacting with DotCMS REST APIs.

91 lines (90 loc) 3.05 kB
import { DotCMSPageEditorConfig, ReorderMenuConfig } from './models/editor.model'; import { INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './models/inline-event.model'; import { Contentlet } from '../client/content/shared/types'; /** * Updates the navigation in the editor. * * @param {string} pathname - The pathname to update the navigation with. * @memberof DotCMSPageEditor * @example * updateNavigation('/home'); // Sends a message to the editor to update the navigation to '/home' */ export declare function updateNavigation(pathname: string): void; /** * You can use this function to edit a contentlet in the editor. * * Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet. * * @export * @template T * @param {Contentlet<T>} contentlet - The contentlet to edit. */ export declare function editContentlet<T>(contentlet: Contentlet<T>): void; /** * Initializes the inline editing in the editor. * * @export * @param {INLINE_EDITING_EVENT_KEY} type * @param {InlineEditEventData} eventData * @return {*} * * * @example * ```html * <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })"> * ${My Content} * </div> * ``` */ export declare function initInlineEditing(type: INLINE_EDITING_EVENT_KEY, data?: InlineEditEventData): void; export declare function reorderMenu(config?: ReorderMenuConfig): void; /** * Checks if the code is running inside the DotCMS Universal Visual Editor (UVE). * * The function checks three conditions: * 1. If window is defined (for SSR environments) * 2. If the page is not in preview mode * 3. If the current window is embedded in a parent frame * * @returns {boolean} Returns true if running inside the UVE editor, false if running standalone or in preview mode * @example * ```ts * // Check if code is running in editor before initializing editor-specific features * if (isInsideEditor()) { * initEditor(config); * } else { * initStandaloneMode(); * } * ``` */ export declare function isInsideEditor(): boolean; export declare function initDotUVE(): void; /** * Initializes the DotCMS page editor. * * @param {DotCMSPageEditorConfig} config - Optional configuration for the editor. * @example * ```ts * const config = { pathname: '/home' }; * initEditor(config); // Initializes the editor with the provided configuration * ``` */ export declare function initEditor(config: DotCMSPageEditorConfig): void; /** * Destroys the editor by removing event listeners and disconnecting observers. * * @example * ```ts * destroyEditor(); // Cleans up the editor by removing all event listeners and disconnecting observers * ``` */ export declare function destroyEditor(): void; /** * Adds a style class to empty contentlets. * * @export * @example * ```ts * addClassToEmptyContentlets(); // Adds the 'empty-contentlet' class to all contentlets that have no height * ``` */ export declare function addClassToEmptyContentlets(): void;