Editor Registry Documentation

Editor Registry module

The Registry keeps track of all editor instances on a page, and acts as an event bus for registration/unregistration/mode switch events. 

It also utilizes some Backbone.Events so you could also reference their documentation for the details.

Available events you can bind to:

  • register
  • switch
  • unregister

All callbacks receive a corresponding editor’s `entry` as an argument. 

Every time an "event" happens it is namespaced by firing 4 different events, so you can bind to the particular editor’s events:

  • eventName
  • eventName:mode
  • eventName:mode:id
  • eventName::id

E.g. when showing up "Comment" editor form with Text mode being default the following events will be fired:

  • register
  • register:source
  • register:source:comment
  • register::comment

then, when switching to Visual mode:

  • switch
  • switch:wysiwyg
  • switch:wysiwyg:comment
  • switch::comment

Entry

Entry class that keeps the current mode and references to editor's main components.

Property Type Description
id
String

Editor's id

id is assigned to the editor upon registration and you can get it from the entry in a register callback.

currentMode
String

Editor's current mode value

mode part of the event name and entry.currentMode property use 'source' and 'wysiwyg' values for Text and Visual mode correspondingly.

But we strongly recommend using require('jira/editor/constants').Modes object instead of raw values.

textArea
Element
Editor's textArea element used in Text mode
toolbar
Element
Editor's toolbar element
rteInstance
Promise
jQuery Promise backed by rich text editor instance
Method Return type Arguments Description
isTextMode
Boolean
 

Checks if editor described by the current entry is in the Text mode

isVisualMode
Boolean
 

Checks if editor described by the current entry is in the Visual mode

onSwitch
Entry
callback: Function

Binds callback to the switch event related to the editor described by this entry (i.e. to the `switch::$id` event)

onSwitchToText
Entry
callback: Function

Binds callback to the switch (to Text mode) event related only to the editor described by this entry (i.e. to the `switch:source:$id` event) 

onSwitchToVisual
Entry
callback: Function

Binds callback to the switch (to Visual mode) event related only to the editor described by this entry (i.e. to the `switch:wysiwyg:$id` event)

onUnregister
Entry
callback: Function

Binds callback to the unregister event related only to the editor described by this entry (i.e. to the `unregister::$id` event)

applyIfTextMode
Entry
callback: Function

Executes callback on the current entry only if the editor is in the Text mode

applyIfVisualMode
Entry
callback: Function

Executes callback on the current entry only if the editor is in the Visual mode

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport