Skip to content
This plugin is new and currently in beta. For the stable version, please use the previous version of the plugin.

BlockApi

Interface providing API access for Block implementations in the Stripo Email Editor Extensions SDK.

typescript
interface BlockApi extends BaseApi, BaseModifierApi

Description

The BlockApi interface provides comprehensive access to editor functionalities for block implementations. It combines base API features (translation, configuration, state management) with document modification capabilities, enabling blocks to interact with and modify email templates while maintaining synchronization with the editor's collaborative features.

Import

typescript
import { BlockApi } from '@stripoinc/ui-editor-extensions';

Inheritance Hierarchy

BaseApi

BlockApi ← BaseModifierApi

Properties

None (all functionality provided through methods)

Methods

setViewOnly()

Sets the view-only state for the current block context.

typescript
setViewOnly(viewOnly: boolean): void

Parameters

ParameterTypeDescription
viewOnlybooleanIf true, interactions might be restricted

Usage Notes

  • Controls whether the block can be dragged and dropped within the template
  • Useful for singleton blocks or conditional editing

Example

typescript
public onDocumentInit(): void {
    // Ensure only one instance can be edited
    const instances = this.api.getDocumentRoot()
        .querySelectorAll(`.${this.getUniqueBlockClassname()}`);

    if (instances.length > 1) {
        this.api.setViewOnly(true);
    }
}

Inherited Methods from BaseApi

BaseApi - Base API interface

Inherited Methods from BaseModifierApi

BaseModifierApi - Document modification API