updateSurfaces
- 1 minute to read
Replaces product surfaces (pages). This is an equivalent of the updateSurfaces method from the IFrame API.
Params
definition
- a product that can be defined through either IProductDefinition or a string. In the latter case, the string stands for a state file ID.surfaces
- an array of surfaces in the current product to be removed.newProductSurfaces
- an array of surfaces in the new product to be inserted.options
- additional configuration settings. See the ISetPrintAreasOptions for more details.preserveSafetyLines
- iftrue
, the current safety lines, if any, are restored in new surfaces. Iffalse
, safety lines from new surfaces are applied. The default value istrue
.preserveUserChanges
- iftrue
, the changes made by a user are restored in the new surfaces if it is possible. Otherwise, all changes made by the user are wiped. The default value istrue
.replaceAll
- iftrue
, design elements whose names do not match move to the new surface in a random order according to their types. If false, only design elements with the same names are moved to the new surface. The default value isfalse
.updateRevertData
- iftrue
, the new surfaces are stored as ones to restore when the product is reverted. Otherwise, the previously stored ones are restored on product revert. The default value istrue
.updateSurfaceSize
- iftrue
, changes the surface size to match the new surface. If it'sfalse
and a mockup is defined, then the surface size remains unchanged. By default,updateSurfaceSize
isfalse
, and the surface size changes only if no mockups are specified.
For the complete list of parameters, you can refer to IUpdateSurfacesCommandDefinition.
Example
Here, we replace the first page of the loaded product with the third page of a state file.
{
"type": "design-editor",
"name": "design-editor",
"params": {
"initial": { ... },
"updateSurfaces": [{
"definition": "{{ $['options']._.props.id }}",
"surfaces": [0],
"newProductSurfaces": [2],
"replaceAll": true
}]
}
}