Skip to content
Nate Mielnik edited this page Jun 6, 2015 · 18 revisions

MediumEditor Custom Events Overview

MediumEditor exposes a variety of custom events for convienience when using the editor with your web application. You can attach and detach listeners to these custom events, as well as manually trigger any custom events including your own custom events.

API Methods

Use the following methods of MediumEditor for custom event interaction:

MediumEditor.subscribe(name, listener)

Attaches a listener for the specified custom event name.

name (string)

Name of the event to listen to. See the list of built-in Custom Events below.

listener(data, editable) (function)

Listener method that will be called whenever the custom event is triggered.

Arguments to listener

  • data
    • For most custom events, this will be the browser's native Event object for the event that triggered the custom event to fire.
    • For some custom events, this will be an object containing information describing the event (depending on which custom event it is)
  • editable
    • A reference to the contenteditable container element that this custom event corresponds to. This is especially useful for instances where one instance of MediumEditor contains multiple elements, or there are multiple instances of MediumEditor on the page.
    • For example, when blur fires, this argument will be the <div contenteditable=true></div> element that is about to receive focus.

unsubscribe(event, listener)

Detaches a custom event listener for the specified custom event name.

name (string)

Name of the event to detach the listener for.

listener (function)_

A reference to the listener to detach. This must be a match by-reference and not a copy.

NOTE

Calling destroy() on the MediumEditor object will automatically remove all custom event listeners.

trigger()

Custom Events

externalInteraction

blur

focus

editableInput

editableClick

editableBlur

editableKeypress

editableKeyup

editableKeydown

editableKeydownEnter

editableKeydownTab

editableKeydownDelete

editableMouseover

editableDrag

editableDrop

editablePaste

Clone this wiki locally