loadUserInfo
- Less than a minute to read
This command enables you to populate the product in the editor with user data. This is an equivalent of the loadUserInfo method from the IFrame API.
Params
data
is a set of key-value pairs in the Editor.IUserInfo format.options
define how this info should be reflected in the history.
Example of how to replace text with an option value
Let's imagine that you have a text layer Name in your design. Here is a simple example of how to automatically change it to the value selected in the options
widget:
{
"type": "design-editor",
"name": "design-editor",
"params": {
"inital": {...},
"loadUserInfo": {
"data": {
"Name": "{{ $['options']._.props.name }}"
}
}
}
}
Example of working with history
The UI Framework supports the editor restoration by using the snapshot approach. You can skip adding the loaded user changes to the history as well as replace the last snapshot. In this example, we change the default behavior and do not add a new snapshot, but replace the previous one with user data changes.
{
"type": "design-editor",
"name": "design-editor",
"params": {
"inital": {...},
"loadUserInfo": {
"data": {
"Name": "John Wood"
},
"options": {
"addSnapshot": false,
"replaceLastSnapshot": true
}
}
}
}