@dotcms/uve
Version:
Official JavaScript library for interacting with Universal Visual Editor (UVE)
103 lines (102 loc) • 3.46 kB
TypeScript
import { Contentlet, DotCMSInlineEditingPayload, DotCMSInlineEditingType, DotCMSBasicContentlet, DotCMSPageResponse } from '@dotcms/types';
import { DotCMSReorderMenuConfig, DotCMSUVEMessage } from '@dotcms/types/internal';
/**
* 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;
/**
* Post message to dotcms page editor
*
* @export
* @template T
* @param {DotCMSUVEMessage<T>} message
*/
export declare function sendMessageToUVE<T = unknown>(message: DotCMSUVEMessage<T>): 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;
export declare function reorderMenu(config?: DotCMSReorderMenuConfig): 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: DotCMSInlineEditingType, data?: DotCMSInlineEditingPayload): void;
/**
* Initializes the block editor inline editing for a contentlet field.
*
* @example
* ```html
* <div onclick="enableBlockEditorInline(contentlet, 'MY_BLOCK_EDITOR_FIELD_VARIABLE')">
* ${My Content}
* </div>
* ```
*
* @export
* @param {DotCMSBasicContentlet} contentlet
* @param {string} fieldName
* @return {*} {void}
*/
export declare function enableBlockEditorInline<T extends DotCMSBasicContentlet>(contentlet: T extends DotCMSBasicContentlet ? T : never, fieldName: keyof T): void;
/**
* Opens the contentlet creation panel for the given content type without adding it to the page.
*
* This function is intended for use cases where you want to create a contentlet in the system
* (e.g., for widgets that auto-pull content) without dropping it onto the current page layout.
*
* @export
* @param {string} contentType - The content type variable or structure inode to create a contentlet for.
*
* @example
* ```js
* // Opens the creation panel for the 'Event' content type
* createContentlet('Event');
* ```
*/
export declare function createContentlet(contentType: string): void;
/**
* Initializes the Universal Visual Editor (UVE) with required handlers and event listeners.
*
* This function sets up:
* - Scroll handling
* - Empty contentlet styling
* - Block editor inline event listening
* - Client ready state
* - UVE event subscriptions
*
* @returns {Object} An object containing the cleanup function
* @returns {Function} destroyUVESubscriptions - Function to clean up all UVE event subscriptions
*
* @example
* ```typescript
* const { destroyUVESubscriptions } = initUVE();
*
* // When done with UVE
* destroyUVESubscriptions();
* ```
*/
export declare function initUVE(config?: DotCMSPageResponse): {
destroyUVESubscriptions: () => void;
};