About Jira modules
Customer portal
Project settings UI locations

Editor registry

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.

  • id

    • Editor's id. id is assigned to the editor upon registration and you can get it from the entry in a register callback. Type: String.
  • currentMode

    • Editor's current mode value. Type: String.

      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

    • Editor's textArea element used in Text mode. Type: Element.
  • toolbar

    • Editor's toolbar element. **Type: **Element.
  • rteInstance

    • jQuery Promise backed by rich text editor instance. Type: Promise.
MethodDescription
1
2
isTextMode

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

Return type:

Boolean

Arguments:

-

1
2
isVisualMode

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

Return type:

Boolean

Arguments:

-

1
2
onSwitch

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

Return type:

Entry

Arguments:

callback: Function

1
2
onSwitchToText

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) 

Return type:

Entry

Arguments:

callback: Function

1
2
onSwitchToVisual

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)

Return type:

Entry

Arguments:

callback: Function

1
2
onUnregister

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

Return type:

Entry

Arguments:

callback: Function

1
2
applyIfTextMode

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

Return type:

Entry

Arguments:

callback: Function

1
2
applyIfVisualMode

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

Return type:

Entry

Arguments:

callback: Function

Rate this page: