Interface: IHeadlessEditor
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:62
Public API of the headless editor.
IHeadlessEditor
Example
const editor = document.querySelector('au-headless-editor') as IHeadlessEditor;
// Initialization
await editor.init(config);
// Changing the active product
const product = await editor.openProduct({ productId: 12345 });
// Selecting a variant
const variant = await editor.setVariantById(67890);
// Triggering the add-to-cart event
const lineItem = await editor.addToCart();
Extends
IWorkflowElement
Properties
injector?
optionalinjector?:Injector
Defined in: workflow-elements-types/workflow-element-base/workflow-element.d.ts:7
Inherited from
IWorkflowElement.injector
Methods
addToCart()
addToCart():
Promise<LineItem>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:306
Saves the design and triggers the add-to-cart event
Returns
Promise<LineItem>
A cart line item containing product information
Throws
If saving the design fails
Example
const lineItem = await editor.addToCart();
console.log(lineItem.productId, lineItem.quantity);
applyContainerSettingsToCurrentSurface()
applyContainerSettingsToCurrentSurface(
updatedContainer):Promise<Container>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:760
Applies updated container settings to the current surface.
Parameters
updatedContainer
Partial<Container>
The modified container object. It is recommended to obtain the base
object via getCurrentSurfaceContainerSettings(), modify its
properties, and pass it back.
Returns
Promise<Container>
A promise resolving to the successfully applied container settings.
Remarks
Use this method to programmatically change the appearance or state of the surface's base container. Typical scenarios include toggling visibility, changing the container type (e.g., to 'Colorless'), or updating visualization properties such as texture opacity.
Throws
If the container is invalid, not found, or the update fails.
Example
// 1. Get current settings
const container = editor.getCurrentSurfaceContainerSettings();
// 2. Modify properties
container.type = 'Colorless';
container.visible = true;
container.visualization = {
type: "TextureVisualization",
opacity: 0.5,
enableGlareEffect: false,
};
// 3. Apply changes
await editor.applyContainerSettingsToCurrentSurface(container);
applyToggleToCurrentDesign()
applyToggleToCurrentDesign(
toggleId,toggleParamLabel,toggleParamValue?):Promise<ToggleSet>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:707
Applies a specific toggle value to the current design.
Parameters
toggleId
string
The ID of the Toggle to apply. Obtain it from getCurrentDesignToggleSet().
toggleParamLabel
string
The label of the parameter value to apply (e.g., "Red", "Roboto Bold").
Must match one of the label values in the Toggle's params array.
toggleParamValue?
string
Optional custom value for TEXT toggles. If provided, overrides the predefined text content of the selected parameter.
Returns
Promise<ToggleSet>
A promise resolving to the updated Toggle Set after applying the toggle.
Throws
If the toggle or parameter is not found, or applying fails.
Examples
// Apply a color toggle
const toggleSet = await editor.getCurrentDesignToggleSet();
const colorToggle = toggleSet.toggles.find(t => t.name === "Primary Color");
await editor.applyToggleToCurrentDesign(colorToggle.id, "Red");
// Apply a font toggle
const fontToggle = toggleSet.toggles.find(t => t.name === "Heading Font");
await editor.applyToggleToCurrentDesign(fontToggle.id, "Roboto Bold");
// Apply a TEXT toggle with custom user input
const textToggle = toggleSet.toggles.find(t => t.name === "Custom Message");
await editor.applyToggleToCurrentDesign(
textToggle.id,
"Default Message",
"Happy Birthday, John!" // custom text overrides the default
);
getChoices()
getChoices():
Choice<string|string[]>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:102
Returns the currently selected product options
Returns
Choice<string | string[]>
Current selections or undefined if no product is loaded
Example
const choices = editor.getChoices();
console.log(choices); // { "1": "red", "2": ["small", "medium"] }
Overrides
IWorkflowElement.getChoices
getChoicesValues()
getChoicesValues():
ChoiceValue
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:114
Returns the values of the selected options (option names and values)
Returns
An object with option names and their values
Example
const values = editor.getChoicesValues();
console.log(values); // { "Color": "Red", "Size": ["Small", "Medium"] }
Overrides
IWorkflowElement.getChoicesValues
getCurrentDesignPermanentPreview()
getCurrentDesignPermanentPreview(
surface?):Promise<string>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:405
Returns a single permanent preview URL for the specified surface of the current design.
Parameters
surface?
Surface selection options (surfaceIndex, surfaceId, or surfaceName).
If not specified, the current active surface is used.
Returns
Promise<string>
A promise resolving to the permanent preview URL, or null if generation fails.
Throws
If saving the design or generating the preview fails.
Example
// Get permanent preview for the current surface
const previewUrl = await editor.getCurrentDesignPermanentPreview();
// Get permanent preview for a specific surface by index
const previewUrl = await editor.getCurrentDesignPermanentPreview({ surfaceIndex: 0 });
// Get permanent preview for a specific surface by id
const previewUrl = await editor.getCurrentDesignPermanentPreview({ surfaceId: "a6ab7678-a673-4a1d-95dc-d44e22aaf86e" });
// Get permanent preview for a specific surface by name
const previewUrl = await editor.getCurrentDesignPermanentPreview({ surfaceName: "Front" });
console.log(previewUrl); // "https://api.customerscanvashub.com/..."
getCurrentDesignPermanentPreviews()
getCurrentDesignPermanentPreviews(
surface?):Promise<string[]>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:430
Returns an array of permanent preview URLs for the specified surface of the current design.
Parameters
surface?
Surface selection options (surfaceIndex, surfaceId, or surfaceName).
If not specified, previews are generated for all surfaces.
Returns
Promise<string[]>
A promise resolving to an array of permanent preview URLs.
Throws
If saving the design or generating the previews fails.
Example
// Get all permanent previews for the current surface
const previewUrls = await editor.getCurrentDesignPermanentPreviews();
previewUrls.forEach(url => console.log(url));
// Get permanent previews for a specific surface
const previewUrls = await editor.getCurrentDesignPermanentPreviews({ surfaceIndex: 0 });
// Use case: Generate thumbnails for all mockups on a surface
const thumbnails = await editor.getCurrentDesignPermanentPreviews({ surfaceName: "Front" });
thumbnails.forEach((url, index) => {
console.log(`Mockup ${index + 1}: ${url}`);
});
getCurrentDesignPrintProductModel()
getCurrentDesignPrintProductModel():
PrintProduct
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:828
Returns the full low-level Print Product model of the current design.
Returns
PrintProduct
The complete Print Product model.
Remarks
Advanced API: This method provides direct access to the raw PrintProduct model from
Design Atoms, opening deep access to all surfaces, containers, and design elements. Use it
only when high-level methods (such as getCurrentSurfaceTextItems,
getCurrentSurfaceImagePlaceholderItems, or getCurrentSurfaceQrCodeItems) are insufficient
for your specific programmatic manipulation tasks.
Modifying the returned object does not affect the design until you pass it back through
setCurrentDesignPrintProductModel().
Throws
If the design is not loaded or the model cannot be obtained.
Example
// Inspect the raw product structure
const printProduct = editor.getCurrentDesignPrintProductModel();
printProduct.surfaces.forEach((surface, index) => {
console.log(`Surface ${index}: ${surface.name}`);
surface.containers.forEach(container => {
console.log(` Container has ${container.items.length} items`);
});
});
getCurrentDesignTempPreview()
getCurrentDesignTempPreview(
surface?):Promise<string>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:455
Returns a temporary preview base64 URL for the specified surface of the current design.
Parameters
surface?
Surface selection options (surfaceIndex, surfaceId, or surfaceName).
If not specified, the current active surface is used.
Returns
Promise<string>
A promise resolving to the temporary preview URL as a data URL (base64).
Throws
If generating the preview fails.
Example
// Get temporary preview for the current surface
const tempPreviewUrl = await editor.getCurrentDesignTempPreview();
document.getElementById('preview').src = tempPreviewUrl; // data:image/png;base64,...
// Get temporary preview for a specific surface
const tempPreviewUrl = await editor.getCurrentDesignTempPreview({ surfaceIndex: 0 });
// Use case: Real-time preview update without saving
async function updatePreview() {
const preview = await editor.getCurrentDesignTempPreview({ surfaceName: "Back" });
displayPreview(preview);
}
getCurrentDesignTempPreviews()
getCurrentDesignTempPreviews():
Promise<string[]>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:480
Returns an array of temporary preview base64 URLs for all surfaces of the current design.
Returns
Promise<string[]>
A promise resolving to an array of temporary preview URLs (one per surface).
Throws
If generating the previews fails.
Example
// Get temporary previews for all surfaces
const allPreviews = await editor.getCurrentDesignTempPreviews();
allPreviews.forEach((url, index) => {
console.log(`Surface ${index}: ${url}`);
});
// Use case: Generate a thumbnail gallery for all surfaces
const gallery = document.getElementById('gallery');
const previews = await editor.getCurrentDesignTempPreviews();
previews.forEach(previewUrl => {
const img = document.createElement('img');
img.src = previewUrl;
gallery.appendChild(img);
});
getCurrentDesignToggleSet()
getCurrentDesignToggleSet():
Promise<ToggleSet>
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:668
Returns the Toggle Set for the current design.
Returns
Promise<ToggleSet>
A promise resolving to the Toggle Set of the current design.
Throws
If the design has no Toggle Set or loading fails.
Examples
// Get the Toggle Set and inspect available toggles
const toggleSet = await editor.getCurrentDesignToggleSet();
toggleSet.toggles.forEach(toggle => {
console.log(`Toggle: ${toggle.name} (${toggle.type})`);
toggle.params.forEach(param => {
console.log(`Label - ${param.label}`);
});
});
// Build a color palette UI from a COLOR toggle
const toggleSet = await editor.getCurrentDesignToggleSet();
const colorToggle = toggleSet.toggles.find(t => t.type === 'color');
if (colorToggle) {
colorToggle.params.forEach(colorParam => {
renderColorButton(colorParam.label, colorParam.previewColor, () => {
editor.applyToggleToCurrentDesign(colorToggle.id, colorParam.label);
});
});
}
getCurrentDesignVariant()
getCurrentDesignVariant():
DesignVariant
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:252
Returns the current design variant
Returns
The current design variant
Example
const designVariant = editor.getCurrentDesignVariant();
getCurrentProduct()
getCurrentProduct():
Product
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:155
Returns the currently loaded product
Returns
The current product
Throws
If no product is loaded
Example
const product = editor.getCurrentProduct();
console.log(product.name);
getCurrentSurface()
getCurrentSurface():
Surface
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:293
Returns the currently active surface
Returns
The current surface
Example
const surface = editor.getCurrentSurface();
console.log(surface.name);
getCurrentSurfaceBarcodeItems()
getCurrentSurfaceBarcodeItems(
options?):IBarcodeItem<BarcodeSubType,BarcodeFormat>[]
Defined in: workflow-elements/headless-editor/app/interfaces/configuration.interface.d.ts:590
Returns a list of QR code and barcode items on the current surface of the active design.
Parameters
options?
Optional filtering options. Use containerId to filter items within a specific container.
Returns
IBarcodeItem<BarcodeSubType, BarcodeFormat>[]
An array of QR code/barcode items enriched with schema data.
Example
// Get all QR codes and barcodes on the current surface
const qrCodes = editor.getCurrentSurfaceBarcodeItems();
// Get QR codes filtered by a specific container
const containerQrCodes = editor.getCurrentSurfaceBarcodeItems({ containerId: "container-123" });
// Example: Find a specific VCard QR code and read its structured data
const vCardQr = qrCodes.find(qr => qr.subType === BarcodeSubType.V_CARD && qr.name === "ContactQR");
if (vCardQr && vCardQr.data.firstName) {
console.log(`Found contact: ${vCardQr.data.firstName} ${vCardQr.data.lastName}`);
}