Page tree
Skip to end of metadata
Go to start of metadata

RELEASE 2.3.0 OR ABOVE

This event occurs after a document is opened (imported).

Adding Event

Using API

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var editor = new SynapEditor(editorId, editorConfig, html);

editor.setEventListener('afterOpenDocument', function (e) {
});

Function

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';

function SynapEditorAfterOpenDocument(e) {
}

new SynapEditor(editorId, editorConfig, html);

When the Editor is initialized

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var eventListeners = {
    afterOpenDocument: function (e) {
    }
};

new SynapEditor(editorId, editorConfig, html, eventListeners);

Object Delivered through Functions

In the form of parameter e delivered through functions

e
{
	editor: SynapEditor,
	eventType:  'afterOpenDocument',
	cancelable: true,
	returnValue: null,
	fileType: 'WORD', // File type ('HTML', 'WORD', 'CELL', ...)
	path: '/upload/path/filename.docx', // Import path
	...... // Data transferred from the server (importPath, serializedData, .....)
}
// release 2.15.0 or above
{
	editor: SynapEditor,
	eventType:  'afterOpenDocument',
	cancelable: true,
	returnValue: null,
	fileType: 'WORD',
	path: '/upload/path/filename.docx',
    error: undefined,  // [2.15.0] Error information when import fails
	...... // Data transferred from the server (importPath, serializedData, .....)
}

Import failed

RELEASE 2.15.0 OR ABOVE

Starting with the 2.15.0 release, the afterOpenDocument event is also raised when an import fails.

When upload fails, an Error object is passed to the error property of the object passed to the afterOpenDocument event.

Example of checking error message when import fails

editor.setEventListener('afterOpenDocument', function (e) {
    if (e.error) {
        console.log(e.error);
    }
});
  • No labels