Events

removeAllEventListeners()

Remove all registered events

on(name, eventType, func)

Register event listener for a specific plugin

Parameters

Param

Type

Description

name

string

Required - The plugin which listens for the event.

eventType

string

Required - The event to listen for.

func

function

Required - Function to call when event is triggered.

Example

import {api, event} from 'writer'
api.events.on('myplugin', Event.DOCUMENT_CHANGED, (event) => {
   // React on event
})

off(name, eventType)

Unregister event listener for a specific plugin.

Parameters

Param

Type

Description

name

string

Required - The plugin which listens for the event.

eventType

string

Required - The event to stop listening for.

Example

import {api, event} from 'writer'
api.events.off('myplugin', Event.DOCUMENT_CHANGED)

trigger(name, eventType, [data])

Trigger an event of specified type with optional specified data

Parameters

Param

Type

Default

Description

name

string

Required - Plugin name or originator of event

eventType

string

Required - Event type to trigger (mandatory)

data

object

Optional data structure to send with event

Example

import {api, event} from 'writer'
api.events.trigger(
   'myplugin',
   Event.DOCUMENT_CHANGED,
   {
      type: 'edit',
      action: 'edit',
      data: {
         key: 'strange things'
      }
   }
)

~~triggerEvent() ~~

Deprecated

Use api.events.trigger() instead, deprecated. Deprecated since 2018-11-20.

~~documentChanged() ~~

Deprecated

Use api.events.trigger() with Event.DOCUMENT_CHANGED instead. Deprecated since 2018-11-20.

~~externalUpdate() ~~

Deprecated

Use api.events.trigger() with Event.DOCUMENT_CHANGED_EXTERNAL instead. Deprecated since 2018-11-20.

~~documentReplaced() ~~

Deprecated

Use api.events.trigger() with Event.DOCUMENT_REPLACED instead. Deprecated since 2018-11-20.

~~documentSaved() ~~

Deprecated

Use api.events.trigger() with Event.DOCUMENT_SAVED instead. Deprecated since 2018-11-20.

~~documentSaveFailed() ~~

Deprecated

Use api.events.trigger() with Event.DOCUMENT_SAVE_FAILED instead. Deprecated since 2018-11-20.

~~userActionSave() ~~

Deprecated

Use api.events.trigger() with Event.USERACTION_SAVE instead. Deprecated since 2018-11-20.

~~userActionCancelSave() ~~

Deprecated

Use api.events.trigger() with Event.USERACTION_CANCEL_SAVE instead. Deprecated since 2018-11-20.

~~userActionLock() ~~

Deprecated

Use api.events.trigger() with Event.USERACTION_LOCK instead. Deprecated since 2018-11-20.

~~userActionUnlock() ~~

Deprecated

Use api.events.trigger() with Event.USERACTION_UNLOCK instead. Deprecated since 2018-11-20.

~~languageChanged() ~~

Deprecated

Use api.events.trigger() with Event.ARTICLELANGUAGE_CHANGED instead. Deprecated since 2018-11-20.

~~onDocumentStartSaving() ~~

Deprecated

Use api.events.trigger() with "document:startsaving" instead. Deprecated since 2018-11-20.

Last updated