Skip to main content

set-text-format

Description

Fires when setting a text format

Usage

"set-text-format": (ITextFormat) => boolean | void;

interface ITextFormat {
bold?: boolean;
italic?: boolean;
strike?: boolean;
underline?: boolean;
}
info

For handling inner events you can use Event Bus methods

Parameters

The callback of the set-text-format event can take an object with the following parameters:

  • bold - a bold text format
  • italic - an italic text format
  • strike - a strike text format
  • underline - an underline text format

Example

// initialize RichText
const editor = new richtext.Richtext("#root", {
// configuration properties
});
// subscribe to the "set-text-format" event
editor.api.on("set-text-format", (obj) => {
console.log(obj);
console.log("The text format was changed");
});
// apply the "italic" and bold text format
editor.api.exec("set-text-format", {
italic: true,
bold: true
});

Change log: The event was added in v2.0