Skip to main content
Version: Latest

Transform Property Values

When you register a tool, you can also create a transformer for that tool. Transformer is a function that is called each time any of the properties is changed and gives you an opportunity to modify any or all of the values in the tool.

unlayer.registerTool({
...
transformer: (values, source) => {
const { name, value, data } = source;

// Transform the values here
let newValues = {
...values
};

// Return updated values
return newValues;
}
});

The arguments passed to the transformer are these:

OptionDescription
valuesCurrent property values for the tool
sourceAn object that contains information for the property that triggered this call:
name of the property
value of the property
data is the optional metadata passed by the updateValue function of the property editor