Events

When initializing the SDK frame, a number of events can be passed to the configuration, which will be executed at the appropriate moment:

onAppError

The function called when SDK is initialized with an error. This error is returned during the initialization.

Example:

function onAppError() {
  console.log("ONLYOFFICE DocSpace reports an error")
}

const docSpace = DocSpace.SDK.initManager({
  events: {
    onAppError,
  },
})

onAppReady

The function called when SDK is initialized successfully.

Example:

function onAppReady() {
  console.log("ONLYOFFICE DocSpace is ready")
}

const docSpace = DocSpace.SDK.initManager({
  events: {
    onAppReady,
  },
})

onAuthSuccess

The function called upon successful authorization.

Example:

function onAuthSuccess() {
  console.log("The authorization is successful.")
}

const docSpace = DocSpace.SDK.initManager({
  events: {
    "onAuthSuccess ": onAuthSuccess,
  },
})

onCloseCallback

The function called only in the room-selector and file-selector modes when the room or file selector is closed or the selection is canceled.

Example:

function onCloseCallback() {
  console.log("The room selector is closed.")
}

const docSpace = DocSpace.SDK.initRoomSelector({
  events: {
    onCloseCallback,
  },
})

onDownload

The function called when firing events to download items from the manager. It returns a link to the download object. This event is called only when the downloadToEvent parameter is specified in the config.

Example:

function onDownload() {
  console.log("The 'New document' file has been downloaded.")
}

const docSpace = DocSpace.SDK.initManager({
  events: {
    onDownload,
  },
})

onEditorCloseCallback

The function called when the document editor is closed.

Example:

function onEditorCloseCallback() {
  console.log("The document editor is closed.")
}

const docSpace = DocSpace.SDK.initEditor({
  events: {
    onEditorCloseCallback,
  },
})

onSelectCallback

The function called only in the room-selector and file-selector modes when a room or file is selected.

Example:

function onSelectCallback() {
  console.log("The 'New room' room was selected.")
}

const docSpace = DocSpace.SDK.initRoomSelector({
  events: {
    onSelectCallback,
  },
})

The information about the selected item is returned:

{
  "icon": "https://example.com/url-to-example-image.svg",
  "id": 34,
  "isSelected": false,
  "label": "roomName"
}

where example.com is the name of the server with the ONLYOFFICE DocSpace installed.

ParameterTypePresenceDescription
iconstringrequiredDefines the URL to the room/file icon.
idintegerrequiredDefines the room/file ID.
isSelectedbooleanrequiredSpecifies whether the current room/file is selected.
labelstringrequiredDefines the room/file label.

onSignOut

The function called when logging out of the user account.

Example:

function onSignOut() {
  console.log("The user is logging out of the DocSpace account.")
}

const docSpace = DocSpace.SDK.initManager({
  events: {
    "onSignOut ": onSignOut,
  },
})

Get Help

  • If you have any questions about ONLYOFFICE DocSpace, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).