Standalone Email Editor
The standalone mode of the email editor enables you to edit existing HTML and text documents.
You can integrate the editor in any application using an iFrame.
Limitations
-
There is no preview option in the editor, so you can preview documents only from outside the editor.
-
There is no option to create new documents, only to edit exiting ones.
-
There is no code button in the editor, so you can only work in design mode.
-
It is possible to use the standalone mode only in an iFrame, not as a separate window or popup.
-
The standalone mode should not be opened simultaneously with Circle in the same browser. This will cause the token in the editor to expire after 15 minutes (see Authentication).
Integration
Follow these steps to use the editor in standalone mode:
-
Log in to Circle using the API (https://eu.xmcircle.com/CloudAPI/v1/system/login)
-
POST request: https://eu.xmcircle.com/CloudAPI/v1/system/login
-
Set the following body:
{ " UserName ": "USER_NAME", " UserPassword ": "USER_PASSWORD" } -
Use the value returned by the call as the circle_token.
-
-
Call the following POST request:
https://eu.xmcircle.com/cloudAPI/v1/{{subscription}}/projects/{{project}}/email/editor/singleSignOnUrl?securityToken={{circle_token}}
-
Set the correct subscription and project ID in the URL.
-
circle_token – a token received in the login call (URL encoded).
-
Set the following body with HTML or text document GUID
{ "DocumentID": "DOCUMENT-GUID" }
-
-
Use the URL returned by the last API call as the “src” of the email editor iFrame.
Notes:
-
Check our HTML example: EmailEditorStandAlone.html
-
You can handle authentication issues by catching an event in the iFrame parent (see Authentication).
Additional information
The following is an example of a URL returned in the API, that opens the email editor as standalone:
https://2g.xmcircle.com/#!/editor-modal/{subscriptionId}/{projectId}/?docId={docId}&docType={docType}&token={token}
This URL includes path params:
-
subscriptionId
-
projectId
This URL includes list of query params:
-
docId – ID of selected document
-
docType – type of selected document
-
token - token for getting access to the email editor
Authentication
If the application is idle for 3 consecutive hours, then the token expires.
When the token expires, the application redirects to the Circle login page. The email editor sends an event to the parent window. This event is sent by postMessage (‘message’). The message inside the event is {isExpiredToken: true}.
To catch this message use addEventListener inside the parent window.
window.addEventListener('message', function(event) {
if (event.data.isExpiredToken) {
// create new url for email editor standalone
}
})
If you open the link 15 minutes after receiving it, the token will have already expired. Nothing will be shown on the screen and you will need to create a new API request and get a new URL.
If the user clicks on the save button and the token had already expired, the application will redirect to the login page.
If the user opens the standalone email editor and the Circle email editor together, the token for the standalone email editor will expire after 15 minutes.