HTML AddOn
Overview
The HTML AddOn type allows you to insert custom HTML content blocks into the Beefree SDK editor. This is ideal for embedding custom widgets, specialized markup, or any HTML content that requires flexibility beyond standard content blocks.
Prerequisites
Before implementing an HTML AddOn in your code, you must first create the addon in the Beefree SDK Developer Console:
Log into the Developer Console and navigate to your application
Create a new Custom AddOn and select "HTML" as the type
Configure the addon with a unique handle (e.g.,
my-html-addon)Choose your implementation method (Content Dialog or External iframe)
Save the addon configuration
Content Object Schema
Required Structure
The HTML AddOn uses a simple schema with a single html property containing your markup as a string. This structure tells Beefree to treat the content as raw HTML, preserving your markup exactly as provided while rendering it within the editor.
{
type: 'html',
value: {
html: string // Your HTML markup as a string
}
}Basic Example
This minimal example shows the simplest HTML addon implementation—a single div with text content. Any valid HTML can be inserted this way, from simple text containers to complex nested structures with multiple elements and inline styles.
Styled Example
This example demonstrates a more styled HTML block with proper email-safe formatting. Note the use of inline styles (required for email compatibility), table-based structure (for better email client support), and semantic paragraph tags for proper text rendering across different email environments.
Content Dialog Implementation
Basic Handler
The Content Dialog method lets you insert HTML content programmatically when users drag your addon onto the stage. The handler function receives resolve and reject callbacks—call resolve with your HTML object to insert content, or reject to cancel the operation. This immediate resolution pattern is perfect for addons that don't require user input before insertion.
Pattern: With User Input
This pattern demonstrates how to collect user input before inserting HTML content. By opening a custom dialog or modal, you can let users provide content, configuration, or selections that determine what HTML gets generated. The handler waits for the user's confirmation before resolving, giving you full control over the insertion process and allowing for validation or transformation of user input.
Pattern: Multiple AddOns
When you have multiple HTML addons registered in the console, you can handle them all in a single handler by checking the args.contentDialogId property. This allows you to organize different HTML content types under one handler function, making your code more maintainable while supporting various HTML insertion use cases from simple static content to complex user-driven dialogs.
Iframe Implementation
Conceptual Flow
The Iframe method provides complete UI flexibility by loading your custom web application inside the Beefree editor. Your iframe communicates with Beefree using the postMessage API, following a specific protocol: first notify Beefree when loaded, then receive initialization data, and finally send your HTML content when the user confirms. This approach is ideal when you need a rich, complex interface for HTML generation or configuration.
Required postMessage Communication
Your iframe must implement a specific message protocol to integrate properly with Beefree. The "loaded" message tells Beefree your UI is ready and specifies the dialog dimensions. The "init" message from Beefree provides context like locale and editor state. When ready to insert content, send "onSave" with your HTML object, or send "onCancel" if the user abandons the action. This bidirectional communication enables seamless integration between your custom UI and the Beefree editor.
1. Send "loaded" when your iframe is ready:
2. Listen for "init" and "load" messages from Beefree:
3. Send "onSave" with HTML content:
4. Send "onCancel" if user cancels:
Simple Iframe Example
This complete HTML example demonstrates a functional HTML editor interface that integrates with Beefree. It includes the full postMessage protocol implementation, a simple textarea for HTML input, and proper save/cancel handling. You can enhance this basic example with syntax highlighting, live preview, validation, or pre-built HTML templates to create a more sophisticated user experience.
Last updated
Was this helpful?

