npm.io
1.0.1 • Published 6 years ago

@elateral/brandgility-embedded-api

Licence
UNLICENSED
Version
1.0.1
Deps
0
Size
10 kB
Vulns
0
Weekly
0

How to embed Brandgility's configurator into an iframe:

  • get the id of template to be configured from Brandgility application
  • To open an asset for customization, copy and paste below code into your page/component, replace :id in src attribute with your template's id:
<iframe src="<BRANDGILITY_ENDPOINT>/embedded-template-configure/{new|edit}/:id?action=DRAFT_TEMPLATE_CONFIGURATION_START&eid=:id&embedded=true" />
  • To configure an already saved template customization, copy and paste below code into your page/component, replace :id in src attribute with your saved template customization id:
<iframe src="<BRANDGILITY_ENDPOINT>/embedded-template-configure/{new|edit}/:id?action=DRAFT_TEMPLATE_CONFIGURATION_EDIT&eid=:id&embedded=true" />

API library

Brandgility embedded api library allows you to issue commands to Brandgility configurator in embedded mode

Methods

method description parameters
on subscribes to event eventName: <string>, argument: <function>
emit triggers an event eventName: <string>, argument: <serializable, see The structured clone algorithm>

Events to listen

To subscribe on event use on method:
brandgilityEmbeddedApi.on('load', () => console.info('loaded'));
event description arguments
load load event entity { type: <string> , id: <string> }
save success save event id of saved item <string>
error error event error { message: <string> }

Events to trigger

To trigger an event use emit method:
brandgilityEmbeddedApi.emit('save');
event description parameters
save saves a current version of template -
saveAs creates a new saved customization from an existing saved customization new item { name: <string>, comments: <string> }