Skip to main content

api.on()

Description​

Allows attaching a handler to the inner events

Usage​

api.on(
event: string,
handler: function
): void;

Parameters​

  • event - (required) an event to be fired
  • handler - (required) a handler to be attached (the handler arguments will depend on the event to be fired)

Events​

info

The full list of RichText internal events can be found here

Example​

// initialize RichText
const editor = new richtext.Richtext("#root", {
// configuration properties
});
// subscribe to the "set-font-size" event
editor.api.on("set-font-size", (obj) => {
console.log(obj.fontSize);
});

Change log: The method was updated in v2.0. The context parameter were removed