import { BlockApi } from '../api/BlockApi'; import { BaseValidatedClass } from '../BaseValidatedClass'; import { BlockCompositionType } from '../constants/BlockCompositionType'; import { ConstructorOfType } from '../ConstructorOfType'; import { HtmlNodeModifier } from '../modifications/HtmlCssNodeModifier'; import { ImmutableHtmlNode } from '../modifications/ImmutableNode'; import { BlockRenderer } from './BlockRenderer'; export declare class Block extends BaseValidatedClass { /** Provides access to editor functionalities specific to this block instance. */ api: BlockApi; /** List of methods that must be implemented by subclasses */ private static readonly REQUIRED_METHODS; constructor(); /** * Determines if the block should be available for use in the editor. * Override to provide custom logic based on editor state or configuration. * @returns True if the block is enabled, false otherwise. Defaults to true. */ isEnabled(): boolean; /** * Determines if the block can be saved as a reusable module by the user. * @returns True if the block can be saved as a module, false otherwise. Defaults to false. */ canBeSavedAsModule(): boolean; /** * Specifies the context actions available for this block. * If not overridden, the editor might use a default set of actions. * Use IDs from {@link ContextActionType} or custom action IDs. * @returns An array of context action IDs, or undefined to use defaults (if any). */ getContextActionsIds(): string[] | undefined; /** * Provides a custom renderer class for this block, allowing for specialized rendering logic. * @returns A constructor for a class extending {@link BlockRenderer}, or undefined to use the default renderer. */ getCustomRenderer(): ConstructorOfType | undefined; /** * Gets a unique CSS class name specifically for this block type. * Used for targeting styles. * @returns A unique CSS class name. Defaults to `esd-{blockId}`. */ getUniqueBlockClassname(): string; /** * Lifecycle hook called when the editor document is initialized. * Useful for performing initial setup or modifications on existing block instances in the template. */ onDocumentInit(): void; /** * Lifecycle hook called when an instance of this block is selected in the editor. * @param node - The immutable HTML node representing the selected block instance. */ onSelect(node: ImmutableHtmlNode): void; /** * Lifecycle hook called when an instance of this block is copied. * @param modifier - The HTML node modifier to apply changes to the copied block instance. */ onCopy(modifier: HtmlNodeModifier): void; /** * Lifecycle hook called when an instance of this block is deleted. * @param node - The immutable HTML node representing the block instance being deleted. */ onDelete(node: ImmutableHtmlNode): void; /** * Lifecycle hook called after a new instance of this block is created and added to the document (e.g., via drag-and-drop). * @param node - The immutable HTML node representing the newly created block instance. */ onCreated(node: ImmutableHtmlNode): void; /** * Lifecycle hook called when any part of the document template has changed. * This can be frequent; use cautiously for performance-sensitive operations. * @param node - The immutable HTML node representing current node instance */ onDocumentChanged(node: ImmutableHtmlNode): void; /** * @description Determines if block is atomic or composite. * {@link BlockCompositionType.BLOCK} - atomic block which can be inserted inside other container and cannot hold other objects * {@link BlockCompositionType.STRUCTURE} - composite block which can serve as a container for another atomic block * @returns The type of the block. Defaults to {@link BlockCompositionType.BLOCK}. */ getBlockCompositionType(): BlockCompositionType; /** * @description Determines if block should be included in empty container quick insert actions list. * @returns True to show a quick-add icon for this block in empty containers, false otherwise. Defaults to false. */ shouldDisplayQuickAddIcon(): boolean; /** * Determines if the block should be shown in the blocks panel. * Override to hide the block from the blocks panel while keeping it available elsewhere. * @returns True if the block should appear in the blocks panel. Defaults to true. */ shouldDisplayInBlocksPanel(): boolean; /** * @description Determines if nested blocks selection allowed in extension of type {@link BlockCompositionType.STRUCTURE} */ allowInnerBlocksSelection(): boolean; /** * @description Determines if nested blocks drag and drop allowed in extension of type {@link BlockCompositionType.STRUCTURE} */ allowInnerBlocksDND(): boolean; allowInteractWithAMPWhenSelected(): boolean; /** * Gets the unique identifier for this block type. * This ID is used for registration and referencing the block. * @returns A unique string ID. */ getId(): string; /** * Gets the HTML template string that defines the initial structure of this block. * This template will be used when the block is dragged into the editor. * @returns An HTML string. */ getTemplate(): string; /** * Gets a CSS template string that contains the custom styles that apply to the block. * This CSS will be used when a block is dragged into the editor and removed when the last block is deleted. * @returns An CSS string. */ getTemplateStyles(): string; /** * Gets the URL or path to the icon representing this block in the editor's block panel. * @returns A string representing the icon source (e.g., URL, data URI). */ getIcon(): string; /** * Gets the display name of the block shown to the user in the block panel. * Use `this.api.translate()` for localization. * @returns The localized block name string. */ getName(): string; /** * Retrieves the name of block in the block panel. * Can contain html markup * If not implemented by the subclass, getName() function will be used to display name in the block panel * * @return {string} The name of the block panel. */ getSettingsPanelTitleHtml(): string; /** * Gets a short description of the block shown to the user, often as a tooltip in the block panel. * Use `this.api.translate()` for localization. * @returns The localized description string. */ getDescription(): string; }