To integrate the Mockup Request Widget into your website, you need to include the widget script, initialize it, and then open it when necessary (e.g., on a button click).
Add the following script snippet to your HTML document (in the <head> or right before </body>). Ensure you replace [YOUR_BACKEND_URL] with the appropriate environment URL (e.g., https://demo.pdb.graphxserver.io).
(function (i, s, o, g, r, a, m, c) {
i['MockupRequestWidget'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
m = s.getElementsByTagName(o)[0];
a.addEventListener('load', c);
m.parentNode.insertBefore(a, m)
})(window, document, 'script', `https://demo.pdb.graphxserver.io/public/mockup-request-widget/main.js`, 'gsx_widget_mockup', undefined, undefined, () => {
console.log('Widget script is loaded and ready');
Once the script is loaded, the MockupRequestWidget object becomes available globally on the window object. First, initialize the widget by calling .init(). Then, open the widget by calling .open() with the required properties and callbacks.
const Widget = MockupRequestWidget.init({
authToken: 'YOUR_AUTH_TOKEN',
transactionIds: ['transaction-uuid-123'],
console.log('Saved data:', result.data);
onGenerate: (blob, transactionId) => {
console.log('TransactionId:', transactionId);
const objectURL = URL.createObjectURL(blob);
window.open(objectURL, '_blank');
Authentication token used for API interactions.
Below are the properties that the open method accepts:
An array of transaction IDs to load mockups for.
(result: { data: SavePayload }) => void
Callback function executed when the user completes and saves their mockups.
Callback function executed when the user clicks 'Generate'. The widget processes the current active view layer layout and requests a high-resolution preview from the backend API, returning it as a Blob.
Allows the user to create custom views.
The widget is packed as a UMD module. When the script executes, it automatically assigns its exports to window.MockupRequestWidget. The inline async script snippet provided above safely bootstraps this process with a load callback.
(function (i, s, o, g, r, a, m, c) {
i['MockupRequestWidget'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
m = s.getElementsByTagName(o)[0];
a.addEventListener('load', c);
m.parentNode.insertBefore(a, m)
})(window, document, 'script', `https://dev.pdb.graphxserver.io/public/mockup-request-widget/main.js?t=${new Date().toISOString()}`, 'gsx_widget_mockup', undefined, undefined, () => {
console.log('Widget is loaded');
document.getElementById('button').addEventListener('click', () => {
const Widget = MockupRequestWidget.init({authToken: 'TOKEN'});
'958cb4f9-920a-4395-a81f-dd0b1dfd79aa'
onGenerate: (blob, transactionId) => {
console.log('Blob size:', blob.size);
console.log('Blob type:', blob.type);
console.log('TransactionId:', transactionId);
const objectURL = URL.createObjectURL(blob);
window.open(objectURL, '_blank');
<button type="button" id="button" >Click</button>