IframeCommunicationManager

How to get IframeCommunicationManager

ES2015+:

import IframeCommunicationManager from 'fontoxml-iframe-communication/iframeCommunicationManager'

ES5:

define([
	'fontoxml-iframe-communication/iframeCommunicationManager'
], function (
	IframeCommunicationManager
) {
});

Type: Class

Allows the application hosting a Fonto window to control the active Fonto instance and vice versa.

Import fontoxml-iframe-communication/iframeCommunicationManager from the Fonto application to communicate with the hosting application. Use the browser's native postMessage API to control the Fonto instance from the hosting application.

Messages posted to the Fonto window or iframe should have as their data a JSON-encoded object with at least a type property specifying the type of the message, as listed in the table below.

Accepted messages

Message type Description
fontoxml-execute-operation Execute an operation. The message data should contain the operationName to invoke, and data to pass to the operation. Only operations from a limited whitelist may be invoked from an external source. By default this list is empty. Set the iframe-communication-operations-whitelist configuration setting to an array of operation names to specify the whitelist.

Methods

Name Description
postMessageToParent

Post a custom command message to the parent window.


  Arguments
# Name Type Description
1. type String

The type of message to send to the parent (CMS)

2. [metadata] Object

An object containing command specific properties

sendClose

Tell the hosting application to close the Fonto instance. The hosting application is responsible for cleaning up auto-saves, releasing locks and closing the window or iframe. If discardSaves is true, all saves of the current session should be discarded.


  Arguments
# Name Type Description
1. discardSaves Boolean

whether all the saves of the current edit session should be discarded

sendToggleFullScreen

Tell the hosting application to resize the Fonto window or iframe between a full-screen view and one hosted in the CMS interface.


  Arguments
# Name Type Description
1. isInFullScreenMode Boolean

whether the editor should be toggled to full screen or not