Available Functions

The rw object provides several functions for manipulating component output and behavior.

Quick Reference

Function
Description

Pass data to templates

Configure the root HTML element

Register an anchor for the link picker

Resize image resources

Get theme breakpoint configuration

Basic Usage

const transformHook = (rw) => {
    const { title, customId, image } = rw.props;
    
    // Pass data to templates
    rw.setProps({
        title,
        displayTitle: title.toUpperCase()
    });
    
    // Configure the root HTML element
    rw.setRootElement({
        as: 'section',
        class: 'my-component p-4',
        args: { id: customId }
    });
    
    // Register anchor for link picker
    if (customId) {
        rw.addAnchor(customId);
    }
    
    // Resize image for thumbnail
    const thumbnail = rw.resizeResource(image, 400);
};

exports.transformHook = transformHook;

Function Details

setProps

The primary way to pass data to your templates. Any data passed here becomes available in template files.

setRootElement

Configure the wrapper element that Elements generates for your component. Control the tag name, CSS classes, and HTML attributes.

addAnchor

Register a custom anchor ID so users can link directly to this component instance using the link picker.

resizeResource

Resize an image resource to a specific width. Returns the path to the resized image.

Last updated

Was this helpful?